REOPENED 188852
Improve compatibility with hyperlink auditing spec
https://bugs.webkit.org/show_bug.cgi?id=188852
Summary Improve compatibility with hyperlink auditing spec
Brent Fulgham
Reported 2018-08-22 09:48:46 PDT
The hyperlink auditing spec <http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing> indicates that the user agent can optionally ignore a ping request, for example if the user as chosen to block its use. This patch checks the target URL of the ping request and decides not to fire the request if the URL in question is a prevalent resource.
Attachments
Patch (4.03 KB, patch)
2018-08-22 13:48 PDT, Brent Fulgham
no flags
Patch (4.08 KB, patch)
2018-08-22 13:52 PDT, Brent Fulgham
no flags
Archive of layout-test-results from ews107 for mac-sierra-wk2 (3.22 MB, application/zip)
2018-08-22 14:59 PDT, EWS Watchlist
no flags
Patch (4.12 KB, patch)
2018-08-22 16:02 PDT, Brent Fulgham
no flags
Patch (8.99 KB, patch)
2018-08-23 10:05 PDT, Brent Fulgham
no flags
Archive of layout-test-results from ews125 for ios-simulator-wk2 (15.54 MB, application/zip)
2018-08-23 12:06 PDT, EWS Watchlist
no flags
Patch (10.00 KB, patch)
2018-08-23 13:20 PDT, Brent Fulgham
no flags
Patch (13.46 KB, patch)
2018-08-23 14:39 PDT, Brent Fulgham
no flags
Patch (19.42 KB, patch)
2018-08-23 17:05 PDT, Brent Fulgham
no flags
Patch (19.20 KB, patch)
2018-08-23 17:08 PDT, Brent Fulgham
no flags
Patch (19.84 KB, patch)
2018-08-24 08:54 PDT, Brent Fulgham
no flags
Patch (5.17 KB, patch)
2020-01-25 12:37 PST, Rob Buis
no flags
Brent Fulgham
Comment 1 2018-08-22 13:41:30 PDT
Brent Fulgham
Comment 2 2018-08-22 13:48:02 PDT
Brent Fulgham
Comment 3 2018-08-22 13:52:59 PDT
EWS Watchlist
Comment 4 2018-08-22 14:59:41 PDT
Comment on attachment 347842 [details] Patch Attachment 347842 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/8949139 New failing tests: css3/filters/backdrop/add-remove-add-backdrop-filter.html
EWS Watchlist
Comment 5 2018-08-22 14:59:43 PDT
Created attachment 347851 [details] Archive of layout-test-results from ews107 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
youenn fablet
Comment 6 2018-08-22 15:13:17 PDT
Comment on attachment 347842 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=347842&action=review > Source/WebKit/ChangeLog:11 > + has been granted Storage Access API permissions, allow the ping. Is there a way to test this change? > Source/WebKit/NetworkProcess/PingLoad.cpp:64 > + if (this->loadIsForPrevalentDomain()) { This check applies to all PingLoad users, like Beacon API loads for instance. Will we not cancel some loads that we should conduct? > Source/WebKit/NetworkProcess/PingLoad.cpp:132 > + if (this->loadIsForPrevalentDomain()) { loadIsForPrevalentDomain is using m_parameters.request.url(), and it seems we are not updating this URL. Maybe loadIsForPrevalentDomain should take a const URL& as input parameter.
Brent Fulgham
Comment 7 2018-08-22 16:02:22 PDT
Brent Fulgham
Comment 8 2018-08-22 16:03:03 PDT
It doesn't seem like the image-only failure for 'css3/filters/backdrop/add-remove-add-backdrop-filter.html' is related to this PingLoad change.
John Wilander
Comment 9 2018-08-22 17:56:58 PDT
Comment on attachment 347866 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=347866&action=review You should be able to create a layout test using the Resource Load Statistics and the Storage Access API test infrastructure. > Source/WebKit/NetworkProcess/PingLoad.cpp:89 > + return networkSession->networkStorageSession().shouldBlockCookies(sourceOrigin, url, m_parameters.webPageID, m_parameters.webFrameID); pageID and frameID should be flipped. I've been wanting to revisit the parameter ordering throughout the call chain. The reason for the current ordering is that the frameID is the main key in the data structure but we should opt for an ordering that's less confusing instead. > Source/WebKit/NetworkProcess/PingLoad.cpp:133 > + this->didFinish(ResourceError { String { }, 0, request.url(), "Redirection to prevalent Domain"_s, ResourceError::Type::AccessControl }); Lower case 'd' in domain.
Brent Fulgham
Comment 10 2018-08-23 10:05:27 PDT
EWS Watchlist
Comment 11 2018-08-23 12:06:35 PDT
Comment on attachment 347929 [details] Patch Attachment 347929 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/8959290 New failing tests: http/tests/resourceLoadStatistics/ping-to-prevalent-resource.html
EWS Watchlist
Comment 12 2018-08-23 12:06:37 PDT
Created attachment 347945 [details] Archive of layout-test-results from ews125 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews125 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.4
John Wilander
Comment 13 2018-08-23 12:22:24 PDT
The test failure on iOS Sim is probably the event sender. IIRC, the Storage Access API tests that involve taps/clicks are not enabled on iOS for this very reason. :(
Brent Fulgham
Comment 14 2018-08-23 13:17:06 PDT
(In reply to John Wilander from comment #13) > The test failure on iOS Sim is probably the event sender. IIRC, the Storage > Access API tests that involve taps/clicks are not enabled on iOS for this > very reason. :( Oh! I'll add a skip on iOS.
Brent Fulgham
Comment 15 2018-08-23 13:20:45 PDT
youenn fablet
Comment 16 2018-08-23 13:28:41 PDT
It is not clear to me whether Beacon API loads should also be blocked in that case. If that is the case, can we also include a test for it?
John Wilander
Comment 17 2018-08-23 14:21:45 PDT
Comment on attachment 347949 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=347949&action=review Looks good to me. One nit below. > Source/WebKit/NetworkProcess/PingLoad.cpp:65 > + this->didFinish(ResourceError { String { }, 0, this->m_parameters.request.url(), "Ping request to prevalent Domain"_s, ResourceError::Type::AccessControl }); Should be a lower case 'd' in my opinion.
Brent Fulgham
Comment 18 2018-08-23 14:39:44 PDT
Alex Christensen
Comment 19 2018-08-23 15:26:25 PDT
This will encourage the use of sync xhr. Can we block sync xhr if we have chosen to block its use?
youenn fablet
Comment 20 2018-08-23 15:52:38 PDT
Auditing hyperlink spec allows to not fetch the resource. On the other hand, Beacon API spec does not provide the ability to skip the load. I am not sure we have a way to identify whether a given request is hyperlink auditing vs. beacon API in the network process, maybe we should pass that information from web process.
Brent Fulgham
Comment 21 2018-08-23 17:01:25 PDT
(In reply to Alex Christensen from comment #19) > This will encourage the use of sync xhr. Can we block sync xhr if we have > chosen to block its use? Yes, I think we can do so using the same criteria for Ping and Beacon.
Brent Fulgham
Comment 22 2018-08-23 17:05:44 PDT
Brent Fulgham
Comment 23 2018-08-23 17:08:02 PDT
Alex Christensen
Comment 24 2018-08-23 17:12:16 PDT
Comment on attachment 347977 [details] Patch One of the motivations for the Beacon API was to give people using sync xhr to phone home an alternative that doesn't hurt performance. If we make that alternative, people will notice that some of their analytics don't arrive and they will use sync xhr instead. Unless we do the same restrictions to sync xhr I think this is a step in the wrong direction.
John Wilander
Comment 25 2018-08-23 18:04:28 PDT
(In reply to Alex Christensen from comment #24) > Comment on attachment 347977 [details] > Patch > > One of the motivations for the Beacon API was to give people using sync xhr > to phone home an alternative that doesn't hurt performance. If we make that > alternative, people will notice that some of their analytics don't arrive > and they will use sync xhr instead. Unless we do the same restrictions to > sync xhr I think this is a step in the wrong direction. We should absolutely block sync XHR for them. That’ll help deprecating sync XHR all together, which is good for the web.
youenn fablet
Comment 26 2018-08-23 21:40:59 PDT
Comment on attachment 347977 [details] Patch I am still fuzzy of the benefit here. As per https://html.spec.whatwg.org/multipage/links.html#hyperlink-auditing, the ping is only sent when user clicks the link. If this ping is blocked and the script really wants to send this information, it has a bunch of options: - Have a function executed at click time to send the information through web socket/XHR before doing the navigation. - Use a redirection URL for the navigation to provide the exact same information. - Send that information as regular XHR/fetch at loading of the next page (work pretty easily for same site navigation) - Use service worker and trigger a regular fetch in service worker. Blocking ping loads is ok as per spec. Blocking sync XHR is probably fine since we want to deprecate it and there is a way for the app to know whether it failed so that it can take some measures. Blocking sendBeacon on the other hand is not currently allowed by the spec and there is no way for the web developer to know that it was blocked. This might not encourage web developers to use it and they may rely on regular XHR/fetch API instead. This would be sad since one of the point of sendBeacon is that the beacon requests could be optimized as described in the spec: - The user agent MAY delay transmission of provided data to optimize network and energy efficiency - The user agent MUST schedule immediate transmission of all beacon requests when the document visibilityState transitions to hidden View in context: https://bugs.webkit.org/attachment.cgi?id=347977&action=review > Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:209 > + if (this->isSynchronous() && this->loadIsForPrevalentDomain(this->m_parameters.request.url())) { There is no need to do this check after network load checker did it. It could be done just before if (m_networkLoadChecker). Also, sync XHR redirections are not checked in this patch, see NetworkResourceLoader::willSendRedirectedRequest.
Brent Fulgham
Comment 27 2018-08-24 08:31:34 PDT
Comment on attachment 347977 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=347977&action=review >> Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:209 >> + if (this->isSynchronous() && this->loadIsForPrevalentDomain(this->m_parameters.request.url())) { > > There is no need to do this check after network load checker did it. > It could be done just before if (m_networkLoadChecker). > > Also, sync XHR redirections are not checked in this patch, see NetworkResourceLoader::willSendRedirectedRequest. Which check do you mean? The check for synchronicity? Or the prevalence check? Thanks for catching the redirect case, I'll fix that.
Brent Fulgham
Comment 28 2018-08-24 08:37:41 PDT
(In reply to Alex Christensen from comment #24) > Comment on attachment 347977 [details] > Patch > > One of the motivations for the Beacon API was to give people using sync xhr > to phone home an alternative that doesn't hurt performance. If we make that > alternative, people will notice that some of their analytics don't arrive > and they will use sync xhr instead. Unless we do the same restrictions to > sync xhr I think this is a step in the wrong direction. I agree. The current patch (now) subjects synchronous XHR to the same checks and blocking as ping or beacon operations.
Brent Fulgham
Comment 29 2018-08-24 08:54:23 PDT
Rob Buis
Comment 30 2020-01-25 12:37:15 PST
youenn fablet
Comment 31 2020-01-26 01:24:40 PST
Comment on attachment 388786 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=388786&action=review > Source/WebCore/ChangeLog:13 > + http/tests/navigation/ping-attribute/area-cross-origin.html Are we missing some WPT tests?
Rob Buis
Comment 32 2020-01-26 01:33:00 PST
Comment on attachment 388786 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=388786&action=review >> Source/WebCore/ChangeLog:13 >> + http/tests/navigation/ping-attribute/area-cross-origin.html > > Are we missing some WPT tests? Yes. Dominic Farolino left a comment adding WPT tests for this in chromium sources so I will coordinate with him.
WebKit Commit Bot
Comment 33 2020-01-26 04:17:27 PST
Comment on attachment 388786 [details] Patch Clearing flags on attachment: 388786 Committed r255129: <https://trac.webkit.org/changeset/255129>
WebKit Commit Bot
Comment 34 2020-01-26 04:17:29 PST
All reviewed patches have been landed. Closing bug.
Rob Buis
Comment 35 2020-01-26 04:20:52 PST
Reopening since Brent was targeting a different compatibility problem initially.
youenn fablet
Comment 36 2020-01-26 07:22:52 PST
(In reply to Rob Buis from comment #35) > Reopening since Brent was targeting a different compatibility problem > initially. Oh yes, the referrer patch should have had its own bug.
Ahmad Saleem
Comment 37 2022-09-12 15:13:17 PDT
@Brent - I think we can create separate bug for referrer refinement as per Comment 36 and close this one? Or it is something still in your radar? Thanks!
Note You need to log in before you can comment on or make changes to this bug.