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::setJavaScriptProfilingEnabled(bool flag)
162 void LayoutTestController::setWaitToDump(bool waitUntilDone)
164 static const int timeoutSeconds = 10;
166 m_waitToDump = waitUntilDone;
169 int LayoutTestController::windowCount()
175 void LayoutTestController::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
180 void LayoutTestController::setJavaScriptCanAccessClipboard(bool enabled)
185 void LayoutTestController::setXSSAuditorEnabled(bool enabled)
190 void LayoutTestController::setFrameFlatteningEnabled(bool enabled)
195 void LayoutTestController::setAllowUniversalAccessFromFileURLs(bool enabled)
200 void LayoutTestController::setAllowFileAccessFromFileURLs(bool enabled)
205 void LayoutTestController::setAuthorAndUserStylesEnabled(bool flag)
210 void LayoutTestController::setAutofilled(JSContextRef, JSValueRef element, bool isAutofilled)
215 void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled)
220 void LayoutTestController::setPluginsEnabled(bool flag)
225 bool LayoutTestController::elementDoesAutoCompleteForElementWithId(JSStringRef id)
231 void LayoutTestController::execCommand(JSStringRef name, JSStringRef value)
236 void LayoutTestController::setPersistentUserStyleSheetLocation(JSStringRef jsURL)
241 void LayoutTestController::clearPersistentUserStyleSheet()
246 void LayoutTestController::clearAllApplicationCaches()
248 // FIXME: Implement to support application cache quotas.
251 void LayoutTestController::clearApplicationCacheForOrigin(JSStringRef url)
253 // FIXME: Implement to support deleting all application cache for an origin.
256 long long LayoutTestController::localStorageDiskUsageForOrigin(JSStringRef originIdentifier)
258 // FIXME: Implement to support getting disk usage in bytes for an origin.
262 void LayoutTestController::setApplicationCacheOriginQuota(unsigned long long quota)
264 // FIXME: Implement to support application cache quotas.
267 long long LayoutTestController::applicationCacheDiskUsageForOrigin(JSStringRef origin)
269 // FIXME: Implement to support getting disk usage by all application caches for an origin.
274 JSValueRef LayoutTestController::originsWithApplicationCache(JSContextRef context)
276 // FIXME: Implement to get origins that have application caches.
280 void LayoutTestController::clearAllDatabases()
285 void LayoutTestController::setDatabaseQuota(unsigned long long quota)
290 void LayoutTestController::goBack()
292 // FIXME: implement to enable loader/navigation-while-deferring-loads.html
295 void LayoutTestController::setDefersLoading(bool)
297 // FIXME: implement to enable loader/navigation-while-deferring-loads.html
300 void LayoutTestController::setDomainRelaxationForbiddenForURLScheme(bool, JSStringRef)
305 void LayoutTestController::setAppCacheMaximumSize(unsigned long long size)
310 unsigned LayoutTestController::numberOfActiveAnimations() const
316 void LayoutTestController::suspendAnimations() const
321 void LayoutTestController::resumeAnimations() const
326 unsigned LayoutTestController::workerThreadCount() const
332 void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
337 bool LayoutTestController::pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId)
343 void LayoutTestController::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma)
345 // FIXME: Implement for DeviceOrientation layout tests.
346 // See https://bugs.webkit.org/show_bug.cgi?id=30335.
349 void LayoutTestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy)
351 // FIXME: Implement for Geolocation layout tests.
352 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
355 void LayoutTestController::setMockGeolocationError(int code, JSStringRef message)
357 // FIXME: Implement for Geolocation layout tests.
358 // See https://bugs.webkit.org/show_bug.cgi?id=28264.
361 void LayoutTestController::setGeolocationPermission(bool allow)
363 // FIXME: Implement for Geolocation layout tests.
364 setGeolocationPermissionCommon(allow);
367 int LayoutTestController::numberOfPendingGeolocationPermissionRequests()
369 // FIXME: Implement for Geolocation layout tests.
373 void LayoutTestController::addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language)
375 // FIXME: Implement for speech input layout tests.
376 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
379 void LayoutTestController::startSpeechInput(JSContextRef inputElement)
381 // FIXME: Implement for speech input layout tests.
382 // See https://bugs.webkit.org/show_bug.cgi?id=39485.
385 void LayoutTestController::setIconDatabaseEnabled(bool iconDatabaseEnabled)
390 bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId)
396 bool LayoutTestController::sampleSVGAnimationForElementAtTime(JSStringRef animationId, double time, JSStringRef elementId)
402 void LayoutTestController::setCacheModel(int)
407 bool LayoutTestController::isCommandEnabled(JSStringRef /*name*/)
413 size_t LayoutTestController::webHistoryItemCount()
419 void LayoutTestController::waitForPolicyDelegate()
421 // FIXME: Implement this.
424 void LayoutTestController::overridePreference(JSStringRef /* key */, JSStringRef /* value */)
429 void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames)
431 printf("LayoutTestController::addUserScript not implemented.\n");
434 void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames)
436 printf("LayoutTestController::addUserStyleSheet not implemented.\n");
439 void LayoutTestController::showWebInspector()
441 // FIXME: Implement this.
444 void LayoutTestController::closeWebInspector()
446 // FIXME: Implement this.
449 void LayoutTestController::evaluateInWebInspector(long callId, JSStringRef script)
451 // FIXME: Implement this.
454 void LayoutTestController::removeAllVisitedLinks()
456 // FIXME: Implement this.
459 void LayoutTestController::evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script)
464 void LayoutTestController::disableImageLoading()
469 void LayoutTestController::addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains)
474 void LayoutTestController::removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains)
479 void LayoutTestController::setScrollbarPolicy(JSStringRef orientation, JSStringRef policy)
484 JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef id)
489 int LayoutTestController::pageNumberForElementById(JSStringRef, float, float)
495 int LayoutTestController::numberOfPages(float, float)
501 void LayoutTestController::apiTestNewWindowDataLoadBaseURL(JSStringRef utf8Data, JSStringRef baseURL)
506 void LayoutTestController::apiTestGoToCurrentBackForwardItem()
511 void LayoutTestController::setSpatialNavigationEnabled(bool)
516 void LayoutTestController::setWebViewEditable(bool)
520 bool LayoutTestController::callShouldCloseOnWebView()
525 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
530 JSRetainPtr<JSStringRef> LayoutTestController::markerTextForListItem(JSContextRef context, JSValueRef nodeObject) const
535 JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef, JSValueRef)
540 JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
542 // FIXME: Implement this.
546 void LayoutTestController::authenticateSession(JSStringRef, JSStringRef, JSStringRef)
550 void LayoutTestController::setEditingBehavior(const char* editingBehavior)
555 void LayoutTestController::abortModal()
559 bool LayoutTestController::hasSpellingMarker(int, int)
565 bool LayoutTestController::hasGrammarMarker(int, int)
571 void LayoutTestController::dumpConfigurationForViewport(int /*deviceDPI*/, int /*deviceWidth*/, int /*deviceHeight*/, int /*availableWidth*/, int /*availableHeight*/)
576 JSRetainPtr<JSStringRef> LayoutTestController::pageProperty(const char* propertyName, int pageNumber) const
582 bool LayoutTestController::isPageBoxVisible(int pageNumber) const
588 JSRetainPtr<JSStringRef> LayoutTestController::pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const
594 void LayoutTestController::setAsynchronousSpellCheckingEnabled(bool)
596 // FIXME: Implement this.
599 bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
605 void LayoutTestController::setSerializeHTTPLoads(bool)
610 void LayoutTestController::setMinimumTimerInterval(double interval) {
614 void LayoutTestController::syncLocalStorage()
619 void LayoutTestController::observeStorageTrackerNotifications(unsigned number)
624 void LayoutTestController::deleteAllLocalStorage()
629 JSValueRef LayoutTestController::originsWithLocalStorage(JSContextRef context)
635 void LayoutTestController::deleteLocalStorageForOrigin(JSStringRef URL)
640 void LayoutTestController::setTextDirection(JSStringRef direction)
645 void LayoutTestController::allowRoundingHacks()