2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef LayoutTestControllerQt_h
31 #define LayoutTestControllerQt_h
33 #include <QBasicTimer>
39 #include <QTimerEvent>
42 #include <qwebdatabase.h>
43 #include <qwebelement.h>
44 #include <qwebframe.h>
45 #include <qwebhistory.h>
47 #include <qwebsecurityorigin.h>
50 class DumpRenderTreeSupportQt;
54 class LayoutTestController : public QObject {
56 Q_PROPERTY(int webHistoryItemCount READ webHistoryItemCount)
57 Q_PROPERTY(int workerThreadCount READ workerThreadCount)
58 Q_PROPERTY(bool globalFlag READ globalFlag WRITE setGlobalFlag)
60 LayoutTestController(WebCore::DumpRenderTree* drt);
62 bool shouldDisallowIncreaseForApplicationCacheQuota() const { return m_disallowIncreaseForApplicationCacheQuota; }
63 bool shouldDumpAsText() const { return m_textDump; }
64 bool shouldDumpBackForwardList() const { return m_dumpBackForwardList; }
65 bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; }
66 bool shouldDumpChildFrameScrollPositions() const { return m_dumpChildFrameScrollPositions; }
67 bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
68 bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
69 bool shouldDumpStatusCallbacks() const { return m_dumpStatusCallbacks; }
70 bool shouldWaitUntilDone() const { return m_waitForDone; }
71 bool shouldHandleErrorPages() const { return m_handleErrorPages; }
72 bool canOpenWindows() const { return m_canOpenWindows; }
73 bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
74 bool waitForPolicy() const { return m_waitForPolicy; }
75 bool ignoreReqestForPermission() const { return m_ignoreDesktopNotification; }
76 bool isPrinting() { return m_isPrinting; }
80 static const unsigned int maxViewWidth;
81 static const unsigned int maxViewHeight;
84 void timerEvent(QTimerEvent*);
91 void geolocationPermissionSet();
94 void maybeDump(bool ok);
95 void disallowIncreaseForApplicationCacheQuota() { m_disallowIncreaseForApplicationCacheQuota = true; }
96 void dumpAsText() { m_textDump = true; }
97 void dumpChildFramesAsText() { m_dumpChildrenAsText = true; }
98 void dumpChildFrameScrollPositions() { m_dumpChildFrameScrollPositions = true; }
99 void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
100 void dumpApplicationCacheDelegateCallbacks() { m_dumpApplicationCacheDelegateCallbacks = true; }
101 void dumpStatusCallbacks() { m_dumpStatusCallbacks = true; }
102 void setCanOpenWindows() { m_canOpenWindows = true; }
103 void setPrinting() { m_isPrinting = true; }
104 void waitUntilDone();
105 QString counterValueForElementById(const QString& id);
106 int webHistoryItemCount();
107 void keepWebHistory();
109 void dumpBackForwardList() { m_dumpBackForwardList = true; }
110 bool globalFlag() const { return m_globalFlag; }
111 void setGlobalFlag(bool flag) { m_globalFlag = flag; }
112 void handleErrorPages() { m_handleErrorPages = true; }
113 void dumpEditingCallbacks();
114 void dumpFrameLoadCallbacks();
115 void dumpProgressFinishedCallback();
116 void dumpUserGestureInFrameLoadCallbacks();
117 void dumpResourceLoadCallbacks();
118 void dumpResourceResponseMIMETypes();
119 void dumpHistoryCallbacks();
120 void dumpConfigurationForViewport(int deviceDPI, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
121 void setWillSendRequestReturnsNullOnRedirect(bool enabled);
122 void setWillSendRequestReturnsNull(bool enabled);
123 void setWillSendRequestClearHeader(const QStringList& headers);
124 void queueBackNavigation(int howFarBackward);
125 void queueForwardNavigation(int howFarForward);
126 void queueLoad(const QString& url, const QString& target = QString());
127 void queueLoadHTMLString(const QString& content, const QString& baseURL = QString(), const QString& failingURL = QString());
129 void queueLoadingScript(const QString& script);
130 void queueNonLoadingScript(const QString& script);
131 void provisionalLoad();
132 void setCloseRemainingWindowsWhenComplete(bool = false) {}
134 void grantDesktopNotificationPermission(const QString& origin);
135 void ignoreDesktopNotificationPermissionRequests();
136 bool checkDesktopNotificationPermission(const QString& origin);
137 void simulateDesktopNotificationClick(const QString& title);
139 void displayInvalidatedRegion();
140 void clearBackForwardList();
141 QString pathToLocalResource(const QString& url);
142 void dumpTitleChanges() { m_dumpTitleChanges = true; }
143 QString encodeHostName(const QString& host);
144 QString decodeHostName(const QString& host);
145 void dumpSelectionRect() const {}
146 void setDeveloperExtrasEnabled(bool);
147 void setAsynchronousSpellCheckingEnabled(bool);
148 void showWebInspector();
149 void closeWebInspector();
150 void evaluateInWebInspector(long callId, const QString& script);
151 void removeAllVisitedLinks();
152 void setMediaType(const QString& type);
153 void setFrameFlatteningEnabled(bool enable);
154 void setAllowUniversalAccessFromFileURLs(bool enable);
155 void setAllowFileAccessFromFileURLs(bool enable);
156 void setAppCacheMaximumSize(unsigned long long quota);
157 void setAutofilled(const QWebElement&, bool enable);
158 void setJavaScriptProfilingEnabled(bool enable);
159 void setValueForUser(const QWebElement&, const QString& value);
160 void setFixedContentsSize(int width, int height);
161 void setPrivateBrowsingEnabled(bool enable);
162 void setSpatialNavigationEnabled(bool enabled);
163 void setPluginsEnabled(bool flag);
164 void setPopupBlockingEnabled(bool enable);
165 void setPOSIXLocale(const QString& locale);
166 void resetLoadFinished() { m_loadFinished = false; }
167 void setWindowIsKey(bool isKey);
168 void setMainFrameIsFirstResponder(bool isFirst);
169 void setDeferMainResourceDataLoad(bool);
170 void setJavaScriptCanAccessClipboard(bool enable);
171 void setXSSAuditorEnabled(bool enable);
172 void setCaretBrowsingEnabled(bool enable);
173 void setAuthorAndUserStylesEnabled(bool);
174 void setViewModeMediaFeature(const QString& mode);
175 void setSmartInsertDeleteEnabled(bool enable);
176 void setSelectTrailingWhitespaceEnabled(bool enable);
177 void execCommand(const QString& name, const QString& value = QString());
178 bool isCommandEnabled(const QString& name) const;
179 bool findString(const QString& string, const QStringList& optionArray);
181 bool pauseAnimationAtTimeOnElementWithId(const QString& animationName, double time, const QString& elementId);
182 bool pauseTransitionAtTimeOnElementWithId(const QString& propertyName, double time, const QString& elementId);
183 bool sampleSVGAnimationForElementAtTime(const QString& animationId, double time, const QString& elementId);
184 bool elementDoesAutoCompleteForElementWithId(const QString& elementId);
186 unsigned numberOfActiveAnimations() const;
187 void suspendAnimations() const;
188 void resumeAnimations() const;
190 void addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
191 void removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
193 void dispatchPendingLoadRequests();
194 void disableImageLoading();
196 void clearAllApplicationCaches();
197 void clearApplicationCacheForOrigin(const QString& url);
198 void setApplicationCacheOriginQuota(unsigned long long quota);
199 QStringList originsWithApplicationCache();
200 long long applicationCacheDiskUsageForOrigin(const QString&);
201 void setCacheModel(int);
203 void setDatabaseQuota(int size);
204 void clearAllDatabases();
205 void setIconDatabaseEnabled(bool enable);
207 void setCustomPolicyDelegate(bool enabled, bool permissive = false);
208 void waitForPolicyDelegate();
210 void overridePreference(const QString& name, const QVariant& value);
211 void setUserStyleSheetLocation(const QString& url);
212 void setUserStyleSheetEnabled(bool enabled);
213 void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme);
214 int workerThreadCount();
215 int pageNumberForElementById(const QString& id, float width = 0, float height = 0);
216 int numberOfPages(float width = maxViewWidth, float height = maxViewHeight);
217 bool callShouldCloseOnWebView();
218 // For now, this is a no-op. This may change depending on outcome of
219 // https://bugs.webkit.org/show_bug.cgi?id=33333
220 void setCallCloseOnWebViews() {}
221 // This is a no-op - it allows us to pass
222 // plugins/get-url-that-the-resource-load-delegate-will-disallow.html
223 // which is a Mac-specific test.
224 void addDisallowedURL(const QString&) {}
226 void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
228 void setMockGeolocationError(int code, const QString& message);
229 void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
230 void setGeolocationPermission(bool allow);
231 int numberOfPendingGeolocationPermissionRequests();
232 bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; }
233 bool geolocationPermission() const { return m_geolocationPermission; }
235 void addMockSpeechInputResult(const QString& result, double confidence, const QString& language);
236 void startSpeechInput(const QString& inputElement);
238 // Empty stub method to keep parity with object model exposed by global LayoutTestController.
240 bool hasSpellingMarker(int from, int length);
242 QVariantList nodesFromRect(const QWebElement& document, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping);
244 void addURLToRedirect(const QString& origin, const QString& destination);
247 Policy values: 'on', 'auto' or 'off'.
248 Orientation values: 'vertical' or 'horizontal'.
250 void setScrollbarPolicy(const QString& orientation, const QString& policy);
252 QString markerTextForListItem(const QWebElement& listItem);
253 QVariantMap computedStyleIncludingVisitedInfo(const QWebElement& element) const;
255 // Simulate a request an embedding application could make, populating per-session credential storage.
256 void authenticateSession(const QString& url, const QString& username, const QString& password);
258 void setEditingBehavior(const QString& editingBehavior);
260 void evaluateScriptInIsolatedWorld(int worldID, const QString& script);
261 bool isPageBoxVisible(int pageIndex);
262 QString pageSizeAndMarginsInPixels(int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
263 QString pageProperty(const QString& propertyName, int pageNumber);
264 void addUserStyleSheet(const QString& sourceCode);
266 void setMinimumTimerInterval(double);
268 void originsWithLocalStorage();
269 void deleteAllLocalStorage();
270 void deleteLocalStorageForOrigin(const QString& originIdentifier);
271 long long localStorageDiskUsageForOrigin(const QString& originIdentifier);
272 void observeStorageTrackerNotifications(unsigned number);
273 void syncLocalStorage();
274 QString layerTreeAsText();
275 void setTextDirection(const QString& directionName);
277 void setDefersLoading(bool);
278 #if QT_VERSION >= 0x040800
279 void setAlwaysAcceptCookies(bool);
280 void setAlwaysBlockCookies(bool);
287 void setGeolocationPermissionCommon(bool allow);
292 bool m_disallowIncreaseForApplicationCacheQuota;
293 bool m_dumpBackForwardList;
294 bool m_dumpChildrenAsText;
295 bool m_dumpChildFrameScrollPositions;
296 bool m_canOpenWindows;
298 bool m_dumpTitleChanges;
299 bool m_dumpDatabaseCallbacks;
300 bool m_dumpApplicationCacheDelegateCallbacks;
301 bool m_dumpStatusCallbacks;
302 bool m_waitForPolicy;
303 bool m_handleErrorPages;
306 bool m_userStyleSheetEnabled;
307 bool m_isGeolocationPermissionSet;
309 bool m_geolocationPermission;
311 QUrl m_userStyleSheetLocation;
312 QBasicTimer m_timeoutTimer;
313 QWebFrame* m_topLoadingFrame;
314 WebCore::DumpRenderTree* m_drt;
315 QWebHistory* m_webHistory;
316 QStringList m_desktopNotificationAllowedOrigins;
317 bool m_ignoreDesktopNotification;
320 #endif // LayoutTestControllerQt_h