1 /* |
|
2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
|
3 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
8 * |
|
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. |
|
17 * |
|
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. |
|
28 */ |
|
29 #include "config.h" |
|
30 #include "LayoutTestControllerQt.h" |
|
31 #include "../../../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" |
|
32 |
|
33 #include "DumpRenderTreeQt.h" |
|
34 #include "WorkQueue.h" |
|
35 #include "WorkQueueItemQt.h" |
|
36 #include <QDir> |
|
37 #include <QLocale> |
|
38 #include <qwebsettings.h> |
|
39 |
|
40 LayoutTestController::LayoutTestController(WebCore::DumpRenderTree* drt) |
|
41 : QObject() |
|
42 , m_drt(drt) |
|
43 { |
|
44 qRegisterMetaType<QWebElement>("QWebElement"); |
|
45 reset(); |
|
46 DumpRenderTreeSupportQt::dumpNotification(true); |
|
47 } |
|
48 |
|
49 void LayoutTestController::reset() |
|
50 { |
|
51 m_hasDumped = false; |
|
52 m_loadFinished = false; |
|
53 m_textDump = false; |
|
54 m_dumpBackForwardList = false; |
|
55 m_dumpChildrenAsText = false; |
|
56 m_dumpChildFrameScrollPositions = false; |
|
57 m_canOpenWindows = false; |
|
58 m_waitForDone = false; |
|
59 m_dumpTitleChanges = false; |
|
60 m_dumpDatabaseCallbacks = false; |
|
61 m_dumpStatusCallbacks = false; |
|
62 m_timeoutTimer.stop(); |
|
63 m_topLoadingFrame = 0; |
|
64 m_waitForPolicy = false; |
|
65 m_handleErrorPages = false; |
|
66 m_webHistory = 0; |
|
67 m_globalFlag = false; |
|
68 m_userStyleSheetEnabled = false; |
|
69 m_desktopNotificationAllowedOrigins.clear(); |
|
70 m_ignoreDesktopNotification = false; |
|
71 |
|
72 DumpRenderTreeSupportQt::dumpEditingCallbacks(false); |
|
73 DumpRenderTreeSupportQt::dumpFrameLoader(false); |
|
74 DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false); |
|
75 DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(false); |
|
76 DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(true); |
|
77 DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(false); |
|
78 DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(false); |
|
79 DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(QStringList()); |
|
80 DumpRenderTreeSupportQt::clearScriptWorlds(); |
|
81 DumpRenderTreeSupportQt::setCustomPolicyDelegate(false, false); |
|
82 setIconDatabaseEnabled(false); |
|
83 |
|
84 emit hidePage(); |
|
85 } |
|
86 |
|
87 void LayoutTestController::processWork() |
|
88 { |
|
89 // qDebug() << ">>>processWork"; |
|
90 |
|
91 // if we didn't start a new load, then we finished all the commands, so we're ready to dump state |
|
92 if (WorkQueue::shared()->processWork() && !shouldWaitUntilDone()) { |
|
93 emit done(); |
|
94 m_hasDumped = true; |
|
95 } |
|
96 } |
|
97 |
|
98 // Called on loadFinished on WebPage |
|
99 void LayoutTestController::maybeDump(bool success) |
|
100 { |
|
101 |
|
102 // This can happen on any of the http/tests/security/window-events-*.html tests, where the test opens |
|
103 // a new window, calls the unload and load event handlers on the window's page, and then immediately |
|
104 // issues a notifyDone. Needs investigation. |
|
105 if (!m_topLoadingFrame) |
|
106 return; |
|
107 |
|
108 // It is possible that we get called by windows created from the main page that have finished |
|
109 // loading, so we don't ASSERT here. At the moment we do not gather results from such windows, |
|
110 // but may need to in future. |
|
111 if (sender() != m_topLoadingFrame->page()) |
|
112 return; |
|
113 |
|
114 m_loadFinished = true; |
|
115 // as the function is called on loadFinished, the test might |
|
116 // already have dumped and thus no longer be active, thus |
|
117 // bail out here. |
|
118 if (m_hasDumped) |
|
119 return; |
|
120 |
|
121 WorkQueue::shared()->setFrozen(true); // first complete load freezes the queue for the rest of this test |
|
122 if (WorkQueue::shared()->count()) |
|
123 QTimer::singleShot(0, this, SLOT(processWork())); |
|
124 else if (!shouldWaitUntilDone()) { |
|
125 if (success) |
|
126 emit done(); |
|
127 m_hasDumped = true; |
|
128 } |
|
129 } |
|
130 |
|
131 void LayoutTestController::waitUntilDone() |
|
132 { |
|
133 //qDebug() << ">>>>waitForDone"; |
|
134 m_waitForDone = true; |
|
135 m_timeoutTimer.start(30000, this); |
|
136 } |
|
137 |
|
138 QString LayoutTestController::counterValueForElementById(const QString& id) |
|
139 { |
|
140 return DumpRenderTreeSupportQt::counterValueForElementById(m_drt->webPage()->mainFrame(), id); |
|
141 } |
|
142 |
|
143 void LayoutTestController::setViewModeMediaFeature(const QString& mode) |
|
144 { |
|
145 m_drt->webPage()->setProperty("_q_viewMode", mode); |
|
146 } |
|
147 |
|
148 int LayoutTestController::webHistoryItemCount() |
|
149 { |
|
150 if (!m_webHistory) |
|
151 return -1; |
|
152 |
|
153 // Subtract one here as our QWebHistory::count() includes the actual page, |
|
154 // which is not considered in the DRT tests. |
|
155 return m_webHistory->count() - 1; |
|
156 } |
|
157 |
|
158 void LayoutTestController::keepWebHistory() |
|
159 { |
|
160 m_webHistory = m_drt->webPage()->history(); |
|
161 } |
|
162 |
|
163 void LayoutTestController::notifyDone() |
|
164 { |
|
165 qDebug() << ">>>>notifyDone"; |
|
166 |
|
167 if (!m_timeoutTimer.isActive()) |
|
168 return; |
|
169 |
|
170 m_timeoutTimer.stop(); |
|
171 m_waitForDone = false; |
|
172 |
|
173 // If the page has not finished loading (i.e. loadFinished() has not been emitted) then |
|
174 // content created by the likes of document.write() JS methods will not be available yet. |
|
175 // When the page has finished loading, maybeDump above will dump the results now that we have |
|
176 // just set shouldWaitUntilDone to false. |
|
177 if (!m_loadFinished) |
|
178 return; |
|
179 |
|
180 emit done(); |
|
181 |
|
182 // FIXME: investigate why always resetting these result in timeouts |
|
183 m_hasDumped = true; |
|
184 m_waitForPolicy = false; |
|
185 } |
|
186 |
|
187 int LayoutTestController::windowCount() |
|
188 { |
|
189 return m_drt->windowCount(); |
|
190 } |
|
191 |
|
192 void LayoutTestController::grantDesktopNotificationPermission(const QString& origin) |
|
193 { |
|
194 m_desktopNotificationAllowedOrigins.append(origin); |
|
195 } |
|
196 |
|
197 void LayoutTestController::ignoreDesktopNotificationPermissionRequests() |
|
198 { |
|
199 m_ignoreDesktopNotification = true; |
|
200 } |
|
201 |
|
202 bool LayoutTestController::checkDesktopNotificationPermission(const QString& origin) |
|
203 { |
|
204 return !m_ignoreDesktopNotification && m_desktopNotificationAllowedOrigins.contains(origin); |
|
205 } |
|
206 |
|
207 void LayoutTestController::display() |
|
208 { |
|
209 emit showPage(); |
|
210 } |
|
211 |
|
212 void LayoutTestController::clearBackForwardList() |
|
213 { |
|
214 m_drt->webPage()->history()->clear(); |
|
215 } |
|
216 |
|
217 QString LayoutTestController::pathToLocalResource(const QString& url) |
|
218 { |
|
219 // Function introduced in r28690. |
|
220 return QDir::toNativeSeparators(url); |
|
221 } |
|
222 |
|
223 void LayoutTestController::dumpEditingCallbacks() |
|
224 { |
|
225 qDebug() << ">>>dumpEditingCallbacks"; |
|
226 DumpRenderTreeSupportQt::dumpEditingCallbacks(true); |
|
227 } |
|
228 |
|
229 void LayoutTestController::dumpFrameLoadCallbacks() |
|
230 { |
|
231 DumpRenderTreeSupportQt::dumpFrameLoader(true); |
|
232 } |
|
233 |
|
234 void LayoutTestController::dumpResourceLoadCallbacks() |
|
235 { |
|
236 DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(true); |
|
237 } |
|
238 |
|
239 void LayoutTestController::dumpResourceResponseMIMETypes() |
|
240 { |
|
241 DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(true); |
|
242 } |
|
243 |
|
244 void LayoutTestController::setWillSendRequestReturnsNullOnRedirect(bool enabled) |
|
245 { |
|
246 DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(enabled); |
|
247 } |
|
248 |
|
249 void LayoutTestController::setWillSendRequestReturnsNull(bool enabled) |
|
250 { |
|
251 DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(enabled); |
|
252 } |
|
253 |
|
254 void LayoutTestController::setWillSendRequestClearHeader(const QStringList& headers) |
|
255 { |
|
256 DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(headers); |
|
257 } |
|
258 |
|
259 void LayoutTestController::setDeferMainResourceDataLoad(bool defer) |
|
260 { |
|
261 DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(defer); |
|
262 } |
|
263 |
|
264 void LayoutTestController::queueBackNavigation(int howFarBackward) |
|
265 { |
|
266 //qDebug() << ">>>queueBackNavigation" << howFarBackward; |
|
267 WorkQueue::shared()->queue(new BackItem(howFarBackward, m_drt->webPage())); |
|
268 } |
|
269 |
|
270 void LayoutTestController::queueForwardNavigation(int howFarForward) |
|
271 { |
|
272 //qDebug() << ">>>queueForwardNavigation" << howFarForward; |
|
273 WorkQueue::shared()->queue(new ForwardItem(howFarForward, m_drt->webPage())); |
|
274 } |
|
275 |
|
276 void LayoutTestController::queueLoad(const QString& url, const QString& target) |
|
277 { |
|
278 //qDebug() << ">>>queueLoad" << url << target; |
|
279 QUrl mainResourceUrl = m_drt->webPage()->mainFrame()->url(); |
|
280 QString absoluteUrl = mainResourceUrl.resolved(QUrl(url)).toEncoded(); |
|
281 WorkQueue::shared()->queue(new LoadItem(absoluteUrl, target, m_drt->webPage())); |
|
282 } |
|
283 |
|
284 void LayoutTestController::queueLoadHTMLString(const QString& content, const QString& baseURL) |
|
285 { |
|
286 WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, m_drt->webPage())); |
|
287 } |
|
288 |
|
289 void LayoutTestController::queueReload() |
|
290 { |
|
291 //qDebug() << ">>>queueReload"; |
|
292 WorkQueue::shared()->queue(new ReloadItem(m_drt->webPage())); |
|
293 } |
|
294 |
|
295 void LayoutTestController::queueLoadingScript(const QString& script) |
|
296 { |
|
297 //qDebug() << ">>>queueLoadingScript" << script; |
|
298 WorkQueue::shared()->queue(new LoadingScriptItem(script, m_drt->webPage())); |
|
299 } |
|
300 |
|
301 void LayoutTestController::queueNonLoadingScript(const QString& script) |
|
302 { |
|
303 //qDebug() << ">>>queueNonLoadingScript" << script; |
|
304 WorkQueue::shared()->queue(new NonLoadingScriptItem(script, m_drt->webPage())); |
|
305 } |
|
306 |
|
307 void LayoutTestController::provisionalLoad() |
|
308 { |
|
309 QWebFrame* frame = qobject_cast<QWebFrame*>(sender()); |
|
310 if (!m_topLoadingFrame && !m_hasDumped) |
|
311 m_topLoadingFrame = frame; |
|
312 } |
|
313 |
|
314 void LayoutTestController::timerEvent(QTimerEvent *ev) |
|
315 { |
|
316 if (ev->timerId() == m_timeoutTimer.timerId()) { |
|
317 const char* message = "FAIL: Timed out waiting for notifyDone to be called\n"; |
|
318 fprintf(stderr, "%s", message); |
|
319 fprintf(stdout, "%s", message); |
|
320 notifyDone(); |
|
321 } else |
|
322 QObject::timerEvent(ev); |
|
323 } |
|
324 |
|
325 QString LayoutTestController::encodeHostName(const QString& host) |
|
326 { |
|
327 QString encoded = QString::fromLatin1(QUrl::toAce(host + QLatin1String(".no"))); |
|
328 encoded.truncate(encoded.length() - 3); // strip .no |
|
329 return encoded; |
|
330 } |
|
331 |
|
332 QString LayoutTestController::decodeHostName(const QString& host) |
|
333 { |
|
334 QString decoded = QUrl::fromAce(host.toLatin1() + QByteArray(".no")); |
|
335 decoded.truncate(decoded.length() - 3); |
|
336 return decoded; |
|
337 } |
|
338 |
|
339 void LayoutTestController::setMediaType(const QString& type) |
|
340 { |
|
341 DumpRenderTreeSupportQt::setMediaType(m_drt->webPage()->mainFrame(), type); |
|
342 } |
|
343 |
|
344 void LayoutTestController::closeWebInspector() |
|
345 { |
|
346 DumpRenderTreeSupportQt::webInspectorClose(m_drt->webPage()); |
|
347 m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false); |
|
348 } |
|
349 |
|
350 void LayoutTestController::setDeveloperExtrasEnabled(bool enabled) |
|
351 { |
|
352 m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enabled); |
|
353 } |
|
354 |
|
355 void LayoutTestController::showWebInspector() |
|
356 { |
|
357 m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); |
|
358 DumpRenderTreeSupportQt::webInspectorShow(m_drt->webPage()); |
|
359 } |
|
360 |
|
361 void LayoutTestController::evaluateInWebInspector(long callId, const QString& script) |
|
362 { |
|
363 DumpRenderTreeSupportQt::webInspectorExecuteScript(m_drt->webPage(), callId, script); |
|
364 } |
|
365 |
|
366 void LayoutTestController::setFrameFlatteningEnabled(bool enabled) |
|
367 { |
|
368 DumpRenderTreeSupportQt::setFrameFlatteningEnabled(m_drt->webPage(), enabled); |
|
369 } |
|
370 |
|
371 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled) |
|
372 { |
|
373 m_drt->webPage()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, enabled); |
|
374 } |
|
375 |
|
376 void LayoutTestController::setAllowFileAccessFromFileURLs(bool enabled) |
|
377 { |
|
378 m_drt->webPage()->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, enabled); |
|
379 } |
|
380 |
|
381 void LayoutTestController::setAppCacheMaximumSize(unsigned long long quota) |
|
382 { |
|
383 m_drt->webPage()->settings()->setOfflineWebApplicationCacheQuota(quota); |
|
384 } |
|
385 |
|
386 void LayoutTestController::setJavaScriptProfilingEnabled(bool enable) |
|
387 { |
|
388 setDeveloperExtrasEnabled(enable); |
|
389 DumpRenderTreeSupportQt::setJavaScriptProfilingEnabled(m_topLoadingFrame, enable); |
|
390 } |
|
391 |
|
392 void LayoutTestController::setTimelineProfilingEnabled(bool enable) |
|
393 { |
|
394 DumpRenderTreeSupportQt::setTimelineProfilingEnabled(m_drt->webPage(), enable); |
|
395 } |
|
396 |
|
397 void LayoutTestController::setFixedContentsSize(int width, int height) |
|
398 { |
|
399 m_topLoadingFrame->page()->setPreferredContentsSize(QSize(width, height)); |
|
400 } |
|
401 |
|
402 void LayoutTestController::setPrivateBrowsingEnabled(bool enable) |
|
403 { |
|
404 m_drt->webPage()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable); |
|
405 } |
|
406 |
|
407 void LayoutTestController::setSpatialNavigationEnabled(bool enable) |
|
408 { |
|
409 m_drt->webPage()->settings()->setAttribute(QWebSettings::SpatialNavigationEnabled, enable); |
|
410 } |
|
411 |
|
412 void LayoutTestController::setPopupBlockingEnabled(bool enable) |
|
413 { |
|
414 m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !enable); |
|
415 } |
|
416 |
|
417 void LayoutTestController::setPluginsEnabled(bool flag) |
|
418 { |
|
419 // FIXME: Implement |
|
420 } |
|
421 |
|
422 void LayoutTestController::setPOSIXLocale(const QString& locale) |
|
423 { |
|
424 QLocale qlocale(locale); |
|
425 QLocale::setDefault(qlocale); |
|
426 } |
|
427 |
|
428 void LayoutTestController::setWindowIsKey(bool isKey) |
|
429 { |
|
430 m_drt->switchFocus(isKey); |
|
431 } |
|
432 |
|
433 void LayoutTestController::setMainFrameIsFirstResponder(bool isFirst) |
|
434 { |
|
435 //FIXME: only need this for the moment: https://bugs.webkit.org/show_bug.cgi?id=32990 |
|
436 } |
|
437 |
|
438 void LayoutTestController::setJavaScriptCanAccessClipboard(bool enable) |
|
439 { |
|
440 m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, enable); |
|
441 } |
|
442 |
|
443 void LayoutTestController::setXSSAuditorEnabled(bool enable) |
|
444 { |
|
445 // Set XSSAuditingEnabled globally so that windows created by the test inherit it too. |
|
446 // resetSettings() will call this to reset the page and global setting to false again. |
|
447 // Needed by http/tests/security/xssAuditor/link-opens-new-window.html |
|
448 QWebSettings* globalSettings = QWebSettings::globalSettings(); |
|
449 globalSettings->setAttribute(QWebSettings::XSSAuditingEnabled, enable); |
|
450 m_drt->webPage()->settings()->setAttribute(QWebSettings::XSSAuditingEnabled, enable); |
|
451 } |
|
452 |
|
453 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(const QString& animationName, |
|
454 double time, |
|
455 const QString& elementId) |
|
456 { |
|
457 QWebFrame* frame = m_drt->webPage()->mainFrame(); |
|
458 Q_ASSERT(frame); |
|
459 return DumpRenderTreeSupportQt::pauseAnimation(frame, animationName, time, elementId); |
|
460 } |
|
461 |
|
462 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(const QString& propertyName, |
|
463 double time, |
|
464 const QString& elementId) |
|
465 { |
|
466 QWebFrame* frame = m_drt->webPage()->mainFrame(); |
|
467 Q_ASSERT(frame); |
|
468 return DumpRenderTreeSupportQt::pauseTransitionOfProperty(frame, propertyName, time, elementId); |
|
469 } |
|
470 |
|
471 bool LayoutTestController::sampleSVGAnimationForElementAtTime(const QString& animationId, |
|
472 double time, |
|
473 const QString& elementId) |
|
474 { |
|
475 QWebFrame* frame = m_drt->webPage()->mainFrame(); |
|
476 Q_ASSERT(frame); |
|
477 return DumpRenderTreeSupportQt::pauseSVGAnimation(frame, animationId, time, elementId); |
|
478 } |
|
479 |
|
480 unsigned LayoutTestController::numberOfActiveAnimations() const |
|
481 { |
|
482 QWebFrame* frame = m_drt->webPage()->mainFrame(); |
|
483 Q_ASSERT(frame); |
|
484 return DumpRenderTreeSupportQt::numberOfActiveAnimations(frame); |
|
485 } |
|
486 |
|
487 void LayoutTestController::disableImageLoading() |
|
488 { |
|
489 m_drt->webPage()->settings()->setAttribute(QWebSettings::AutoLoadImages, false); |
|
490 } |
|
491 |
|
492 void LayoutTestController::dispatchPendingLoadRequests() |
|
493 { |
|
494 // FIXME: Implement for testing fix for 6727495 |
|
495 } |
|
496 |
|
497 void LayoutTestController::setDatabaseQuota(int size) |
|
498 { |
|
499 if (!m_topLoadingFrame) |
|
500 return; |
|
501 m_topLoadingFrame->securityOrigin().setDatabaseQuota(size); |
|
502 } |
|
503 |
|
504 void LayoutTestController::clearAllDatabases() |
|
505 { |
|
506 QWebDatabase::removeAllDatabases(); |
|
507 } |
|
508 |
|
509 void LayoutTestController::addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) |
|
510 { |
|
511 DumpRenderTreeSupportQt::whiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); |
|
512 } |
|
513 |
|
514 void LayoutTestController::removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains) |
|
515 { |
|
516 DumpRenderTreeSupportQt::removeWhiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains); |
|
517 } |
|
518 |
|
519 void LayoutTestController::setCustomPolicyDelegate(bool enabled, bool permissive) |
|
520 { |
|
521 DumpRenderTreeSupportQt::setCustomPolicyDelegate(enabled, permissive); |
|
522 } |
|
523 |
|
524 void LayoutTestController::waitForPolicyDelegate() |
|
525 { |
|
526 m_waitForPolicy = true; |
|
527 waitUntilDone(); |
|
528 } |
|
529 |
|
530 void LayoutTestController::overridePreference(const QString& name, const QVariant& value) |
|
531 { |
|
532 QWebSettings* settings = m_topLoadingFrame->page()->settings(); |
|
533 |
|
534 if (name == "WebKitJavaScriptEnabled") |
|
535 settings->setAttribute(QWebSettings::JavascriptEnabled, value.toBool()); |
|
536 else if (name == "WebKitTabToLinksPreferenceKey") |
|
537 settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, value.toBool()); |
|
538 else if (name == "WebKitOfflineWebApplicationCacheEnabled") |
|
539 settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool()); |
|
540 else if (name == "WebKitDefaultFontSize") |
|
541 settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt()); |
|
542 else if (name == "WebKitUsesPageCachePreferenceKey") |
|
543 QWebSettings::setMaximumPagesInCache(value.toInt()); |
|
544 else if (name == "WebKitEnableCaretBrowsing") |
|
545 setCaretBrowsingEnabled(value.toBool()); |
|
546 else if (name == "WebKitPluginsEnabled") |
|
547 settings->setAttribute(QWebSettings::PluginsEnabled, value.toBool()); |
|
548 else if (name == "WebKitWebGLEnabled") |
|
549 settings->setAttribute(QWebSettings::WebGLEnabled, value.toBool()); |
|
550 else |
|
551 printf("ERROR: LayoutTestController::overridePreference() does not support the '%s' preference\n", |
|
552 name.toLatin1().data()); |
|
553 } |
|
554 |
|
555 void LayoutTestController::setUserStyleSheetLocation(const QString& url) |
|
556 { |
|
557 m_userStyleSheetLocation = QUrl(url); |
|
558 |
|
559 if (m_userStyleSheetEnabled) |
|
560 setUserStyleSheetEnabled(true); |
|
561 } |
|
562 |
|
563 void LayoutTestController::setCaretBrowsingEnabled(bool value) |
|
564 { |
|
565 DumpRenderTreeSupportQt::setCaretBrowsingEnabled(m_drt->webPage(), value); |
|
566 } |
|
567 |
|
568 void LayoutTestController::setUserStyleSheetEnabled(bool enabled) |
|
569 { |
|
570 m_userStyleSheetEnabled = enabled; |
|
571 |
|
572 if (enabled) |
|
573 m_drt->webPage()->settings()->setUserStyleSheetUrl(m_userStyleSheetLocation); |
|
574 else |
|
575 m_drt->webPage()->settings()->setUserStyleSheetUrl(QUrl()); |
|
576 } |
|
577 |
|
578 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme) |
|
579 { |
|
580 DumpRenderTreeSupportQt::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme); |
|
581 } |
|
582 |
|
583 int LayoutTestController::workerThreadCount() |
|
584 { |
|
585 return DumpRenderTreeSupportQt::workerThreadCount(); |
|
586 } |
|
587 |
|
588 int LayoutTestController::pageNumberForElementById(const QString& id, float width, float height) |
|
589 { |
|
590 // If no size specified, webpage viewport size is used |
|
591 if (!width && !height) { |
|
592 width = m_drt->webPage()->viewportSize().width(); |
|
593 height = m_drt->webPage()->viewportSize().height(); |
|
594 } |
|
595 |
|
596 return DumpRenderTreeSupportQt::pageNumberForElementById(m_drt->webPage()->mainFrame(), id, width, height); |
|
597 } |
|
598 |
|
599 int LayoutTestController::numberOfPages(float width, float height) |
|
600 { |
|
601 return DumpRenderTreeSupportQt::numberOfPages(m_drt->webPage()->mainFrame(), width, height); |
|
602 } |
|
603 |
|
604 bool LayoutTestController::callShouldCloseOnWebView() |
|
605 { |
|
606 return DumpRenderTreeSupportQt::shouldClose(m_drt->webPage()->mainFrame()); |
|
607 } |
|
608 |
|
609 void LayoutTestController::setScrollbarPolicy(const QString& orientation, const QString& policy) |
|
610 { |
|
611 Qt::Orientation o; |
|
612 Qt::ScrollBarPolicy p; |
|
613 |
|
614 if (orientation == "vertical") |
|
615 o = Qt::Vertical; |
|
616 else if (orientation == "horizontal") |
|
617 o = Qt::Horizontal; |
|
618 else |
|
619 return; |
|
620 |
|
621 if (policy == "on") |
|
622 p = Qt::ScrollBarAlwaysOn; |
|
623 else if (policy == "auto") |
|
624 p = Qt::ScrollBarAsNeeded; |
|
625 else if (policy == "off") |
|
626 p = Qt::ScrollBarAlwaysOff; |
|
627 else |
|
628 return; |
|
629 |
|
630 m_drt->webPage()->mainFrame()->setScrollBarPolicy(o, p); |
|
631 } |
|
632 |
|
633 void LayoutTestController::setSmartInsertDeleteEnabled(bool enable) |
|
634 { |
|
635 DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(m_drt->webPage(), enable); |
|
636 } |
|
637 |
|
638 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool enable) |
|
639 { |
|
640 DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(m_drt->webPage(), enable); |
|
641 } |
|
642 |
|
643 void LayoutTestController::execCommand(const QString& name, const QString& value) |
|
644 { |
|
645 DumpRenderTreeSupportQt::executeCoreCommandByName(m_drt->webPage(), name, value); |
|
646 } |
|
647 |
|
648 bool LayoutTestController::isCommandEnabled(const QString& name) const |
|
649 { |
|
650 return DumpRenderTreeSupportQt::isCommandEnabled(m_drt->webPage(), name); |
|
651 } |
|
652 |
|
653 QString LayoutTestController::markerTextForListItem(const QWebElement& listItem) |
|
654 { |
|
655 return DumpRenderTreeSupportQt::markerTextForListItem(listItem); |
|
656 } |
|
657 |
|
658 QVariantMap LayoutTestController::computedStyleIncludingVisitedInfo(const QWebElement& element) const |
|
659 { |
|
660 return DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(element); |
|
661 } |
|
662 |
|
663 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(const QString& elementId) |
|
664 { |
|
665 return DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(m_drt->webPage()->mainFrame(), elementId); |
|
666 } |
|
667 |
|
668 void LayoutTestController::authenticateSession(const QString&, const QString&, const QString&) |
|
669 { |
|
670 // FIXME: If there is a concept per-session (per-process) credential storage, the credentials should be added to it for later use. |
|
671 } |
|
672 |
|
673 void LayoutTestController::setIconDatabaseEnabled(bool enable) |
|
674 { |
|
675 if (enable && !m_drt->persistentStoragePath().isEmpty()) |
|
676 QWebSettings::setIconDatabasePath(m_drt->persistentStoragePath()); |
|
677 else |
|
678 QWebSettings::setIconDatabasePath(QString()); |
|
679 } |
|
680 |
|
681 void LayoutTestController::setEditingBehavior(const QString& editingBehavior) |
|
682 { |
|
683 DumpRenderTreeSupportQt::setEditingBehavior(m_drt->webPage(), editingBehavior); |
|
684 } |
|
685 |
|
686 void LayoutTestController::setGeolocationPermission(bool allow) |
|
687 { |
|
688 m_isGeolocationPermissionSet = true; |
|
689 m_geolocationPermission = allow; |
|
690 } |
|
691 |
|
692 void LayoutTestController::setMockGeolocationError(int code, const QString& message) |
|
693 { |
|
694 DumpRenderTreeSupportQt::setMockGeolocationError(code, message); |
|
695 } |
|
696 |
|
697 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) |
|
698 { |
|
699 DumpRenderTreeSupportQt::setMockGeolocationPosition(latitude, longitude, accuracy); |
|
700 } |
|
701 |
|
702 void LayoutTestController::evaluateScriptInIsolatedWorld(int worldID, const QString& script) |
|
703 { |
|
704 DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(m_drt->webPage()->mainFrame(), worldID, script); |
|
705 } |
|
706 |
|
707 bool LayoutTestController::isPageBoxVisible(int pageIndex) |
|
708 { |
|
709 return DumpRenderTreeSupportQt::isPageBoxVisible(m_drt->webPage()->mainFrame(), pageIndex); |
|
710 } |
|
711 |
|
712 QString LayoutTestController::pageSizeAndMarginsInPixels(int pageIndex, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) |
|
713 { |
|
714 return DumpRenderTreeSupportQt::pageSizeAndMarginsInPixels(m_drt->webPage()->mainFrame(), pageIndex, |
|
715 width, height, marginTop, marginRight, marginBottom, marginLeft); |
|
716 } |
|
717 |
|
718 QString LayoutTestController::pageProperty(const QString& propertyName, int pageNumber) |
|
719 { |
|
720 return DumpRenderTreeSupportQt::pageProperty(m_drt->webPage()->mainFrame(), propertyName, pageNumber); |
|
721 } |
|
722 |
|
723 void LayoutTestController::addUserStyleSheet(const QString& sourceCode) |
|
724 { |
|
725 DumpRenderTreeSupportQt::addUserStyleSheet(m_drt->webPage(), sourceCode); |
|
726 } |
|
727 |
|
728 const unsigned LayoutTestController::maxViewWidth = 800; |
|
729 const unsigned LayoutTestController::maxViewHeight = 600; |
|