diff --git a/testing/web-platform/tests/fetch/range/sw.https.window.js b/testing/web-platform/tests/fetch/range/sw.https.window.js index 625e513a8133a..76f80e9416c61 100644 --- a/testing/web-platform/tests/fetch/range/sw.https.window.js +++ b/testing/web-platform/tests/fetch/range/sw.https.window.js @@ -86,11 +86,11 @@ promise_test(async t => { // Fetching should reject const fetchPromise = w.fetch('?action=use-stored-ranged-response', { mode: 'no-cors' }); - promise_rejects_js(t, TypeError, fetchPromise); + await promise_rejects_js(t, w.TypeError, fetchPromise); // Script loading should error too const loadScriptPromise = loadScript('?action=use-stored-ranged-response', { doc: w.document }); - promise_rejects_js(t, Error, loadScriptPromise); + await promise_rejects_js(t, Error, loadScriptPromise); await loadScriptPromise.catch(() => {}); diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js index f1617109cfa13..62b44c7880168 100644 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-add.js @@ -1,8 +1,11 @@ if (self.importScripts) { importScripts('/resources/testharness.js'); + importScripts('/common/get-host-info.sub.js'); importScripts('../resources/test-helpers.js'); } +const { REMOTE_HOST } = get_host_info(); + cache_test(function(cache, test) { return promise_rejects_js( test, @@ -104,6 +107,21 @@ cache_test(function(cache, test) { 'Cache.addAll should reject with TypeError if any request fails'); }, 'Cache.addAll with 206 response'); +cache_test(function(cache, test) { + var urls = ['../resources/fetch-status.py?status=206', + '../resources/fetch-status.py?status=200']; + var requests = urls.map(function(url) { + var cross_origin_url = new URL(url, location.href); + cross_origin_url.hostname = REMOTE_HOST; + return new Request(cross_origin_url.href, { mode: 'no-cors' }); + }); + return promise_rejects_js( + test, + TypeError, + cache.addAll(requests), + 'Cache.addAll should reject with TypeError if any request fails'); + }, 'Cache.addAll with opaque-filtered 206 response'); + cache_test(function(cache, test) { return promise_rejects_js( test, diff --git a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js index 44ba565d86ca0..b45910a3b8ba0 100644 --- a/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js +++ b/testing/web-platform/tests/service-workers/cache-storage/script-tests/cache-put.js @@ -1,10 +1,12 @@ if (self.importScripts) { importScripts('/resources/testharness.js'); + importScripts('/common/get-host-info.sub.js'); importScripts('../resources/test-helpers.js'); } var test_url = 'https://example.com/foo'; var test_body = 'Hello world!'; +const { REMOTE_HOST } = get_host_info(); cache_test(function(cache) { var request = new Request(test_url); @@ -129,6 +131,23 @@ cache_test(function(cache, test) { }); }, 'Cache.put with HTTP 206 response'); +cache_test(function(cache, test) { + var test_url = new URL('../resources/fetch-status.py?status=206', location.href); + test_url.hostname = REMOTE_HOST; + var request = new Request(test_url.href, { mode: 'no-cors' }); + var response; + return fetch(request) + .then(function(fetch_result) { + assert_equals(fetch_result.type, 'opaque', + 'Test framework error: The response type should be opaque.'); + assert_equals(fetch_result.status, 0, + 'Test framework error: The status code should be 0 for an ' + + ' opaque-filtered response. This is actually HTTP 206.'); + response = fetch_result.clone(); + return promise_rejects_js(test, TypeError, cache.put(request, fetch_result)); + }); + }, 'Cache.put with opaque-filtered HTTP 206 response'); + cache_test(function(cache) { var test_url = new URL('../resources/fetch-status.py?status=500', location.href).href; var request = new Request(test_url); diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html index 8dfb786cf3567..b5a64c6c369b5 100644 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-add.https.html @@ -4,5 +4,6 @@ + diff --git a/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html b/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html index 1ee14bdd124ee..9641c34705186 100644 --- a/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html +++ b/testing/web-platform/tests/service-workers/cache-storage/window/cache-put.https.html @@ -4,6 +4,7 @@ +