- Revision
- 202724
- Author
- [email protected]
- Date
- 2016-06-30 22:23:02 -0700 (Thu, 30 Jun 2016)
Log Message
Source/WebKit2:
Add SPI to allow restoring session state without navigation in WKPage
https://bugs.webkit.org/show_bug.cgi?id=159326
Patch by Tina Liu <[email protected]> on 2016-06-30
Reviewed by Brady Eidson.
* UIProcess/API/C/WKPage.cpp:
(restoreFromSessionState):
Added a helper function that takes a bool parameter to specify whether
to navigate or not when restoring from the session state.
(WKPageRestoreFromSessionState):
Calling restoreFromSessionState, passing navigate = true.
(WKPageRestoreFromSessionStateWithoutNavigation):
Ditto but passing navigate = false.
* UIProcess/API/C/WKPagePrivate.h:
Tools:
Add an API test for WKPageRestoreFromSessionStateWithoutNavigation.
https://bugs.webkit.org/show_bug.cgi?id=159326
Patch by Tina Liu <[email protected]> on 2016-06-30
Reviewed by Brady Eidson.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/RestoreSessionStateWithoutNavigation.cpp: Added.
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::didChangeBackForwardListForPage):
(TestWebKitAPI::setPageLoaderClient):
Set the page loader client and register for didFinishLoadForFrame and
didChangeBackForwardList callbacks.
(TestWebKitAPI::createSessionStateData):
Load a webpage ("simple.html") and return the session state for this page.
(TestWebKitAPI::TEST):
Restore the page session state with that of "simple.html" without navigation.
Verify that the committed URL is NULL since there's no navigation involved.
Verify that the current item in the back forward list, which should be what
we restored from the session state, has the expected URL.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (202723 => 202724)
--- trunk/Source/WebKit2/ChangeLog 2016-07-01 01:29:47 UTC (rev 202723)
+++ trunk/Source/WebKit2/ChangeLog 2016-07-01 05:23:02 UTC (rev 202724)
@@ -1,3 +1,20 @@
+2016-06-30 Tina Liu <[email protected]>
+
+ Add SPI to allow restoring session state without navigation in WKPage
+ https://bugs.webkit.org/show_bug.cgi?id=159326
+
+ Reviewed by Brady Eidson.
+
+ * UIProcess/API/C/WKPage.cpp:
+ (restoreFromSessionState):
+ Added a helper function that takes a bool parameter to specify whether
+ to navigate or not when restoring from the session state.
+ (WKPageRestoreFromSessionState):
+ Calling restoreFromSessionState, passing navigate = true.
+ (WKPageRestoreFromSessionStateWithoutNavigation):
+ Ditto but passing navigate = false.
+ * UIProcess/API/C/WKPagePrivate.h:
+
2016-06-30 Chris Dumez <[email protected]>
[iOS] WebContent processes do not exit promptly
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (202723 => 202724)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2016-07-01 01:29:47 UTC (rev 202723)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2016-07-01 05:23:02 UTC (rev 202724)
@@ -444,7 +444,7 @@
return toAPI(&API::SessionState::create(WTFMove(sessionState)).leakRef());
}
-void WKPageRestoreFromSessionState(WKPageRef pageRef, WKTypeRef sessionStateRef)
+static void restoreFromSessionState(WKPageRef pageRef, WKTypeRef sessionStateRef, bool navigate)
{
SessionState sessionState;
@@ -458,9 +458,19 @@
sessionState = toImpl(static_cast<WKSessionStateRef>(sessionStateRef))->sessionState();
}
- toImpl(pageRef)->restoreFromSessionState(WTFMove(sessionState), true);
+ toImpl(pageRef)->restoreFromSessionState(WTFMove(sessionState), navigate);
}
+void WKPageRestoreFromSessionState(WKPageRef pageRef, WKTypeRef sessionStateRef)
+{
+ restoreFromSessionState(pageRef, sessionStateRef, true);
+}
+
+void WKPageRestoreFromSessionStateWithoutNavigation(WKPageRef pageRef, WKTypeRef sessionStateRef)
+{
+ restoreFromSessionState(pageRef, sessionStateRef, false);
+}
+
double WKPageGetTextZoomFactor(WKPageRef pageRef)
{
return toImpl(pageRef)->textZoomFactor();
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (202723 => 202724)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h 2016-07-01 01:29:47 UTC (rev 202723)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h 2016-07-01 05:23:02 UTC (rev 202724)
@@ -145,6 +145,8 @@
WK_EXPORT bool WKPageGetResourceCachingDisabled(WKPageRef page);
WK_EXPORT void WKPageSetResourceCachingDisabled(WKPageRef page, bool disabled);
+WK_EXPORT void WKPageRestoreFromSessionStateWithoutNavigation(WKPageRef page, WKTypeRef sessionState);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/Tools/ChangeLog (202723 => 202724)
--- trunk/Tools/ChangeLog 2016-07-01 01:29:47 UTC (rev 202723)
+++ trunk/Tools/ChangeLog 2016-07-01 05:23:02 UTC (rev 202724)
@@ -1,3 +1,25 @@
+2016-06-30 Tina Liu <[email protected]>
+
+ Add an API test for WKPageRestoreFromSessionStateWithoutNavigation.
+ https://bugs.webkit.org/show_bug.cgi?id=159326
+
+ Reviewed by Brady Eidson.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2/RestoreSessionStateWithoutNavigation.cpp: Added.
+ (TestWebKitAPI::didFinishLoadForFrame):
+ (TestWebKitAPI::didChangeBackForwardListForPage):
+ (TestWebKitAPI::setPageLoaderClient):
+ Set the page loader client and register for didFinishLoadForFrame and
+ didChangeBackForwardList callbacks.
+ (TestWebKitAPI::createSessionStateData):
+ Load a webpage ("simple.html") and return the session state for this page.
+ (TestWebKitAPI::TEST):
+ Restore the page session state with that of "simple.html" without navigation.
+ Verify that the committed URL is NULL since there's no navigation involved.
+ Verify that the current item in the back forward list, which should be what
+ we restored from the session state, has the expected URL.
+
2016-06-29 Filip Pizlo <[email protected]>
Generators violate bytecode liveness validation
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (202723 => 202724)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-01 01:29:47 UTC (rev 202723)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-07-01 05:23:02 UTC (rev 202724)
@@ -325,6 +325,7 @@
7CCE7F2F1A411B1000447C4C /* WKBrowsingContextLoadDelegateTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC3C4C7014575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm */; };
7CEFA9661AC0B9E200B910FD /* _WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */; };
7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
+ 835CF9671D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */; };
83CF1C301C4F1B8B00688447 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */; };
930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9361002814DC957B0061379D /* lots-of-iframes.html */; };
@@ -787,6 +788,7 @@
7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
81B50192140F232300D9EB58 /* StringBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilder.cpp; sourceTree = "<group>"; };
+ 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionStateWithoutNavigation.cpp; sourceTree = "<group>"; };
83B88A331C80056D00BB2418 /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLParserIdioms.cpp; sourceTree = "<group>"; };
83CF1C2C1C4F19AE00688447 /* StringUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringUtilities.mm; sourceTree = "<group>"; };
86BD19971A2DB05B006DCF0A /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCounter.cpp; sourceTree = "<group>"; };
@@ -1405,6 +1407,7 @@
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
+ 835CF9661D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp */,
2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */,
51FCF7971534AC6D00104491 /* ShouldGoToBackForwardListItem_Bundle.cpp */,
51FCF7981534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp */,
@@ -2109,6 +2112,7 @@
7C417F331D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm in Sources */,
7CCE7EA61A411A0F00447C4C /* PlatformUtilitiesMac.mm in Sources */,
7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
+ 835CF9671D25FCD6001A65D4 /* RestoreSessionStateWithoutNavigation.cpp in Sources */,
7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */,
7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */,
7C83E0BD1D0A650C00FEBCF3 /* FullscreenTopContentInset.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateWithoutNavigation.cpp (0 => 202724)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateWithoutNavigation.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/RestoreSessionStateWithoutNavigation.cpp 2016-07-01 05:23:02 UTC (rev 202724)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2016 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"
+
+#if WK_HAVE_C_SPI
+
+#include "_javascript_Test.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit/WKPagePrivate.h>
+#include <WebKit/WKSessionStateRef.h>
+
+namespace TestWebKitAPI {
+
+static bool didFinishLoad;
+static bool didChangeBackForwardList;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+ didFinishLoad = true;
+}
+
+static void didChangeBackForwardListForPage(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef, const void*)
+{
+ didChangeBackForwardList = true;
+}
+
+static void setPageLoaderClient(WKPageRef page)
+{
+ WKPageLoaderClientV0 loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.base.version = 0;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ loaderClient.didChangeBackForwardList = didChangeBackForwardListForPage;
+
+ WKPageSetPageLoaderClient(page, &loaderClient.base);
+}
+
+static WKRetainPtr<WKDataRef> createSessionStateData(WKContextRef context)
+{
+ PlatformWebView webView(context);
+ setPageLoaderClient(webView.page());
+
+ WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get());
+ Util::run(&didFinishLoad);
+ didFinishLoad = false;
+
+ auto sessionState = adoptWK(static_cast<WKSessionStateRef>(WKPageCopySessionState(webView.page(), reinterpret_cast<void*>(1), nullptr)));
+ return adoptWK(WKSessionStateCopyData(sessionState.get()));
+}
+
+TEST(WebKit2, RestoreSessionStateWithoutNavigation)
+{
+ WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+ PlatformWebView webView(context.get());
+ setPageLoaderClient(webView.page());
+
+ WKRetainPtr<WKDataRef> data = ""
+ EXPECT_NOT_NULL(data);
+
+ auto sessionState = adoptWK(WKSessionStateCreateFromData(data.get()));
+ WKPageRestoreFromSessionStateWithoutNavigation(webView.page(), sessionState.get());
+
+ Util::run(&didChangeBackForwardList);
+
+ WKRetainPtr<WKURLRef> committedURL = adoptWK(WKPageCopyCommittedURL(webView.page()));
+ EXPECT_NULL(committedURL.get());
+
+ auto backForwardList = WKPageGetBackForwardList(webView.page());
+ auto currentItem = WKBackForwardListGetCurrentItem(backForwardList);
+ auto currentItemURL = adoptWK(WKBackForwardListItemCopyURL(currentItem));
+ auto expectedURL = adoptWK(Util::createURLForResource("simple", "html"));
+ EXPECT_NOT_NULL(expectedURL);
+ EXPECT_TRUE(WKURLIsEqual(currentItemURL.get(), expectedURL.get()));
+}
+
+} // namespace TestWebKitAPI
+
+#endif