Title: [207445] trunk
Revision
207445
Author
timothy_hor...@apple.com
Date
2016-10-17 17:45:05 -0700 (Mon, 17 Oct 2016)

Log Message

REGRESSION (r169805): WKWebView canGoBack returning YES when nothing is in the back-forward list after restoring session state
https://bugs.webkit.org/show_bug.cgi?id=163573
<rdar://problem/28744549>

Reviewed by Dan Bernstein.

Source/WebKit2:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::restoreFromSessionState):
Update PageLoadState's canGoBack/canGoForward bits when restoring from
session state, because in the don't-navigate case, nothing else will make this happen,
and it will remain stale.

Tools:

* TestWebKitAPI/Tests/WebKit2/WKBackForwardList.mm:
(TEST):
Add a test ensuring that canGoBack returns NO after restoring session state without navigating.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (207444 => 207445)


--- trunk/Source/WebKit2/ChangeLog	2016-10-18 00:36:12 UTC (rev 207444)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-18 00:45:05 UTC (rev 207445)
@@ -1,3 +1,17 @@
+2016-10-17  Tim Horton  <timothy_hor...@apple.com>
+
+        REGRESSION (r169805): WKWebView canGoBack returning YES when nothing is in the back-forward list after restoring session state
+        https://bugs.webkit.org/show_bug.cgi?id=163573
+        <rdar://problem/28744549>
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::restoreFromSessionState):
+        Update PageLoadState's canGoBack/canGoForward bits when restoring from
+        session state, because in the don't-navigate case, nothing else will make this happen,
+        and it will remain stale.
+
 2016-10-17  Andy Estes  <aes...@apple.com>
 
         Crash in ASCIICaseInsensitiveHash::hash() when a response has a null MIME type

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (207444 => 207445)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-10-18 00:36:12 UTC (rev 207444)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2016-10-18 00:45:05 UTC (rev 207445)
@@ -2397,6 +2397,10 @@
 
         process().send(Messages::WebPage::RestoreSession(m_backForwardList->itemStates()), m_pageID);
 
+        auto transaction = m_pageLoadState.transaction();
+        m_pageLoadState.setCanGoBack(transaction, m_backForwardList->backItem());
+        m_pageLoadState.setCanGoForward(transaction, m_backForwardList->forwardItem());
+
         // The back / forward list was restored from a sessionState so we don't want to snapshot the current
         // page when navigating away. Suppress navigation snapshotting until the next load has committed
         m_suppressAutomaticNavigationSnapshotting = true;

Modified: trunk/Tools/ChangeLog (207444 => 207445)


--- trunk/Tools/ChangeLog	2016-10-18 00:36:12 UTC (rev 207444)
+++ trunk/Tools/ChangeLog	2016-10-18 00:45:05 UTC (rev 207445)
@@ -1,3 +1,15 @@
+2016-10-17  Tim Horton  <timothy_hor...@apple.com>
+
+        REGRESSION (r169805): WKWebView canGoBack returning YES when nothing is in the back-forward list after restoring session state
+        https://bugs.webkit.org/show_bug.cgi?id=163573
+        <rdar://problem/28744549>
+
+        Reviewed by Dan Bernstein.
+
+        * TestWebKitAPI/Tests/WebKit2/WKBackForwardList.mm:
+        (TEST):
+        Add a test ensuring that canGoBack returns NO after restoring session state without navigating.
+
 2016-10-17  Andy Estes  <aes...@apple.com>
 
         Crash in ASCIICaseInsensitiveHash::hash() when a response has a null MIME type

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/WKBackForwardList.mm (207444 => 207445)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/WKBackForwardList.mm	2016-10-18 00:36:12 UTC (rev 207444)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/WKBackForwardList.mm	2016-10-18 00:45:05 UTC (rev 207445)
@@ -72,4 +72,35 @@
     EXPECT_STREQ([[newList.currentItem URL] absoluteString].UTF8String, loadableURL2.UTF8String);
 }
 
+TEST(WKBackForwardList, CanNotGoBackAfterRestoringEmptySessionState)
+{
+    auto webView = adoptNS([[WKWebView alloc] init]);
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL1]]];
+    [webView _test_waitForDidFinishNavigation];
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL2]]];
+    [webView _test_waitForDidFinishNavigation];
+
+    WKBackForwardList *list = [webView backForwardList];
+    EXPECT_EQ(YES, [webView canGoBack]);
+    EXPECT_EQ(NO, [webView canGoForward]);
+    EXPECT_EQ((NSUInteger)1, list.backList.count);
+    EXPECT_EQ((NSUInteger)0, list.forwardList.count);
+
+    auto singlePageWebView = adoptNS([[WKWebView alloc] init]);
+
+    [singlePageWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadableURL1]]];
+    [singlePageWebView _test_waitForDidFinishNavigation];
+
+    [webView _restoreSessionState:[singlePageWebView _sessionState] andNavigate:NO];
+
+    WKBackForwardList *newList = [webView backForwardList];
+
+    EXPECT_EQ(NO, [webView canGoBack]);
+    EXPECT_EQ(NO, [webView canGoForward]);
+    EXPECT_EQ((NSUInteger)0, newList.backList.count);
+    EXPECT_EQ((NSUInteger)0, newList.forwardList.count);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to