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.
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.
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.
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.
23 #ifndef DumpRenderTreeSupportQt_h
24 #define DumpRenderTreeSupportQt_h
26 #include "qwebkitglobal.h"
27 #include <QNetworkCookieJar>
30 typedef const struct OpaqueJSContext* JSContextRef;
38 #if defined(WTF_USE_V8) && WTF_USE_V8
41 class QtDRTNodeRuntime;
47 class QtDRTNodeRuntime;
55 class QWebHistoryItem;
56 class QWebScriptWorld;
62 extern QMap<int, QWebScriptWorld*> m_worldMap;
64 // Used to pass WebCore::Node's to layout tests using LayoutTestController
65 class QWEBKIT_EXPORT QDRTNode {
68 QDRTNode(const QDRTNode&);
69 QDRTNode &operator=(const QDRTNode&);
73 explicit QDRTNode(WebCore::Node*);
75 friend class DumpRenderTreeSupportQt;
77 #if defined(WTF_USE_V8) && WTF_USE_V8
78 friend class V8::Bindings::QtDRTNodeRuntime;
80 friend class QtDRTNodeRuntime;
83 WebCore::Node* m_node;
86 Q_DECLARE_METATYPE(QDRTNode)
88 class QtDRTNodeRuntime {
90 static QDRTNode create(WebCore::Node*);
91 static WebCore::Node* get(const QDRTNode&);
92 static void initialize();
95 class QWEBKIT_EXPORT DumpRenderTreeSupportQt {
99 DumpRenderTreeSupportQt();
100 ~DumpRenderTreeSupportQt();
102 static void initialize();
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);
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);
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);
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);
135 static void webInspectorExecuteScript(QWebPage* page, long callId, const QString& script);
136 static void webInspectorShow(QWebPage* page);
137 static void webInspectorClose(QWebPage* page);
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);
153 static void clearAllApplicationCaches();
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();
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);
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*);
169 static int workerThreadCount();
171 static QString markerTextForListItem(const QWebElement& listItem);
172 static QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element);
173 static QString plainText(const QVariant& rng);
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);
187 static void setDeferMainResourceDataLoad(bool b);
189 static void dumpEditingCallbacks(bool b);
190 static void dumpSetAcceptsEditing(bool b);
192 static void dumpNotification(bool b);
194 static QMap<QString, QWebHistoryItem> getChildHistoryItems(const QWebHistoryItem& historyItem);
195 static bool isTargetItem(const QWebHistoryItem& historyItem);
196 static QString historyItemTarget(const QWebHistoryItem& historyItem);
198 static bool shouldClose(QWebFrame* frame);
200 static void setCustomPolicyDelegate(bool enabled, bool permissive);
202 static bool isPageBoxVisible(QWebFrame* frame, int pageIndex);
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);
210 static void scalePageBy(QWebFrame*, float scale, const QPoint& origin);
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*);
218 static double defaultMinimumTimerInterval(); // Not really tied to WebView
219 static void setMinimumTimerInterval(QWebPage*, double);
221 static QUrl mediaContentUrlByElementId(QWebFrame*, const QString& elementId);
222 static void setAlternateHtml(QWebFrame*, const QString& html, const QUrl& baseUrl, const QUrl& failingUrl);
224 static QString layerTreeAsText(QWebFrame*);
226 static void injectInternalsObject(QWebFrame*);
227 static void injectInternalsObject(JSContextRef);
228 static void resetInternalsObject(QWebFrame*);
230 static void setInteractiveFormValidationEnabled(QWebPage*, bool);
232 static void setDefersLoading(QWebPage*, bool flag);
233 static void goBack(QWebPage*);
235 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
236 static bool thirdPartyCookiePolicyAllows(QWebPage*, const QUrl&, const QUrl& firstPartyUrl);
239 static bool defaultHixie76WebSocketProtocolEnabled();
240 static void setHixie76WebSocketProtocolEnabled(QWebPage*, bool);