Title: [236987] trunk
Revision
236987
Author
cdu...@apple.com
Date
2018-10-09 16:21:18 -0700 (Tue, 09 Oct 2018)

Log Message

Anchor target should be ignored on activation when the download attribute is set
https://bugs.webkit.org/show_bug.cgi?id=190408

Reviewed by Geoffrey Garen.

Source/WebCore:

Anchor target should be ignored on activation when the download attribute is set:
- https://html.spec.whatwg.org/#the-a-element:downloading-hyperlinks-2

When the download attribute is set, we should use the "download the hyperlink" algorithm [1]
instead of the "follow the hyperlink" [2] algorithm.

Note that the "download the hyperlink" triggers a download and ignores the target attribute
entirely.

This is important as an anchor element with target=_blank and the download attribute set may
fail because of Safari's popup blocker if we do not disregard the anchor target.

[1] https://html.spec.whatwg.org/#downloading-hyperlinks
[2] https://html.spec.whatwg.org/#following-hyperlinks-2

Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html
       fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):

Tools:

Update WebKitTestRunner to block popups by default and add support for testRunner.setCanOpenWindows()
for tests that need popups. This aligns WebKitTestRunner with DumpRenderTree and allows testing
popup blocking.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setCanOpenWindows):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createOtherPage):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/TestInvocation.h:

LayoutTests:

* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html: Added.
Add layout test coverage.

* http/tests/download/anchor-load-after-download.html:
* http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
Update existing WK2-only layout tests to call testRunner.setCanOpenWindows() since they rely on
opening a new window. We failed to notice the issue because these tests are not run on WK1.

* platform/ios-wk2/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:
Skip new tests on WebKit1 since the download attribute is only supported on WebKit2.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (236986 => 236987)


--- trunk/LayoutTests/ChangeLog	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/ChangeLog	2018-10-09 23:21:18 UTC (rev 236987)
@@ -1,5 +1,28 @@
 2018-10-09  Chris Dumez  <cdu...@apple.com>
 
+        Anchor target should be ignored on activation when the download attribute is set
+        https://bugs.webkit.org/show_bug.cgi?id=190408
+
+        Reviewed by Geoffrey Garen.
+
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html: Added.
+        Add layout test coverage.
+
+        * http/tests/download/anchor-load-after-download.html:
+        * http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
+        Update existing WK2-only layout tests to call testRunner.setCanOpenWindows() since they rely on
+        opening a new window. We failed to notice the issue because these tests are not run on WK1.
+
+        * platform/ios-wk2/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+        Skip new tests on WebKit1 since the download attribute is only supported on WebKit2.
+
+2018-10-09  Chris Dumez  <cdu...@apple.com>
+
         Unreviewed, skip fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html on iOS.
 
         The download attribute is not supported on iOS yet.

Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt (0 => 236987)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt	2018-10-09 23:21:18 UTC (rev 236987)
@@ -0,0 +1,6 @@
+Download started.
+Downloading URL with suggested filename "abe.png"
+Download completed.
+The suggested filename above should be "abe.png" and the download should succeed.
+
+File backed blob URL

Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html (0 => 236987)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html	2018-10-09 23:21:18 UTC (rev 236987)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<base target="_blank">
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.setShouldLogDownloadCallbacks(true);
+  testRunner.waitUntilDownloadFinished();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "abe.png" and the download should succeed.</p>
+<a id="blob-url" download="abe.png" target="_blank">File backed blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    file = internals.createFile("../resources/abe.png");
+    var link = document.getElementById("blob-url");
+    link.href = ""
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt (0 => 236987)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt	2018-10-09 23:21:18 UTC (rev 236987)
@@ -0,0 +1,6 @@
+Download started.
+Downloading URL with suggested filename "abe.png"
+Download completed.
+The suggested filename above should be "abe.png" and the download should succeed.
+
+File backed blob URL

Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html (0 => 236987)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html	2018-10-09 23:21:18 UTC (rev 236987)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.setShouldLogDownloadCallbacks(true);
+  testRunner.waitUntilDownloadFinished();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "abe.png" and the download should succeed.</p>
+<a id="blob-url" download="abe.png" target="_blank">File backed blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    file = internals.createFile("../resources/abe.png");
+    var link = document.getElementById("blob-url");
+    link.href = ""
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/http/tests/download/anchor-load-after-download.html (236986 => 236987)


--- trunk/LayoutTests/http/tests/download/anchor-load-after-download.html	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/http/tests/download/anchor-load-after-download.html	2018-10-09 23:21:18 UTC (rev 236987)
@@ -4,6 +4,7 @@
 <script>
 if (window.testRunner) {
   testRunner.dumpAsText();
+  testRunner.setCanOpenWindows();
   testRunner.waitUntilDone();
 }
 </script>

Modified: trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js (236986 => 236987)


--- trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js	2018-10-09 23:21:18 UTC (rev 236987)
@@ -1,6 +1,9 @@
 // This test makes sure that two different windows from two different domains who spam SW registrations get responses intertwined with each other
 // as each registration should operate on its own task queue.
 
+if (window.testRunner)
+    testRunner.setCanOpenWindows();
+
 if (location.hostname != "127.0.0.1")
     alert("This test must be initiated from the hostname 127.0.0.1");
 

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (236986 => 236987)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2018-10-09 23:21:18 UTC (rev 236987)
@@ -1067,7 +1067,9 @@
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download-async-delegate.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html [ Skip ]
+webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (236986 => 236987)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2018-10-09 23:21:18 UTC (rev 236987)
@@ -307,7 +307,9 @@
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html [ Skip ]
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (236986 => 236987)


--- trunk/LayoutTests/platform/win/TestExpectations	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/LayoutTests/platform/win/TestExpectations	2018-10-09 23:21:18 UTC (rev 236987)
@@ -455,7 +455,9 @@
 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target.html [ Skip ]
+fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (236986 => 236987)


--- trunk/Source/WebCore/ChangeLog	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Source/WebCore/ChangeLog	2018-10-09 23:21:18 UTC (rev 236987)
@@ -1,3 +1,31 @@
+2018-10-09  Chris Dumez  <cdu...@apple.com>
+
+        Anchor target should be ignored on activation when the download attribute is set
+        https://bugs.webkit.org/show_bug.cgi?id=190408
+
+        Reviewed by Geoffrey Garen.
+
+        Anchor target should be ignored on activation when the download attribute is set:
+        - https://html.spec.whatwg.org/#the-a-element:downloading-hyperlinks-2
+
+        When the download attribute is set, we should use the "download the hyperlink" algorithm [1]
+        instead of the "follow the hyperlink" [2] algorithm.
+
+        Note that the "download the hyperlink" triggers a download and ignores the target attribute
+        entirely.
+
+        This is important as an anchor element with target=_blank and the download attribute set may
+        fail because of Safari's popup blocker if we do not disregard the anchor target.
+
+        [1] https://html.spec.whatwg.org/#downloading-hyperlinks
+        [2] https://html.spec.whatwg.org/#following-hyperlinks-2
+
+        Tests: fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-base-target-popup-not-allowed.html
+               fast/dom/HTMLAnchorElement/anchor-file-blob-download-blank-target-popup-not-allowed.html
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadURL):
+
 2018-10-09  Michael Catanzaro  <mcatanz...@igalia.com>
 
         [WPE][GTK] Complex text crashes with harfbuzz 1.8.8

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (236986 => 236987)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2018-10-09 23:21:18 UTC (rev 236987)
@@ -1322,7 +1322,8 @@
 
     Ref<Frame> protect(m_frame);
 
-    String frameName = frameLoadRequest.frameName();
+    // Anchor target is ignored when the download attribute is set since it will download the hyperlink rather than follow it.
+    String effectiveFrameName = frameLoadRequest.downloadAttribute().isNull() ? frameLoadRequest.frameName() : String();
     AllowNavigationToInvalidURL allowNavigationToInvalidURL = frameLoadRequest.allowNavigationToInvalidURL();
     NewFrameOpenerPolicy openerPolicy = frameLoadRequest.newFrameOpenerPolicy();
     LockHistory lockHistory = frameLoadRequest.lockHistory();
@@ -1345,7 +1346,7 @@
     ASSERT(newLoadType != FrameLoadType::Same);
 
     // The search for a target frame is done earlier in the case of form submission.
-    Frame* targetFrame = isFormSubmission ? nullptr : findFrameForNavigation(frameName);
+    Frame* targetFrame = isFormSubmission ? nullptr : findFrameForNavigation(effectiveFrameName);
     if (targetFrame && targetFrame != &m_frame) {
         frameLoadRequest.setFrameName("_self");
         targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, WTFMove(formState), completionHandlerCaller.release());
@@ -1360,9 +1361,9 @@
         action.setOpenedViaWindowOpenWithOpener();
     action.setHasOpenedFrames(!m_openedFrames.isEmpty());
 
-    if (!targetFrame && !frameName.isEmpty()) {
+    if (!targetFrame && !effectiveFrameName.isEmpty()) {
         action = "" frameLoadRequest));
-        policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), frameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable {
+        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();
         });

Modified: trunk/Tools/ChangeLog (236986 => 236987)


--- trunk/Tools/ChangeLog	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/ChangeLog	2018-10-09 23:21:18 UTC (rev 236987)
@@ -1,3 +1,25 @@
+2018-10-09  Chris Dumez  <cdu...@apple.com>
+
+        Anchor target should be ignored on activation when the download attribute is set
+        https://bugs.webkit.org/show_bug.cgi?id=190408
+
+        Reviewed by Geoffrey Garen.
+
+        Update WebKitTestRunner to block popups by default and add support for testRunner.setCanOpenWindows()
+        for tests that need popups. This aligns WebKitTestRunner with DumpRenderTree and allows testing
+        popup blocking.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setCanOpenWindows):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createOtherPage):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+        * WebKitTestRunner/TestInvocation.h:
+
 2018-10-09  Jer Noble  <jer.no...@apple.com>
 
         WebDriver: thrown ObjC exception under -[WKFullScreenWindowController windowDidFailToEnterFullScreen:] when session is terminated

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-10-09 23:21:18 UTC (rev 236987)
@@ -66,7 +66,7 @@
     // Special options.
     void keepWebHistory();
     void setAcceptsEditing(boolean value);
-    void setCanOpenWindows(boolean value);
+    void setCanOpenWindows();
     void setCloseRemainingWindowsWhenComplete(boolean value);
     void setXSSAuditorEnabled(boolean value);
     void setAllowUniversalAccessFromFileURLs(boolean value);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2018-10-09 23:21:18 UTC (rev 236987)
@@ -410,15 +410,11 @@
     return WKBundlePageIsEditingCommandEnabled(InjectedBundle::singleton().page()->page(), toWK(name).get());
 }
 
-void TestRunner::setCanOpenWindows(bool)
+void TestRunner::setCanOpenWindows()
 {
-    // The test plugins/get-url-with-blank-target.html requires that the embedding client forbid
-    // opening windows (by omitting a call to this function) so as to test that NPN_GetURL()
-    // with a blank target will return an error.
-    //
-    // It is not clear if we should implement this functionality or remove it and plugins/get-url-with-blank-target.html
-    // per the remark in <https://trac.webkit.org/changeset/64504/trunk/LayoutTests/platform/mac-wk2/Skipped>.
-    // For now, just ignore this setting.
+    WKRetainPtr<WKStringRef> messsageName(AdoptWK, WKStringCreateWithUTF8CString("SetCanOpenWindows"));
+    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(true));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messsageName.get(), messageBody.get(), nullptr);
 }
 
 void TestRunner::setXSSAuditorEnabled(bool enabled)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-10-09 23:21:18 UTC (rev 236987)
@@ -99,7 +99,7 @@
     // Special options.
     void keepWebHistory();
     void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; }
-    void setCanOpenWindows(bool);
+    void setCanOpenWindows();
     void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; }
     void setXSSAuditorEnabled(bool);
     void setModernMediaControlsEnabled(bool);

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2018-10-09 23:21:18 UTC (rev 236987)
@@ -242,10 +242,18 @@
     WKPageDidAllowPointerLock(page);
 }
 
-WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
+WKPageRef TestController::createOtherPage(WKPageRef, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
 {
     PlatformWebView* parentView = static_cast<PlatformWebView*>(const_cast<void*>(clientInfo));
+    return TestController::singleton().createOtherPage(parentView, configuration, navigationAction, windowFeatures);
+}
 
+WKPageRef TestController::createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures)
+{
+    // The test needs to call testRunner.setCanOpenWindows() to open new windows.
+    if (!m_currentInvocation->canOpenWindows())
+        return nullptr;
+
     PlatformWebView* view = platformCreateOtherPage(parentView, configuration, parentView->options());
     WKPageRef newPage = view->page();
 

Modified: trunk/Tools/WebKitTestRunner/TestController.h (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/TestController.h	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2018-10-09 23:21:18 UTC (rev 236987)
@@ -400,6 +400,7 @@
     void didUpdateHistoryTitle(WKStringRef title, WKURLRef, WKFrameRef);
 
     static WKPageRef createOtherPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void*);
+    WKPageRef createOtherPage(PlatformWebView* parentView, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef);
 
     static void runModal(WKPageRef, const void* clientInfo);
     static void runModal(PlatformWebView*);

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2018-10-09 23:21:18 UTC (rev 236987)
@@ -802,6 +802,12 @@
     if (WKStringIsEqualToUTF8CString(messageName, "GetDumpFrameLoadCallbacks"))
         return WKRetainPtr<WKTypeRef>(AdoptWK, WKBooleanCreate(m_dumpFrameLoadCallbacks));
 
+    if (WKStringIsEqualToUTF8CString(messageName, "SetCanOpenWindows")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        m_canOpenWindows = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "SetWindowIsKey")) {
         ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
         WKBooleanRef isKeyValue = static_cast<WKBooleanRef>(messageBody);

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (236986 => 236987)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2018-10-09 22:31:55 UTC (rev 236986)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2018-10-09 23:21:18 UTC (rev 236987)
@@ -84,6 +84,8 @@
     void didRemoveAllSessionCredentials();
     
     void dumpResourceLoadStatistics();
+
+    bool canOpenWindows() const { return m_canOpenWindows; }
     
 private:
     WKRetainPtr<WKMutableDictionaryRef> createTestSettingsDictionary();
@@ -132,6 +134,7 @@
     bool m_dumpPixels { false };
     bool m_pixelResultIsPending { false };
     bool m_shouldDumpResourceLoadStatistics { false };
+    bool m_canOpenWindows { false };
     WhatToDump m_whatToDump { WhatToDump::RenderTree };
 
     StringBuilder m_textOutput;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to