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
#include "TestRunnerQt.h"
32
#include "DumpRenderTreeQt.h"
33
#include "DumpRenderTreeSupportQt.h"
34
#include "WorkQueue.h"
35
#include "WorkQueueItemQt.h"
36
#include <QCoreApplication>
39
#include <qwebsettings.h>
41
TestRunner::TestRunner(WebCore::DumpRenderTree* drt)
44
, m_shouldTimeout(true)
48
DumpRenderTreeSupportQt::dumpNotification(true);
51
void TestRunner::reset()
54
m_loadFinished = false;
56
m_shouldDumpPixels = true;
57
m_dumpBackForwardList = false;
58
m_dumpChildrenAsText = false;
59
m_dumpChildFrameScrollPositions = false;
60
m_canOpenWindows = false;
61
m_waitForDone = false;
62
m_disallowIncreaseForApplicationCacheQuota = false;
63
m_dumpTitleChanges = false;
64
m_dumpDatabaseCallbacks = false;
65
m_dumpApplicationCacheDelegateCallbacks = false;
66
m_dumpStatusCallbacks = false;
67
m_timeoutTimer.stop();
68
m_topLoadingFrame = 0;
69
m_waitForPolicy = false;
70
m_handleErrorPages = false;
73
m_userStyleSheetEnabled = false;
74
m_desktopNotificationAllowedOrigins.clear();
75
m_ignoreDesktopNotification = false;
76
m_isGeolocationPermissionSet = false;
78
m_geolocationPermission = false;
80
DumpRenderTreeSupportQt::dumpEditingCallbacks(false);
81
DumpRenderTreeSupportQt::dumpFrameLoader(false);
82
DumpRenderTreeSupportQt::dumpProgressFinishedCallback(false);
83
DumpRenderTreeSupportQt::dumpUserGestureInFrameLoader(false);
84
DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false);
85
DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(false);
86
DumpRenderTreeSupportQt::dumpWillCacheResponseCallbacks(false);
87
DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(true);
88
DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(false);
89
DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(false);
90
DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(QStringList());
91
DumpRenderTreeSupportQt::clearScriptWorlds();
92
DumpRenderTreeSupportQt::setCustomPolicyDelegate(false, false);
93
DumpRenderTreeSupportQt::dumpHistoryCallbacks(false);
94
DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(false);
95
DumpRenderTreeSupportQt::resetGeolocationMock(m_drt->webPage());
96
setIconDatabaseEnabled(false);
98
// The default state for DRT is to block third-party cookies, mimicing the Mac port
99
setAlwaysAcceptCookies(false);
103
void TestRunner::processWork()
105
// qDebug() << ">>>processWork";
107
// if we didn't start a new load, then we finished all the commands, so we're ready to dump state
108
if (WorkQueue::shared()->processWork() && !shouldWaitUntilDone()) {
114
// Called on loadFinished on WebPage
115
void TestRunner::maybeDump(bool /*success*/)
118
// This can happen on any of the http/tests/security/window-events-*.html tests, where the test opens
119
// a new window, calls the unload and load event handlers on the window's page, and then immediately
120
// issues a notifyDone. Needs investigation.
121
if (!m_topLoadingFrame)
124
// It is possible that we get called by windows created from the main page that have finished
125
// loading, so we don't ASSERT here. At the moment we do not gather results from such windows,
126
// but may need to in future.
127
if (sender() != m_topLoadingFrame->page())
130
m_loadFinished = true;
131
// as the function is called on loadFinished, the test might
132
// already have dumped and thus no longer be active, thus
137
WorkQueue::shared()->setFrozen(true); // first complete load freezes the queue for the rest of this test
138
if (WorkQueue::shared()->count())
139
QTimer::singleShot(0, this, SLOT(processWork()));
140
else if (!shouldWaitUntilDone()) {
146
void TestRunner::dumpAsText(bool shouldDumpPixels)
149
m_shouldDumpPixels = shouldDumpPixels;
152
void TestRunner::waitUntilDone()
154
//qDebug() << ">>>>waitForDone";
155
m_waitForDone = true;
157
if (!m_shouldTimeout)
160
m_timeoutTimer.start(m_timeout, this);
163
void TestRunner::setViewModeMediaFeature(const QString& mode)
165
m_drt->webPage()->setProperty("_q_viewMode", mode);
168
int TestRunner::webHistoryItemCount()
173
// Subtract one here as our QWebHistory::count() includes the actual page,
174
// which is not considered in the DRT tests.
175
return m_webHistory->count() - 1;
178
void TestRunner::keepWebHistory()
180
m_webHistory = m_drt->webPage()->history();
183
void TestRunner::notifyDone()
185
qDebug() << ">>>>notifyDone";
187
if (m_shouldTimeout && !m_timeoutTimer.isActive())
190
m_timeoutTimer.stop();
191
m_waitForDone = false;
193
// If the page has not finished loading (i.e. loadFinished() has not been emitted) then
194
// content created by the likes of document.write() JS methods will not be available yet.
195
// When the page has finished loading, maybeDump above will dump the results now that we have
196
// just set shouldWaitUntilDone to false.
202
// FIXME: investigate why always resetting these result in timeouts
204
m_waitForPolicy = false;
207
int TestRunner::windowCount()
209
return m_drt->windowCount();
212
void TestRunner::grantWebNotificationPermission(const QString& origin)
214
QWebFrame* frame = m_drt->webPage()->mainFrame();
215
m_drt->webPage()->setFeaturePermission(frame, QWebPage::Notifications, QWebPage::PermissionGrantedByUser);
216
m_desktopNotificationAllowedOrigins.append(origin);
219
void TestRunner::ignoreLegacyWebNotificationPermissionRequests()
221
m_ignoreDesktopNotification = true;
224
void TestRunner::denyWebNotificationPermission(const QString& origin)
229
void TestRunner::removeAllWebNotificationPermissions()
234
void TestRunner::simulateWebNotificationClick(const QWebElement& notification)
239
void TestRunner::simulateLegacyWebNotificationClick(const QString& title)
241
DumpRenderTreeSupportQt::simulateDesktopNotificationClick(title);
244
void TestRunner::display()
246
DumpRenderTreeSupportQt::setTrackRepaintRects(m_topLoadingFrame, true);
250
void TestRunner::displayInvalidatedRegion()
255
void TestRunner::clearBackForwardList()
257
m_drt->webPage()->history()->clear();
260
QString TestRunner::pathToLocalResource(const QString& url)
262
QString localTmpUrl(QLatin1String("file:///tmp/LayoutTests"));
264
// Translate a request for /tmp/LayoutTests to the repository LayoutTests directory.
265
// Do not rely on a symlink to be created via the test runner, which will not work on Windows.
266
if (url.startsWith(localTmpUrl)) {
267
// DumpRenderTree lives in WebKit/WebKitBuild/<build_mode>/bin.
268
// Translate from WebKit/WebKitBuild/Release/bin => WebKit/LayoutTests.
269
QFileInfo layoutTestsRoot(QCoreApplication::applicationDirPath() + QLatin1String("/../../../LayoutTests/"));
270
if (layoutTestsRoot.exists())
271
return QLatin1String("file://") + layoutTestsRoot.absolutePath() + url.mid(localTmpUrl.length());
277
void TestRunner::dumpEditingCallbacks()
279
qDebug() << ">>>dumpEditingCallbacks";
280
DumpRenderTreeSupportQt::dumpEditingCallbacks(true);
283
void TestRunner::dumpFrameLoadCallbacks()
285
DumpRenderTreeSupportQt::dumpFrameLoader(true);
288
void TestRunner::dumpProgressFinishedCallback()
290
DumpRenderTreeSupportQt::dumpProgressFinishedCallback(true);
293
void TestRunner::dumpUserGestureInFrameLoadCallbacks()
295
DumpRenderTreeSupportQt::dumpUserGestureInFrameLoader(true);
298
void TestRunner::dumpResourceLoadCallbacks()
300
DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(true);
303
void TestRunner::dumpResourceResponseMIMETypes()
305
DumpRenderTreeSupportQt::dumpResourceResponseMIMETypes(true);
308
void TestRunner::dumpWillCacheResponse()
310
DumpRenderTreeSupportQt::dumpWillCacheResponseCallbacks(true);
313
void TestRunner::dumpHistoryCallbacks()
315
DumpRenderTreeSupportQt::dumpHistoryCallbacks(true);
318
void TestRunner::setWillSendRequestReturnsNullOnRedirect(bool enabled)
320
DumpRenderTreeSupportQt::setWillSendRequestReturnsNullOnRedirect(enabled);
323
void TestRunner::setWillSendRequestReturnsNull(bool enabled)
325
DumpRenderTreeSupportQt::setWillSendRequestReturnsNull(enabled);
328
void TestRunner::setWillSendRequestClearHeader(const QStringList& headers)
330
DumpRenderTreeSupportQt::setWillSendRequestClearHeaders(headers);
333
void TestRunner::setDeferMainResourceDataLoad(bool defer)
335
DumpRenderTreeSupportQt::setDeferMainResourceDataLoad(defer);
338
void TestRunner::queueBackNavigation(int howFarBackward)
340
//qDebug() << ">>>queueBackNavigation" << howFarBackward;
341
for (int i = 0; i != howFarBackward; ++i)
342
WorkQueue::shared()->queue(new BackItem(1, m_drt->webPage()));
345
void TestRunner::queueForwardNavigation(int howFarForward)
347
//qDebug() << ">>>queueForwardNavigation" << howFarForward;
348
for (int i = 0; i != howFarForward; ++i)
349
WorkQueue::shared()->queue(new ForwardItem(1, m_drt->webPage()));
352
void TestRunner::queueLoad(const QString& url, const QString& target)
354
//qDebug() << ">>>queueLoad" << url << target;
355
QUrl mainResourceUrl = m_drt->webPage()->mainFrame()->url();
356
QString absoluteUrl = mainResourceUrl.resolved(QUrl(url)).toEncoded();
357
WorkQueue::shared()->queue(new LoadItem(absoluteUrl, target, m_drt->webPage()));
360
void TestRunner::queueLoadHTMLString(const QString& content, const QString& baseURL, const QString& failingURL)
362
if (failingURL.isEmpty())
363
WorkQueue::shared()->queue(new LoadHTMLStringItem(content, baseURL, m_drt->webPage()));
365
WorkQueue::shared()->queue(new LoadAlternateHTMLStringItem(content, baseURL, failingURL, m_drt->webPage()));
368
void TestRunner::queueReload()
370
//qDebug() << ">>>queueReload";
371
WorkQueue::shared()->queue(new ReloadItem(m_drt->webPage()));
374
void TestRunner::queueLoadingScript(const QString& script)
376
//qDebug() << ">>>queueLoadingScript" << script;
377
WorkQueue::shared()->queue(new LoadingScriptItem(script, m_drt->webPage()));
380
void TestRunner::queueNonLoadingScript(const QString& script)
382
//qDebug() << ">>>queueNonLoadingScript" << script;
383
WorkQueue::shared()->queue(new NonLoadingScriptItem(script, m_drt->webPage()));
386
void TestRunner::provisionalLoad()
388
QWebFrame* frame = qobject_cast<QWebFrame*>(sender());
389
if (!m_topLoadingFrame && !m_hasDumped)
390
m_topLoadingFrame = frame;
393
void TestRunner::timerEvent(QTimerEvent *ev)
395
if (ev->timerId() == m_timeoutTimer.timerId()) {
396
const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
397
fprintf(stderr, "%s", message);
398
fprintf(stdout, "%s", message);
401
QObject::timerEvent(ev);
404
QString TestRunner::encodeHostName(const QString& host)
406
QString encoded = QString::fromLatin1(QUrl::toAce(host + QLatin1String(".no")));
407
encoded.truncate(encoded.length() - 3); // strip .no
411
QString TestRunner::decodeHostName(const QString& host)
413
QString decoded = QUrl::fromAce(host.toLatin1() + QByteArray(".no"));
414
decoded.truncate(decoded.length() - 3);
418
void TestRunner::closeWebInspector()
420
DumpRenderTreeSupportQt::webInspectorClose(m_drt->webPage());
421
m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
424
void TestRunner::setDeveloperExtrasEnabled(bool enabled)
426
m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enabled);
429
void TestRunner::setAsynchronousSpellCheckingEnabled(bool)
431
// FIXME: Implement this.
434
void TestRunner::showWebInspector()
436
m_drt->webPage()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
437
DumpRenderTreeSupportQt::webInspectorShow(m_drt->webPage());
440
void TestRunner::evaluateInWebInspector(long callId, const QString& script)
442
DumpRenderTreeSupportQt::webInspectorExecuteScript(m_drt->webPage(), callId, script);
445
void TestRunner::setFrameFlatteningEnabled(bool enabled)
447
DumpRenderTreeSupportQt::setFrameFlatteningEnabled(m_drt->webPage(), enabled);
450
void TestRunner::goBack()
452
DumpRenderTreeSupportQt::goBack(m_drt->webPage());
455
void TestRunner::setDefersLoading(bool flag)
457
DumpRenderTreeSupportQt::setDefersLoading(m_drt->webPage(), flag);
460
void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
462
m_drt->webPage()->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, enabled);
465
void TestRunner::setAllowFileAccessFromFileURLs(bool enabled)
467
m_drt->webPage()->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, enabled);
470
void TestRunner::setAppCacheMaximumSize(unsigned long long quota)
472
m_drt->webPage()->settings()->setOfflineWebApplicationCacheQuota(quota);
475
void TestRunner::setAutofilled(const QWebElement& element, bool isAutofilled)
477
return DumpRenderTreeSupportQt::setAutofilled(element, isAutofilled);
480
void TestRunner::setValueForUser(const QWebElement& element, const QString& value)
482
DumpRenderTreeSupportQt::setValueForUser(element, value);
485
void TestRunner::setFixedContentsSize(int width, int height)
487
m_topLoadingFrame->page()->setPreferredContentsSize(QSize(width, height));
490
void TestRunner::setPrivateBrowsingEnabled(bool enable)
492
m_drt->webPage()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, enable);
495
void TestRunner::setSpatialNavigationEnabled(bool enable)
497
m_drt->webPage()->settings()->setAttribute(QWebSettings::SpatialNavigationEnabled, enable);
500
void TestRunner::setPopupBlockingEnabled(bool enable)
502
m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, !enable);
505
void TestRunner::setPluginsEnabled(bool flag)
510
void TestRunner::setPOSIXLocale(const QString& locale)
512
QLocale qlocale(locale);
513
QLocale::setDefault(qlocale);
516
void TestRunner::setWindowIsKey(bool isKey)
518
m_drt->switchFocus(isKey);
521
void TestRunner::setMainFrameIsFirstResponder(bool isFirst)
523
//FIXME: only need this for the moment: https://bugs.webkit.org/show_bug.cgi?id=32990
526
void TestRunner::setJavaScriptCanAccessClipboard(bool enable)
528
m_drt->webPage()->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, enable);
531
void TestRunner::setXSSAuditorEnabled(bool enable)
533
// Set XSSAuditingEnabled globally so that windows created by the test inherit it too.
534
// resetSettings() will call this to reset the page and global setting to false again.
535
// Needed by http/tests/security/xssAuditor/link-opens-new-window.html
536
QWebSettings* globalSettings = QWebSettings::globalSettings();
537
globalSettings->setAttribute(QWebSettings::XSSAuditingEnabled, enable);
538
m_drt->webPage()->settings()->setAttribute(QWebSettings::XSSAuditingEnabled, enable);
541
bool TestRunner::pauseAnimationAtTimeOnElementWithId(const QString& animationName,
543
const QString& elementId)
545
QWebFrame* frame = m_drt->webPage()->mainFrame();
547
return DumpRenderTreeSupportQt::pauseAnimation(frame, animationName, time, elementId);
550
bool TestRunner::pauseTransitionAtTimeOnElementWithId(const QString& propertyName,
552
const QString& elementId)
554
QWebFrame* frame = m_drt->webPage()->mainFrame();
556
return DumpRenderTreeSupportQt::pauseTransitionOfProperty(frame, propertyName, time, elementId);
559
unsigned TestRunner::numberOfActiveAnimations() const
561
QWebFrame* frame = m_drt->webPage()->mainFrame();
563
return DumpRenderTreeSupportQt::numberOfActiveAnimations(frame);
566
void TestRunner::disableImageLoading()
568
m_drt->webPage()->settings()->setAttribute(QWebSettings::AutoLoadImages, false);
571
void TestRunner::dispatchPendingLoadRequests()
573
// FIXME: Implement for testing fix for 6727495
576
void TestRunner::clearAllApplicationCaches()
578
DumpRenderTreeSupportQt::clearAllApplicationCaches();
581
void TestRunner::clearApplicationCacheForOrigin(const QString& url)
583
// FIXME: Implement to support deleting all application caches for an origin.
586
long long TestRunner::localStorageDiskUsageForOrigin(const QString& originIdentifier)
588
// FIXME: Implement to support getting disk usage in bytes for an origin.
592
void TestRunner::setApplicationCacheOriginQuota(unsigned long long quota)
594
if (!m_topLoadingFrame)
596
m_topLoadingFrame->securityOrigin().setApplicationCacheQuota(quota);
599
long long TestRunner::applicationCacheDiskUsageForOrigin(const QString& origin)
601
// FIXME: Implement to support getting disk usage by all application caches for an origin.
605
QStringList TestRunner::originsWithApplicationCache()
607
// FIXME: Implement to get origins that have application caches.
608
return QStringList();
611
void TestRunner::setCacheModel(int model)
613
// qwebsetting doesn't have matched setting yet :
614
// WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER
615
// WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER
616
// WEBKIT_CACHE_MODEL_WEB_BROWSER
621
void TestRunner::setDatabaseQuota(int size)
623
if (!m_topLoadingFrame)
625
m_topLoadingFrame->securityOrigin().setDatabaseQuota(size);
628
void TestRunner::clearAllDatabases()
630
QWebDatabase::removeAllDatabases();
633
void TestRunner::addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains)
635
DumpRenderTreeSupportQt::whiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains);
638
void TestRunner::removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains)
640
DumpRenderTreeSupportQt::removeWhiteListAccessFromOrigin(sourceOrigin, destinationProtocol, destinationHost, allowDestinationSubdomains);
643
void TestRunner::setCustomPolicyDelegate(bool enabled, bool permissive)
645
DumpRenderTreeSupportQt::setCustomPolicyDelegate(enabled, permissive);
648
void TestRunner::waitForPolicyDelegate()
650
setCustomPolicyDelegate(true);
651
m_waitForPolicy = true;
655
void TestRunner::overridePreference(const QString& name, const QVariant& value)
657
QWebSettings* settings = m_topLoadingFrame->page()->settings();
659
if (name == "WebKitJavaScriptEnabled")
660
settings->setAttribute(QWebSettings::JavascriptEnabled, value.toBool());
661
else if (name == "WebKitTabToLinksPreferenceKey")
662
settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, value.toBool());
663
else if (name == "WebKitOfflineWebApplicationCacheEnabled")
664
settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, value.toBool());
665
else if (name == "WebKitDefaultFontSize")
666
settings->setFontSize(QWebSettings::DefaultFontSize, value.toInt());
667
else if (name == "WebKitUsesPageCachePreferenceKey")
668
QWebSettings::setMaximumPagesInCache(value.toInt());
669
else if (name == "WebKitEnableCaretBrowsing")
670
setCaretBrowsingEnabled(value.toBool());
671
else if (name == "WebKitPluginsEnabled")
672
settings->setAttribute(QWebSettings::PluginsEnabled, value.toBool());
673
else if (name == "WebKitWebGLEnabled")
674
settings->setAttribute(QWebSettings::WebGLEnabled, value.toBool());
675
else if (name == "WebKitCSSRegionsEnabled")
676
settings->setAttribute(QWebSettings::CSSRegionsEnabled, value.toBool());
677
else if (name == "WebKitCSSGridLayoutEnabled")
678
settings->setAttribute(QWebSettings::CSSGridLayoutEnabled, value.toBool());
679
else if (name == "WebKitHyperlinkAuditingEnabled")
680
settings->setAttribute(QWebSettings::HyperlinkAuditingEnabled, value.toBool());
681
else if (name == "WebKitAcceleratedCompositingEnabled")
682
settings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, value.toBool());
683
else if (name == "WebKitDisplayImagesKey")
684
settings->setAttribute(QWebSettings::AutoLoadImages, value.toBool());
686
printf("ERROR: TestRunner::overridePreference() does not support the '%s' preference\n",
687
name.toLatin1().data());
690
void TestRunner::setUserStyleSheetLocation(const QString& url)
692
QByteArray urlData = pathToLocalResource(url).toLatin1();
693
m_userStyleSheetLocation = QUrl::fromEncoded(urlData, QUrl::StrictMode);
695
if (m_userStyleSheetEnabled)
696
setUserStyleSheetEnabled(true);
699
void TestRunner::setCaretBrowsingEnabled(bool value)
701
DumpRenderTreeSupportQt::setCaretBrowsingEnabled(m_drt->webPage(), value);
704
void TestRunner::setAuthorAndUserStylesEnabled(bool value)
706
DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled(m_drt->webPage(), value);
709
void TestRunner::setUserStyleSheetEnabled(bool enabled)
711
m_userStyleSheetEnabled = enabled;
714
m_drt->webPage()->settings()->setUserStyleSheetUrl(m_userStyleSheetLocation);
716
m_drt->webPage()->settings()->setUserStyleSheetUrl(QUrl());
719
void TestRunner::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme)
721
DumpRenderTreeSupportQt::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme);
724
int TestRunner::workerThreadCount()
726
return DumpRenderTreeSupportQt::workerThreadCount();
729
bool TestRunner::callShouldCloseOnWebView()
731
return DumpRenderTreeSupportQt::shouldClose(m_drt->webPage()->mainFrame());
734
void TestRunner::setScrollbarPolicy(const QString& orientation, const QString& policy)
737
Qt::ScrollBarPolicy p;
739
if (orientation == "vertical")
741
else if (orientation == "horizontal")
747
p = Qt::ScrollBarAlwaysOn;
748
else if (policy == "auto")
749
p = Qt::ScrollBarAsNeeded;
750
else if (policy == "off")
751
p = Qt::ScrollBarAlwaysOff;
755
m_drt->webPage()->mainFrame()->setScrollBarPolicy(o, p);
758
void TestRunner::setSmartInsertDeleteEnabled(bool enable)
760
DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(m_drt->webPage(), enable);
763
void TestRunner::setSelectTrailingWhitespaceEnabled(bool enable)
765
DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(m_drt->webPage(), enable);
768
void TestRunner::execCommand(const QString& name, const QString& value)
770
DumpRenderTreeSupportQt::executeCoreCommandByName(m_drt->webPage(), name, value);
773
bool TestRunner::isCommandEnabled(const QString& name) const
775
return DumpRenderTreeSupportQt::isCommandEnabled(m_drt->webPage(), name);
778
bool TestRunner::findString(const QString& string, const QStringList& optionArray)
780
return DumpRenderTreeSupportQt::findString(m_drt->webPage(), string, optionArray);
783
QString TestRunner::markerTextForListItem(const QWebElement& listItem)
785
return DumpRenderTreeSupportQt::markerTextForListItem(listItem);
788
QVariantMap TestRunner::computedStyleIncludingVisitedInfo(const QWebElement& element) const
790
return DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(element);
793
bool TestRunner::elementDoesAutoCompleteForElementWithId(const QString& elementId)
795
return DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(m_drt->webPage()->mainFrame(), elementId);
798
void TestRunner::authenticateSession(const QString&, const QString&, const QString&)
800
// FIXME: If there is a concept per-session (per-process) credential storage, the credentials should be added to it for later use.
803
void TestRunner::setIconDatabaseEnabled(bool enable)
805
if (enable && !m_drt->persistentStoragePath().isEmpty())
806
QWebSettings::setIconDatabasePath(m_drt->persistentStoragePath());
808
QWebSettings::setIconDatabasePath(QString());
811
void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
813
QList<WebCore::WebPage*> pages = m_drt->getAllPages();
814
foreach (WebCore::WebPage* page, pages)
815
DumpRenderTreeSupportQt::setMockDeviceOrientation(page, canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
818
void TestRunner::setGeolocationPermission(bool allow)
820
setGeolocationPermissionCommon(allow);
821
QList<WebCore::WebPage*> pages = m_drt->getAllPages();
822
foreach (WebCore::WebPage* page, pages)
823
DumpRenderTreeSupportQt::setMockGeolocationPermission(page, allow);
826
int TestRunner::numberOfPendingGeolocationPermissionRequests()
828
int pendingPermissionCount = 0;
829
QList<WebCore::WebPage*> pages = m_drt->getAllPages();
830
foreach (WebCore::WebPage* page, pages)
831
pendingPermissionCount += DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(page);
833
return pendingPermissionCount;
836
void TestRunner::setGeolocationPermissionCommon(bool allow)
838
m_isGeolocationPermissionSet = true;
839
m_geolocationPermission = allow;
842
void TestRunner::setMockGeolocationPositionUnavailableError(const QString& message)
844
QList<WebCore::WebPage*> pages = m_drt->getAllPages();
845
foreach (WebCore::WebPage* page, pages)
846
DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(page, message);
849
void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
851
QList<WebCore::WebPage*> pages = m_drt->getAllPages();
852
foreach (WebCore::WebPage* page, pages)
853
DumpRenderTreeSupportQt::setMockGeolocationPosition(page, latitude, longitude, accuracy);
856
void TestRunner::addMockSpeechInputResult(const QString& result, double confidence, const QString& language)
858
// FIXME: Implement for speech input layout tests.
859
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
862
void TestRunner::setMockSpeechInputDumpRect(bool flag)
864
// FIXME: Implement for speech input layout tests.
865
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
868
void TestRunner::startSpeechInput(const QString& inputElement)
870
// FIXME: Implement for speech input layout tests.
871
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
874
void TestRunner::evaluateScriptInIsolatedWorldAndReturnValue(int worldID, const QString& script)
879
void TestRunner::evaluateScriptInIsolatedWorld(int worldID, const QString& script)
881
DumpRenderTreeSupportQt::evaluateScriptInIsolatedWorld(m_drt->webPage()->mainFrame(), worldID, script);
884
void TestRunner::addUserStyleSheet(const QString& sourceCode)
886
DumpRenderTreeSupportQt::addUserStyleSheet(m_drt->webPage(), sourceCode);
889
void TestRunner::removeAllVisitedLinks()
891
QWebHistory* history = m_drt->webPage()->history();
893
DumpRenderTreeSupportQt::dumpVisitedLinksCallbacks(true);
896
void TestRunner::addURLToRedirect(const QString& origin, const QString& destination)
898
DumpRenderTreeSupportQt::addURLToRedirect(origin, destination);
901
void TestRunner::setMinimumTimerInterval(double minimumTimerInterval)
903
DumpRenderTreeSupportQt::setMinimumTimerInterval(m_drt->webPage(), minimumTimerInterval);
906
void TestRunner::originsWithLocalStorage()
911
void TestRunner::deleteAllLocalStorage()
916
void TestRunner::deleteLocalStorageForOrigin(const QString& originIdentifier)
921
void TestRunner::observeStorageTrackerNotifications(unsigned number)
926
void TestRunner::syncLocalStorage()
931
void TestRunner::resetPageVisibility()
933
// FIXME: Implement this.
936
void TestRunner::setPageVisibility(const char*)
938
// FIXME: Implement this.
941
void TestRunner::setAutomaticLinkDetectionEnabled(bool)
943
// FIXME: Implement this.
946
void TestRunner::setTextDirection(const QString& directionName)
948
if (directionName == "auto")
949
m_drt->webPage()->triggerAction(QWebPage::SetTextDirectionDefault);
950
else if (directionName == "rtl")
951
m_drt->webPage()->triggerAction(QWebPage::SetTextDirectionRightToLeft);
952
else if (directionName == "ltr")
953
m_drt->webPage()->triggerAction(QWebPage::SetTextDirectionLeftToRight);
956
void TestRunner::setAlwaysAcceptCookies(bool accept)
958
QWebSettings* globalSettings = QWebSettings::globalSettings();
960
globalSettings->setThirdPartyCookiePolicy(QWebSettings::AlwaysAllowThirdPartyCookies);
962
// This matches the Safari third-party cookie blocking policy tested in third-party-cookie-relaxing.html
963
globalSettings->setThirdPartyCookiePolicy(QWebSettings::AllowThirdPartyWithExistingCookies);
967
void TestRunner::setAlwaysBlockCookies(bool block)
969
QWebSettings* globalSettings = QWebSettings::globalSettings();
971
globalSettings->setThirdPartyCookiePolicy(QWebSettings::AlwaysBlockThirdPartyCookies);
973
globalSettings->setThirdPartyCookiePolicy(QWebSettings::AlwaysAllowThirdPartyCookies);
976
const unsigned TestRunner::maxViewWidth = 800;
977
const unsigned TestRunner::maxViewHeight = 600;