Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Clicks on Link with download attribute causes all (other) links to tr…
…igger download when clicked https://bugs.webkit.org/show_bug.cgi?id=178267 <rdar://problem/34985016> Reviewed by Darin Adler. LayoutTests/imported/w3c: Rebaseline test which behave differently now in WebKit2 due to WKTR's injected bundle using PassThrough policy for new windows. The new result is identical to what you would get when you open the test in Safari so I think this is a good thing. * web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt: Source/WebKit: When clicking on an anchor with the download attribute, the m_syncNavigationActionHasDownloadAttribute flag on WebPageProxy would get set. This flag would not get reset right away and instead, it would get updated during the next call to WebPageProxy::decidePolicyForNavigationAction(). The issue is that if you later click on a link with target="_blank", WebPageProxy::decidePolicyForNewWindowAction() gets called instead of WebPageProxy::decidePolicyForNavigationAction() and we do not reset the m_syncNavigationActionHasDownloadAttribute flag and we force a download. To address the problem, I got rid of this flag on WebPageProxy and it is error-prone and should really not be at page-level. Instead, I added a shouldForceDownload flag on the navigation object. It makes more sense to associate the flag with the navigation and makes it less error-prone. * UIProcess/API/APINavigation.h: (API::Navigation::setShouldForceDownload): (API::Navigation::shouldForceDownload const): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::receivedPolicyDecision): (WebKit::WebPageProxy::decidePolicyForNavigationAction): * UIProcess/WebPageProxy.h: Tools: Use PassThrough policy in WKTR's InjectedBundle's decidePolicyForNewWindowAction so that the request is sent to the UIProcess. This gets WKTR's closer to Safari behavior and helps reproduce the bug. Without this change, I would not be able to write a regression test for this bug that is very easily reproducible in Safari. * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: (WTR::InjectedBundlePage::decidePolicyForNewWindowAction): LayoutTests: Add layout test coverage. * http/tests/download/anchor-load-after-download-expected.txt: Added. * http/tests/download/anchor-load-after-download.html: Added. * platform/ios-wk2/TestExpectations: * platform/mac-wk1/TestExpectations: * platform/mac-wk1/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt. Canonical link: https://commits.webkit.org/194558@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223413 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
131 additions
and 18 deletions.
- +16 −0 LayoutTests/ChangeLog
- +5 −0 LayoutTests/http/tests/download/anchor-load-after-download-expected.txt
- +29 −0 LayoutTests/http/tests/download/anchor-load-after-download.html
- +14 −0 LayoutTests/imported/w3c/ChangeLog
- +1 −7 ...utTests/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt
- +1 −0 LayoutTests/platform/ios-wk2/TestExpectations
- +1 −0 LayoutTests/platform/mac-wk1/TestExpectations
- +13 −0 ...mac-wk1/imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt
- +27 −0 Source/WebKit/ChangeLog
- +4 −0 Source/WebKit/UIProcess/API/APINavigation.h
- +3 −6 Source/WebKit/UIProcess/WebPageProxy.cpp
- +0 −4 Source/WebKit/UIProcess/WebPageProxy.h
- +16 −0 Tools/ChangeLog
- +1 −1 Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,5 @@ | ||
Clicking the download link link and then the non-download link should not cause a second download. | ||
|
||
This test passes if it does not time out. | ||
|
||
Link with download attribute. Link without download attribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<p>Clicking the download link link and then the non-download link should not cause a second download.</p> | ||
<p>This test passes if it does not time out.</p> | ||
<a id="download-url" href='data:text/html,HelloWorld!' download="test.html">Link with download attribute.</a> | ||
<a id="non-download-url" href="/misc/resources/success-notify-done.html" target="_blank">Link without download attribute.</a> | ||
<script> | ||
function runTest() | ||
{ | ||
var downloadLink = document.getElementById("download-url"); | ||
var nonDownloadLink = document.getElementById("non-download-url"); | ||
downloadLink.click(); | ||
setTimeout(function() { | ||
nonDownloadLink.click(); | ||
}, 0); | ||
} | ||
runTest(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,13 +1,7 @@ | ||
|
||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,13 @@ | ||
CONSOLE MESSAGE: line 37: 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. | ||
|
||
CONSOLE MESSAGE: line 38: 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. | ||
|
||
CONSOLE MESSAGE: line 38: 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 | ||
|
||
PASS 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 | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters