2
* Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com>
3
* Copyright (C) 2012 Apple Inc. All Rights Reserved.
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.
31
#include "TestRunner.h"
33
#include "DumpRenderTree.h"
34
#include "WorkQueue.h"
35
#include "WorkQueueItem.h"
36
#include <JavaScriptCore/JSRetainPtr.h>
37
#include <JavaScriptCore/JSStringRef.h>
43
TestRunner::~TestRunner()
48
void TestRunner::addDisallowedURL(JSStringRef url)
53
void TestRunner::clearBackForwardList()
57
JSStringRef TestRunner::copyDecodedHostName(JSStringRef name)
63
JSStringRef TestRunner::copyEncodedHostName(JSStringRef name)
69
void TestRunner::dispatchPendingLoadRequests()
71
// FIXME: Implement for testing fix for 6727495
74
void TestRunner::display()
78
void TestRunner::keepWebHistory()
83
void TestRunner::notifyDone()
85
if (m_waitToDump && !WorkQueue::shared()->count())
90
JSStringRef TestRunner::pathToLocalResource(JSContextRef context, JSStringRef url)
92
// Function introduced in r28690. This may need special-casing on Windows.
93
return JSStringRetain(url); // Do nothing on Unix.
96
void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
98
// FIXME: We need to resolve relative URLs here
99
WorkQueue::shared()->queue(new LoadItem(url, target));
102
void TestRunner::setAcceptsEditing(bool acceptsEditing)
106
void TestRunner::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
108
// FIXME: Implement this (and restore the default value before running each test in DumpRenderTree.cpp).
111
void TestRunner::setCustomPolicyDelegate(bool, bool)
116
void TestRunner::setMainFrameIsFirstResponder(bool flag)
121
void TestRunner::setTabKeyCyclesThroughElements(bool cycles)
126
void TestRunner::setUseDashboardCompatibilityMode(bool flag)
131
void TestRunner::setUserStyleSheetEnabled(bool flag)
135
void TestRunner::setUserStyleSheetLocation(JSStringRef path)
139
void TestRunner::setValueForUser(JSContextRef context, JSValueRef element, JSStringRef value)
144
void TestRunner::setViewModeMediaFeature(JSStringRef mode)
149
void TestRunner::setWindowIsKey(bool windowIsKey)
154
void TestRunner::setSmartInsertDeleteEnabled(bool flag)
159
void TestRunner::setWaitToDump(bool waitUntilDone)
161
static const int timeoutSeconds = 10;
163
m_waitToDump = waitUntilDone;
166
int TestRunner::windowCount()
172
void TestRunner::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
177
void TestRunner::setJavaScriptCanAccessClipboard(bool enabled)
182
void TestRunner::setXSSAuditorEnabled(bool enabled)
187
void TestRunner::setFrameFlatteningEnabled(bool enabled)
192
void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
197
void TestRunner::setAllowFileAccessFromFileURLs(bool enabled)
202
void TestRunner::setAuthorAndUserStylesEnabled(bool flag)
207
void TestRunner::setAutofilled(JSContextRef, JSValueRef element, bool isAutofilled)
212
void TestRunner::setPopupBlockingEnabled(bool popupBlockingEnabled)
217
void TestRunner::setPluginsEnabled(bool flag)
222
bool TestRunner::elementDoesAutoCompleteForElementWithId(JSStringRef id)
228
void TestRunner::execCommand(JSStringRef name, JSStringRef value)
233
void TestRunner::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
238
void TestRunner::clearPersistentUserStyleSheet()
243
void TestRunner::clearAllApplicationCaches()
245
// FIXME: Implement to support application cache quotas.
248
void TestRunner::clearApplicationCacheForOrigin(JSStringRef url)
250
// FIXME: Implement to support deleting all application cache for an origin.
253
long long TestRunner::localStorageDiskUsageForOrigin(JSStringRef originIdentifier)
255
// FIXME: Implement to support getting disk usage in bytes for an origin.
259
void TestRunner::setApplicationCacheOriginQuota(unsigned long long quota)
261
// FIXME: Implement to support application cache quotas.
264
long long TestRunner::applicationCacheDiskUsageForOrigin(JSStringRef origin)
266
// FIXME: Implement to support getting disk usage by all application caches for an origin.
271
JSValueRef TestRunner::originsWithApplicationCache(JSContextRef context)
273
// FIXME: Implement to get origins that have application caches.
277
void TestRunner::clearAllDatabases()
282
void TestRunner::setDatabaseQuota(unsigned long long quota)
287
void TestRunner::goBack()
289
// FIXME: implement to enable loader/navigation-while-deferring-loads.html
292
void TestRunner::setDefersLoading(bool)
294
// FIXME: implement to enable loader/navigation-while-deferring-loads.html
297
void TestRunner::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
302
void TestRunner::setAppCacheMaximumSize(unsigned long long size)
307
unsigned TestRunner::numberOfActiveAnimations() const
313
unsigned TestRunner::workerThreadCount() const
319
void TestRunner::setSelectTrailingWhitespaceEnabled(bool flag)
324
bool TestRunner::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
330
void TestRunner::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
332
// FIXME: Implement for DeviceOrientation layout tests.
333
// See https://bugs.webkit.org/show_bug.cgi?id=30335.
336
void TestRunner::setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
338
// FIXME: Implement for Geolocation layout tests.
339
// See https://bugs.webkit.org/show_bug.cgi?id=28264.
342
void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef)
344
// FIXME: Implement for Geolocation layout tests.
345
// See https://bugs.webkit.org/show_bug.cgi?id=28264.
348
void TestRunner::setGeolocationPermission(bool allow)
350
// FIXME: Implement for Geolocation layout tests.
351
setGeolocationPermissionCommon(allow);
354
int TestRunner::numberOfPendingGeolocationPermissionRequests()
356
// FIXME: Implement for Geolocation layout tests.
360
void TestRunner::addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language)
362
// FIXME: Implement for speech input layout tests.
363
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
366
void TestRunner::setMockSpeechInputDumpRect(bool flag)
368
// FIXME: Implement for speech input layout tests.
369
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
372
void TestRunner::startSpeechInput(JSContextRef inputElement)
374
// FIXME: Implement for speech input layout tests.
375
// See https://bugs.webkit.org/show_bug.cgi?id=39485.
378
void TestRunner::setIconDatabaseEnabled(bool iconDatabaseEnabled)
383
bool TestRunner::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
389
void TestRunner::setCacheModel(int)
394
bool TestRunner::isCommandEnabled(JSStringRef /*name*/)
400
size_t TestRunner::webHistoryItemCount()
406
void TestRunner::waitForPolicyDelegate()
408
// FIXME: Implement this.
411
void TestRunner::overridePreference(JSStringRef /* key */, JSStringRef /* value */)
416
void TestRunner::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
418
printf("TestRunner::addUserScript not implemented.\n");
421
void TestRunner::addUserStyleSheet(JSStringRef source, bool allFrames)
423
printf("TestRunner::addUserStyleSheet not implemented.\n");
426
void TestRunner::showWebInspector()
428
// FIXME: Implement this.
431
void TestRunner::closeWebInspector()
433
// FIXME: Implement this.
436
void TestRunner::evaluateInWebInspector(long callId, JSStringRef script)
438
// FIXME: Implement this.
441
void TestRunner::removeAllVisitedLinks()
443
// FIXME: Implement this.
446
void TestRunner::evaluateScriptInIsolatedWorldAndReturnValue(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
451
void TestRunner::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
456
void TestRunner::disableImageLoading()
461
void TestRunner::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains)
466
void TestRunner::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains)
471
void TestRunner::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
476
void TestRunner::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
481
void TestRunner::apiTestGoToCurrentBackForwardItem()
486
void TestRunner::setSpatialNavigationEnabled(bool)
491
void TestRunner::setWebViewEditable(bool)
495
bool TestRunner::callShouldCloseOnWebView()
500
JSRetainPtr<JSStringRef> TestRunner::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
505
JSValueRef TestRunner::computedStyleIncludingVisitedInfo(JSContextRef, JSValueRef)
510
void TestRunner::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
514
void TestRunner::abortModal()
518
void TestRunner::setAsynchronousSpellCheckingEnabled(bool)
520
// FIXME: Implement this.
523
bool TestRunner::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
529
void TestRunner::setSerializeHTTPLoads(bool)
534
void TestRunner::setMinimumTimerInterval(double interval)
539
void TestRunner::syncLocalStorage()
544
void TestRunner::observeStorageTrackerNotifications(unsigned number)
549
void TestRunner::deleteAllLocalStorage()
554
JSValueRef TestRunner::originsWithLocalStorage(JSContextRef context)
560
void TestRunner::deleteLocalStorageForOrigin(JSStringRef URL)
565
void TestRunner::setTextDirection(JSStringRef direction)
570
void TestRunner::addChromeInputField()
574
void TestRunner::removeChromeInputField()
578
void TestRunner::focusWebView()
582
void TestRunner::setBackingScaleFactor(double)
586
void TestRunner::simulateDesktopNotificationClick(JSStringRef title)
591
void TestRunner::resetPageVisibility()
593
// FIXME: Implement this.
596
void TestRunner::setPageVisibility(const char*)
598
// FIXME: Implement this.
601
void TestRunner::setAutomaticLinkDetectionEnabled(bool)
603
// FIXME: Implement this.
606
void TestRunner::sendWebIntentResponse(JSStringRef)
608
// FIXME: Implement this.
611
void TestRunner::deliverWebIntent(JSStringRef, JSStringRef, JSStringRef)
613
// FIXME: Implement this.
616
void TestRunner::setStorageDatabaseIdleInterval(double)
618
// FIXME: Implement this.