Title: [241909] branches/safari-607-branch

Diff

Modified: branches/safari-607-branch/LayoutTests/ChangeLog (241908 => 241909)


--- branches/safari-607-branch/LayoutTests/ChangeLog	2019-02-21 22:55:05 UTC (rev 241908)
+++ branches/safari-607-branch/LayoutTests/ChangeLog	2019-02-21 22:55:12 UTC (rev 241909)
@@ -1,3 +1,19 @@
+2019-02-21  Alan Coon  <[email protected]>
+
+        Apply patch. rdar://problem/48229545
+
+    2019-02-21  Ryosuke Niwa  <[email protected]>
+
+            REGRESSION(r240909): Release assertion in FrameLoader::loadPostRequest when opening new window
+            https://bugs.webkit.org/show_bug.cgi?id=194820
+
+            Reviewed by Geoffrey Garen and Brady Eidson.
+
+            Added a regression test.
+
+            * fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation-expected.txt: Added.
+            * fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation.html: Added.
+
 2019-02-20  Alan Coon  <[email protected]>
 
         Cherry-pick r241788. rdar://problem/48248202

Added: branches/safari-607-branch/LayoutTests/fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation-expected.txt (0 => 241909)


--- branches/safari-607-branch/LayoutTests/fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation-expected.txt	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation-expected.txt	2019-02-21 22:55:12 UTC (rev 241909)
@@ -0,0 +1,5 @@
+ALERT: PASS
+This tests navigating via an anchor element with a non-existent target name, which should create a new window.
+WebKit should not hit any assertions and alert "PASS".
+
+

Added: branches/safari-607-branch/LayoutTests/fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation.html (0 => 241909)


--- branches/safari-607-branch/LayoutTests/fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation.html	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation.html	2019-02-21 22:55:12 UTC (rev 241909)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+    testRunner.setCanOpenWindows();
+    testRunner.setCloseRemainingWindowsWhenComplete();
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+}
+
+if (location.search == '?third') {
+    alert('PASS');
+    if (window.testRunner)
+        testRunner.notifyDone();
+} else if (self == top) {
+    document.write(`<p>This tests navigating via an anchor element with a non-existent target name, which should create a new window.<br>
+WebKit should not hit any assertions and alert "PASS".</p>`);
+    const frame = document.createElement('iframe');
+    frame.src = '';
+    let step = 0;
+    frame._onload_ = () => {
+        switch (step++) {
+        case 0:
+            setTimeout(() => frame.src = '', 0);
+            break;
+        case 1:
+            setTimeout(() => history.back(), 0);
+            break;
+        }
+    }
+    document.body.appendChild(frame);
+} else {
+    if (location.search == '?first') {
+        if (localStorage.getItem('loaded')) {
+            localStorage.removeItem('loaded');
+            window._onload_ = () => {
+                setTimeout(() => document.querySelector('form').submit(), 0);
+            }
+        } else
+            localStorage.setItem('loaded', 'true');
+    }
+    document.write(location.search);
+    document.write(` <form action="" method="post" target="unknownTarget"><input type="text" name="query"><input type="submit"></a>`);
+}
+
+</script>
+</body>
+</html>

Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (241908 => 241909)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-21 22:55:05 UTC (rev 241908)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-21 22:55:12 UTC (rev 241909)
@@ -1,3 +1,31 @@
+2019-02-21  Alan Coon  <[email protected]>
+
+        Apply patch. rdar://problem/48229545
+
+    2019-02-21  Ryosuke Niwa  <[email protected]>
+
+            REGRESSION(r240909): Release assertion in FrameLoader::loadPostRequest when opening new window
+            https://bugs.webkit.org/show_bug.cgi?id=194820
+
+            Reviewed by Geoffrey Garen and Brady Eidson.
+
+            This release assertion was wrong. The invocation of PolicyChecker::checkNewWindowPolicy in FrameLoader
+            doesn’t require PolicyChecker's load type to be set in PolicyChecker because FrameLoader's
+            continueLoadAfterNewWindowPolicy invokes loadWithNavigationAction which sets the load type later,
+            and we don't rely on PolicyChecker's load type until then.
+
+            Fixed the crash by removing relese asserts before invoking checkNewWindowPolicy accordingly.
+
+            This patch reverts r241015 since it too was asserting that PolicyChecker's load type is set before
+            invoking checkNewWindowPolicy which is not the right assumption.
+
+            Test: fast/loader/navigate-with-post-to-new-target-after-back-forward-navigation.html
+
+            * loader/FrameLoader.cpp:
+            (WebCore::FrameLoader::loadURL):
+            (WebCore::FrameLoader::load):
+            (WebCore::FrameLoader::loadPostRequest):
+
 2019-02-20  Alan Coon  <[email protected]>
 
         Cherry-pick r241848. rdar://problem/48257838

Modified: branches/safari-607-branch/Source/WebCore/loader/DocumentLoader.cpp (241908 => 241909)


--- branches/safari-607-branch/Source/WebCore/loader/DocumentLoader.cpp	2019-02-21 22:55:05 UTC (rev 241908)
+++ branches/safari-607-branch/Source/WebCore/loader/DocumentLoader.cpp	2019-02-21 22:55:12 UTC (rev 241909)
@@ -664,7 +664,7 @@
 
     // FIXME: Add a load type check.
     auto& policyChecker = frameLoader()->policyChecker();
-    RELEASE_ASSERT(!isBackForwardLoadType(policyChecker.loadType()) || frameLoader()->history().provisionalItem());
+    ASSERT(!isBackForwardLoadType(policyChecker.loadType()) || frameLoader()->history().provisionalItem());
     policyChecker.checkNavigationPolicy(WTFMove(newRequest), redirectResponse, WTFMove(navigationPolicyCompletionHandler));
 }
 
@@ -845,7 +845,11 @@
     auto requestIdentifier = PolicyCheckIdentifier::create();
     frameLoader()->checkContentPolicy(m_response, requestIdentifier, [this, protectedThis = makeRef(*this), mainResourceLoader = WTFMove(mainResourceLoader),
         completionHandler = completionHandlerCaller.release(), requestIdentifier] (PolicyAction policy, PolicyCheckIdentifier responseIdentifeir) mutable {
-        RELEASE_ASSERT(responseIdentifeir.isValidFor(requestIdentifier));
+#if ASSERT_DISABLED
+        UNUSED_PARAM(requestIdentifier);
+        UNUSED_PARAM(responseIdentifeir);
+#endif
+        ASSERT(responseIdentifeir.isValidFor(requestIdentifier));
         continueAfterContentPolicy(policy);
         if (mainResourceLoader)
             mainResourceLoader->didReceiveResponsePolicy();

Modified: branches/safari-607-branch/Source/WebCore/loader/FrameLoader.cpp (241908 => 241909)


--- branches/safari-607-branch/Source/WebCore/loader/FrameLoader.cpp	2019-02-21 22:55:05 UTC (rev 241908)
+++ branches/safari-607-branch/Source/WebCore/loader/FrameLoader.cpp	2019-02-21 22:55:12 UTC (rev 241909)
@@ -1379,8 +1379,6 @@
 
     if (!targetFrame && !effectiveFrameName.isEmpty()) {
         action = "" frameLoadRequest));
-        policyChecker().setLoadType(newLoadType);
-        RELEASE_ASSERT(!isBackForwardLoadType(policyChecker().loadType()));
         policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), effectiveFrameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
             completionHandler();
@@ -1401,7 +1399,7 @@
         oldDocumentLoader->setLastCheckedRequest(ResourceRequest());
         policyChecker().stopCheck();
         policyChecker().setLoadType(newLoadType);
-        RELEASE_ASSERT(!isBackForwardLoadType(newLoadType) || history().provisionalItem());
+        ASSERT(!isBackForwardLoadType(newLoadType) || history().provisionalItem());
         policyChecker().checkNavigationPolicy(WTFMove(request), ResourceResponse { } /* redirectResponse */, oldDocumentLoader.get(), WTFMove(formState), [this, protectedFrame = makeRef(m_frame)] (const ResourceRequest& request, WeakPtr<FormState>&&, NavigationPolicyDecision navigationPolicyDecision) {
             continueFragmentScrollAfterNavigationPolicy(request, navigationPolicyDecision == NavigationPolicyDecision::ContinueLoad);
         }, PolicyDecisionMode::Synchronous);
@@ -1465,7 +1463,6 @@
 
     if (request.shouldCheckNewWindowPolicy()) {
         NavigationAction action { request.requester(), request.resourceRequest(), InitiatedByMainFrame::Unknown, NavigationType::Other, request.shouldOpenExternalURLsPolicy() };
-        RELEASE_ASSERT(!isBackForwardLoadType(policyChecker().loadType()));
         policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request.resourceRequest()), { }, request.frameName(), [this] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress);
         });
@@ -1590,7 +1587,7 @@
     }
 
     policyChecker().setLoadType(type);
-    RELEASE_ASSERT(!isBackForwardLoadType(type) || history().provisionalItem());
+    ASSERT(!isBackForwardLoadType(type) || history().provisionalItem());
     bool isFormSubmission = formState;
 
     const String& httpMethod = loader->request().httpMethod();
@@ -1602,7 +1599,7 @@
         oldDocumentLoader->setTriggeringAction(WTFMove(action));
         oldDocumentLoader->setLastCheckedRequest(ResourceRequest());
         policyChecker().stopCheck();
-        RELEASE_ASSERT(!isBackForwardLoadType(policyChecker().loadType()) || history().provisionalItem());
+        ASSERT(!isBackForwardLoadType(policyChecker().loadType()) || history().provisionalItem());
         policyChecker().checkNavigationPolicy(ResourceRequest(loader->request()), ResourceResponse { }  /* redirectResponse */, oldDocumentLoader.get(), WTFMove(formState), [this, protectedFrame = makeRef(m_frame)] (const ResourceRequest& request, WeakPtr<FormState>&&, NavigationPolicyDecision navigationPolicyDecision) {
             continueFragmentScrollAfterNavigationPolicy(request, navigationPolicyDecision == NavigationPolicyDecision::ContinueLoad);
         }, PolicyDecisionMode::Synchronous);
@@ -1637,7 +1634,7 @@
         return;
     }
 
-    RELEASE_ASSERT(!isBackForwardLoadType(policyChecker().loadType()) || history().provisionalItem());
+    ASSERT(!isBackForwardLoadType(policyChecker().loadType()) || history().provisionalItem());
     policyChecker().checkNavigationPolicy(ResourceRequest(loader->request()), ResourceResponse { } /* redirectResponse */, loader, WTFMove(formState), [this, protectedFrame = makeRef(m_frame), allowNavigationToInvalidURL, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, NavigationPolicyDecision navigationPolicyDecision) mutable {
         continueLoadAfterNavigationPolicy(request, formState.get(), navigationPolicyDecision, allowNavigationToInvalidURL);
         completionHandler();
@@ -2997,7 +2994,6 @@
             return;
         }
 
-        RELEASE_ASSERT(!isBackForwardLoadType(policyChecker().loadType()));
         policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(workingResourceRequest), WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = WTFMove(completionHandler)] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
             continueLoadAfterNewWindowPolicy(request, formState.get(), frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
             completionHandler();

Modified: branches/safari-607-branch/Source/WebCore/loader/PolicyChecker.cpp (241908 => 241909)


--- branches/safari-607-branch/Source/WebCore/loader/PolicyChecker.cpp	2019-02-21 22:55:05 UTC (rev 241908)
+++ branches/safari-607-branch/Source/WebCore/loader/PolicyChecker.cpp	2019-02-21 22:55:12 UTC (rev 241909)
@@ -80,9 +80,9 @@
 
 bool PolicyCheckIdentifier::isValidFor(PolicyCheckIdentifier expectedIdentifier)
 {
-    RELEASE_ASSERT_WITH_MESSAGE(m_policyCheck, "Received 0 as the policy check identifier");
-    RELEASE_ASSERT_WITH_MESSAGE(m_process == expectedIdentifier.m_process, "Received a policy check response for a wrong process");
-    RELEASE_ASSERT_WITH_MESSAGE(m_policyCheck <= expectedIdentifier.m_policyCheck, "Received a policy check response from the future");
+    ASSERT_WITH_MESSAGE(m_policyCheck, "Received 0 as the policy check identifier");
+    ASSERT_WITH_MESSAGE(m_process == expectedIdentifier.m_process, "Received a policy check response for a wrong process");
+    ASSERT_WITH_MESSAGE(m_policyCheck <= expectedIdentifier.m_policyCheck, "Received a policy check response from the future");
     return m_policyCheck == expectedIdentifier.m_policyCheck;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to