Title: [292129] branches/safari-613-branch
Revision
292129
Author
[email protected]
Date
2022-03-30 16:44:00 -0700 (Wed, 30 Mar 2022)

Log Message

Cherry-pick r290371. rdar://problem/88652375

    Call WKNavigationDelegate.didFailProvisionalNavigation even after a cross-origin navigation with COOP
    https://bugs.webkit.org/show_bug.cgi?id=237071
    <rdar://88652375>

    Patch by Alex Christensen <[email protected]> on 2022-02-23
    Reviewed by Chris Dumez.

    Source/WebKit:

    There was an assumption that this callback wasn't needed in this case, but it is.
    Covered by an API test that verifies the callback is received.

    * UIProcess/ProvisionalPageProxy.cpp:
    (WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame):

    Tools:

    * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
    (TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290371 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (292128 => 292129)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-30 23:33:13 UTC (rev 292128)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-30 23:44:00 UTC (rev 292129)
@@ -1,5 +1,45 @@
 2022-03-29  Alan Coon  <[email protected]>
 
+        Cherry-pick r290371. rdar://problem/88652375
+
+    Call WKNavigationDelegate.didFailProvisionalNavigation even after a cross-origin navigation with COOP
+    https://bugs.webkit.org/show_bug.cgi?id=237071
+    <rdar://88652375>
+    
+    Patch by Alex Christensen <[email protected]> on 2022-02-23
+    Reviewed by Chris Dumez.
+    
+    Source/WebKit:
+    
+    There was an assumption that this callback wasn't needed in this case, but it is.
+    Covered by an API test that verifies the callback is received.
+    
+    * UIProcess/ProvisionalPageProxy.cpp:
+    (WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
+    (TEST):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-23  Alex Christensen  <[email protected]>
+
+            Call WKNavigationDelegate.didFailProvisionalNavigation even after a cross-origin navigation with COOP
+            https://bugs.webkit.org/show_bug.cgi?id=237071
+            <rdar://88652375>
+
+            Reviewed by Chris Dumez.
+
+            There was an assumption that this callback wasn't needed in this case, but it is.
+            Covered by an API test that verifies the callback is received.
+
+            * UIProcess/ProvisionalPageProxy.cpp:
+            (WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame):
+
+2022-03-29  Alan Coon  <[email protected]>
+
         Apply patch. rdar://problem/89997669
 
     2022-02-14  Kimmo Kinnunen  <[email protected]>

Modified: branches/safari-613-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (292128 => 292129)


--- branches/safari-613-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2022-03-30 23:33:13 UTC (rev 292128)
+++ branches/safari-613-branch/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2022-03-30 23:44:00 UTC (rev 292129)
@@ -297,15 +297,6 @@
     ASSERT(!m_provisionalLoadURL.isNull());
     m_provisionalLoadURL = { };
 
-    if (m_isProcessSwappingOnNavigationResponse) {
-        // If the provisional load fails and we were process-swapping on navigation response, then we simply destroy ourselves.
-        // In this case, the provisional load is still ongoing in the committed process and the ProvisionalPageProxy destructor
-        // will stop it and cause the committed process to send its own DidFailProvisionalLoadForFrame IPC.
-        ASSERT(m_page.provisionalPageProxy() == this);
-        m_page.destroyProvisionalPage();
-        return;
-    }
-
     // Make sure the Page's main frame's expectedURL gets cleared since we updated it in didStartProvisionalLoad.
     if (auto* pageMainFrame = m_page.mainFrame())
         pageMainFrame->didFailProvisionalLoad();

Modified: branches/safari-613-branch/Tools/ChangeLog (292128 => 292129)


--- branches/safari-613-branch/Tools/ChangeLog	2022-03-30 23:33:13 UTC (rev 292128)
+++ branches/safari-613-branch/Tools/ChangeLog	2022-03-30 23:44:00 UTC (rev 292129)
@@ -1,5 +1,42 @@
 2022-03-29  Alan Coon  <[email protected]>
 
+        Cherry-pick r290371. rdar://problem/88652375
+
+    Call WKNavigationDelegate.didFailProvisionalNavigation even after a cross-origin navigation with COOP
+    https://bugs.webkit.org/show_bug.cgi?id=237071
+    <rdar://88652375>
+    
+    Patch by Alex Christensen <[email protected]> on 2022-02-23
+    Reviewed by Chris Dumez.
+    
+    Source/WebKit:
+    
+    There was an assumption that this callback wasn't needed in this case, but it is.
+    Covered by an API test that verifies the callback is received.
+    
+    * UIProcess/ProvisionalPageProxy.cpp:
+    (WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame):
+    
+    Tools:
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
+    (TEST):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-23  Alex Christensen  <[email protected]>
+
+            Call WKNavigationDelegate.didFailProvisionalNavigation even after a cross-origin navigation with COOP
+            https://bugs.webkit.org/show_bug.cgi?id=237071
+            <rdar://88652375>
+
+            Reviewed by Chris Dumez.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
+            (TEST):
+
+2022-03-29  Alan Coon  <[email protected]>
+
         Apply patch. rdar://problem/89997669
 
     2022-02-14  Kimmo Kinnunen  <[email protected]>

Modified: branches/safari-613-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm (292128 => 292129)


--- branches/safari-613-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm	2022-03-30 23:33:13 UTC (rev 292128)
+++ branches/safari-613-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm	2022-03-30 23:44:00 UTC (rev 292129)
@@ -38,6 +38,8 @@
 #import <WebKit/WKNavigationPrivate.h>
 #import <WebKit/WKWebView.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
 
@@ -1010,3 +1012,54 @@
 
     EXPECT_FALSE(didTryToLoadRadarURL);
 }
+
+TEST(WKNavigation, CrossOriginCOOPCancelResponseFailProvisionalNavigationCallback)
+{
+    using namespace TestWebKitAPI;
+    HTTPServer server({
+        { "/path1", { "hi" } },
+        { "/path2", { "hi" } },
+        { "/path3", { { { "Cross-Origin-Opener-Policy", "same-origin" } }, "hi" } }
+    }, HTTPServer::Protocol::HttpsProxy);
+
+    auto storeConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration]);
+    [storeConfiguration setProxyConfiguration:@{
+        (NSString *)kCFStreamPropertyHTTPSProxyHost: @"127.0.0.1",
+        (NSString *)kCFStreamPropertyHTTPSProxyPort: @(server.port())
+    }];
+    auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:storeConfiguration.get()]);
+    auto configuration = adoptNS([WKWebViewConfiguration new]);
+    [configuration setWebsiteDataStore:dataStore.get()];
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
+
+    __block Vector<bool> finishedSuccessfullyCallbacks;
+    auto loadWithResponsePolicy = ^(WKWebView *webView, NSString *url, WKNavigationResponsePolicy responsePolicy) {
+        auto callbacksSizeBefore = finishedSuccessfullyCallbacks.size();
+
+        auto delegate = adoptNS([TestNavigationDelegate new]);
+        delegate.get().decidePolicyForNavigationResponse = ^(WKNavigationResponse *response, void (^decisionHandler)(WKNavigationResponsePolicy)) {
+            decisionHandler(responsePolicy);
+        };
+
+        delegate.get().didReceiveAuthenticationChallenge = ^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
+            completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+        };
+        delegate.get().didFailProvisionalNavigation = ^(WKWebView *, WKNavigation *, NSError *) {
+            finishedSuccessfullyCallbacks.append(false);
+        };
+        delegate.get().didFinishNavigation = ^(WKWebView *, WKNavigation *) {
+            finishedSuccessfullyCallbacks.append(true);
+        };
+        [webView setNavigationDelegate:delegate.get()];
+        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
+        while (finishedSuccessfullyCallbacks.size() == callbacksSizeBefore)
+            TestWebKitAPI::Util::spinRunLoop(10);
+    };
+
+    loadWithResponsePolicy(webView.get(), @"https://webkit.org/path1", WKNavigationResponsePolicyAllow);
+    loadWithResponsePolicy(webView.get(), @"https://webkit.org/path2", WKNavigationResponsePolicyCancel);
+    loadWithResponsePolicy(webView.get(), @"https://example.com/path3", WKNavigationResponsePolicyCancel);
+
+    Vector<bool> expectedCallbacks { true, false, false };
+    EXPECT_EQ(finishedSuccessfullyCallbacks, expectedCallbacks);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to