Title: [229341] trunk
Revision
229341
Author
cdu...@apple.com
Date
2018-03-06 14:01:27 -0800 (Tue, 06 Mar 2018)

Log Message

fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates
https://bugs.webkit.org/show_bug.cgi?id=183345

Reviewed by Alex Christensen.

Source/WebCore:

FrameLoader::loadURL() was calling loadWithNavigationAction() and then resetting the
m_quickRedirectComing flag right after. This works if the navigation policy decision
triggered by loadWithNavigationAction() is made synchronously. However, when it is
made asynchronously, the flag gets reset too early, before the policy decision
handler has been called. This is an issue because the policy decision handler
relies on the m_quickRedirectComing flag.

Similarly, FrameLoader::loadFrameRequest() was calling loadPostRequest() / loadURL()
and then focusing a frame right after. This does not work as intended when the navigation
policy decision is made asynchronously.

To address the issue, we now pass a completion handler that gets called when the operation
has actually completion, after the policy decision has been made. This maintains the
behavior in place with synchronous policy delegates.

Test: fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURLIntoChildFrame):
(WebCore::FrameLoader::loadFrameRequest):
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithNavigationAction):
(WebCore::FrameLoader::load):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::reloadWithOverrideEncoding):
(WebCore::FrameLoader::reload):
(WebCore::FrameLoader::loadPostRequest):
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
(WebCore::FrameLoader::loadDifferentDocumentItem):
* loader/FrameLoader.h:

Tools:

Add layout test infrastructure so a test can know when didCancelClientRedirectForFrame has
been called. The tests used to rely on a 0-timer but this does not work when the client
responds to the navigation policy asynchronously.

* DumpRenderTree/TestRunner.cpp:
(getDidCancelClientRedirect):
(TestRunner::staticValues):
* DumpRenderTree/TestRunner.h:
(TestRunner::didCancelClientRedirect const):
(TestRunner::setDidCancelClientRedirect):
* DumpRenderTree/mac/FrameLoadDelegate.mm:
(-[FrameLoadDelegate webView:didCancelClientRedirectForFrame:]):
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::didCancelClientRedirectForFrame):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::didCancelClientRedirect const):
(WTR::TestRunner::setDidCancelClientRedirect):

LayoutTests:

* fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt: Added.
* fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html: Added.
Add layout test coverage.

* fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt:
* fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed.html:
* fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt:
* fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html:
* fast/loader/window-open-to-invalid-url-disallowed-expected.txt:
* fast/loader/window-open-to-invalid-url-disallowed.html:
* platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt:
* platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt: Added.
* platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt:
* platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt:
Update tests that were relying on a 0-timer to make sure that didCancelClientRedirectForFrame was
called to rely on our new test infrastructure instead. This is needed so that these tests keep passing
once we make policy delegates asynchronous by default. Without this, the didCancelClientRedirectForFrame lines
would be missing in the tests' output.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (229340 => 229341)


--- trunk/LayoutTests/ChangeLog	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/ChangeLog	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,3 +1,29 @@
+2018-03-06  Chris Dumez  <cdu...@apple.com>
+
+        fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates
+        https://bugs.webkit.org/show_bug.cgi?id=183345
+
+        Reviewed by Alex Christensen.
+
+        * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt: Added.
+        * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html: Added.
+        Add layout test coverage.
+
+        * fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt:
+        * fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed.html:
+        * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt:
+        * fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html:
+        * fast/loader/window-open-to-invalid-url-disallowed-expected.txt:
+        * fast/loader/window-open-to-invalid-url-disallowed.html:
+        * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt:
+        * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt: Added.
+        * platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt:
+        * platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt:
+        Update tests that were relying on a 0-timer to make sure that didCancelClientRedirectForFrame was
+        called to rely on our new test infrastructure instead. This is needed so that these tests keep passing
+        once we make policy delegates asynchronous by default. Without this, the didCancelClientRedirectForFrame lines
+        would be missing in the tests' output.
+
 2018-03-06  Youenn Fablet  <you...@apple.com>
 
         Service worker test gardening

Modified: trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt (229340 => 229341)


--- trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,7 +1,15 @@
+main frame - didFinishDocumentLoadForFrame
 main frame - willPerformClientRedirectToURL: http://A=a%B=b 
-main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
 main frame - didFinishLoadForFrame
 main frame - didCancelClientRedirectForFrame
 Tests that we do not redirect to an invalid URL initiated by _javascript_. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
 
-Note, this test must be run in DumpRenderTree.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed.html (229340 => 229341)


--- trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed.html	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed.html	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,23 +1,20 @@
 <!DOCTYPE html>
 <html>
 <head>
+<script src=""
 <script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
+if (window.testRunner)
     testRunner.dumpFrameLoadCallbacks();
-    testRunner.waitUntilDone();
-}
+jsTestIsAsync = true;
 </script>
 </head>
 <body>
-<p>Tests that we do not redirect to an invalid URL initiated by _javascript_. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.</p>
-<p>Note, this test must be run in DumpRenderTree.</p>
 <script>
-window.location.href = ""
-window.setTimeout(function() {
-    if (window.testRunner)
-        testRunner.notifyDone();
-}, 0);
+description("Tests that we do not redirect to an invalid URL initiated by _javascript_. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.");
+_onload_ = function() {
+    window.location.href = ""
+    shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest);
+}
 </script>
 </body>
 </html>

Copied: trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt (from rev 229340, trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt) (0 => 229341)


--- trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -0,0 +1,15 @@
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - willPerformClientRedirectToURL: http://A=a%B=b 
+main frame - didFinishLoadForFrame
+main frame - didCancelClientRedirectForFrame
+Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html (0 => 229341)


--- trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html	                        (rev 0)
+++ trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html	2018-03-06 22:01:27 UTC (rev 229341)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="refresh" content="0; url=""
+<script src=""
+<script>
+if (window.testRunner) {
+    testRunner.dumpFrameLoadCallbacks();
+    if (testRunner.setShouldDecideNavigationPolicyAfterDelay)
+        testRunner.setShouldDecideNavigationPolicyAfterDelay(true);
+}
+jsTestIsAsync = true;
+</script>
+</head>
+<body>
+<script>
+description("Tests that we do not redirect to an invalid URL initiated by &lt;meta http-equiv=&quot;refresh&quot;&gt;. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.");
+
+shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest);
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt (229340 => 229341)


--- trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -5,4 +5,11 @@
 main frame - didCancelClientRedirectForFrame
 Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
 
-Note, this test must be run in DumpRenderTree.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html (229340 => 229341)


--- trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html	2018-03-06 22:01:27 UTC (rev 229341)
@@ -2,26 +2,18 @@
 <html>
 <head>
 <meta http-equiv="refresh" content="0; url=""
+<script src=""
 <script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
+if (window.testRunner)
     testRunner.dumpFrameLoadCallbacks();
-    testRunner.waitUntilDone();
-}
+jsTestIsAsync = true;
 </script>
 </head>
 <body>
-<p>Tests that we do not redirect to an invalid URL initiated by &lt;meta http-equiv=&quot;refresh&quot;&gt;. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.</p>
-<p>Note, this test must be run in DumpRenderTree.</p>
 <script>
-// This ugly double-timeout ensures that the scheduled meta-refresh, whose timer isn't even started until the frame finishes loading,
-// fires before notifyDone() is called, ensuring that didCancelClientRedirectForFrame is logged by DumpRenderTree.
-window.setTimeout(function() {
-    window.setTimeout(function() {
-        if (window.testRunner)
-            testRunner.notifyDone();
-    }, 0);
-}, 0);
+description("Tests that we do not redirect to an invalid URL initiated by &lt;meta http-equiv=&quot;refresh&quot;&gt;. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.");
+
+shouldBecomeEqual("testRunner.didCancelClientRedirect", "true", finishJSTest);
 </script>
 </body>
 </html>

Modified: trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed-expected.txt (229340 => 229341)


--- trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed-expected.txt	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,7 +1,15 @@
+main frame - didFinishDocumentLoadForFrame
 main frame - willPerformClientRedirectToURL: http://A=a%B=b 
-main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
 main frame - didFinishLoadForFrame
 main frame - didCancelClientRedirectForFrame
 Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
 
-Note, this test must be run in DumpRenderTree.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS win.testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed.html (229340 => 229341)


--- trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed.html	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/fast/loader/window-open-to-invalid-url-disallowed.html	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,24 +1,22 @@
 <!DOCTYPE html>
 <html>
 <head>
+<script src=""
 <script>
 if (window.testRunner) {
-    testRunner.dumpAsText();
     testRunner.dumpFrameLoadCallbacks();
-    testRunner.waitUntilDone();
     testRunner.setCanOpenWindows();
 }
+jsTestIsAsync = true;
 </script>
 </head>
 <body>
-<p>Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.</p>
-<p>Note, this test must be run in DumpRenderTree.</p>
 <script>
-window.open("http://A=a%B=b", "_top");
-window.setTimeout(function() {
-    if (window.testRunner)
-        testRunner.notifyDone();
-}, 0);
+description("Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: &quot;willPerformClientRedirectToURL: http://A=a%B=b&quot; followed by &quot;didCancelClientRedirectForFrame&quot;.");
+_onload_ = function() {
+    win = window.open("http://A=a%B=b", "_top");
+    shouldBecomeEqual("win.testRunner.didCancelClientRedirect", "true", finishJSTest);
+};
 </script>
 </body>
 </html>

Modified: trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt (229340 => 229341)


--- trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-_javascript_-disallowed-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,7 +1,15 @@
+main frame - didFinishDocumentLoadForFrame
 main frame - willPerformClientRedirectToURL: http://A=a%25B=b 
-main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
 main frame - didFinishLoadForFrame
 main frame - didCancelClientRedirectForFrame
 Tests that we do not redirect to an invalid URL initiated by _javascript_. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
 
-Note, this test must be run in DumpRenderTree.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt (from rev 229340, trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt) (0 => 229341)


--- trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -0,0 +1,15 @@
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - willPerformClientRedirectToURL: http://A=a%25B=b 
+main frame - didFinishLoadForFrame
+main frame - didCancelClientRedirectForFrame
+Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt (229340 => 229341)


--- trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/platform/mac-wk1/fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -5,4 +5,11 @@
 main frame - didCancelClientRedirectForFrame
 Tests that we do not redirect to an invalid URL initiated by <meta http-equiv="refresh">. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
 
-Note, this test must be run in DumpRenderTree.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt (229340 => 229341)


--- trunk/LayoutTests/platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/LayoutTests/platform/mac-wk1/fast/loader/window-open-to-invalid-url-disallowed-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,7 +1,15 @@
+main frame - didFinishDocumentLoadForFrame
 main frame - willPerformClientRedirectToURL: http://A=a%25B=b 
-main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
 main frame - didFinishLoadForFrame
 main frame - didCancelClientRedirectForFrame
 Tests that we do not open a new window to an invalid URL. This test PASSED if you see an entry in the dumped frame load callbacks of the form: "willPerformClientRedirectToURL: http://A=a%B=b" followed by "didCancelClientRedirectForFrame".
 
-Note, this test must be run in DumpRenderTree.
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS win.testRunner.didCancelClientRedirect became true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/wk2/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt (0 => 229341)


--- trunk/LayoutTests/platform/wk2/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/wk2/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt	2018-03-06 22:01:27 UTC (rev 229341)
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: Unsafe _javascript_ attempt to initiate navigation for frame with URL '' from frame with URL 'http://localhost:8800/html/browsers/windows/noreferrer-window-name.html'. The frame attempting navigation is neither same-origin with the target, nor is it the target's parent or opener.
+
+
+Harness Error (TIMEOUT), message = null
+
+TIMEOUT Following a noreferrer link with a named target should not cause creation of a window that can be targeted by another noreferrer link with the same named target Test timed out
+PASS Targeting a rel=noreferrer link at an existing named subframe should work 
+TIMEOUT Targeting a rel=noreferrer link at an existing named window should work Test timed out
+

Modified: trunk/Source/WebCore/ChangeLog (229340 => 229341)


--- trunk/Source/WebCore/ChangeLog	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Source/WebCore/ChangeLog	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,3 +1,41 @@
+2018-03-06  Chris Dumez  <cdu...@apple.com>
+
+        fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates
+        https://bugs.webkit.org/show_bug.cgi?id=183345
+
+        Reviewed by Alex Christensen.
+
+        FrameLoader::loadURL() was calling loadWithNavigationAction() and then resetting the
+        m_quickRedirectComing flag right after. This works if the navigation policy decision
+        triggered by loadWithNavigationAction() is made synchronously. However, when it is
+        made asynchronously, the flag gets reset too early, before the policy decision
+        handler has been called. This is an issue because the policy decision handler
+        relies on the m_quickRedirectComing flag.
+
+        Similarly, FrameLoader::loadFrameRequest() was calling loadPostRequest() / loadURL()
+        and then focusing a frame right after. This does not work as intended when the navigation
+        policy decision is made asynchronously.
+
+        To address the issue, we now pass a completion handler that gets called when the operation
+        has actually completion, after the policy decision has been made. This maintains the
+        behavior in place with synchronous policy delegates.
+
+        Test: fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed-async-delegates.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURLIntoChildFrame):
+        (WebCore::FrameLoader::loadFrameRequest):
+        (WebCore::FrameLoader::loadURL):
+        (WebCore::FrameLoader::loadWithNavigationAction):
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::loadWithDocumentLoader):
+        (WebCore::FrameLoader::reloadWithOverrideEncoding):
+        (WebCore::FrameLoader::reload):
+        (WebCore::FrameLoader::loadPostRequest):
+        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
+        (WebCore::FrameLoader::loadDifferentDocumentItem):
+        * loader/FrameLoader.h:
+
 2018-03-06  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] Add a new CSSTransition subclass of WebAnimation

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (229340 => 229341)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2018-03-06 22:01:27 UTC (rev 229341)
@@ -935,7 +935,7 @@
     auto initiatedByMainFrame = lexicalFrame && lexicalFrame->isMainFrame() ? InitiatedByMainFrame::Yes : InitiatedByMainFrame::Unknown;
 
     FrameLoadRequest frameLoadRequest { *m_frame.document(), m_frame.document()->securityOrigin(), { url }, ASCIILiteral("_self"), LockHistory::No, LockBackForwardList::Yes, ShouldSendReferrer::MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress, ShouldOpenExternalURLsPolicy::ShouldNotAllow, initiatedByMainFrame };
-    childFrame->loader().loadURL(WTFMove(frameLoadRequest), referer, FrameLoadType::RedirectWithLockedBackForwardList, nullptr, nullptr);
+    childFrame->loader().loadURL(WTFMove(frameLoadRequest), referer, FrameLoadType::RedirectWithLockedBackForwardList, nullptr, nullptr, [] { });
 }
 
 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
@@ -1200,22 +1200,23 @@
     else
         loadType = FrameLoadType::Standard;
 
-    String frameName = request.frameName();
+    auto completionHandler = [this, protectedFrame = makeRef(m_frame), formState = makeRefPtr(formState), frameName = request.frameName()] {
+        // FIXME: It's possible this targetFrame will not be the same frame that was targeted by the actual
+        // load if frame names have changed.
+        Frame* sourceFrame = formState ? formState->sourceDocument().frame() : &m_frame;
+        if (!sourceFrame)
+            sourceFrame = &m_frame;
+        Frame* targetFrame = sourceFrame->loader().findFrameForNavigation(frameName);
+        if (targetFrame && targetFrame != sourceFrame) {
+            if (Page* page = targetFrame->page())
+                page->chrome().focus();
+        }
+    };
+
     if (request.resourceRequest().httpMethod() == "POST")
-        loadPostRequest(WTFMove(request), referrer, loadType, event, formState);
+        loadPostRequest(WTFMove(request), referrer, loadType, event, formState, WTFMove(completionHandler));
     else
-        loadURL(WTFMove(request), referrer, loadType, event, formState);
-
-    // FIXME: It's possible this targetFrame will not be the same frame that was targeted by the actual
-    // load if frame names have changed.
-    Frame* sourceFrame = formState ? formState->sourceDocument().frame() : &m_frame;
-    if (!sourceFrame)
-        sourceFrame = &m_frame;
-    Frame* targetFrame = sourceFrame->loader().findFrameForNavigation(frameName);
-    if (targetFrame && targetFrame != sourceFrame) {
-        if (Page* page = targetFrame->page())
-            page->chrome().focus();
-    }
+        loadURL(WTFMove(request), referrer, loadType, event, formState, WTFMove(completionHandler));
 }
 
 static ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicyToApply(Frame& currentFrame, InitiatedByMainFrame initiatedByMainFrame, ShouldOpenExternalURLsPolicy propagatedPolicy)
@@ -1261,8 +1262,9 @@
     bool value { false };
 };
 
-void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& referrer, FrameLoadType newLoadType, Event* event, FormState* formState)
+void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& referrer, FrameLoadType newLoadType, Event* event, FormState* formState, CompletionHandler<void()>&& completionHandler)
 {
+    CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler));
     if (m_inStopAllLoaders)
         return;
 
@@ -1294,7 +1296,7 @@
     Frame* targetFrame = isFormSubmission ? nullptr : findFrameForNavigation(frameName);
     if (targetFrame && targetFrame != &m_frame) {
         frameLoadRequest.setFrameName("_self");
-        targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, formState);
+        targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, formState, completionHandlerCaller.release());
         return;
     }
 
@@ -1305,8 +1307,9 @@
 
     if (!targetFrame && !frameName.isEmpty()) {
         action = "" frameLoadRequest));
-        policyChecker().checkNewWindowPolicy(WTFMove(action), request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(WTFMove(action), request, formState, frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
+            completionHandler();
         });
         return;
     }
@@ -1340,19 +1343,21 @@
 
     // must grab this now, since this load may stop the previous load and clear this flag
     bool isRedirect = m_quickRedirectComing;
-    loadWithNavigationAction(request, action, lockHistory, newLoadType, formState, allowNavigationToInvalidURL);
-    if (isRedirect) {
-        m_quickRedirectComing = false;
-        if (m_provisionalDocumentLoader)
-            m_provisionalDocumentLoader->setIsClientRedirect(true);
-        else if (m_policyDocumentLoader)
-            m_policyDocumentLoader->setIsClientRedirect(true);
-    } else if (sameURL && !isReload(newLoadType)) {
-        // Example of this case are sites that reload the same URL with a different cookie
-        // driving the generated content, or a master frame with links that drive a target
-        // frame, where the user has clicked on the same link repeatedly.
-        m_loadType = FrameLoadType::Same;
-    }
+    loadWithNavigationAction(request, action, lockHistory, newLoadType, formState, allowNavigationToInvalidURL, [this, isRedirect, sameURL, newLoadType, protectedFrame = makeRef(m_frame), completionHandler = completionHandlerCaller.release()] {
+        if (isRedirect) {
+            m_quickRedirectComing = false;
+            if (m_provisionalDocumentLoader)
+                m_provisionalDocumentLoader->setIsClientRedirect(true);
+            else if (m_policyDocumentLoader)
+                m_policyDocumentLoader->setIsClientRedirect(true);
+        } else if (sameURL && !isReload(newLoadType)) {
+            // Example of this case are sites that reload the same URL with a different cookie
+            // driving the generated content, or a master frame with links that drive a target
+            // frame, where the user has clicked on the same link repeatedly.
+            m_loadType = FrameLoadType::Same;
+        }
+        completionHandler();
+    });
 }
 
 SubstituteData FrameLoader::defaultSubstituteDataForURL(const URL& url)
@@ -1401,7 +1406,7 @@
     load(loader.ptr());
 }
 
-void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, LockHistory lockHistory, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL)
+void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, const NavigationAction& action, LockHistory lockHistory, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL, CompletionHandler<void()>&& completionHandler)
 {
     Ref<DocumentLoader> loader = m_client.createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, action.initiatedByMainFrame(), action.shouldOpenExternalURLsPolicy());
@@ -1413,7 +1418,7 @@
     if (m_documentLoader)
         loader->setOverrideEncoding(m_documentLoader->overrideEncoding());
 
-    loadWithDocumentLoader(loader.ptr(), type, formState, allowNavigationToInvalidURL);
+    loadWithDocumentLoader(loader.ptr(), type, formState, allowNavigationToInvalidURL, WTFMove(completionHandler));
 }
 
 void FrameLoader::load(DocumentLoader* newDocumentLoader)
@@ -1452,14 +1457,16 @@
         type = FrameLoadType::Reload;
     }
 
-    loadWithDocumentLoader(newDocumentLoader, type, 0, AllowNavigationToInvalidURL::Yes);
+    loadWithDocumentLoader(newDocumentLoader, type, 0, AllowNavigationToInvalidURL::Yes, [] { });
 }
 
-void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL)
+void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, FormState* formState, AllowNavigationToInvalidURL allowNavigationToInvalidURL, CompletionHandler<void()>&& completionHandler)
 {
     // Retain because dispatchBeforeLoadEvent may release the last reference to it.
     Ref<Frame> protect(m_frame);
 
+    CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler));
+
     ASSERT(m_client.hasWebView());
 
     // Unfortunately the view must be non-nil, this is ultimately due
@@ -1531,8 +1538,9 @@
 
     m_frame.navigationScheduler().cancel(true);
 
-    policyChecker().checkNavigationPolicy(ResourceRequest(loader->request()), false /* didReceiveRedirectResponse */, loader, formState, [this, protectedFrame = makeRef(m_frame), allowNavigationToInvalidURL] (const ResourceRequest& request, FormState* formState, bool shouldContinue) {
+    policyChecker().checkNavigationPolicy(ResourceRequest(loader->request()), false /* didReceiveRedirectResponse */, loader, formState, [this, protectedFrame = makeRef(m_frame), allowNavigationToInvalidURL, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, FormState* formState, bool shouldContinue) {
         continueLoadAfterNavigationPolicy(request, formState, shouldContinue, allowNavigationToInvalidURL);
+        completionHandler();
     });
 }
 
@@ -1630,7 +1638,7 @@
 
     loader->setOverrideEncoding(encoding);
 
-    loadWithDocumentLoader(loader.ptr(), FrameLoadType::Reload, 0, AllowNavigationToInvalidURL::Yes);
+    loadWithDocumentLoader(loader.ptr(), FrameLoadType::Reload, 0, AllowNavigationToInvalidURL::Yes, [] { });
 }
 
 void FrameLoader::reload(OptionSet<ReloadOption> options)
@@ -1675,7 +1683,7 @@
         return FrameLoadType::Reload;
     };
     
-    loadWithDocumentLoader(loader.ptr(), frameLoadTypeForReloadOptions(options), 0, AllowNavigationToInvalidURL::Yes);
+    loadWithDocumentLoader(loader.ptr(), frameLoadTypeForReloadOptions(options), 0, AllowNavigationToInvalidURL::Yes, [] { });
 }
 
 void FrameLoader::stopAllLoaders(ClearProvisionalItemPolicy clearProvisionalItemPolicy)
@@ -2747,7 +2755,7 @@
     request.setHTTPHeaderField(HTTPHeaderName::UpgradeInsecureRequests, ASCIILiteral("1"));
 }
 
-void FrameLoader::loadPostRequest(FrameLoadRequest&& request, const String& referrer, FrameLoadType loadType, Event* event, FormState* formState)
+void FrameLoader::loadPostRequest(FrameLoadRequest&& request, const String& referrer, FrameLoadType loadType, Event* event, FormState* formState, CompletionHandler<void()>&& completionHandler)
 {
     String frameName = request.frameName();
     LockHistory lockHistory = request.lockHistory();
@@ -2777,12 +2785,13 @@
     if (!frameName.isEmpty()) {
         // The search for a target frame is done earlier in the case of form submission.
         if (Frame* targetFrame = formState ? 0 : findFrameForNavigation(frameName)) {
-            targetFrame->loader().loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL);
+            targetFrame->loader().loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL, WTFMove(completionHandler));
             return;
         }
 
-        policyChecker().checkNewWindowPolicy(WTFMove(action), workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
+        policyChecker().checkNewWindowPolicy(WTFMove(action), workingResourceRequest, WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = WTFMove(completionHandler)] (const ResourceRequest& request, FormState* formState, const String& frameName, const NavigationAction& action, bool shouldContinue) {
             continueLoadAfterNewWindowPolicy(request, formState, frameName, action, shouldContinue, allowNavigationToInvalidURL, openerPolicy);
+            completionHandler();
         });
         return;
     }
@@ -2789,14 +2798,16 @@
 
     // must grab this now, since this load may stop the previous load and clear this flag
     bool isRedirect = m_quickRedirectComing;
-    loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL);
-    if (isRedirect) {
-        m_quickRedirectComing = false;
-        if (m_provisionalDocumentLoader)
-            m_provisionalDocumentLoader->setIsClientRedirect(true);
-        else if (m_policyDocumentLoader)
-            m_policyDocumentLoader->setIsClientRedirect(true);
-    }
+    loadWithNavigationAction(workingResourceRequest, action, lockHistory, loadType, WTFMove(formState), allowNavigationToInvalidURL, [this, isRedirect, protectedFrame = makeRef(m_frame), completionHandler = WTFMove(completionHandler)] {
+        if (isRedirect) {
+            m_quickRedirectComing = false;
+            if (m_provisionalDocumentLoader)
+                m_provisionalDocumentLoader->setIsClientRedirect(true);
+            else if (m_policyDocumentLoader)
+                m_policyDocumentLoader->setIsClientRedirect(true);
+        }
+        completionHandler();
+    });
 }
 
 unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& request, StoredCredentialsPolicy storedCredentialsPolicy, ClientCredentialPolicy clientCredentialPolicy, ResourceError& error, ResourceResponse& response, RefPtr<SharedBuffer>& data)
@@ -3258,7 +3269,7 @@
     }
 
     NavigationAction newAction { *frame->document(), request, InitiatedByMainFrame::Unknown, NavigationType::Other, action.shouldOpenExternalURLsPolicy() };
-    mainFrame->loader().loadWithNavigationAction(request, newAction, LockHistory::No, FrameLoadType::Standard, formState, allowNavigationToInvalidURL);
+    mainFrame->loader().loadWithNavigationAction(request, newAction, LockHistory::No, FrameLoadType::Standard, formState, allowNavigationToInvalidURL, [] { });
 }
 
 void FrameLoader::requestFromDelegate(ResourceRequest& request, unsigned long& identifier, ResourceError& error)
@@ -3448,7 +3459,7 @@
         m_client.updateCachedDocumentLoader(*documentLoader);
         documentLoader->setTriggeringAction({ *m_frame.document(), documentLoader->request(), initiatedByMainFrame, loadType, false });
         documentLoader->setLastCheckedRequest(ResourceRequest());
-        loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes);
+        loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes, [] { });
         return;
     }
 
@@ -3534,7 +3545,7 @@
         action = { *m_frame.document(), requestForOriginalURL, initiatedByMainFrame, loadType, isFormSubmission, event, shouldOpenExternalURLsPolicy };
     }
 
-    loadWithNavigationAction(request, action, LockHistory::No, loadType, 0, AllowNavigationToInvalidURL::Yes);
+    loadWithNavigationAction(request, action, LockHistory::No, loadType, 0, AllowNavigationToInvalidURL::Yes, [] { });
 }
 
 // Loads content into this frame, as specified by history item

Modified: trunk/Source/WebCore/loader/FrameLoader.h (229340 => 229341)


--- trunk/Source/WebCore/loader/FrameLoader.h	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2018-03-06 22:01:27 UTC (rev 229341)
@@ -359,13 +359,13 @@
 
     void urlSelected(FrameLoadRequest&&, Event*);
 
-    void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, FormState*, AllowNavigationToInvalidURL); // Calls continueLoadAfterNavigationPolicy
+    void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, FormState*, AllowNavigationToInvalidURL, CompletionHandler<void()>&&); // Calls continueLoadAfterNavigationPolicy
     void load(DocumentLoader*); // Calls loadWithDocumentLoader
 
-    void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, LockHistory, FrameLoadType, FormState*, AllowNavigationToInvalidURL); // Calls loadWithDocumentLoader
+    void loadWithNavigationAction(const ResourceRequest&, const NavigationAction&, LockHistory, FrameLoadType, FormState*, AllowNavigationToInvalidURL, CompletionHandler<void()>&&); // Calls loadWithDocumentLoader
 
-    void loadPostRequest(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState*);
-    void loadURL(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState*);
+    void loadPostRequest(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState*, CompletionHandler<void()>&&);
+    void loadURL(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, FormState*, CompletionHandler<void()>&&);
 
     bool shouldReload(const URL& currentURL, const URL& destinationURL);
 

Modified: trunk/Tools/ChangeLog (229340 => 229341)


--- trunk/Tools/ChangeLog	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/ChangeLog	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1,3 +1,29 @@
+2018-03-06  Chris Dumez  <cdu...@apple.com>
+
+        fast/loader/redirect-to-invalid-url-using-meta-refresh-disallowed.html fails with async policy delegates
+        https://bugs.webkit.org/show_bug.cgi?id=183345
+
+        Reviewed by Alex Christensen.
+
+        Add layout test infrastructure so a test can know when didCancelClientRedirectForFrame has
+        been called. The tests used to rely on a 0-timer but this does not work when the client
+        responds to the navigation policy asynchronously.
+
+        * DumpRenderTree/TestRunner.cpp:
+        (getDidCancelClientRedirect):
+        (TestRunner::staticValues):
+        * DumpRenderTree/TestRunner.h:
+        (TestRunner::didCancelClientRedirect const):
+        (TestRunner::setDidCancelClientRedirect):
+        * DumpRenderTree/mac/FrameLoadDelegate.mm:
+        (-[FrameLoadDelegate webView:didCancelClientRedirectForFrame:]):
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::didCancelClientRedirectForFrame):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::didCancelClientRedirect const):
+        (WTR::TestRunner::setDidCancelClientRedirect):
+
 2018-03-06  Zan Dobersek  <zdober...@igalia.com>
 
         REGRESSION(r229309): s_exceptionInstructions allocation change causing crashes in LLInt on WPE

Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (229340 => 229341)


--- trunk/Tools/DumpRenderTree/TestRunner.cpp	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1809,6 +1809,12 @@
     return JSValueMakeBoolean(context, controller->globalFlag());
 }
 
+static JSValueRef getDidCancelClientRedirect(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeBoolean(context, controller->didCancelClientRedirect());
+}
+
 static JSValueRef getDatabaseDefaultQuotaCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
     TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
@@ -2077,6 +2083,7 @@
 JSStaticValue* TestRunner::staticValues()
 {
     static JSStaticValue staticValues[] = {
+        { "didCancelClientRedirect", getDidCancelClientRedirect, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "timeout", getTimeoutCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "globalFlag", getGlobalFlagCallback, setGlobalFlagCallback, kJSPropertyAttributeNone },
         { "webHistoryItemCount", getWebHistoryItemCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },

Modified: trunk/Tools/DumpRenderTree/TestRunner.h (229340 => 229341)


--- trunk/Tools/DumpRenderTree/TestRunner.h	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/DumpRenderTree/TestRunner.h	2018-03-06 22:01:27 UTC (rev 229341)
@@ -380,6 +380,9 @@
     const std::vector<std::string>& openPanelFiles() const { return m_openPanelFiles; }
     void setOpenPanelFiles(JSContextRef, JSValueRef);
 
+    bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
+    void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
+
 private:
     TestRunner(const std::string& testURL, const std::string& expectedPixelHash);
 
@@ -445,6 +448,7 @@
     bool m_customFullScreenBehavior;
     bool m_hasPendingWebNotificationClick;
     bool m_dumpJSConsoleLogInStdErr { false };
+    bool m_didCancelClientRedirect { false };
 
     double m_databaseDefaultQuota;
     double m_databaseMaxQuota;

Modified: trunk/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm (229340 => 229341)


--- trunk/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm	2018-03-06 22:01:27 UTC (rev 229341)
@@ -404,6 +404,7 @@
         NSString *string = [NSString stringWithFormat:@"%@ - didCancelClientRedirectForFrame", [frame _drt_descriptionSuitableForTestResult]];
         printf ("%s\n", [string UTF8String]);
     }
+    gTestRunner->setDidCancelClientRedirect(true);
 }
 
 - (void)webView:(WebView *)sender didFinishDocumentLoadForFrame:(WebFrame *)frame

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (229340 => 229341)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-03-06 22:01:27 UTC (rev 229341)
@@ -316,6 +316,8 @@
     void terminateNetworkProcess();
     void terminateServiceWorkerProcess();
 
+    readonly attribute boolean didCancelClientRedirect;
+
     void removeAllSessionCredentials(object callback);
 
     void getApplicationManifestThen(object callback);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (229340 => 229341)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2018-03-06 22:01:27 UTC (rev 229341)
@@ -1006,10 +1006,10 @@
     if (!injectedBundle.isTestRunning())
         return;
 
-    if (!injectedBundle.testRunner()->shouldDumpFrameLoadCallbacks())
-        return;
+    if (injectedBundle.testRunner()->shouldDumpFrameLoadCallbacks())
+        dumpLoadEvent(frame, "didCancelClientRedirectForFrame");
 
-    dumpLoadEvent(frame, "didCancelClientRedirectForFrame");
+    injectedBundle.testRunner()->setDidCancelClientRedirect(true);
 }
 
 void InjectedBundlePage::willPerformClientRedirectForFrame(WKBundlePageRef, WKBundleFrameRef frame, WKURLRef url, double delay, double date)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (229340 => 229341)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-03-06 21:27:03 UTC (rev 229340)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-03-06 22:01:27 UTC (rev 229341)
@@ -335,6 +335,9 @@
     void setIgnoresViewportScaleLimits(bool);
     void setShouldDownloadUndisplayableMIMETypes(bool);
 
+    bool didCancelClientRedirect() const { return m_didCancelClientRedirect; }
+    void setDidCancelClientRedirect(bool value) { m_didCancelClientRedirect = value; }
+
     void runUIScript(JSStringRef script, JSValueRef callback);
     void runUIScriptCallback(unsigned callbackID, JSStringRef result);
 
@@ -479,6 +482,7 @@
     bool m_shouldDecideNavigationPolicyAfterDelay { false };
     bool m_shouldDecideResponsePolicyAfterDelay { false };
     bool m_shouldFinishAfterDownload { false };
+    bool m_didCancelClientRedirect { false };
 
     bool m_userStyleSheetEnabled;
     WKRetainPtr<WKStringRef> m_userStyleSheetLocation;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to