зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1450612 [wpt PR 10265] - Set SkipServiceWorker flag for synchronous loads from the main thread., a=testonly
Automatic update from web-platform-testsSet SkipServiceWorker flag for synchronous loads from the main thread. Before 5e1b52dd7e828fb2e4bd69f599c0c30eec3e873c, synchronous XHR on worker was handled by service workers. It is because the |is_sync_load| was false when the sync request is from worker thread. But after the CL, the |is_sync_load| flag for the sync request from worker became true, so the request will not go to the service worker. This CL will fix this by - Set the SkipServiceWorker flag for synchronous loads from the main thread in the renderer process. (FetchParameters.cpp) - Don't set skip_service_worker even if is_sync_load is true in the browser process. (resource_dispatcher_host_impl.cc) Bug: 706331,827473 Change-Id: I186bc97f3f8d298e0a04942d0ec4b708b3022cc1 Reviewed-on: https://chromium-review.googlesource.com/989376 Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Cr-Commit-Position: refs/heads/master@{#547407} wpt-commits: d68f044162867a8283c6d4adbf19e9587b6ea2fa wpt-pr: 10265 wpt-commits: d68f044162867a8283c6d4adbf19e9587b6ea2fa wpt-pr: 10265
This commit is contained in:
Родитель
978ec810c5
Коммит
bf32f73ed5
|
@ -292864,6 +292864,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/resources/fetch-request-xhr-sync-on-worker-worker.js": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/resources/fetch-request-xhr-sync-worker.js": [
|
||||
[
|
||||
{}
|
||||
|
@ -361615,6 +361620,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/fetch-request-xhr-sync-on-worker.https.html": [
|
||||
[
|
||||
"/service-workers/service-worker/fetch-request-xhr-sync-on-worker.https.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/fetch-request-xhr-sync.https.html": [
|
||||
[
|
||||
"/service-workers/service-worker/fetch-request-xhr-sync.https.html",
|
||||
|
@ -594206,6 +594217,10 @@
|
|||
"d21ef5a4263e26cd3053a89171e2597424eaad82",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/fetch-request-xhr-sync-on-worker.https.html": [
|
||||
"aca28d4ad02c803873bea5fc922b8e4d427ccc4b",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/fetch-request-xhr-sync.https.html": [
|
||||
"4aaa0b1995643f4e18c47d1947476a1a67fe997d",
|
||||
"testharness"
|
||||
|
@ -595014,6 +595029,10 @@
|
|||
"a168a0326207e734f0229d49cce12af9a37e81ec",
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/fetch-request-xhr-sync-on-worker-worker.js": [
|
||||
"0b7167334e08425c399bb7fa189cf7c55e480633",
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/fetch-request-xhr-sync-worker.js": [
|
||||
"fe1386a87464c16d62e23eb102b25891960e7209",
|
||||
"support"
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Service Worker: Synchronous XHR on Worker is intercepted</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
promise_test((t) => {
|
||||
const url = 'resources/fetch-request-xhr-sync-on-worker-worker.js';
|
||||
const scope = 'resources/fetch-request-xhr-sync-on-worker-scope/';
|
||||
const non_existent_file = 'non-existent-file.txt';
|
||||
|
||||
// In Chromium, the service worker scope matching for workers is based on
|
||||
// the URL of the parent HTML. So this test creates an iframe which is
|
||||
// controlled by the service worker first, and creates a worker from the
|
||||
// iframe.
|
||||
return service_worker_unregister_and_register(t, url, scope)
|
||||
.then((registration) => {
|
||||
t.add_cleanup(() => registration.unregister());
|
||||
return wait_for_state(t, registration.installing, 'activated');
|
||||
})
|
||||
.then(() => { return with_iframe(scope + 'iframe_page'); })
|
||||
.then((frame) => {
|
||||
t.add_cleanup(() => frame.remove());
|
||||
return frame.contentWindow.performSyncXHROnWorker(non_existent_file);
|
||||
})
|
||||
.then((result) => {
|
||||
assert_equals(
|
||||
result.status,
|
||||
200,
|
||||
'HTTP response status code for intercepted request'
|
||||
);
|
||||
assert_equals(
|
||||
result.responseText,
|
||||
'Response from service worker',
|
||||
'HTTP response text for intercepted request'
|
||||
);
|
||||
});
|
||||
}, 'Verify SyncXHR on Worker is intercepted');
|
||||
</script>
|
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
self.onfetch = function(event) {
|
||||
if (event.request.url.indexOf('non-existent-file.txt') !== -1) {
|
||||
event.respondWith(new Response('Response from service worker'));
|
||||
} else if (event.request.url.indexOf('/iframe_page') !== -1) {
|
||||
event.respondWith(new Response(
|
||||
'<!DOCTYPE html>\n' +
|
||||
'<script>\n' +
|
||||
'function performSyncXHROnWorker(url) {\n' +
|
||||
' return new Promise((resolve) => {\n' +
|
||||
' var worker =\n' +
|
||||
' new Worker(\'./worker_script\');\n' +
|
||||
' worker.addEventListener(\'message\', (msg) => {\n' +
|
||||
' resolve(msg.data);\n' +
|
||||
' });\n' +
|
||||
' worker.postMessage({\n' +
|
||||
' url: url\n' +
|
||||
' });\n' +
|
||||
' });\n' +
|
||||
'}\n' +
|
||||
'</script>',
|
||||
{
|
||||
headers: [['content-type', 'text/html']]
|
||||
}));
|
||||
} else if (event.request.url.indexOf('/worker_script') !== -1) {
|
||||
event.respondWith(new Response(
|
||||
'self.onmessage = (msg) => {' +
|
||||
' const syncXhr = new XMLHttpRequest();' +
|
||||
' syncXhr.open(\'GET\', msg.data.url, false);' +
|
||||
' syncXhr.send();' +
|
||||
' self.postMessage({' +
|
||||
' status: syncXhr.status,' +
|
||||
' responseText: syncXhr.responseText' +
|
||||
' });' +
|
||||
'}',
|
||||
{
|
||||
headers: [['content-type', 'application/javascript']]
|
||||
}));
|
||||
}
|
||||
};
|
Загрузка…
Ссылка в новой задаче