tizen beta release
[framework/web/webkit-efl.git] / Source / WebKit / qt / WebCoreSupport / DumpRenderTreeSupportQt.h
1 /*
2     Copyright (C) 2010 Robert Hogan <robert@roberthogan.net>
3     Copyright (C) 2008,2009,2010 Nokia Corporation and/or its subsidiary(-ies)
4     Copyright (C) 2007 Staikos Computing Services Inc.
5     Copyright (C) 2007 Apple Inc.
6
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Library General Public
9     License as published by the Free Software Foundation; either
10     version 2 of the License, or (at your option) any later version.
11
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15     Library General Public License for more details.
16
17     You should have received a copy of the GNU Library General Public License
18     along with this library; see the file COPYING.LIB.  If not, write to
19     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20     Boston, MA 02110-1301, USA.
21 */
22
23 #ifndef DumpRenderTreeSupportQt_h
24 #define DumpRenderTreeSupportQt_h
25
26 #include "qwebkitglobal.h"
27 #include <QNetworkCookieJar>
28 #include <QVariant>
29
30 typedef const struct OpaqueJSContext* JSContextRef;
31
32 namespace WebCore {
33 class Text;
34 class Node;
35 }
36
37
38 #if defined(WTF_USE_V8) && WTF_USE_V8
39 namespace V8 {
40 namespace Bindings {
41 class QtDRTNodeRuntime;
42 }
43 }
44 #else
45 namespace JSC {
46 namespace Bindings {
47 class QtDRTNodeRuntime;
48 }
49 }
50 #endif
51
52 class QWebElement;
53 class QWebFrame;
54 class QWebPage;
55 class QWebHistoryItem;
56 class QWebScriptWorld;
57
58 QT_BEGIN_NAMESPACE
59 class QUrl;
60 QT_END_NAMESPACE
61
62 extern QMap<int, QWebScriptWorld*> m_worldMap;
63
64 // Used to pass WebCore::Node's to layout tests using LayoutTestController
65 class QWEBKIT_EXPORT QDRTNode {
66 public:
67     QDRTNode();
68     QDRTNode(const QDRTNode&);
69     QDRTNode &operator=(const QDRTNode&);
70     ~QDRTNode();
71
72 private:
73     explicit QDRTNode(WebCore::Node*);
74
75     friend class DumpRenderTreeSupportQt;
76
77 #if defined(WTF_USE_V8) && WTF_USE_V8
78     friend class V8::Bindings::QtDRTNodeRuntime;
79 #else
80     friend class QtDRTNodeRuntime;
81 #endif
82
83     WebCore::Node* m_node;
84 };
85
86 Q_DECLARE_METATYPE(QDRTNode)
87
88 class QtDRTNodeRuntime {
89 public:
90     static QDRTNode create(WebCore::Node*);
91     static WebCore::Node* get(const QDRTNode&);
92     static void initialize();
93 };
94
95 class QWEBKIT_EXPORT DumpRenderTreeSupportQt {
96
97 public:
98
99     DumpRenderTreeSupportQt();
100     ~DumpRenderTreeSupportQt();
101
102     static void initialize();
103
104     static void executeCoreCommandByName(QWebPage* page, const QString& name, const QString& value);
105     static bool isCommandEnabled(QWebPage* page, const QString& name);
106     static bool findString(QWebPage* page, const QString& string, const QStringList& optionArray);
107     static void setSmartInsertDeleteEnabled(QWebPage* page, bool enabled);
108     static void setSelectTrailingWhitespaceEnabled(QWebPage* page, bool enabled);
109     static QVariantList selectedRange(QWebPage* page);
110     static QVariantList firstRectForCharacterRange(QWebPage* page, int location, int length);
111     static void confirmComposition(QWebPage*, const char* text);
112
113     static bool pauseAnimation(QWebFrame*, const QString& name, double time, const QString& elementId);
114     static bool pauseTransitionOfProperty(QWebFrame*, const QString& name, double time, const QString& elementId);
115     static bool pauseSVGAnimation(QWebFrame*, const QString& animationId, double time, const QString& elementId);
116     static void suspendActiveDOMObjects(QWebFrame* frame);
117     static void resumeActiveDOMObjects(QWebFrame* frame);
118
119     static void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme);
120     static void setFrameFlatteningEnabled(QWebPage*, bool);
121     static void setCaretBrowsingEnabled(QWebPage* page, bool value);
122     static void setAuthorAndUserStylesEnabled(QWebPage*, bool);
123     static void setMediaType(QWebFrame* qframe, const QString& type);
124     static void setDumpRenderTreeModeEnabled(bool b);
125
126     static void garbageCollectorCollect();
127     static void garbageCollectorCollectOnAlternateThread(bool waitUntilDone);
128     static void setAutofilled(const QWebElement&, bool enabled);
129     static void setJavaScriptProfilingEnabled(QWebFrame*, bool enabled);
130     static void setValueForUser(const QWebElement&, const QString& value);
131     static int javaScriptObjectsCount();
132     static void clearScriptWorlds();
133     static void evaluateScriptInIsolatedWorld(QWebFrame* frame, int worldID, const QString& script);
134
135     static void webInspectorExecuteScript(QWebPage* page, long callId, const QString& script);
136     static void webInspectorShow(QWebPage* page);
137     static void webInspectorClose(QWebPage* page);
138
139     static QString webPageGroupName(QWebPage *page);
140     static QString counterValueForElementById(QWebFrame* frame, const QString& id);
141     static void webPageSetGroupName(QWebPage* page, const QString& groupName);
142     static void clearFrameName(QWebFrame* frame);
143     static void overwritePluginDirectories();
144     static int numberOfActiveAnimations(QWebFrame*);
145     static void suspendAnimations(QWebFrame*);
146     static void resumeAnimations(QWebFrame*);
147     static int numberOfPages(QWebFrame* frame, float width, float height);
148     static int pageNumberForElementById(QWebFrame* frame, const QString& id, float width, float height);
149     static bool hasDocumentElement(QWebFrame* frame);
150     static bool elementDoesAutoCompleteForElementWithId(QWebFrame* frame, const QString& elementId);
151     static void setEditingBehavior(QWebPage* page, const QString& editingBehavior);
152
153     static void clearAllApplicationCaches();
154
155     static void whiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
156     static void removeWhiteListAccessFromOrigin(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
157     static void resetOriginAccessWhiteLists();
158
159     static void activeMockDeviceOrientationClient(bool b);
160     static void removeMockDeviceOrientation();
161     static void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
162
163     static void resetGeolocationMock(QWebPage*);
164     static void setMockGeolocationPermission(QWebPage*, bool allowed);
165     static void setMockGeolocationPosition(QWebPage*, double latitude, double longitude, double accuracy);
166     static void setMockGeolocationError(QWebPage*, int errorCode, const QString& message);
167     static int numberOfPendingGeolocationPermissionRequests(QWebPage*);
168
169     static int workerThreadCount();
170
171     static QString markerTextForListItem(const QWebElement& listItem);
172     static QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element);
173     static QString plainText(const QVariant& rng);
174
175     static void dumpFrameLoader(bool b);
176     static void dumpProgressFinishedCallback(bool);
177     static void dumpUserGestureInFrameLoader(bool b);
178     static void dumpResourceLoadCallbacks(bool b);
179     static void dumpResourceResponseMIMETypes(bool b);
180     static void dumpResourceLoadCallbacksPath(const QString& path);
181     static void setWillSendRequestReturnsNullOnRedirect(bool b);
182     static void setWillSendRequestReturnsNull(bool b);
183     static void setWillSendRequestClearHeaders(const QStringList& headers);
184     static void dumpHistoryCallbacks(bool b);
185     static void dumpVisitedLinksCallbacks(bool b);
186
187     static void setDeferMainResourceDataLoad(bool b);
188
189     static void dumpEditingCallbacks(bool b);
190     static void dumpSetAcceptsEditing(bool b);
191
192     static void dumpNotification(bool b);
193
194     static QMap<QString, QWebHistoryItem> getChildHistoryItems(const QWebHistoryItem& historyItem);
195     static bool isTargetItem(const QWebHistoryItem& historyItem);
196     static QString historyItemTarget(const QWebHistoryItem& historyItem);
197
198     static bool shouldClose(QWebFrame* frame);
199
200     static void setCustomPolicyDelegate(bool enabled, bool permissive);
201
202     static bool isPageBoxVisible(QWebFrame* frame, int pageIndex);
203
204     static QString pageSizeAndMarginsInPixels(QWebFrame* frame, int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
205     static QString pageProperty(QWebFrame* frame, const QString& propertyName, int pageNumber);
206     static void addUserStyleSheet(QWebPage* page, const QString& sourceCode);
207     static void simulateDesktopNotificationClick(const QString& title);
208     static QString viewportAsText(QWebPage*, int deviceDPI, const QSize& deviceSize, const QSize& availableSize);
209
210     static void scalePageBy(QWebFrame*, float scale, const QPoint& origin);
211
212     static QVariantList nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping);
213     static QString responseMimeType(QWebFrame*);
214     static void clearOpener(QWebFrame*);
215     static void addURLToRedirect(const QString& origin, const QString& destination);
216     static QStringList contextMenu(QWebPage*);
217
218     static double defaultMinimumTimerInterval(); // Not really tied to WebView
219     static void setMinimumTimerInterval(QWebPage*, double);
220
221     static QUrl mediaContentUrlByElementId(QWebFrame*, const QString& elementId);
222     static void setAlternateHtml(QWebFrame*, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl);
223
224     static QString layerTreeAsText(QWebFrame*);
225
226     static void injectInternalsObject(QWebFrame*);
227     static void injectInternalsObject(JSContextRef);
228     static void resetInternalsObject(QWebFrame*);
229
230     static void setInteractiveFormValidationEnabled(QWebPage*, bool);
231
232     static void setDefersLoading(QWebPage*, bool flag);
233     static void goBack(QWebPage*);
234
235 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
236     static bool thirdPartyCookiePolicyAllows(QWebPage*, const QUrl&, const QUrl& firstPartyUrl);
237 #endif
238
239     static bool defaultHixie76WebSocketProtocolEnabled();
240     static void setHixie76WebSocketProtocolEnabled(QWebPage*, bool);
241 };
242
243 #endif