diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-26 10:42:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-26 10:42:44 +0200 |
commit | 33b26980cb24288b5a9f2590ccf32a949281bb79 (patch) | |
tree | cc0203dac37338b24b0b25a4694c0b76d4e4164b /Tools/WebKitTestRunner | |
parent | 715be629d51174233403237bfc563cf150087dc8 (diff) | |
download | qtwebkit-33b26980cb24288b5a9f2590ccf32a949281bb79.tar.gz |
Imported WebKit commit c596dd7f03007fa7ed896b928106497e8784b3b5 (http://svn.webkit.org/repository/webkit/trunk@129610)
New snapshot that removes QtQuick1 support (to be moved into QtQuick1 module)
Diffstat (limited to 'Tools/WebKitTestRunner')
17 files changed, 248 insertions, 19 deletions
diff --git a/Tools/WebKitTestRunner/Configurations/Base.xcconfig b/Tools/WebKitTestRunner/Configurations/Base.xcconfig index 8bdeee2c5..512104b17 100644 --- a/Tools/WebKitTestRunner/Configurations/Base.xcconfig +++ b/Tools/WebKitTestRunner/Configurations/Base.xcconfig @@ -72,3 +72,5 @@ SDKROOT_TARGETING_SAME_OS_X_VERSION_ = macosx; WEBKIT_UMBRELLA_FRAMEWORKS_DIR = $(NEXT_ROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks; WEBCORE_PRIVATE_HEADERS_DIR = $(WEBKIT_UMBRELLA_FRAMEWORKS_DIR)/WebCore.framework/PrivateHeaders; + +WEBKIT_SYSTEM_INTERFACE_LIBRARY = WebKitSystemInterface diff --git a/Tools/WebKitTestRunner/Configurations/DebugRelease.xcconfig b/Tools/WebKitTestRunner/Configurations/DebugRelease.xcconfig index 54ad20d82..1f5144554 100644 --- a/Tools/WebKitTestRunner/Configurations/DebugRelease.xcconfig +++ b/Tools/WebKitTestRunner/Configurations/DebugRelease.xcconfig @@ -40,3 +40,13 @@ MACOSX_DEPLOYMENT_TARGET_1080 = 10.8; MACOSX_DEPLOYMENT_TARGET_1090 = 10.9; WEBKIT_UMBRELLA_FRAMEWORKS_DIR = $(BUILT_PRODUCTS_DIR); + +WEBKIT_SYSTEM_INTERFACE_LIBRARY = $(WEBKIT_SYSTEM_INTERFACE_LIBRARY_$(REAL_PLATFORM_NAME)); +WEBKIT_SYSTEM_INTERFACE_LIBRARY_iphoneos = WebKitSystemInterface; +WEBKIT_SYSTEM_INTERFACE_LIBRARY_iphonesimulator = $(WEBKIT_SYSTEM_INTERFACE_LIBRARY_iphoneos); +WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx = $(WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx_$(TARGET_MAC_OS_X_VERSION_MAJOR)); +WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx_1050 = WebKitSystemInterfaceLeopard; +WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx_1060 = WebKitSystemInterfaceSnowLeopard; +WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx_1070 = WebKitSystemInterfaceLion; +WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx_1080 = WebKitSystemInterfaceMountainLion; +WEBKIT_SYSTEM_INTERFACE_LIBRARY_macosx_1090 = WebKitSystemInterfaceMountainLion; diff --git a/Tools/WebKitTestRunner/Configurations/InjectedBundle.xcconfig b/Tools/WebKitTestRunner/Configurations/InjectedBundle.xcconfig index 57b8d56d6..4235ead85 100644 --- a/Tools/WebKitTestRunner/Configurations/InjectedBundle.xcconfig +++ b/Tools/WebKitTestRunner/Configurations/InjectedBundle.xcconfig @@ -26,3 +26,4 @@ PRODUCT_NAME = WebKitTestRunnerInjectedBundle; INSTALL_PATH = $(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Resources; SKIP_INSTALL = NO; +OTHER_LDFLAGS = -l$(WEBKIT_SYSTEM_INTERFACE_LIBRARY) diff --git a/Tools/WebKitTestRunner/GeolocationProviderMock.cpp b/Tools/WebKitTestRunner/GeolocationProviderMock.cpp index babbf6e0d..5877c65f6 100644 --- a/Tools/WebKitTestRunner/GeolocationProviderMock.cpp +++ b/Tools/WebKitTestRunner/GeolocationProviderMock.cpp @@ -46,6 +46,7 @@ static void stopUpdatingCallback(WKGeolocationManagerRef geolocationManager, con GeolocationProviderMock::GeolocationProviderMock(WKContextRef context) : m_isActive(false) + , m_hasError(false) { m_geolocationManager = WKContextGetGeolocationManager(context); @@ -57,11 +58,17 @@ GeolocationProviderMock::GeolocationProviderMock(WKContextRef context) WKGeolocationManagerSetProvider(m_geolocationManager, &providerCallback); } -void GeolocationProviderMock::setMockGeolocationPosition(double latitude, double longitude, double accuracy) +void GeolocationProviderMock::setPosition(double latitude, double longitude, double accuracy) { m_position.adopt(WKGeolocationPositionCreate(currentTime(), latitude, longitude, accuracy)); - if (m_isActive) - WKGeolocationManagerProviderDidChangePosition(m_geolocationManager, m_position.get()); + sendPositionIfNeeded(); +} + +void GeolocationProviderMock::setPositionUnavailableError(WKStringRef errorMessage) +{ + m_errorMessage = errorMessage; + m_hasError = true; + sendErrorIfNeeded(); } void GeolocationProviderMock::startUpdating(WKGeolocationManagerRef geolocationManager) @@ -69,8 +76,8 @@ void GeolocationProviderMock::startUpdating(WKGeolocationManagerRef geolocationM ASSERT_UNUSED(geolocationManager, geolocationManager == m_geolocationManager); m_isActive = true; - if (m_position) - WKGeolocationManagerProviderDidChangePosition(m_geolocationManager, m_position.get()); + sendPositionIfNeeded(); + sendErrorIfNeeded(); } void GeolocationProviderMock::stopUpdating(WKGeolocationManagerRef geolocationManager) @@ -80,4 +87,21 @@ void GeolocationProviderMock::stopUpdating(WKGeolocationManagerRef geolocationMa m_isActive = false; } +void GeolocationProviderMock::sendPositionIfNeeded() +{ + if (m_isActive && m_position) { + WKGeolocationManagerProviderDidChangePosition(m_geolocationManager, m_position.get()); + m_position.clear(); + } +} + +void GeolocationProviderMock::sendErrorIfNeeded() +{ + if (m_isActive && m_hasError) { + m_hasError = false; + WKGeolocationManagerProviderDidFailToDeterminePositionWithErrorMessage(m_geolocationManager, m_errorMessage.get()); + m_errorMessage.clear(); + } +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/GeolocationProviderMock.h b/Tools/WebKitTestRunner/GeolocationProviderMock.h index 0f6284a2f..4a06f08f9 100644 --- a/Tools/WebKitTestRunner/GeolocationProviderMock.h +++ b/Tools/WebKitTestRunner/GeolocationProviderMock.h @@ -34,16 +34,23 @@ class GeolocationProviderMock { public: GeolocationProviderMock(WKContextRef); - void setMockGeolocationPosition(double latitude, double longitude, double accuracy); + void setPosition(double latitude, double longitude, double accuracy); + void setPositionUnavailableError(WKStringRef errorMessage); void startUpdating(WKGeolocationManagerRef); void stopUpdating(WKGeolocationManagerRef); private: + void sendPositionIfNeeded(); + void sendErrorIfNeeded(); + WKGeolocationManagerRef m_geolocationManager; bool m_isActive; WKRetainPtr<WKGeolocationPositionRef> m_position; + + bool m_hasError; + WKRetainPtr<WKStringRef> m_errorMessage; }; } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl index 35af514fe..6efd78e32 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl @@ -138,6 +138,7 @@ module WTR { void setTextDirection(in DOMString direction); void setWillSendRequestReturnsNull(in boolean flag); + void setWillSendRequestReturnsNullOnRedirect(in boolean flag); void setShouldStayOnPageAfterHandlingBeforeUnload(in boolean flag); @@ -180,6 +181,7 @@ module WTR { // Geolocation void setGeolocationPermission(in boolean value); void setMockGeolocationPosition(in double latitude, in double longitude, in double accuracy); + void setMockGeolocationPositionUnavailableError(in DOMString errorMessage); boolean callShouldCloseOnWebView(); }; diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index 2b24240ef..13765c0ff 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -386,4 +386,10 @@ void InjectedBundle::setMockGeolocationPosition(double latitude, double longitud WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get()); } +void InjectedBundle::setMockGeolocationPositionUnavailableError(WKStringRef errorMessage) +{ + WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetMockGeolocationPositionUnavailableError")); + WKBundlePostMessage(m_bundle, messageName.get(), errorMessage); +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h index 673a4be34..e296142c1 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h @@ -93,6 +93,7 @@ public: // Geolocation. void setGeolocationPermission(bool); void setMockGeolocationPosition(double latitude, double longitude, double accuracy); + void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage); private: InjectedBundle(); diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp index ab579c41b..782829f39 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp @@ -328,7 +328,8 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) didFinishProgress, // didFinishProgress 0, // shouldForceUniversalAccessFromLocalURL didReceiveIntentForFrame, // didReceiveIntentForFrame - registerIntentServiceForFrame // registerIntentServiceForFrame + registerIntentServiceForFrame, // registerIntentServiceForFrame + 0, // didLayout }; WKBundlePageSetPageLoaderClient(m_page, &loaderClient); @@ -742,6 +743,8 @@ void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame) if (!InjectedBundle::shared().isTestRunning()) return; + platformDidStartProvisionalLoadForFrame(frame); + if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) { dumpFrameDescriptionSuitableForTestResult(frame); InjectedBundle::shared().stringBuilder()->appendLiteral(" - didStartProvisionalLoadForFrame\n"); @@ -1147,9 +1150,6 @@ static inline bool isHTTPOrHTTPSScheme(WKStringRef scheme) WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t identifier, WKURLRequestRef request, WKURLResponseRef response) { - if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().testRunner()->willSendRequestReturnsNull()) - return 0; - if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().testRunner()->shouldDumpResourceLoadCallbacks()) { dumpResourceURL(identifier); @@ -1160,6 +1160,15 @@ WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKB InjectedBundle::shared().stringBuilder()->append('\n'); } + if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().testRunner()->willSendRequestReturnsNull()) + return 0; + + WKRetainPtr<WKURLRef> redirectURL = adoptWK(WKURLResponseCopyURL(response)); + if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().testRunner()->willSendRequestReturnsNullOnRedirect() && redirectURL) { + InjectedBundle::shared().stringBuilder()->appendLiteral("Returning null for this redirect\n"); + return 0; + } + WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request)); WKRetainPtr<WKStringRef> host = adoptWK(WKURLCopyHostName(url.get())); WKRetainPtr<WKStringRef> scheme = adoptWK(WKURLCopyScheme(url.get())); @@ -1863,4 +1872,10 @@ void InjectedBundlePage::dumpBackForwardList() InjectedBundle::shared().stringBuilder()->appendLiteral("===============================================\n"); } +#if !PLATFORM(MAC) +void InjectedBundlePage::platformDidStartProvisionalLoadForFrame(WKBundleFrameRef) +{ +} +#endif + } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h index 894fb305b..2754132ed 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h @@ -172,6 +172,8 @@ private: void dumpAllFramesText(); void dumpAllFrameScrollPositions(); + void platformDidStartProvisionalLoadForFrame(WKBundleFrameRef); + WKBundlePageRef m_page; WKRetainPtr<WKBundleScriptWorldRef> m_world; WKRetainPtr<WKBundleBackForwardListItemRef> m_previousTestBackForwardListItem; diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp index e2ef1557c..c2fd342e1 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp @@ -87,6 +87,7 @@ TestRunner::TestRunner() , m_testRepaint(false) , m_testRepaintSweepHorizontally(false) , m_willSendRequestReturnsNull(false) + , m_willSendRequestReturnsNullOnRedirect(false) , m_shouldStopProvisionalFrameLoads(false) , m_policyDelegateEnabled(false) , m_policyDelegatePermissive(false) @@ -784,6 +785,12 @@ void TestRunner::setMockGeolocationPosition(double latitude, double longitude, d InjectedBundle::shared().setMockGeolocationPosition(latitude, longitude, accuracy); } +void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message) +{ + WKRetainPtr<WKStringRef> messageWK = toWK(message); + InjectedBundle::shared().setMockGeolocationPositionUnavailableError(messageWK.get()); +} + bool TestRunner::callShouldCloseOnWebView() { WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h index a44129938..8458943fc 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h +++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h @@ -199,8 +199,10 @@ public: void setPOSIXLocale(JSStringRef); - bool willSendRequestReturnsNull() { return m_willSendRequestReturnsNull; } + bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; } void setWillSendRequestReturnsNull(bool f) { m_willSendRequestReturnsNull = f; } + bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; } + void setWillSendRequestReturnsNullOnRedirect(bool f) { m_willSendRequestReturnsNullOnRedirect = f; } void setTextDirection(JSStringRef); @@ -250,6 +252,7 @@ public: // Geolocation. void setGeolocationPermission(bool); void setMockGeolocationPosition(double latitude, double longitude, double accuracy); + void setMockGeolocationPositionUnavailableError(JSStringRef message); JSRetainPtr<JSStringRef> platformName(); @@ -291,6 +294,7 @@ private: bool m_testRepaintSweepHorizontally; bool m_willSendRequestReturnsNull; + bool m_willSendRequestReturnsNullOnRedirect; bool m_shouldStopProvisionalFrameLoads; bool m_policyDelegateEnabled; diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundlePageMac.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundlePageMac.mm new file mode 100644 index 000000000..46c273f1f --- /dev/null +++ b/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundlePageMac.mm @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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. + */ + +#import "config.h" +#import "InjectedBundlePage.h" + +#import "StringFunctions.h" +#import <WebKit2/WKBundleFrame.h> +#import <WebKit2/WKURLCF.h> +#import <WebKitSystemInterface.h> +#import <wtf/RetainPtr.h> +#import <wtf/text/StringBuilder.h> +#import <wtf/text/WTFString.h> + +namespace WTR { + +using namespace WTF; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 +static String testPathFromURL(WKURLRef url) +{ + RetainPtr<CFURLRef> cfURL(AdoptCF, WKURLCopyCFURL(kCFAllocatorDefault, url)); + if (!cfURL) + return String(); + + RetainPtr<CFStringRef> schemeCFString(AdoptCF, CFURLCopyScheme(cfURL.get())); + RetainPtr<CFStringRef> pathCFString(AdoptCF, CFURLCopyPath(cfURL.get())); + + String schemeString(schemeCFString.get()); + String pathString(pathCFString.get()); + + if (equalIgnoringCase(schemeString, "file")) { + String layoutTests("/LayoutTests/"); + size_t layoutTestsOffset = pathString.find(layoutTests); + if (layoutTestsOffset == notFound) + return String(); + + return pathString.substring(layoutTestsOffset + layoutTests.length()); + } + + if (!equalIgnoringCase(schemeString, "http") && !equalIgnoringCase(schemeString, "https")) + return String(); + + RetainPtr<CFStringRef> hostCFString(AdoptCF, CFURLCopyHostName(cfURL.get())); + String hostString(hostCFString.get()); + if (hostString == "127.0.0.1" && (CFURLGetPortNumber(cfURL.get()) == 8000 || CFURLGetPortNumber(cfURL.get()) == 8443)) + return pathString; + + return String(); +} +#endif + +void InjectedBundlePage::platformDidStartProvisionalLoadForFrame(WKBundleFrameRef frame) +{ +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 + if (!WKBundleFrameIsMainFrame(frame)) + return; + + WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyProvisionalURL(frame)); + + String testPath = testPathFromURL(mainFrameURL.get()); + if (!testPath.isNull()) { + StringBuilder builder; + builder.appendLiteral("CRASHING TEST: "); + builder.append(testPath); + RetainPtr<CFStringRef> cfString(AdoptCF, builder.toString().createCFString()); + WKSetCrashReportApplicationSpecificInformation(cfString.get()); + } +#endif +} + +} // namespace WTR diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp index 9d63f035e..33d913fdb 100644 --- a/Tools/WebKitTestRunner/TestController.cpp +++ b/Tools/WebKitTestRunner/TestController.cpp @@ -91,6 +91,7 @@ TestController::TestController(int argc, const char* argv[]) , m_didPrintWebProcessCrashedMessage(false) , m_shouldExitWhenWebProcessCrashes(true) , m_beforeUnloadReturnValue(true) + , m_isGeolocationPermissionSet(false) , m_isGeolocationPermissionAllowed(false) #if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL) , m_eventSenderProxy(new EventSenderProxy(this)) @@ -174,10 +175,7 @@ static void unfocus(WKPageRef page, const void* clientInfo) static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo) { TestController* testController = static_cast<TestController*>(const_cast<void*>(clientInfo)); - if (testController->isGeolocationPermissionAllowed()) - WKGeolocationPermissionRequestAllow(permissionRequest); - else - WKGeolocationPermissionRequestDeny(permissionRequest); + testController->handleGeolocationPermissionRequest(permissionRequest); } WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*) @@ -444,6 +442,7 @@ void TestController::initialize(int argc, const char* argv[]) 0, // pluginDidFail 0, // didReceiveIntentForFrame 0, // registerIntentServiceForFrame + 0, // didLayout }; WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient); } @@ -516,6 +515,7 @@ bool TestController::resetStateToConsistentValues() WKPreferencesSetSansSerifFontFamily(preferences, sansSerifFontFamily); WKPreferencesSetSerifFontFamily(preferences, serifFontFamily); #endif + WKPreferencesSetScreenFontSubstitutionEnabled(preferences, true); WKPreferencesSetInspectorUsesWebKitUserInterface(preferences, true); // in the case that a test using the chrome input field failed, be sure to clean up for the next test @@ -528,6 +528,11 @@ bool TestController::resetStateToConsistentValues() // Reset notification permissions m_webNotificationProvider.reset(); + // Reset Geolocation permissions. + m_geolocationPermissionRequests.clear(); + m_isGeolocationPermissionSet = false; + m_isGeolocationPermissionAllowed = false; + // Reset main page back to about:blank m_doneResetting = false; @@ -999,9 +1004,41 @@ void TestController::simulateWebNotificationClick(uint64_t notificationID) m_webNotificationProvider.simulateWebNotificationClick(notificationID); } +void TestController::setGeolocationPermission(bool enabled) +{ + m_isGeolocationPermissionSet = true; + m_isGeolocationPermissionAllowed = enabled; + decidePolicyForGeolocationPermissionRequestIfPossible(); +} + void TestController::setMockGeolocationPosition(double latitude, double longitude, double accuracy) { - m_geolocationProvider->setMockGeolocationPosition(latitude, longitude, accuracy); + m_geolocationProvider->setPosition(latitude, longitude, accuracy); +} + +void TestController::setMockGeolocationPositionUnavailableError(WKStringRef errorMessage) +{ + m_geolocationProvider->setPositionUnavailableError(errorMessage); +} + +void TestController::handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef geolocationPermissionRequest) +{ + m_geolocationPermissionRequests.append(geolocationPermissionRequest); + decidePolicyForGeolocationPermissionRequestIfPossible(); +} + +void TestController::decidePolicyForGeolocationPermissionRequestIfPossible() +{ + if (!m_isGeolocationPermissionSet) + return; + + for (size_t i = 0; i < m_geolocationPermissionRequests.size(); ++i) { + WKGeolocationPermissionRequestRef& permissionRequest = m_geolocationPermissionRequests[i]; + if (m_isGeolocationPermissionAllowed) + WKGeolocationPermissionRequestAllow(permissionRequest); + else + WKGeolocationPermissionRequestDeny(permissionRequest); + } } void TestController::decidePolicyForNotificationPermissionRequest(WKPageRef page, WKSecurityOriginRef origin, WKNotificationPermissionRequestRef request, const void* clientInfo) diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h index 8125a3646..f7888923b 100644 --- a/Tools/WebKitTestRunner/TestController.h +++ b/Tools/WebKitTestRunner/TestController.h @@ -32,6 +32,7 @@ #include <string> #include <vector> #include <wtf/OwnPtr.h> +#include <wtf/Vector.h> namespace WTR { @@ -67,9 +68,10 @@ public: void simulateWebNotificationClick(uint64_t notificationID); // Geolocation. - void setGeolocationPermission(bool enabled) { m_isGeolocationPermissionAllowed = enabled; } - bool isGeolocationPermissionAllowed() const { return m_isGeolocationPermissionAllowed; } + void setGeolocationPermission(bool); void setMockGeolocationPosition(double latitude, double longitude, double accuracy); + void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage); + void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef); bool resetStateToConsistentValues(); @@ -87,6 +89,8 @@ private: void initializeInjectedBundlePath(); void initializeTestPluginDirectory(); + void decidePolicyForGeolocationPermissionRequestIfPossible(); + // WKContextInjectedBundleClient static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*); static void didReceiveSynchronousMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void*); @@ -129,7 +133,6 @@ private: OwnPtr<PlatformWebView> m_mainWebView; WKRetainPtr<WKContextRef> m_context; WKRetainPtr<WKPageGroupRef> m_pageGroup; - OwnPtr<GeolocationProviderMock> m_geolocationProvider; enum State { Initial, @@ -150,6 +153,9 @@ private: bool m_beforeUnloadReturnValue; + OwnPtr<GeolocationProviderMock> m_geolocationProvider; + Vector<WKGeolocationPermissionRequestRef> m_geolocationPermissionRequests; + bool m_isGeolocationPermissionSet; bool m_isGeolocationPermissionAllowed; EventSenderProxy* m_eventSenderProxy; diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp index 449c1b0d3..9ca75aef7 100644 --- a/Tools/WebKitTestRunner/TestInvocation.cpp +++ b/Tools/WebKitTestRunner/TestInvocation.cpp @@ -375,6 +375,13 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName return; } + if (WKStringIsEqualToUTF8CString(messageName, "SetMockGeolocationPositionUnavailableError")) { + ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID()); + WKStringRef errorMessage = static_cast<WKStringRef>(messageBody); + TestController::shared().setMockGeolocationPositionUnavailableError(errorMessage); + return; + } + ASSERT_NOT_REACHED(); } diff --git a/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj b/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj index 00a67fb72..f80f30012 100644 --- a/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj +++ b/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ /* Begin PBXBuildFile section */ 0F5169CB1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; }; 0F5169CC1445222D00E0A9D7 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; }; + 0FAF67EF160D6C100077CB2B /* InjectedBundlePageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FAF67EE160D6C100077CB2B /* InjectedBundlePageMac.mm */; }; 26D758E7160BECDD00268472 /* GeolocationProviderMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D758E5160BECDC00268472 /* GeolocationProviderMock.cpp */; }; 29210EAE144CACB700835BB5 /* AccessibilityUIElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA9144CACB200835BB5 /* AccessibilityUIElement.cpp */; }; 29210EB0144CACBD00835BB5 /* AccessibilityController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA2144CAAA500835BB5 /* AccessibilityController.cpp */; }; @@ -102,6 +103,7 @@ /* Begin PBXFileReference section */ 0F5169CA1445222D00E0A9D7 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 0FAF67EE160D6C100077CB2B /* InjectedBundlePageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundlePageMac.mm; sourceTree = "<group>"; }; 26D758E5160BECDC00268472 /* GeolocationProviderMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationProviderMock.cpp; sourceTree = "<group>"; }; 26D758E6160BECDD00268472 /* GeolocationProviderMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationProviderMock.h; sourceTree = "<group>"; }; 29210EA2144CAAA500835BB5 /* AccessibilityController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityController.cpp; sourceTree = "<group>"; }; @@ -325,6 +327,7 @@ children = ( 65EB859F11EC67CC0034D300 /* ActivateFonts.mm */, BC8DAD771316D7B900EC96FC /* InjectedBundleMac.mm */, + 0FAF67EE160D6C100077CB2B /* InjectedBundlePageMac.mm */, ); path = mac; sourceTree = "<group>"; @@ -618,6 +621,7 @@ 29A8FCE5145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm in Sources */, 8097338A14874A5A008156D9 /* AccessibilityNotificationHandler.mm in Sources */, 8034C6621487636400AC32E9 /* AccessibilityControllerMac.mm in Sources */, + 0FAF67EF160D6C100077CB2B /* InjectedBundlePageMac.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |