Skip to content

Commit

Permalink
Add WPT tests for blocking 206 response. r=bkelly.
Browse files Browse the repository at this point in the history
  • Loading branch information
chihweitung authored and jgraham committed Jan 3, 2017
1 parent f729d72 commit 0722399
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions service-workers/cache-storage/script-tests/cache-add.js
Expand Up @@ -83,6 +83,26 @@ cache_test(function(cache) {
});
}, 'Cache.add with request with null body (not consumed)');

cache_test(function(cache, test) {
return assert_promise_rejects(
test,
new TypeError(),
cache.add('../resources/fetch-status.py?status=206'),
'Cache.add should reject on partial response');
}, 'Cache.add 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) {
return new Request(url);
});
return promise_rejects(
new TypeError(),
cache.addAll(requests),
'Cache.addAll should reject with TypeError if any request fails');
}, 'Cache.addAll with 206 response');

cache_test(function(cache, test) {
return promise_rejects(
test,
Expand All @@ -91,6 +111,7 @@ cache_test(function(cache, test) {
'Cache.add should reject if response is !ok');
}, 'Cache.add with request that results in a status of 404');


cache_test(function(cache, test) {
return promise_rejects(
test,
Expand Down
13 changes: 13 additions & 0 deletions service-workers/cache-storage/script-tests/cache-put.js
Expand Up @@ -102,6 +102,19 @@ cache_test(function(cache) {
});
}, 'Cache.put with an empty response body');

cache_test(function(cache) {
var request = new Request(test_url);
var response = new Response('', {
status: 206,
headers: [['Content-Type', 'text/plain']]
});

return assert_promise_rejects(
cache.put(request, response),
new TypeError(),
'Cache.put should reject 206 Responses with a TypeError.');
}, 'Cache.put with 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

0 comments on commit 0722399

Please sign in to comment.