Title: [240485] trunk
Revision
240485
Author
[email protected]
Date
2019-01-25 10:54:54 -0800 (Fri, 25 Jan 2019)

Log Message

Regression(PSON) cross-site provisional page is not canceled if a new same-site one is started
https://bugs.webkit.org/show_bug.cgi?id=193788
<rdar://problem/47531231>

Reviewed by Alex Christensen.

Source/WebKit:

When the page starts a new provisional load, make sure we cancel any pending one in the provisional
process, as it would have happened in the first provisional load happened in the same process.
Without this, we could have 2 parallel loads happening, one in the committed process and another
in the provisional one, leading to assertion failures in debug.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(-[PSONNavigationDelegate webView:didStartProvisionalNavigation:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (240484 => 240485)


--- trunk/Source/WebKit/ChangeLog	2019-01-25 18:49:01 UTC (rev 240484)
+++ trunk/Source/WebKit/ChangeLog	2019-01-25 18:54:54 UTC (rev 240485)
@@ -1,5 +1,21 @@
 2019-01-25  Chris Dumez  <[email protected]>
 
+        Regression(PSON) cross-site provisional page is not canceled if a new same-site one is started
+        https://bugs.webkit.org/show_bug.cgi?id=193788
+        <rdar://problem/47531231>
+
+        Reviewed by Alex Christensen.
+
+        When the page starts a new provisional load, make sure we cancel any pending one in the provisional
+        process, as it would have happened in the first provisional load happened in the same process.
+        Without this, we could have 2 parallel loads happening, one in the committed process and another
+        in the provisional one, leading to assertion failures in debug.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didStartProvisionalLoadForFrameShared):
+
+2019-01-25  Chris Dumez  <[email protected]>
+
         Drop WebKit::WebKitPolicyAction type as it is no longer needed
         https://bugs.webkit.org/show_bug.cgi?id=193827
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (240484 => 240485)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-01-25 18:49:01 UTC (rev 240484)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-01-25 18:54:54 UTC (rev 240485)
@@ -3775,6 +3775,12 @@
     MESSAGE_CHECK(process, frame);
     MESSAGE_CHECK_URL(process, url);
 
+    // If the page starts a new main frame provisional load, then cancel any pending one in a provisional process.
+    if (frame->isMainFrame() && m_provisionalPage && m_provisionalPage->mainFrame() != frame) {
+        m_provisionalPage->cancel();
+        m_provisionalPage = nullptr;
+    }
+
     // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
     RefPtr<API::Navigation> navigation;
     if (frame->isMainFrame() && navigationID)

Modified: trunk/Tools/ChangeLog (240484 => 240485)


--- trunk/Tools/ChangeLog	2019-01-25 18:49:01 UTC (rev 240484)
+++ trunk/Tools/ChangeLog	2019-01-25 18:54:54 UTC (rev 240485)
@@ -1,3 +1,16 @@
+2019-01-25  Chris Dumez  <[email protected]>
+
+        Regression(PSON) cross-site provisional page is not canceled if a new same-site one is started
+        https://bugs.webkit.org/show_bug.cgi?id=193788
+        <rdar://problem/47531231>
+
+        Reviewed by Alex Christensen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        (-[PSONNavigationDelegate webView:didStartProvisionalNavigation:]):
+
 2019-01-25  Jonathan Bedard  <[email protected]>
 
         webkitpy: Missing PID in crashlog name should not be fatal (Follow-up fix)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (240484 => 240485)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-01-25 18:49:01 UTC (rev 240484)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-01-25 18:54:54 UTC (rev 240485)
@@ -61,6 +61,7 @@
 @end
 
 static bool done;
+static bool didStartProvisionalLoad;
 static bool failed;
 static bool didCreateWebView;
 static int numberOfDecidePolicyCalls;
@@ -119,6 +120,11 @@
     done = true;
 }
 
+- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
+{
+    didStartProvisionalLoad = true;
+}
+
 - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
 {
     ++numberOfDecidePolicyCalls;
@@ -2258,6 +2264,46 @@
     EXPECT_EQ(1u, seenPIDs.size());
 }
 
+TEST(ProcessSwap, DoSameSiteNavigationAfterCrossSiteProvisionalLoadStarted)
+{
+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    [processPoolConfiguration setProcessSwapsOnNavigation:YES];
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [webViewConfiguration setProcessPool:processPool.get()];
+    auto handler = adoptNS([[PSONScheme alloc] init]);
+    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main1.html"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto webkitPID = [webView _webProcessIdentifier];
+
+    didStartProvisionalLoad = false;
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&didStartProvisionalLoad);
+    didStartProvisionalLoad = false;
+
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main2.html"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_WK_STREQ(@"pson://www.webkit.org/main2.html", [[webView URL] absoluteString]);
+    EXPECT_EQ(webkitPID, [webView _webProcessIdentifier]);
+}
+
 TEST(ProcessSwap, SuspendedPageLimit)
 {
     auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to