[wpt-sync] Sync PR 18061 - Use correct URLLoaderFactory in an unload handler.
Categories
(Core :: DOM: Networking, task, P5)
Tracking
()
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: mozilla.org, Unassigned)
References
()
Details
(Whiteboard: [necko-triaged][wptsync downstream])
Sync web-platform-tests PR 18061 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/18061
Details from upstream follow.
Lukasz Anforowicz <lukasza@chromium.org> wrote:
Use correct URLLoaderFactory in an unload handler.
Context and behavior implemented + expected before and after the CL
A content::RenderFrameImpl stores |subresource_loader_factories| that
are used for all requests/XHRs/etc initiated by the frame. We don't
currently swap the RenderFrame when committing another same-process
document (this future work is tracked by https://crbug.com/936696).The URLLoaderFactory for handling http/https requests contains a
|request_initiator_site_lock| in network::URLLoaderFactoryParams.
This lock limits what network::ResourceRequest::request_initiator may be
used. The lock is currently used in various, security-sensitive
features like CORB, CORP, Sec-Fetch-Site. In the future the lock may be
consulted for all requests handled by the NetworkService (see
https://crbug.com/920634 and also https://crbug.com/961614).When a cross-origin, same-process navigation commits, then:
The commit IPC carries a bundle of |subresource_loader_factories|.
The new |subresource_loader_factories| should be used by the newly
committed document.Before committing the new document, the old document's unload
handler needs to run. The unload handler needs to use the old
|subresource_loader_factories| (e.g. because otherwise
|URLLoaderFactoryParams::request_initiator_site_lock| might
not match the document origin).The problematic behavior before this CL
Before the CL, content::RenderFrameImpl::CommitNavigationWithParams
would start using the new |subresource_loader_factories| before running
the unload handler of the old document (i.e. before calling
blink::WebNavigationControl::CommitNavigation on |frame_|).The CL adds WPT tests that fail when the old, incorrect behavior
happens. The new test initiates a beacon request from a frame's unload
handler and verifies the Sec-Fetch-Site request header associated with
this request. The header depends on the correct
request_initiator_site_lock / on using the correct URLLoaderFactory.The fixes in this CL
This CL introduces the |call_before_attaching_new_document| callback
that is taken by blink::WebNavigationControl::CommitNavigation and
called after finishing running the old document's unload handler
and before the new document can initiate any requests of its own.This fix is a bit icky. In the long-term the callback can be avoided if
the |subresource_loader_factories| are stored in a per-document object
(i.e. if we swap RenderFrame on every document change, or if we replace
RenderFrame with a RenderDocument - see https://crbug.com/936696). The
CL adds a TODO to call this out.The fix had to refactor BuildServiceWorkerNetworkProviderForNavigation
to make sure that it uses the |new_loader_factories| (even though they
have not yet been passes to SetLoaderFactoryBundle).The fix also refactored GetLoaderFactoryBundleFromCreator to a separate
method, so that setting the creator-based factories can also be
postponed to |call_before_attaching_new_document|.Bug: 986577
Change-Id: If0209df61b0305ec43b5179bfdc1b9f8668a88b5
Reviewed-on: https://chromium-review.googlesource.com/1716084
WPT-Export-Revision: 9248c2aa2fced8ffac6f4467bde195a81b181ca3
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=f2b0c6ebd310448d9d73068c2fac68f7bc5889d1
Assignee | ||
Comment 2•5 years ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/#/jobs?repo=try&revision=f186f77f937eb8b6abed76b28f9cdc721f1193cd
Updated•5 years ago
|
Assignee | ||
Comment 3•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=5ff9e21e9190b7f67bd9f66bdbe05b278728c5a5
Assignee | ||
Comment 4•5 years ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/#/jobs?repo=try&revision=ccefb615777783153780d4cf89516335696a0dfb
Assignee | ||
Comment 5•5 years ago
|
||
Pushed to try https://treeherder.mozilla.org/#/jobs?repo=try&revision=cc2604cbaaea0dc27cb745bf035981b8b94f626e
Assignee | ||
Comment 6•5 years ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/#/jobs?repo=try&revision=ad212c35f64c6ccc7e57630b0c1391cce67e4f2e
Assignee | ||
Comment 7•5 years ago
|
||
Ran 1 tests and 1 subtests OK : 1 FAIL : 1 New tests that have failures or other problems: /fetch/sec-metadata/unload.tentative.https.sub.html Fetch from an unload handler: FAIL
Pushed by wptsync@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/c67426ef2222 [wpt PR 18061] - Use correct URLLoaderFactory in an unload handler., a=testonly https://hg.mozilla.org/integration/mozilla-inbound/rev/2e654ff196f6 [wpt PR 18061] - Update wpt metadata, a=testonly
Comment 9•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c67426ef2222
https://hg.mozilla.org/mozilla-central/rev/2e654ff196f6
Description
•