HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Jelly Bean MR2
|
4.3_r1
下载
查看原文件
收藏
根目录
external
webkit
Tools
DumpRenderTree
LayoutTestController.cpp
/* * Copyright (C) 2007, 2008, 2009, 2011 Apple Inc. All rights reserved. * Copyright (C) 2010 Joone Hur
* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "LayoutTestController.h" #include "WorkQueue.h" #include "WorkQueueItem.h" #include
#include
#include
#include
#include
#include
#include
#include
#include
LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash) : m_dumpApplicationCacheDelegateCallbacks(false) , m_dumpAsAudio(false) , m_dumpAsPDF(false) , m_dumpAsText(false) , m_dumpBackForwardList(false) , m_dumpChildFrameScrollPositions(false) , m_dumpChildFramesAsText(false) , m_dumpDOMAsWebArchive(false) , m_dumpDatabaseCallbacks(false) , m_dumpEditingCallbacks(false) , m_dumpFrameLoadCallbacks(false) , m_dumpUserGestureInFrameLoadCallbacks(false) , m_dumpHistoryDelegateCallbacks(false) , m_dumpResourceLoadCallbacks(false) , m_dumpResourceResponseMIMETypes(false) , m_dumpSelectionRect(false) , m_dumpSourceAsWebArchive(false) , m_dumpStatusCallbacks(false) , m_dumpTitleChanges(false) , m_dumpIconChanges(false) , m_dumpVisitedLinksCallback(false) , m_dumpWillCacheResponse(false) , m_generatePixelResults(true) , m_callCloseOnWebViews(true) , m_canOpenWindows(false) , m_closeRemainingWindowsWhenComplete(true) , m_newWindowsCopyBackForwardList(false) , m_stopProvisionalFrameLoads(false) , m_testOnscreen(false) , m_testRepaint(false) , m_testRepaintSweepHorizontally(false) , m_waitToDump(false) , m_willSendRequestReturnsNull(false) , m_willSendRequestReturnsNullOnRedirect(false) , m_windowIsKey(true) , m_alwaysAcceptCookies(false) , m_globalFlag(false) , m_isGeolocationPermissionSet(false) , m_geolocationPermission(false) , m_handlesAuthenticationChallenges(false) , m_isPrinting(false) , m_deferMainResourceDataLoad(true) , m_shouldPaintBrokenImage(true) , m_testPathOrURL(testPathOrURL) , m_expectedPixelHash(expectedPixelHash) { } PassRefPtr
LayoutTestController::create(const std::string& testPathOrURL, const std::string& expectedPixelHash) { return adoptRef(new LayoutTestController(testPathOrURL, expectedPixelHash)); } // Static Functions static JSValueRef dumpApplicationCacheDelegateCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpApplicationCacheDelegateCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpAsPDFCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpAsPDF(true); return JSValueMakeUndefined(context); } static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpAsText(true); // Optional paramater, describing whether it's allowed to dump pixel results in dumpAsText mode. controller->setGeneratePixelResults(argumentCount > 0 ? JSValueToBoolean(context, arguments[0]) : false); return JSValueMakeUndefined(context); } static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpBackForwardList(true); return JSValueMakeUndefined(context); } static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpChildFramesAsText(true); return JSValueMakeUndefined(context); } static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpChildFrameScrollPositions(true); return JSValueMakeUndefined(context); } static JSValueRef dumpConfigurationForViewportCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 2) return JSValueMakeUndefined(context); double deviceDPI = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); double deviceWidth = JSValueToNumber(context, arguments[1], exception); ASSERT(!*exception); double deviceHeight = JSValueToNumber(context, arguments[2], exception); ASSERT(!*exception); double availableWidth = JSValueToNumber(context, arguments[3], exception); ASSERT(!*exception); double availableHeight = JSValueToNumber(context, arguments[4], exception); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->dumpConfigurationForViewport(static_cast
(deviceDPI), static_cast
(deviceWidth), static_cast
(deviceHeight), static_cast
(availableWidth), static_cast
(availableHeight)); return JSValueMakeUndefined(context); } static JSValueRef dumpDatabaseCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpDatabaseCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpDOMAsWebArchive(true); return JSValueMakeUndefined(context); } static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpEditingCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpFrameLoadCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpUserGestureInFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpUserGestureInFrameLoadCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpResourceLoadCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpResourceResponseMIMETypesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpResourceResponseMIMETypes(true); return JSValueMakeUndefined(context); } static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpSelectionRect(true); return JSValueMakeUndefined(context); } static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpSourceAsWebArchive(true); return JSValueMakeUndefined(context); } static JSValueRef dumpStatusCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpStatusCallbacks(true); return JSValueMakeUndefined(context); } static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpTitleChanges(true); return JSValueMakeUndefined(context); } static JSValueRef dumpIconChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpIconChanges(true); return JSValueMakeUndefined(context); } static JSValueRef dumpWillCacheResponseCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpWillCacheResponse(true); return JSValueMakeUndefined(context); } static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSRetainPtr
localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get())); if (!convertedPath) return JSValueMakeUndefined(context); return JSValueMakeString(context, convertedPath.get()); } static JSValueRef removeAllVisitedLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDumpVisitedLinksCallback(true); controller->removeAllVisitedLinks(); return JSValueMakeUndefined(context); } static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setTestRepaintSweepHorizontally(true); return JSValueMakeUndefined(context); } static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setCallCloseOnWebViews(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setCanOpenWindows(true); return JSValueMakeUndefined(context); } static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get()); OwnArrayPtr
encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]); JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setEncodedAudioData(encodedAudioDataBuffer.get()); controller->setDumpAsAudio(true); return JSValueMakeUndefined(context); } static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setTestOnscreen(true); return JSValueMakeUndefined(context); } static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setTestRepaint(true); return JSValueMakeUndefined(context); } static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
url(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->addDisallowedURL(url.get()); return JSValueMakeUndefined(context); } static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 2) return JSValueMakeUndefined(context); JSRetainPtr
origin(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
destination(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get()); OwnArrayPtr
originBuffer = adoptArrayPtr(new char[maxLength + 1]); JSStringGetUTF8CString(origin.get(), originBuffer.get(), maxLength + 1); maxLength = JSStringGetMaximumUTF8CStringSize(destination.get()); OwnArrayPtr
destinationBuffer = adoptArrayPtr(new char[maxLength + 1]); JSStringGetUTF8CString(destination.get(), destinationBuffer.get(), maxLength + 1); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->addURLToRedirect(originBuffer.get(), destinationBuffer.get()); return JSValueMakeUndefined(context); } static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->callShouldCloseOnWebView()); } static JSValueRef clearAllApplicationCachesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->clearAllApplicationCaches(); return JSValueMakeUndefined(context); } static JSValueRef clearApplicationCacheForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
originURL(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->clearApplicationCacheForOrigin(originURL.get()); return JSValueMakeUndefined(context); } static JSValueRef originsWithApplicationCacheCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return controller->originsWithApplicationCache(context); } static JSValueRef clearAllDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->clearAllDatabases(); return JSValueMakeUndefined(context); } static JSValueRef syncLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->syncLocalStorage(); return JSValueMakeUndefined(context); } static JSValueRef observeStorageTrackerNotificationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); if (argumentCount < 1) return JSValueMakeUndefined(context); unsigned numNotifications = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); controller->observeStorageTrackerNotifications(numNotifications); return JSValueMakeUndefined(context); } static JSValueRef deleteAllLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->deleteAllLocalStorage(); return JSValueMakeUndefined(context); } static JSValueRef deleteLocalStorageForOriginCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
url(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); controller->deleteLocalStorageForOrigin(url.get()); return JSValueMakeUndefined(context); } static JSValueRef originsWithLocalStorageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return controller->originsWithLocalStorage(context); } static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->clearBackForwardList(); return JSValueMakeUndefined(context); } static JSValueRef clearPersistentUserStyleSheetCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->clearPersistentUserStyleSheet(); return JSValueMakeUndefined(context); } static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
name(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSRetainPtr
decodedHostName(Adopt, controller->copyDecodedHostName(name.get())); return JSValueMakeString(context, decodedHostName.get()); } static JSValueRef disableImageLoadingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation, needs windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->disableImageLoading(); return JSValueMakeUndefined(context); } static JSValueRef dispatchPendingLoadRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation, needs windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->dispatchPendingLoadRequests(); return JSValueMakeUndefined(context); } static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->display(); return JSValueMakeUndefined(context); } static JSValueRef displayInvalidatedRegionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); // LayoutTestController::display() only renders the invalidated region so // we can just use that. controller->display(); return JSValueMakeUndefined(context); } static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
name(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSRetainPtr
encodedHostName(Adopt, controller->copyEncodedHostName(name.get())); return JSValueMakeString(context, encodedHostName.get()); } static JSValueRef execCommandCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac & Windows implementations. if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
name(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); // Ignoring the second parameter (userInterface), as this command emulates a manual action. JSRetainPtr
value; if (argumentCount >= 3) { value.adopt(JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); } else value.adopt(JSStringCreateWithUTF8CString("")); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->execCommand(name.get(), value.get()); return JSValueMakeUndefined(context); } static JSValueRef findStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac implementation. if (argumentCount < 2) return JSValueMakeUndefined(context); JSRetainPtr
target(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSObjectRef options = JSValueToObject(context, arguments[1], exception); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->findString(context, target.get(), options)); } static JSValueRef counterValueForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception)); if (*exception) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSRetainPtr
counterValue(controller->counterValueForElementById(elementId.get())); if (!counterValue.get()) return JSValueMakeUndefined(context); return JSValueMakeString(context, counterValue.get()); } static JSValueRef grantDesktopNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->grantDesktopNotificationPermission(JSValueToStringCopy(context, arguments[0], NULL)); return JSValueMakeUndefined(context); } static JSValueRef isCommandEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac implementation. if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
name(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->isCommandEnabled(name.get())); } static JSValueRef overridePreferenceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 2) return JSValueMakeUndefined(context); JSRetainPtr
key(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
value(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->overridePreference(key.get(), value.get()); return JSValueMakeUndefined(context); } static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->keepWebHistory(); return JSValueMakeUndefined(context); } static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 1) return JSValueMakeUndefined(context); // Has mac implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return controller->computedStyleIncludingVisitedInfo(context, arguments[0]); } static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 8) return JSValueMakeUndefined(context); int x = JSValueToNumber(context, arguments[1], NULL); int y = JSValueToNumber(context, arguments[2], NULL); int top = static_cast
(JSValueToNumber(context, arguments[3], NULL)); int right = static_cast
(JSValueToNumber(context, arguments[4], NULL)); int bottom = static_cast
(JSValueToNumber(context, arguments[5], NULL)); int left = static_cast
(JSValueToNumber(context, arguments[6], NULL)); bool ignoreClipping = JSValueToBoolean(context, arguments[7]); // Has mac implementation. LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping); } static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeString(context, controller->layerTreeAsText().get()); } static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->notifyDone(); return JSValueMakeUndefined(context); } static bool parsePageParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, float& pageWidthInPixels, float& pageHeightInPixels) { pageWidthInPixels = LayoutTestController::maxViewWidth; pageHeightInPixels = LayoutTestController::maxViewHeight; switch (argumentCount) { case 2: pageWidthInPixels = static_cast
(JSValueToNumber(context, arguments[0], exception)); if (*exception) return false; pageHeightInPixels = static_cast
(JSValueToNumber(context, arguments[1], exception)); if (*exception) return false; case 0: // Fall through. break; default: return false; } return true; } // Caller needs to delete[] propertyName. static bool parsePagePropertyParameters(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, char*& propertyName, int& pageNumber) { pageNumber = 0; switch (argumentCount) { case 2: pageNumber = static_cast
(JSValueToNumber(context, arguments[1], exception)); if (*exception) return false; // Fall through. case 1: { JSRetainPtr
propertyNameString(Adopt, JSValueToStringCopy(context, arguments[0], exception)); if (*exception) return false; size_t maxLength = JSStringGetMaximumUTF8CStringSize(propertyNameString.get()); propertyName = new char[maxLength + 1]; JSStringGetUTF8CString(propertyNameString.get(), propertyName, maxLength + 1); return true; } case 0: default: return false; } } static bool parsePageNumber(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber) { pageNumber = 0; switch (argumentCount) { case 1: pageNumber = static_cast
(JSValueToNumber(context, arguments[0], exception)); if (*exception) return false; // Fall through. case 0: return true; default: return false; } } static bool parsePageNumberSizeMarings(JSContextRef context, int argumentCount, const JSValueRef* arguments, JSValueRef* exception, int& pageNumber, int& width, int& height, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft) { pageNumber = 0; width = height = 0; marginTop = marginRight = marginBottom = marginLeft = 0; switch (argumentCount) { case 7: marginLeft = static_cast
(JSValueToNumber(context, arguments[6], exception)); if (*exception) return false; // Fall through. case 6: marginBottom = static_cast
(JSValueToNumber(context, arguments[5], exception)); if (*exception) return false; // Fall through. case 5: marginRight = static_cast
(JSValueToNumber(context, arguments[4], exception)); if (*exception) return false; // Fall through. case 4: marginTop = static_cast
(JSValueToNumber(context, arguments[3], exception)); if (*exception) return false; // Fall through. case 3: height = static_cast
(JSValueToNumber(context, arguments[2], exception)); if (*exception) return false; // Fall through. case 2: width = static_cast
(JSValueToNumber(context, arguments[1], exception)); if (*exception) return false; // Fall through. case 1: pageNumber = static_cast
(JSValueToNumber(context, arguments[0], exception)); if (*exception) return false; // Fall through. return true; default: return false; } } static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { float pageWidthInPixels = 0; float pageHeightInPixels = 0; if (!parsePageParameters(context, argumentCount - 1, arguments + 1, exception, pageWidthInPixels, pageHeightInPixels)) return JSValueMakeUndefined(context); JSRetainPtr
elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception)); if (*exception) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels); return JSValueMakeNumber(context, pageNumber); } static JSValueRef numberOfPagesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { float pageWidthInPixels = 0; float pageHeightInPixels = 0; if (!parsePageParameters(context, argumentCount, arguments, exception, pageWidthInPixels, pageHeightInPixels)) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeNumber(context, controller->numberOfPages(pageWidthInPixels, pageHeightInPixels)); } static JSValueRef numberOfPendingGeolocationPermissionRequestsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeNumber(context, controller->numberOfPendingGeolocationPermissionRequests()); } static JSValueRef pagePropertyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { char* propertyName = 0; int pageNumber = 0; if (!parsePagePropertyParameters(context, argumentCount, arguments, exception, propertyName, pageNumber)) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSValueRef value = JSValueMakeString(context, controller->pageProperty(propertyName, pageNumber).get()); delete[] propertyName; return value; } static JSValueRef isPageBoxVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int pageNumber = 0; if (!parsePageNumber(context, argumentCount, arguments, exception, pageNumber)) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->isPageBoxVisible(pageNumber)); } static JSValueRef pageSizeAndMarginsInPixelsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int pageNumber = 0; int width = 0, height = 0; int marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0; if (!parsePageNumberSizeMarings(context, argumentCount, arguments, exception, pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft)) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeString(context, controller->pageSizeAndMarginsInPixels(pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft).get()); } static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue if (argumentCount < 1) return JSValueMakeUndefined(context); double howFarBackDouble = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->queueBackNavigation(static_cast
(howFarBackDouble)); return JSValueMakeUndefined(context); } static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue if (argumentCount < 1) return JSValueMakeUndefined(context); double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->queueForwardNavigation(static_cast
(howFarForwardDouble)); return JSValueMakeUndefined(context); } static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
url(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
target; if (argumentCount >= 2) { target.adopt(JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); } else target.adopt(JSStringCreateWithUTF8CString("")); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->queueLoad(url.get(), target.get()); return JSValueMakeUndefined(context); } static JSValueRef queueLoadHTMLStringCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac & Windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
content(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
baseURL; if (argumentCount >= 2) { baseURL.adopt(JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); } else baseURL.adopt(JSStringCreateWithUTF8CString("")); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); if (argumentCount >= 3) { JSRetainPtr
unreachableURL; unreachableURL.adopt(JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); controller->queueLoadAlternateHTMLString(content.get(), baseURL.get(), unreachableURL.get()); return JSValueMakeUndefined(context); } controller->queueLoadHTMLString(content.get(), baseURL.get()); return JSValueMakeUndefined(context); } static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->queueReload(); return JSValueMakeUndefined(context); } static JSValueRef queueLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
script(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->queueLoadingScript(script.get()); return JSValueMakeUndefined(context); } static JSValueRef queueNonLoadingScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation // May be able to be made platform independant by using shared WorkQueue if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
script(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->queueNonLoadingScript(script.get()); return JSValueMakeUndefined(context); } static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setAlwaysAcceptCookiesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAlwaysAcceptCookies(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setAppCacheMaximumSizeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); double size = JSValueToNumber(context, arguments[0], NULL); if (!isnan(size)) controller->setAppCacheMaximumSize(static_cast
(size)); return JSValueMakeUndefined(context); } static JSValueRef setApplicationCacheOriginQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); double size = JSValueToNumber(context, arguments[0], NULL); if (!isnan(size)) controller->setApplicationCacheOriginQuota(static_cast
(size)); return JSValueMakeUndefined(context); } static JSValueRef setAuthenticationPasswordCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
password(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); size_t maxLength = JSStringGetMaximumUTF8CStringSize(password.get()); char* passwordBuffer = new char[maxLength + 1]; JSStringGetUTF8CString(password.get(), passwordBuffer, maxLength + 1); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAuthenticationPassword(passwordBuffer); delete[] passwordBuffer; return JSValueMakeUndefined(context); } static JSValueRef setAuthenticationUsernameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
username(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); size_t maxLength = JSStringGetMaximumUTF8CStringSize(username.get()); char* usernameBuffer = new char[maxLength + 1]; JSStringGetUTF8CString(username.get(), usernameBuffer, maxLength + 1); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAuthenticationUsername(usernameBuffer); delete[] usernameBuffer; return JSValueMakeUndefined(context); } static JSValueRef setAuthorAndUserStylesEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAuthorAndUserStylesEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setAutofilledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 2 || !arguments[0]) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAutofilled(context, arguments[0], JSValueToBoolean(context, arguments[1])); return JSValueMakeUndefined(context); } static JSValueRef setCacheModelCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac implementation. if (argumentCount < 1) return JSValueMakeUndefined(context); int cacheModel = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setCacheModel(cacheModel); return JSValueMakeUndefined(context); } static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); bool permissive = false; if (argumentCount >= 2) permissive = JSValueToBoolean(context, arguments[1]); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]), permissive); return JSValueMakeUndefined(context); } static JSValueRef setDatabaseQuotaCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); double quota = JSValueToNumber(context, arguments[0], NULL); if (!isnan(quota)) controller->setDatabaseQuota(static_cast
(quota)); return JSValueMakeUndefined(context); } static JSValueRef setDeferMainResourceDataLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac and Windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setDeferMainResourceDataLoad(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setDomainRelaxationForbiddenForURLSchemeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac and Windows implementation if (argumentCount < 2) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); bool forbidden = JSValueToBoolean(context, arguments[0]); JSRetainPtr
scheme(Adopt, JSValueToStringCopy(context, arguments[1], 0)); controller->setDomainRelaxationForbiddenForURLScheme(forbidden, scheme.get()); return JSValueMakeUndefined(context); } static JSValueRef setMockDeviceOrientationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 6) return JSValueMakeUndefined(context); bool canProvideAlpha = JSValueToBoolean(context, arguments[0]); double alpha = JSValueToNumber(context, arguments[1], exception); ASSERT(!*exception); bool canProvideBeta = JSValueToBoolean(context, arguments[2]); double beta = JSValueToNumber(context, arguments[3], exception); ASSERT(!*exception); bool canProvideGamma = JSValueToBoolean(context, arguments[4]); double gamma = JSValueToNumber(context, arguments[5], exception); ASSERT(!*exception); LayoutTestController* controller = reinterpret_cast
(JSObjectGetPrivate(thisObject)); controller->setMockDeviceOrientation(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); return JSValueMakeUndefined(context); } static JSValueRef setMockGeolocationPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 3) return JSValueMakeUndefined(context); LayoutTestController* controller = reinterpret_cast
(JSObjectGetPrivate(thisObject)); controller->setMockGeolocationPosition(JSValueToNumber(context, arguments[0], NULL), // latitude JSValueToNumber(context, arguments[1], NULL), // longitude JSValueToNumber(context, arguments[2], NULL)); // accuracy return JSValueMakeUndefined(context); } static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 2) return JSValueMakeUndefined(context); int code = JSValueToNumber(context, arguments[0], NULL); JSRetainPtr
message(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); LayoutTestController* controller = reinterpret_cast
(JSObjectGetPrivate(thisObject)); controller->setMockGeolocationError(code, message.get()); return JSValueMakeUndefined(context); } static JSValueRef addMockSpeechInputResultCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 3) return JSValueMakeUndefined(context); JSRetainPtr
result(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); double confidence = JSValueToNumber(context, arguments[1], exception); JSRetainPtr
language(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->addMockSpeechInputResult(result.get(), confidence, language.get()); return JSValueMakeUndefined(context); } static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setGeolocationPermission(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setHandlesAuthenticationChallengesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setHandlesAuthenticationChallenges(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setPOSIXLocaleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSRetainPtr
locale(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); controller->setPOSIXLocale(locale.get()); return JSValueMakeUndefined(context); } static JSValueRef setIconDatabaseEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setIconDatabaseEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setJavaScriptProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setJavaScriptProfilingEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setPersistentUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
path(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setPersistentUserStyleSheetLocation(path.get()); return JSValueMakeUndefined(context); } static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setPrivateBrowsingEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setXSSAuditorEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setSpatialNavigationEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation. if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setSpatialNavigationEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setPrintingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setIsPrinting(true); return JSValueMakeUndefined(context); } static JSValueRef setFrameFlatteningEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setFrameFlatteningEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAllowUniversalAccessFromFileURLs(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setAllowFileAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAllowFileAccessFromFileURLs(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setTimelineProfilingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setTimelineProfilingEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
path(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setUserStyleSheetLocation(path.get()); return JSValueMakeUndefined(context); } static JSValueRef setValueForUserCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount != 2) return JSValueMakeUndefined(context); JSRetainPtr
value(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setValueForUser(context, arguments[0], value.get()); return JSValueMakeUndefined(context); } static JSValueRef setViewModeMediaFeatureCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
mode(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setViewModeMediaFeature(mode.get()); return JSValueMakeUndefined(context); } static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); JSRetainPtr
header(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get()); OwnArrayPtr
headerBuffer = adoptArrayPtr(new char[maxLength + 1]); JSStringGetUTF8CString(header.get(), headerBuffer.get(), maxLength + 1); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setWillSendRequestClearHeader(headerBuffer.get()); return JSValueMakeUndefined(context); } static JSValueRef setWillSendRequestReturnsNullCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has cross-platform implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setWillSendRequestReturnsNull(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has cross-platform implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setWindowIsKey(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setWaitToDump(true); return JSValueMakeUndefined(context); } static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); int windows = controller->windowCount(); return JSValueMakeNumber(context, windows); } static JSValueRef setPopupBlockingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setPopupBlockingEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setPluginsEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setSmartInsertDeleteEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setSelectTrailingWhitespaceEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setSelectTrailingWhitespaceEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef setStopProvisionalFrameLoadsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setStopProvisionalFrameLoads(true); return JSValueMakeUndefined(context); } static JSValueRef setAsynchronousSpellCheckingEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setAsynchronousSpellCheckingEnabled(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef shadowRootCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return controller->shadowRoot(context, arguments[0]); } static JSValueRef showWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->showWebInspector(); return JSValueMakeUndefined(context); } static JSValueRef closeWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setTimelineProfilingEnabled(false); controller->closeWebInspector(); return JSValueMakeUndefined(context); } static JSValueRef evaluateInWebInspectorCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); double callId = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); JSRetainPtr
script(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); controller->evaluateInWebInspector(static_cast
(callId), script.get()); return JSValueMakeUndefined(context); } static JSValueRef evaluateScriptInIsolatedWorldCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); double worldID = JSValueToNumber(context, arguments[0], exception); ASSERT(!*exception); JSRetainPtr
script(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); controller->evaluateScriptInIsolatedWorld(static_cast
(worldID), JSContextGetGlobalObject(context), script.get()); return JSValueMakeUndefined(context); } static JSValueRef elementDoesAutoCompleteForElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); JSRetainPtr
elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); bool autoCompletes = controller->elementDoesAutoCompleteForElementWithId(elementId.get()); return JSValueMakeBoolean(context, autoCompletes); } static JSValueRef pauseAnimationAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 3) return JSValueMakeUndefined(context); JSRetainPtr
animationName(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); double time = JSValueToNumber(context, arguments[1], exception); ASSERT(!*exception); JSRetainPtr
elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->pauseAnimationAtTimeOnElementWithId(animationName.get(), time, elementId.get())); } static JSValueRef pauseTransitionAtTimeOnElementWithIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 3) return JSValueMakeUndefined(context); JSRetainPtr
propertyName(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); double time = JSValueToNumber(context, arguments[1], exception); ASSERT(!*exception); JSRetainPtr
elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->pauseTransitionAtTimeOnElementWithId(propertyName.get(), time, elementId.get())); } static JSValueRef sampleSVGAnimationForElementAtTimeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 3) return JSValueMakeUndefined(context); JSRetainPtr
animationId(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); double time = JSValueToNumber(context, arguments[1], exception); ASSERT(!*exception); JSRetainPtr
elementId(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeBoolean(context, controller->sampleSVGAnimationForElementAtTime(animationId.get(), time, elementId.get())); } static JSValueRef numberOfActiveAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 0) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); return JSValueMakeNumber(context, controller->numberOfActiveAnimations()); } static JSValueRef suspendAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->suspendAnimations(); return JSValueMakeUndefined(context); } static JSValueRef resumeAnimationsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->resumeAnimations(); return JSValueMakeUndefined(context); } static JSValueRef waitForPolicyDelegateCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t, const JSValueRef[], JSValueRef*) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->waitForPolicyDelegate(); return JSValueMakeUndefined(context); } static JSValueRef addOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 4) return JSValueMakeUndefined(context); JSRetainPtr
sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); JSRetainPtr
destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->addOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains); return JSValueMakeUndefined(context); } static JSValueRef removeOriginAccessWhitelistEntryCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 4) return JSValueMakeUndefined(context); JSRetainPtr
sourceOrigin(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
destinationProtocol(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); JSRetainPtr
destinationHost(Adopt, JSValueToStringCopy(context, arguments[2], exception)); ASSERT(!*exception); bool allowDestinationSubdomains = JSValueToBoolean(context, arguments[3]); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->removeOriginAccessWhitelistEntry(sourceOrigin.get(), destinationProtocol.get(), destinationHost.get(), allowDestinationSubdomains); return JSValueMakeUndefined(context); } static JSValueRef setScrollbarPolicyCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 2) return JSValueMakeUndefined(context); JSRetainPtr
orientation(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
policy(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setScrollbarPolicy(orientation.get(), policy.get()); return JSValueMakeUndefined(context); } static JSValueRef addUserScriptCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 3) return JSValueMakeUndefined(context); JSRetainPtr
source(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); bool runAtStart = JSValueToBoolean(context, arguments[1]); bool allFrames = JSValueToBoolean(context, arguments[2]); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->addUserScript(source.get(), runAtStart, allFrames); return JSValueMakeUndefined(context); } static JSValueRef addUserStyleSheetCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 2) return JSValueMakeUndefined(context); JSRetainPtr
source(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); bool allFrames = JSValueToBoolean(context, arguments[1]); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->addUserStyleSheet(source.get(), allFrames); return JSValueMakeUndefined(context); } static JSValueRef setShouldPaintBrokenImageCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setShouldPaintBrokenImage(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef apiTestNewWindowDataLoadBaseURLCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 2) return JSValueMakeUndefined(context); JSRetainPtr
utf8Data(Adopt, JSValueToStringCopy(context, arguments[0], exception)); ASSERT(!*exception); JSRetainPtr
baseURL(Adopt, JSValueToStringCopy(context, arguments[1], exception)); ASSERT(!*exception); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->apiTestNewWindowDataLoadBaseURL(utf8Data.get(), baseURL.get()); return JSValueMakeUndefined(context); } static JSValueRef apiTestGoToCurrentBackForwardItemCallback(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->apiTestGoToCurrentBackForwardItem(); return JSValueMakeUndefined(context); } static JSValueRef setWebViewEditableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has Mac implementation if (argumentCount < 1) return JSValueMakeUndefined(context); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->setWebViewEditable(JSValueToBoolean(context, arguments[0])); return JSValueMakeUndefined(context); } static JSValueRef abortModalCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); controller->abortModal(); return JSValueMakeUndefined(context); } static JSValueRef hasSpellingMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 2) return JSValueMakeUndefined(context); int from = JSValueToNumber(context, arguments[0], 0); int length = JSValueToNumber(context, arguments[1], 0); LayoutTestController* controller = static_cast
(JSObjectGetPrivate(thisObject)); bool ok = controller->hasSpellingMarker(from, length); return JSValueMakeBoolean(context, ok); } static JSValueRef hasGrammarMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (argumentCount != 2) return JSValueMakeUndefined(context); int from = JSValueToNumber(context, arguments[0], 0); int length = JSValueToNumber(context, arguments[1], 0); LayoutTestController* controller = static_cast