summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>2013-01-28 22:38:23 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-08 17:34:02 +0200
commit0dd9e57645d192fca388abe8f04e93ca7bef6ad6 (patch)
tree580a6d97c337b8e5cd7ad71e58ee6081e01d84e8 /Tools
parentf0ce121cf5367b340160408821ab6b9d00d3d0cb (diff)
downloadqtwebkit-0dd9e57645d192fca388abe8f04e93ca7bef6ad6.tar.gz
Improve PageVisibility API with enums
https://bugs.webkit.org/show_bug.cgi?id=107364 Reviewed by Sam Weinig. Source/WebKit/mac: * WebView/WebView.mm: * WebView/WebViewPrivate.h: (corePageVisibilityState): (-[WebView _setVisibilityState:isInitialState:]): Switch the private API form int to a WebPageVisibilityState enum. Source/WebKit2: * Shared/API/c/WKPageVisibilityTypes.h: Added. * Shared/API/c/WKSharedAPICast.h: (WebKit::toPageVisibilityState): Create an enum for page visibility APIs and a conversion function for the WK2 values to WebCore values. * Target.pri: * GNUmakefile.list.am: * WebKit2.xcodeproj/project.pbxproj: Add WKPageVisibilityTypes.h to the build as a private export. * UIProcess/API/C/WKPage.h: * UIProcess/API/C/WKPage.cpp: (WKPageSetVisibilityState): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setVisibilityState): UIProcess API to set visibility state. WebPageProxy already had m_visibilityState, so update that when setter is used. * WebProcess/InjectedBundle/API/c/WKBundle.cpp: * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h: * WebProcess/InjectedBundle/InjectedBundle.cpp: * WebProcess/InjectedBundle/InjectedBundle.h: Remove the old SPI for WebKitTestRunner. Tests now use the C API. * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setVisibilityState): * WebProcess/WebPage/WebPage.messages.in: Update the existing WebPage API to use uint32_t, which matches other enum message types. Tools: * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::resetPageVisibility): (TestRunner::setPageVisibility): Update the WK1 test code to use the new WK1 enums. * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: (WTR::InjectedBundle::setVisibilityState): * WebKitTestRunner/InjectedBundle/InjectedBundle.h: (InjectedBundle): * WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::setPageVisibility): (WTR::TestRunner::resetPageVisibility): * WebKitTestRunner/TestController.cpp: (WTR::TestController::setVisibilityState): * WebKitTestRunner/TestController.h: (TestController): * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Update the WK2 test code to use the new WK2 API and enums. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp: Added. (TestWebKitAPI): (TestWebKitAPI::setPageVisibilityStateWithEvalContinuation): (TestWebKitAPI::assertSerializedScriptValueIsStringValue): (TestWebKitAPI::didRunStep1StateChangeVisibleToHidden): (TestWebKitAPI::didRunStep2StateChangeHiddenToPrerender): (TestWebKitAPI::didRunStep3StateChangePrerenderToPreview): (TestWebKitAPI::didRunStep4InStatePreview): (TestWebKitAPI::TEST): Test the new WK2 API with all enum types. Change-Id: I0a057111d7ef26cb87ade328291d4f94322480b7 git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141010 268f45cc-cd09-0410-ab3c-d52691b4dbfc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Tools')
-rw-r--r--Tools/DumpRenderTree/mac/TestRunnerMac.mm14
-rw-r--r--Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj4
-rw-r--r--Tools/TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp109
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp16
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h3
-rw-r--r--Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp15
-rw-r--r--Tools/WebKitTestRunner/TestController.cpp5
-rw-r--r--Tools/WebKitTestRunner/TestController.h3
-rw-r--r--Tools/WebKitTestRunner/TestInvocation.cpp16
9 files changed, 170 insertions, 15 deletions
diff --git a/Tools/DumpRenderTree/mac/TestRunnerMac.mm b/Tools/DumpRenderTree/mac/TestRunnerMac.mm
index b520e096f..c6a2f4a37 100644
--- a/Tools/DumpRenderTree/mac/TestRunnerMac.mm
+++ b/Tools/DumpRenderTree/mac/TestRunnerMac.mm
@@ -43,7 +43,6 @@
#import <JavaScriptCore/JSStringRef.h>
#import <JavaScriptCore/JSStringRefCF.h>
#import <WebCore/GeolocationPosition.h>
-#import <WebCore/PageVisibilityState.h>
#import <WebKit/DOMDocument.h>
#import <WebKit/DOMElement.h>
#import <WebKit/WebApplicationCache.h>
@@ -1156,9 +1155,8 @@ void TestRunner::setBackingScaleFactor(double backingScaleFactor)
void TestRunner::resetPageVisibility()
{
WebView *webView = [mainFrame webView];
- if ([webView respondsToSelector:@selector(_setVisibilityState:isInitialState:)]) {
- [webView _setVisibilityState:WebCore::PageVisibilityStateVisible isInitialState:NO];
- }
+ if ([webView respondsToSelector:@selector(_setVisibilityState:isInitialState:)])
+ [webView _setVisibilityState:WebPageVisibilityStateVisible isInitialState:YES];
}
void TestRunner::setPageVisibility(const char* newVisibility)
@@ -1168,13 +1166,13 @@ void TestRunner::setPageVisibility(const char* newVisibility)
WebView *webView = [mainFrame webView];
if (!strcmp(newVisibility, "visible"))
- [webView _setVisibilityState:WebCore::PageVisibilityStateVisible isInitialState:NO];
+ [webView _setVisibilityState:WebPageVisibilityStateVisible isInitialState:NO];
else if (!strcmp(newVisibility, "hidden"))
- [webView _setVisibilityState:WebCore::PageVisibilityStateHidden isInitialState:NO];
+ [webView _setVisibilityState:WebPageVisibilityStateHidden isInitialState:NO];
else if (!strcmp(newVisibility, "prerender"))
- [webView _setVisibilityState:WebCore::PageVisibilityStatePrerender isInitialState:NO];
+ [webView _setVisibilityState:WebPageVisibilityStatePrerender isInitialState:NO];
else if (!strcmp(newVisibility, "preview"))
- [webView _setVisibilityState:WebCore::PageVisibilityStatePreview isInitialState:NO];
+ [webView _setVisibilityState:WebPageVisibilityStatePreview isInitialState:NO];
}
void TestRunner::sendWebIntentResponse(JSStringRef)
diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
index 249fc4aa6..cfda4b91d 100644
--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -95,6 +95,7 @@
9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; };
9B4F8FA4159D52B1002D9F94 /* HTMLCollectionNamedItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */; };
9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; };
+ A51B650916ADF9B1007AA5D9 /* PageVisibilityState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A51B650816ADF9B1007AA5D9 /* PageVisibilityState.cpp */; };
A5E2027315B2181900C13E14 /* WindowlessWebViewWithMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */; };
A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
A7A966DB140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */; };
@@ -341,6 +342,7 @@
9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormCollectionNamedItem.html; sourceTree = "<group>"; };
9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; };
9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; };
+ A51B650816ADF9B1007AA5D9 /* PageVisibilityState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageVisibilityState.cpp; sourceTree = "<group>"; };
A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WindowlessWebViewWithMedia.html; sourceTree = "<group>"; };
A5E2027215B2181900C13E14 /* WindowlessWebViewWithMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WindowlessWebViewWithMedia.mm; sourceTree = "<group>"; };
A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CheckedArithmeticOperations.cpp; path = WTF/CheckedArithmeticOperations.cpp; sourceTree = "<group>"; };
@@ -624,6 +626,7 @@
93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */,
BC909779125571AB00083756 /* PageLoadBasic.cpp */,
BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */,
+ A51B650816ADF9B1007AA5D9 /* PageVisibilityState.cpp */,
52E5CE4514D21E9D003B2BD8 /* ParentFrame.cpp */,
52E5CE4814D21EAB003B2BD8 /* ParentFrame_Bundle.cpp */,
333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */,
@@ -973,6 +976,7 @@
93F7E86C14DC8E4D00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames.cpp in Sources */,
BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */,
BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */,
+ A51B650916ADF9B1007AA5D9 /* PageVisibilityState.cpp in Sources */,
52E5CE4614D21E9D003B2BD8 /* ParentFrame.cpp in Sources */,
BC575BC0126F5752006F0F12 /* PlatformUtilities.cpp in Sources */,
BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp
new file mode 100644
index 000000000..00c79ce3a
--- /dev/null
+++ b/Tools/TestWebKitAPI/Tests/WebKit2/PageVisibilityState.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <JavaScriptCore/JSContextRef.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKSerializedScriptValue.h>
+
+namespace TestWebKitAPI {
+
+static bool testDone;
+
+static void didRunStep1StateChangeVisibleToHidden(WKSerializedScriptValueRef, WKErrorRef, void*);
+static void didRunStep2StateChangeHiddenToPrerender(WKSerializedScriptValueRef, WKErrorRef, void*);
+static void didRunStep3StateChangePrerenderToPreview(WKSerializedScriptValueRef, WKErrorRef, void*);
+static void didRunStep4InStatePreview(WKSerializedScriptValueRef, WKErrorRef, void*);
+
+static void setPageVisibilityStateWithEvalContinuation(PlatformWebView* webView, WKPageVisibilityState visibilityState, WKPageRunJavaScriptFunction callback)
+{
+ WKPageSetVisibilityState(webView->page(), visibilityState, false);
+ WKRetainPtr<WKStringRef> javaScriptString(AdoptWK, WKStringCreateWithUTF8CString("document.webkitVisibilityState"));
+ WKPageRunJavaScriptInMainFrame(webView->page(), javaScriptString.get(), static_cast<void*>(webView), callback);
+}
+
+static void assertSerializedScriptValueIsStringValue(WKSerializedScriptValueRef serializedValue, WKErrorRef error, const char *expected)
+{
+ EXPECT_NULL(error);
+ EXPECT_NOT_NULL(serializedValue);
+ if (error || !serializedValue)
+ return;
+
+ JSGlobalContextRef scriptContext = JSGlobalContextCreate(0);
+ JSValueRef scriptValue = WKSerializedScriptValueDeserialize(serializedValue, scriptContext, 0);
+ EXPECT_TRUE(JSValueIsString(scriptContext, scriptValue));
+ if (!JSValueIsString(scriptContext, scriptValue)) {
+ JSGlobalContextRelease(scriptContext);
+ return;
+ }
+
+ JSStringRef expectedString = JSStringCreateWithUTF8CString(expected);
+ JSStringRef scriptString = JSValueToStringCopy(scriptContext, scriptValue, 0);
+ EXPECT_TRUE(JSStringIsEqual(scriptString, expectedString));
+
+ JSStringRelease(scriptString);
+ JSStringRelease(expectedString);
+ JSGlobalContextRelease(scriptContext);
+}
+
+static void didRunStep1StateChangeVisibleToHidden(WKSerializedScriptValueRef resultSerializedScriptValue, WKErrorRef error, void* context)
+{
+ assertSerializedScriptValueIsStringValue(resultSerializedScriptValue, error, "visible");
+ setPageVisibilityStateWithEvalContinuation(static_cast<PlatformWebView*>(context), kWKPageVisibilityStateHidden, didRunStep2StateChangeHiddenToPrerender);
+}
+
+static void didRunStep2StateChangeHiddenToPrerender(WKSerializedScriptValueRef resultSerializedScriptValue, WKErrorRef error, void* context)
+{
+ assertSerializedScriptValueIsStringValue(resultSerializedScriptValue, error, "hidden");
+ setPageVisibilityStateWithEvalContinuation(static_cast<PlatformWebView*>(context), kWKPageVisibilityStatePrerender, didRunStep3StateChangePrerenderToPreview);
+}
+
+static void didRunStep3StateChangePrerenderToPreview(WKSerializedScriptValueRef resultSerializedScriptValue, WKErrorRef error, void* context)
+{
+ assertSerializedScriptValueIsStringValue(resultSerializedScriptValue, error, "prerender");
+ setPageVisibilityStateWithEvalContinuation(static_cast<PlatformWebView*>(context), kWKPageVisibilityStatePreview, didRunStep4InStatePreview);
+}
+
+static void didRunStep4InStatePreview(WKSerializedScriptValueRef resultSerializedScriptValue, WKErrorRef error, void* context)
+{
+ assertSerializedScriptValueIsStringValue(resultSerializedScriptValue, error, "preview");
+ testDone = true;
+}
+
+TEST(WebKit2, PageVisibilityState)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ // Pass the PlatformWebView webView on as the context of the evals, so we can continue to eval on it.
+ PlatformWebView webView(context.get());
+ setPageVisibilityStateWithEvalContinuation(&webView, kWKPageVisibilityStateVisible, didRunStep1StateChangeVisibleToHidden);
+
+ Util::run(&testDone);
+}
+
+} // namespace TestWebKitAPI
diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
index fa7939d3e..96b3d657b 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
@@ -458,6 +458,22 @@ void InjectedBundle::setCustomPolicyDelegate(bool enabled, bool permissive)
WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
}
+void InjectedBundle::setVisibilityState(WKPageVisibilityState visibilityState, bool isInitialState)
+{
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetVisibilityState"));
+ WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate());
+
+ WKRetainPtr<WKStringRef> visibilityStateKeyWK(AdoptWK, WKStringCreateWithUTF8CString("visibilityState"));
+ WKRetainPtr<WKUInt64Ref> visibilityStateWK(AdoptWK, WKUInt64Create(visibilityState));
+ WKDictionaryAddItem(messageBody.get(), visibilityStateKeyWK.get(), visibilityStateWK.get());
+
+ WKRetainPtr<WKStringRef> isInitialKeyWK(AdoptWK, WKStringCreateWithUTF8CString("isInitialState"));
+ WKRetainPtr<WKBooleanRef> isInitialWK(AdoptWK, WKBooleanCreate(isInitialState));
+ WKDictionaryAddItem(messageBody.get(), isInitialKeyWK.get(), isInitialWK.get());
+
+ WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+}
+
bool InjectedBundle::shouldProcessWorkQueue() const
{
if (!m_useWorkQueue)
diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
index 41469ec79..527641e40 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
+++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
@@ -98,6 +98,9 @@ public:
// Policy delegate.
void setCustomPolicyDelegate(bool enabled, bool permissive);
+ // Page Visibility.
+ void setVisibilityState(WKPageVisibilityState, bool isInitialState);
+
// Work queue.
bool shouldProcessWorkQueue() const;
void processWorkQueue();
diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
index 10fccc23e..602e600f0 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
@@ -32,12 +32,13 @@
#include "PlatformWebView.h"
#include "StringFunctions.h"
#include "TestController.h"
-#include <WebCore/PageVisibilityState.h>
+#include <WebKit2/WKBundle.h>
#include <WebKit2/WKBundleBackForwardList.h>
#include <WebKit2/WKBundleFrame.h>
#include <WebKit2/WKBundleFramePrivate.h>
#include <WebKit2/WKBundleInspector.h>
#include <WebKit2/WKBundleNodeHandlePrivate.h>
+#include <WebKit2/WKBundlePage.h>
#include <WebKit2/WKBundlePagePrivate.h>
#include <WebKit2/WKBundlePrivate.h>
#include <WebKit2/WKBundleScriptWorld.h>
@@ -539,21 +540,21 @@ void TestRunner::setDefersLoading(bool shouldDeferLoading)
void TestRunner::setPageVisibility(JSStringRef state)
{
- WebCore::PageVisibilityState visibilityState = WebCore::PageVisibilityStateVisible;
+ WKPageVisibilityState visibilityState = kWKPageVisibilityStateVisible;
if (JSStringIsEqualToUTF8CString(state, "hidden"))
- visibilityState = WebCore::PageVisibilityStateHidden;
+ visibilityState = kWKPageVisibilityStateHidden;
else if (JSStringIsEqualToUTF8CString(state, "prerender"))
- visibilityState = WebCore::PageVisibilityStatePrerender;
+ visibilityState = kWKPageVisibilityStatePrerender;
else if (JSStringIsEqualToUTF8CString(state, "preview"))
- visibilityState = WebCore::PageVisibilityStatePreview;
+ visibilityState = kWKPageVisibilityStatePreview;
- WKBundleSetPageVisibilityState(InjectedBundle::shared().bundle(), InjectedBundle::shared().page()->page(), visibilityState, /* isInitialState */ false);
+ InjectedBundle::shared().setVisibilityState(visibilityState, false);
}
void TestRunner::resetPageVisibility()
{
- WKBundleSetPageVisibilityState(InjectedBundle::shared().bundle(), InjectedBundle::shared().page()->page(), WebCore::PageVisibilityStateVisible, /* isInitialState */ true);
+ InjectedBundle::shared().setVisibilityState(kWKPageVisibilityStateVisible, true);
}
typedef WTF::HashMap<unsigned, JSValueRef> CallbackMap;
diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp
index 0e47f3c24..006892f4f 100644
--- a/Tools/WebKitTestRunner/TestController.cpp
+++ b/Tools/WebKitTestRunner/TestController.cpp
@@ -1077,6 +1077,11 @@ void TestController::setCustomPolicyDelegate(bool enabled, bool permissive)
m_policyDelegatePermissive = permissive;
}
+void TestController::setVisibilityState(WKPageVisibilityState visibilityState, bool isInitialState)
+{
+ WKPageSetVisibilityState(m_mainWebView->page(), visibilityState, isInitialState);
+}
+
void TestController::decidePolicyForGeolocationPermissionRequestIfPossible()
{
if (!m_isGeolocationPermissionSet)
diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h
index 332e33b70..b0ad979e0 100644
--- a/Tools/WebKitTestRunner/TestController.h
+++ b/Tools/WebKitTestRunner/TestController.h
@@ -79,6 +79,9 @@ public:
// Policy delegate.
void setCustomPolicyDelegate(bool enabled, bool permissive);
+ // Page Visibility.
+ void setVisibilityState(WKPageVisibilityState, bool isInitialState);
+
bool resetStateToConsistentValues();
WorkQueueManager& workQueueManager() { return m_workQueueManager; }
diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp
index 8f66cc0dd..f6ad9aa45 100644
--- a/Tools/WebKitTestRunner/TestInvocation.cpp
+++ b/Tools/WebKitTestRunner/TestInvocation.cpp
@@ -478,6 +478,22 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "SetVisibilityState")) {
+ ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+ WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+
+ WKRetainPtr<WKStringRef> visibilityStateKeyWK(AdoptWK, WKStringCreateWithUTF8CString("visibilityState"));
+ WKUInt64Ref visibilityStateWK = static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, visibilityStateKeyWK.get()));
+ WKPageVisibilityState visibilityState = static_cast<WKPageVisibilityState>(WKUInt64GetValue(visibilityStateWK));
+
+ WKRetainPtr<WKStringRef> isInitialKeyWK(AdoptWK, WKStringCreateWithUTF8CString("isInitialState"));
+ WKBooleanRef isInitialWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, isInitialKeyWK.get()));
+ bool isInitialState = WKBooleanGetValue(isInitialWK);
+
+ TestController::shared().setVisibilityState(visibilityState, isInitialState);
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "ProcessWorkQueue")) {
if (TestController::shared().workQueueManager().processWorkQueue()) {
WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("WorkQueueProcessedCallback"));