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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/cache-delete-worker.js

Issue 882383002: [Fetch] Request with GET/HEAD method cannot have body (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 importScripts('worker-testharness.js'); 1 importScripts('worker-testharness.js');
2 importScripts('/resources/testharness-helpers.js'); 2 importScripts('/resources/testharness-helpers.js');
3 3
4 var test_url = 'https://example.com/foo'; 4 var test_url = 'https://example.com/foo';
5 5
6 // Construct a generic Request object. The URL is |test_url|. All other fields 6 // Construct a generic Request object. The URL is |test_url|. All other fields
7 // are defaults. 7 // are defaults.
8 function new_test_request() { 8 function new_test_request() {
9 return new Request(test_url); 9 return new Request(test_url);
10 } 10 }
(...skipping 23 matching lines...) Expand all
34 }) 34 })
35 .then(function() { 35 .then(function() {
36 assert_promise_rejects( 36 assert_promise_rejects(
37 cache.match(test_url), 37 cache.match(test_url),
38 'NotFoundError', 38 'NotFoundError',
39 'Cache.delete should remove matching entries from cache.'); 39 'Cache.delete should remove matching entries from cache.');
40 }); 40 });
41 }, 'Cache.delete called with a string URL'); 41 }, 'Cache.delete called with a string URL');
42 42
43 cache_test(function(cache) { 43 cache_test(function(cache) {
44 var request = new Request(test_url, { body: 'Abc' }); 44 var request = new Request(test_url, { method: 'POST', body: 'Abc' });
45 return cache.put(request.clone(), new_test_response()) 45 return cache.put(request.clone(), new_test_response())
46 .then(function() { 46 .then(function() {
47 return cache.delete(request); 47 return cache.delete(request);
48 }) 48 })
49 .then(function(result) { 49 .then(function(result) {
50 assert_true(result, 50 assert_true(result,
51 'Cache.delete should resolve with "true" if an entry ' + 51 'Cache.delete should resolve with "true" if an entry ' +
52 'was successfully deleted.'); 52 'was successfully deleted.');
53 assert_false(request.bodyUsed, 53 assert_false(request.bodyUsed,
54 'Cache.delete should not consume request body.'); 54 'Cache.delete should not consume request body.');
55 }); 55 });
56 }, 'Cache.delete called with a Request object'); 56 }, 'Cache.delete called with a Request object');
57 57
58 cache_test(function(cache) { 58 cache_test(function(cache) {
59 var request = new Request(test_url, { body: 'Abc' }); 59 var request = new Request(test_url, { method: 'POST', body: 'Abc' });
60 return cache.put(request.clone(), new_test_response()) 60 return cache.put(request.clone(), new_test_response())
61 .then(function() { 61 .then(function() {
62 return request.text(); 62 return request.text();
63 }) 63 })
64 .then(function() { 64 .then(function() {
65 assert_true(request.bodyUsed, 65 assert_true(request.bodyUsed,
66 '[https://fetch.spec.whatwg.org/#body-mixin] ' + 66 '[https://fetch.spec.whatwg.org/#body-mixin] ' +
67 'Request.bodyUsed should be true after text() method ' + 67 'Request.bodyUsed should be true after text() method ' +
68 'resolves.'); 68 'resolves.');
69 }) 69 })
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 prepopulated_cache_test(function(cache) { 149 prepopulated_cache_test(function(cache) {
150 return cache.delete('http://example.com/ac', { prefixMatch: true }) 150 return cache.delete('http://example.com/ac', { prefixMatch: true })
151 .then(function(result) { 151 .then(function(result) {
152 assert_false(result, 152 assert_false(result,
153 'Cache.delete should resolve with "false" if there ' + 153 'Cache.delete should resolve with "false" if there ' +
154 'are no matching entries.'); 154 'are no matching entries.');
155 }); 155 });
156 }, 'Cache.delete with CacheQueryOptions.* that don\'t match'); 156 }, 'Cache.delete with CacheQueryOptions.* that don\'t match');
157 157
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698