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

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

Issue 1049983003: [Fetch] Body consume function should not set bodyUsed flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@stream-clone
Patch Set: 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
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('/resources/testharness.js'); 2 importScripts('/resources/testharness.js');
3 importScripts('/resources/testharness-helpers.js'); 3 importScripts('/resources/testharness-helpers.js');
4 importScripts('../resources/test-helpers.js'); 4 importScripts('../resources/test-helpers.js');
5 } 5 }
6 6
7 var test_url = 'https://example.com/foo'; 7 var test_url = 'https://example.com/foo';
8 var test_body = 'Hello world!'; 8 var test_body = 'Hello world!';
9 9
10 cache_test(function(cache) { 10 cache_test(function(cache) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 cache.put(request, new Response(test_body)), 305 cache.put(request, new Response(test_body)),
306 new TypeError(), 306 new TypeError(),
307 'Cache.put should throw a TypeError for a request with used body.'); 307 'Cache.put should throw a TypeError for a request with used body.');
308 }, 'Cache.put with a used request body'); 308 }, 'Cache.put with a used request body');
309 309
310 cache_test(function(cache) { 310 cache_test(function(cache) {
311 var response = new Response(test_body); 311 var response = new Response(test_body);
312 assert_false(response.bodyUsed, 312 assert_false(response.bodyUsed,
313 '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + 313 '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
314 'Response.bodyUsed should be initially false.'); 314 'Response.bodyUsed should be initially false.');
315 response.text().then(function() { 315 return response.text().then(function() {
316 assert_true( 316 assert_false(
317 response.bodyUsed, 317 response.bodyUsed,
318 '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' + 318 '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' +
319 'The text() method should consume the body of the response.'); 319 'The text() method should not set "body passed" flag.');
320 return assert_promise_rejects( 320 return cache.put(new Request(test_url), response);
321 cache.put(new Request(test_url), response),
322 new TypeError(),
323 'Cache.put should throw a TypeError for a response with used body.');
324 }); 321 });
325 }, 'Cache.put with a used response body'); 322 }, 'Cache.put with a used response body');
326 323
327 done(); 324 done();
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/cachestorage/script-tests/cache-add.js ('k') | LayoutTests/http/tests/fetch/script-tests/request.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698