-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the sub resource load also skip the fetch handler if skippable.
In the previous implementation, we did not skip service worker for fetching sub resource load. Since we do not start the service worker when the fetch handler is decided to be skipped, sub resource load may get stuck. This CL make the renderer behave as if the fetch handler does not exist if the fetch handler is skipped in the main resource load. To let the renderer know the fetch handler should be skipped, we introduced the effective fetch handler type in ControllerServiceWorkerInfo. If the effective fetch handler type is skippable, the renderer returns nullptr when the controller is requested. You may wonder why we need to introduce the effective fetch handler type in addition to the existing fetch_handler_type. That is because we cannot change the fetch_handler_type behavior for the service worker registration and the metrics. Since the service worker registration is persistent data, I do not think it is good idea to change its contents by the flag. For metrics, we want to compare the same fetch handler case with the different flags. The fetch_handler_type should also need to be persistent here. Note that FCP/LCP with skippable fetch handler type is taken in this way. Bug: 1364999 Bug: 1347319 Change-Id: I29f5af4589d5a675bf033dd74a17c975dd1a7722 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3905774 Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by: Shunya Shishido <sisidovski@chromium.org> Reviewed-by: Minoru Chikamune <chikamune@chromium.org> Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Cr-Commit-Position: refs/heads/main@{#1052295}
- Loading branch information
1 parent
66cb5c8
commit f9a2383
Showing
15 changed files
with
177 additions
and
37 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
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
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
2 changes: 2 additions & 0 deletions
2
third_party/blink/web_tests/http/tests/serviceworker/resources/empty-fetch-handler.js
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,2 @@ | ||
// An empty fetch handler. | ||
self.addEventListener('fetch', event => {}); |
6 changes: 5 additions & 1 deletion
6
third_party/blink/web_tests/http/tests/serviceworker/resources/network-fallback-worker.js
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
self.addEventListener('fetch', event => { | ||
// Do nothing. | ||
// Actually does nothing, but trick to make this not recognized as | ||
// an empty fetch handler. Otherwise, the test timeout waiting | ||
// kServiceWorkerInterceptedRequestFromOriginDirtyStyleSheet in | ||
// usecounter-request-from-no-cors-style-sheet.html | ||
let a = 0; | ||
}); |
52 changes: 52 additions & 0 deletions
52
third_party/blink/web_tests/http/tests/serviceworker/subresource-load-with-skip-handler.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,52 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title> | ||
The subresource load should not be blocked by skipping the fetch handler. | ||
</title> | ||
<!-- This cannot be upstreamed to WPT because it test uses Chrome's UseCounter | ||
mechanism. --> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/test-helpers.js"></script> | ||
<script> | ||
function isUseCounted(win, feature) { | ||
return win.internals.isUseCounted(win.document, feature); | ||
} | ||
|
||
function observeUseCounter(win, feature) { | ||
return win.internals.observeUseCounter(win.document, feature); | ||
} | ||
|
||
function addStyleSheet(win, href) { | ||
const link = win.document.createElement('link'); | ||
link.rel = 'stylesheet'; | ||
link.href = href; | ||
win.document.head.appendChild(link); | ||
} | ||
|
||
const scope = 'resources/simple.html'; | ||
// |kServiceWorkerNotHandledSubresourceLoad| in web_feature.mojom. | ||
const kFeature = 4363; | ||
|
||
promise_test(async t => { | ||
const registration = await service_worker_unregister_and_register( | ||
t, 'resources/empty-fetch-handler.js', scope); | ||
t.add_cleanup(() => { registration.unregister(); }); | ||
await wait_for_state(t, registration.installing, 'activated'); | ||
|
||
// Set up the iframe in the scope. | ||
const frame = await with_iframe('resources/simple.html'); | ||
t.add_cleanup(() => { frame.remove(); }); | ||
const win = frame.contentWindow; | ||
|
||
// Ensure that the window is controlled by the service worker. | ||
assert_not_equals(win.navigator.serviceWorker.controller, null); | ||
|
||
// The stylesheet loaded at the page controlled by the service worker. | ||
addStyleSheet(win, 'font-face.css'); | ||
|
||
// Ensure the service worker has been skipped. | ||
await observeUseCounter(win, kFeature); | ||
assert_true(isUseCounted(win, kFeature)); | ||
}, 'An empty service worker handler should be skipped for loading subresource'); | ||
</script> |
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