Skip to content

Commit

Permalink
Bug 1659563 [wpt PR 25053] - Allow range requests to pass through a s…
Browse files Browse the repository at this point in the history
…ervice worker, a=testonly

Automatic update from web-platform-tests
Allow range requests to pass through a service worker (#25053)

This change implements the following edits to the Fetch spec:
whatwg/fetch#560
whatwg/fetch#1076

Existing web tests cover the new functionality.

Bug: 847428
Change-Id: Ie63704769e99d4b8d26d8903edf4cc4e3466c124
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339761
Commit-Queue: Nicolas Arciniega <niarci@microsoft.com>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800663}

Co-authored-by: Nicolas Arciniega <niarci@microsoft.com>
--

wpt-commits: 868ca3586f9dda74b2bb3b6f6dfb67a13e359090
wpt-pr: 25053
  • Loading branch information
chromium-wpt-export-bot authored and moz-wptsync-bot committed Aug 27, 2020
1 parent 3a484ff commit e4556cd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions testing/web-platform/tests/fetch/range/sw.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {});

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-add.js"></script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-put.js"></script>
<script>
Expand Down

0 comments on commit e4556cd

Please sign in to comment.