2 * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "LayoutTestController.h"
32 #include "DumpRenderTree.h"
33 #include "WorkQueue.h"
34 #include "WorkQueueItem.h"
35 #include <JavaScriptCore/JSRetainPtr.h>
36 #include <JavaScriptCore/JSStringRef.h>
42 LayoutTestController::~LayoutTestController()
47 void LayoutTestController::addDisallowedURL(JSStringRef url)
52 void LayoutTestController::clearBackForwardList()
56 JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
62 JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
68 void LayoutTestController::dispatchPendingLoadRequests()
70 // FIXME: Implement for testing fix for 6727495
73 void LayoutTestController::display()
77 void LayoutTestController::keepWebHistory()
82 void LayoutTestController::notifyDone()
84 if (m_waitToDump && !WorkQueue::shared()->count())
89 JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
91 // Function introduced in r28690. This may need special-casing on Windows.
92 return JSStringRetain(url); // Do nothing on Unix.
95 void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
97 // FIXME: We need to resolve relative URLs here
98 WorkQueue::shared()->queue(new LoadItem(url, target));
101 void LayoutTestController::setAcceptsEditing(bool acceptsEditing)
105 void LayoutTestController::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
107 // FIXME: Implement this (and restore the default value before running each test in DumpRenderTree.cpp).
110 void LayoutTestController::setCustomPolicyDelegate(bool, bool)
115 void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
120 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
125 void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
130 void LayoutTestController::setUserStyleSheetEnabled(bool flag)
134 void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
138 void LayoutTestController::setValueForUser(JSContextRef context, JSValueRef element, JSStringRef value)
143 void LayoutTestController::setViewModeMediaFeature(JSStringRef mode)
148 void LayoutTestController::setWindowIsKey(bool windowIsKey)
153 void LayoutTestController::setSmartInsertDeleteEnabled(bool flag)
158 void LayoutTestController::setWaitToDump(bool waitUntilDone)
160 static const int timeoutSeconds = 10;
162 m_waitToDump = waitUntilDone;
165 int LayoutTestController::windowCount()
171 void LayoutTestController::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
176 void LayoutTestController::setJavaScriptCanAccessClipboard(bool enabled)
181 void LayoutTestController::setXSSAuditorEnabled(bool enabled)
186 void LayoutTestController::setFrameFlatteningEnabled(bool enabled)
191 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
196 void LayoutTestController::setAllowFileAccessFromFileURLs(bool enabled)
201 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
206 void LayoutTestController::setAutofilled(JSContextRef, JSValueRef element, bool isAutofilled)
211 void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled)
216 void LayoutTestController::setPluginsEnabled(bool flag)
221 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
227 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
232 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
237 void LayoutTestController::clearPersistentUserStyleSheet()
242 void LayoutTestController::clearAllApplicationCaches()
244 // FIXME: Implement to support application cache quotas.
247 void LayoutTestController::clearApplicationCacheForOrigin(JSStringRef url)
249 // FIXME: Implement to support deleting all application cache for an origin.
252 long long LayoutTestController::localStorageDiskUsageForOrigin(JSStringRef originIdentifier)
254 // FIXME: Implement to support getting disk usage in bytes for an origin.
258 void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
260 // FIXME: Implement to support application cache quotas.
263 long long LayoutTestController::applicationCacheDiskUsageForOrigin(JSStringRef origin)
265 // FIXME: Implement to support getting disk usage by all application caches for an origin.
270 JSValueRef LayoutTestController::originsWithApplicationCache(JSContextRef context)
272 // FIXME: Implement to get origins that have application caches.
276 void LayoutTestController::clearAllDatabases()
281 void LayoutTestController::setDatabaseQuota(unsigned long long quota)
286 void LayoutTestController::goBack()
288 // FIXME: implement to enable loader/navigation-while-deferring-loads.html
291 void LayoutTestController::setDefersLoading(bool)
293 // FIXME: implement to enable loader/navigation-while-deferring-loads.html
296 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
301 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
306 unsigned LayoutTestController::numberOfActiveAnimations() const
312 unsigned LayoutTestController::workerThreadCount() const
318 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
323 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
329 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
331 // FIXME: Implement for DeviceOrientation layout tests.
332 // See https://bugs.webkit.org/show_bug.cgi?id=30335.
335 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
337 // FIXME: Implement for Geolocation layout tests.
338 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
341 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message)
343 // FIXME: Implement for Geolocation layout tests.
344 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
347 void LayoutTestController::setGeolocationPermission(bool allow)
349 // FIXME: Implement for Geolocation layout tests.
350 setGeolocationPermissionCommon(allow);
353 int LayoutTestController::numberOfPendingGeolocationPermissionRequests()
355 // FIXME: Implement for Geolocation layout tests.
359 void LayoutTestController::addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language)
361 // FIXME: Implement for speech input layout tests.
362 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
365 void LayoutTestController::setMockSpeechInputDumpRect(bool flag)
367 // FIXME: Implement for speech input layout tests.
368 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
371 void LayoutTestController::startSpeechInput(JSContextRef inputElement)
373 // FIXME: Implement for speech input layout tests.
374 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
377 void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled)
382 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
388 void LayoutTestController::setCacheModel(int)
393 bool LayoutTestController::isCommandEnabled(JSStringRef /*name*/)
399 size_t LayoutTestController::webHistoryItemCount()
405 void LayoutTestController::waitForPolicyDelegate()
407 // FIXME: Implement this.
410 void LayoutTestController::overridePreference(JSStringRef /* key */, JSStringRef /* value */)
415 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
417 printf("LayoutTestController::addUserScript not implemented.\n");
420 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
422 printf("LayoutTestController::addUserStyleSheet not implemented.\n");
425 void LayoutTestController::showWebInspector()
427 // FIXME: Implement this.
430 void LayoutTestController::closeWebInspector()
432 // FIXME: Implement this.
435 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script)
437 // FIXME: Implement this.
440 void LayoutTestController::removeAllVisitedLinks()
442 // FIXME: Implement this.
445 void LayoutTestController::evaluateScriptInIsolatedWorldAndReturnValue(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
450 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
455 void LayoutTestController::disableImageLoading()
460 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains)
465 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains)
470 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
475 int LayoutTestController::numberOfPages(float, float)
481 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
486 void LayoutTestController::apiTestGoToCurrentBackForwardItem()
491 void LayoutTestController::setSpatialNavigationEnabled(bool)
496 void LayoutTestController::setWebViewEditable(bool)
500 bool LayoutTestController::callShouldCloseOnWebView()
505 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
510 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
515 JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef, JSValueRef)
520 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
524 void LayoutTestController::abortModal()
528 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
534 JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const
540 void LayoutTestController::setAsynchronousSpellCheckingEnabled(bool)
542 // FIXME: Implement this.
545 bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
551 void LayoutTestController::setSerializeHTTPLoads(bool)
556 void LayoutTestController::setMinimumTimerInterval(double interval) {
560 void LayoutTestController::syncLocalStorage()
565 void LayoutTestController::observeStorageTrackerNotifications(unsigned number)
570 void LayoutTestController::deleteAllLocalStorage()
575 JSValueRef LayoutTestController::originsWithLocalStorage(JSContextRef context)
581 void LayoutTestController::deleteLocalStorageForOrigin(JSStringRef URL)
586 void LayoutTestController::setTextDirection(JSStringRef direction)
591 void LayoutTestController::addChromeInputField()
595 void LayoutTestController::removeChromeInputField()
599 void LayoutTestController::focusWebView()
603 void LayoutTestController::setBackingScaleFactor(double)
607 void LayoutTestController::simulateDesktopNotificationClick(JSStringRef title)
612 void LayoutTestController::resetPageVisibility()
614 // FIXME: Implement this.
617 void LayoutTestController::setPageVisibility(const char*)
619 // FIXME: Implement this.
622 void LayoutTestController::setAutomaticLinkDetectionEnabled(bool)
624 // FIXME: Implement this.
627 void LayoutTestController::sendWebIntentResponse(JSStringRef)
629 // FIXME: Implement this.
632 void LayoutTestController::deliverWebIntent(JSStringRef, JSStringRef, JSStringRef)
634 // FIXME: Implement this.
637 void LayoutTestController::setStorageDatabaseIdleInterval(double)
639 // FIXME: Implement this.