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

Side by Side Diff: LayoutTests/http/tests/cachestorage/script-tests/cache-put.js

Issue 1032623008: Expose Cache Storage API in global window/worker scope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update webexposed expectations Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 importScripts('worker-testharness.js'); 1 if (self.importScripts) {
2 importScripts('/resources/testharness-helpers.js'); 2 importScripts('/resources/testharness.js');
3 importScripts('override_assert_object_equals.js'); 3 importScripts('/resources/testharness-helpers.js');
4 importScripts('../resources/test-helpers.js');
5 }
4 6
5 var test_url = 'https://example.com/foo'; 7 var test_url = 'https://example.com/foo';
6 var test_body = 'Hello world!'; 8 var test_body = 'Hello world!';
7 9
8 cache_test(function(cache) { 10 cache_test(function(cache) {
9 var request = new Request(test_url); 11 var request = new Request(test_url);
10 var response = new Response(test_body); 12 var response = new Response(test_body);
11 return cache.put(request, response) 13 return cache.put(request, response)
12 .then(function(result) { 14 .then(function(result) {
13 assert_equals(result, undefined, 15 assert_equals(result, undefined,
14 'Cache.put should resolve with undefined on success.'); 16 'Cache.put should resolve with undefined on success.');
15 }); 17 });
16 }, 'Cache.put called with simple Request and Response'); 18 }, 'Cache.put called with simple Request and Response');
17 19
18 cache_test(function(cache) { 20 cache_test(function(cache) {
19 var test_url = new URL('simple.txt', location.href).href; 21 var test_url = new URL('../resources/simple.txt', location.href).href;
20 var request = new Request(test_url); 22 var request = new Request(test_url);
21 var response; 23 var response;
22 return fetch(test_url) 24 return fetch(test_url)
23 .then(function(fetch_result) { 25 .then(function(fetch_result) {
24 response = fetch_result.clone(); 26 response = fetch_result.clone();
25 return cache.put(request, fetch_result); 27 return cache.put(request, fetch_result);
26 }) 28 })
27 .then(function() { 29 .then(function() {
28 return cache.match(test_url); 30 return cache.match(test_url);
29 }) 31 })
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 'Cache.put should store headers.'); 120 'Cache.put should store headers.');
119 return result.text(); 121 return result.text();
120 }) 122 })
121 .then(function(body) { 123 .then(function(body) {
122 assert_equals(body, '', 124 assert_equals(body, '',
123 'Cache.put should store response body.'); 125 'Cache.put should store response body.');
124 }); 126 });
125 }, 'Cache.put with an empty response body'); 127 }, 'Cache.put with an empty response body');
126 128
127 cache_test(function(cache) { 129 cache_test(function(cache) {
128 var test_url = new URL('fetch-status.php?status=500', location.href).href; 130 var test_url = new URL('../resources/fetch-status.php?status=500', location. href).href;
129 var request = new Request(test_url); 131 var request = new Request(test_url);
130 var response; 132 var response;
131 return fetch(test_url) 133 return fetch(test_url)
132 .then(function(fetch_result) { 134 .then(function(fetch_result) {
133 assert_equals(fetch_result.status, 500, 135 assert_equals(fetch_result.status, 500,
134 'Test framework error: The status code should be 500.'); 136 'Test framework error: The status code should be 500.');
135 response = fetch_result.clone(); 137 response = fetch_result.clone();
136 return cache.put(request, fetch_result); 138 return cache.put(request, fetch_result);
137 }) 139 })
138 .then(function() { 140 .then(function() {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 assert_true( 316 assert_true(
315 response.bodyUsed, 317 response.bodyUsed,
316 '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' + 318 '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' +
317 'The text() method should consume the body of the response.'); 319 'The text() method should consume the body of the response.');
318 return assert_promise_rejects( 320 return assert_promise_rejects(
319 cache.put(new Request(test_url), response), 321 cache.put(new Request(test_url), response),
320 new TypeError(), 322 new TypeError(),
321 'Cache.put should throw a TypeError for a response with used body.'); 323 'Cache.put should throw a TypeError for a response with used body.');
322 }); 324 });
323 }, 'Cache.put with a used response body'); 325 }, 'Cache.put with a used response body');
326
327 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698