Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html

Issue 2105503002: Skip foreign fetch when the skipServiceWorker flag is set on a request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rephrase SkipServiceWorker comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
index f6392ffd3afde54abbdb74682cf2f6e22c8dcdc6..0dda3745f9d1c74ee787328527ba13f0a98c36ba 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html
@@ -115,7 +115,7 @@ promise_test(t => {
var ff_scope = 'foreign-fetch/scope/controlled?basic';
var remote_url =
host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope;
- var scope = 'resources/simple.html';
+ var scope = 'resources/simple.html?fetch';
var worker = 'resources/empty-worker.js';
return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope)
.then(() => service_worker_unregister_and_register(t, worker, scope))
@@ -129,7 +129,32 @@ promise_test(t => {
.then(response_text => {
assert_equals(response_text, 'Foreign Fetch');
});
- }, 'Foreign fetch can intercept requests from SW controlled pages.');
+ }, 'Foreign fetch can intercept fetch requests from SW controlled pages.');
+
+promise_test(t => {
+ var ff_scope = 'foreign-fetch/scope/controlled?script';
+ var remote_url =
+ host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + ff_scope;
+ var scope = 'resources/simple.html?script';
+ var worker = 'resources/empty-worker.js';
+ return install_cross_origin_worker(t, worker_for_scopes(['']), ff_scope)
+ .then(() => service_worker_unregister_and_register(t, worker, scope))
+ .then(r => {
+ add_completion_callback(() => r.unregister());
+ return wait_for_state(t, r.installing, 'activated');
+ })
+ .then(() => with_iframe(scope))
+ .then(frame => new Promise(resolve => {
+ frame.contentWindow.DidLoad = resolve;
+ let script = frame.contentWindow.document.createElement('script');
+ script.setAttribute('src', remote_url);
+ script.setAttribute('crossorigin', 'use-credentials');
+ frame.contentWindow.document.head.appendChild(script);
+ }))
+ .then(response_text => {
+ assert_equals(response_text, 'Foreign Fetch');
+ });
+ }, 'Foreign fetch can intercept resource requests from SW controlled pages.');
promise_test(t => {
var scope = 'simple.txt?meta';
@@ -183,5 +208,15 @@ promise_test(t => {
'Error: TypeError: Failed to fetch'));
}, 'Service Worker does not intercept fetches from an insecure context.');
+promise_test(t => {
+ var scope = 'fetch-access-control.php?basic&ACAOrigin=*&ACAMethods=SPECIAL';
+ var remote_url =
+ host_info.HTTPS_REMOTE_ORIGIN + '/serviceworker/resources/' + scope;
+ return install_cross_origin_worker(t, worker_for_scopes(['']), scope)
+ .then(() => fetch(remote_url, {method: 'SPECIAL'}))
+ .then(response => response.text())
+ .then(response_text => assert_true(response_text.startsWith('report(')));
+ }, 'Service Worker does not intercept fetches with CORS preflight');
+
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698