-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that <object>/<embed> navigation bypasses Service Workers.
Step 13 of https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm should exclude `embed` and `object` requests from Service Workers. Our implementation handles this correctly for the initial request, but failed to bypass the Service Worker for subsequent navigations. This patch adds a destination check to `ServiceWorkerMainResourceLoaderInterceptor::ShouldCreateForNavigation`, and ensures that the `destination` for a given request is set early enough in the lifecycle to ensure that the check succeeds. See also whatwg/fetch#948. Change-Id: I21a1d37da438e1d0f185696f2b3b4058bc3911fc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2209456 Reviewed-by: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Tsuyoshi Horo <horo@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Ben Kelly <wanderview@chromium.org> Commit-Queue: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/master@{#773781}
- Loading branch information
1 parent
a0740be
commit f58221d
Showing
3 changed files
with
73 additions
and
0 deletions.
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
23 changes: 23 additions & 0 deletions
23
service-workers/service-worker/resources/embed-navigation-is-not-intercepted-iframe.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>iframe for embed-and-object-are-not-intercepted test</title> | ||
<body> | ||
<script> | ||
// The EMBED element will call this with the result about whether the EMBED | ||
// request was intercepted by the service worker. | ||
var report_result; | ||
|
||
// Our parent (the root frame of the test) will examine this to get the result. | ||
var test_promise = new Promise(resolve => { | ||
report_result = resolve; | ||
}); | ||
|
||
let el = document.createElement('embed'); | ||
el.src = "/common/blank.html"; | ||
el.addEventListener('load', _ => { | ||
window[0].location = "/service-workers/service-worker/resources/embedded-content-from-server.html"; | ||
}, { once: true }); | ||
document.body.appendChild(el); | ||
</script> | ||
|
||
</body> |
24 changes: 24 additions & 0 deletions
24
service-workers/service-worker/resources/object-navigation-is-not-intercepted-iframe.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>iframe for embed-and-object-are-not-intercepted test</title> | ||
<body> | ||
<script> | ||
// The OBJECT element will call this with the result about whether the OBJECT | ||
// request was intercepted by the service worker. | ||
var report_result; | ||
|
||
// Our parent (the root frame of the test) will examine this to get the result. | ||
var test_promise = new Promise(resolve => { | ||
report_result = resolve; | ||
}); | ||
|
||
let el = document.createElement('object'); | ||
el.data = "/common/blank.html"; | ||
el.addEventListener('load', _ => { | ||
window[0].location = "/service-workers/service-worker/resources/embedded-content-from-server.html"; | ||
}, { once: true }); | ||
document.body.appendChild(el); | ||
</script> | ||
|
||
</body> | ||
|