Bug 178267

Summary: Clicks on Link with download attribute causes all (other) links to trigger download when clicked
Product: WebKit Reporter: Jonas Ohlsson Aden <jonas.sebastian.ohlsson>
Component: UI EventsAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, buildbot, cdumez, commit-queue, darin, jond, rniwa, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 11   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP Patch
none
WIP Patch
none
Archive of layout-test-results from ews102 for mac-elcapitan
none
Archive of layout-test-results from ews107 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews115 for mac-elcapitan
none
Archive of layout-test-results from ews121 for ios-simulator-wk2
none
Patch none

Description Jonas Ohlsson Aden 2017-10-13 10:30:03 PDT
Minimal reproducible test case here:
https://codepen.io/pocketjoso/pen/QqVOWy

I can reproduce on:
Safari 11.0 (12604.1.38.1.7)
macOS Sierra (10.12.6)

It does not happen in other browsers; I am not aware whether it happened in earlier Safari versions.
Comment 1 Radar WebKit Bug Importer 2017-10-13 13:54:49 PDT
<rdar://problem/34985016>
Comment 2 Chris Dumez 2017-10-13 14:07:12 PDT
In WebPageProxy.cpp:
#if ENABLE(DOWNLOAD_ATTRIBUTE)
    if (m_syncNavigationActionHasDownloadAttribute && action == PolicyAction::Use)
        action = PolicyAction::Download;
#endif

m_syncNavigationActionHasDownloadAttribute likely does not get reset.
Comment 3 Chris Dumez 2017-10-13 14:22:33 PDT
Created attachment 323749 [details]
WIP Patch
Comment 4 Chris Dumez 2017-10-13 16:43:42 PDT
Created attachment 323770 [details]
WIP Patch
Comment 5 Build Bot 2017-10-13 16:46:31 PDT
Attachment 323770 [details] did not pass style-queue:


ERROR: Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:1362:  Should have a space between // and comment  [whitespace/comments] [4]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Build Bot 2017-10-13 17:45:40 PDT
Comment on attachment 323770 [details]
WIP Patch

Attachment 323770 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/4852456

New failing tests:
http/tests/download/anchor-load-after-download.html
Comment 7 Build Bot 2017-10-13 17:45:41 PDT
Created attachment 323781 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 8 Build Bot 2017-10-13 18:09:06 PDT
Comment on attachment 323770 [details]
WIP Patch

Attachment 323770 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/4852623

New failing tests:
imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name.html
Comment 9 Build Bot 2017-10-13 18:09:08 PDT
Created attachment 323782 [details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 10 Build Bot 2017-10-13 18:44:44 PDT
Comment on attachment 323770 [details]
WIP Patch

Attachment 323770 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/4852749

New failing tests:
http/tests/download/anchor-load-after-download.html
Comment 11 Build Bot 2017-10-13 18:44:45 PDT
Created attachment 323786 [details]
Archive of layout-test-results from ews115 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 12 Build Bot 2017-10-13 19:34:05 PDT
Comment on attachment 323770 [details]
WIP Patch

Attachment 323770 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/4852995

New failing tests:
http/tests/download/anchor-load-after-download.html
Comment 13 Build Bot 2017-10-13 19:34:07 PDT
Created attachment 323791 [details]
Archive of layout-test-results from ews121 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews121  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.6
Comment 14 Chris Dumez 2017-10-15 11:28:30 PDT
Created attachment 323844 [details]
Patch
Comment 15 Sam Weinig 2017-10-15 14:43:34 PDT
Comment on attachment 323844 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323844&action=review

> Source/WebKit/UIProcess/API/APINavigation.h:73
> +    bool m_shouldForceDownload { false };

I'm not sure the should is getting you much here.  Maybe, just forceDownload?
Comment 16 Chris Dumez 2017-10-15 15:06:24 PDT
(In reply to Sam Weinig from comment #15)
> Comment on attachment 323844 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=323844&action=review
> 
> > Source/WebKit/UIProcess/API/APINavigation.h:73
> > +    bool m_shouldForceDownload { false };
> 
> I'm not sure the should is getting you much here.  Maybe, just forceDownload?

I thought this was part of our coding style for Booleans. I personally like it better with the should prefix too.
Comment 17 Darin Adler 2017-10-15 17:52:59 PDT
Comment on attachment 323844 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323844&action=review

>>> Source/WebKit/UIProcess/API/APINavigation.h:73
>>> +    bool m_shouldForceDownload { false };
>> 
>> I'm not sure the should is getting you much here.  Maybe, just forceDownload?
> 
> I thought this was part of our coding style for Booleans. I personally like it better with the should prefix too.

The rule is inspired by Cocoa; it’s to help make sure that getters don’t sound like verb phrases. A function called “force download” doesn’t necessarily sound like a getter to everyone.

I like the way the "should" decreases ambiguity in the function name. And I also like booleans that work as a sentence "navigation should force download" as opposed to "navigation force download".

> LayoutTests/imported/w3c/ChangeLog:13
> +        * web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt:

Do these tests that rely things that have to time out slow down test runs overall, or is there some reason they don’t?
Comment 18 Chris Dumez 2017-10-16 09:31:07 PDT
Comment on attachment 323844 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323844&action=review

>> LayoutTests/imported/w3c/ChangeLog:13
>> +        * web-platform-tests/html/browsers/windows/noreferrer-window-name-expected.txt:
> 
> Do these tests that rely things that have to time out slow down test runs overall, or is there some reason they don’t?

No, I don't think these tests rely on such things. We are timing out on some of them but those are likely bugs in our implementation that I need to investigate.
Comment 19 WebKit Commit Bot 2017-10-16 09:59:51 PDT
Comment on attachment 323844 [details]
Patch

Clearing flags on attachment: 323844

Committed r223413: <https://trac.webkit.org/changeset/223413>
Comment 20 WebKit Commit Bot 2017-10-16 09:59:53 PDT
All reviewed patches have been landed.  Closing bug.
Comment 21 Jonas Ohlsson Aden 2017-10-16 10:26:07 PDT
Thanks for the work on this! When (in what version) in Safari can I expect to see this fixed?
Comment 22 Chris Dumez 2017-10-16 10:30:24 PDT
(In reply to Jonas Ohlsson Aden from comment #21)
> Thanks for the work on this! When (in what version) in Safari can I expect
> to see this fixed?

No problem, thank you for the bug report.

Apple does not communicate when a particular fix will ship to customers.
I suggest validating the fix using the next release of Safari Technology Preview.