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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/cachestorage/script-tests/cache-delete.js

Issue 2204683002: Cache API should not match() HEAD requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add keys()/delete() tests, fix found issues Created 4 years, 4 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/test-helpers.js'); 3 importScripts('../resources/test-helpers.js');
4 } 4 }
5 5
6 var test_url = 'https://example.com/foo'; 6 var test_url = 'https://example.com/foo';
7 7
8 // Construct a generic Request object. The URL is |test_url|. All other fields 8 // Construct a generic Request object. The URL is |test_url|. All other fields
9 // are defaults. 9 // are defaults.
10 function new_test_request() { 10 function new_test_request() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return cache.delete(request); 49 return cache.delete(request);
50 }) 50 })
51 .then(function(result) { 51 .then(function(result) {
52 assert_true(result, 52 assert_true(result,
53 'Cache.delete should resolve with "true" if an entry ' + 53 'Cache.delete should resolve with "true" if an entry ' +
54 'was successfully deleted.'); 54 'was successfully deleted.');
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);
60 var response = new_test_response();
61 return cache.put(request, response)
62 .then(function() {
63 return cache.delete(new Request(test_url, {method: 'HEAD'}));
64 })
65 .then(function(result) {
66 assert_false(result,
67 'Cache.delete should not match a non-GET request ' +
68 'unless ignoreMethod option is set.');
69 return cache.match(test_url);
70 })
71 .then(function(result) {
72 assert_response_equals(result, response,
73 'Cache.delete should leave non-matching response in the cache.');
74 });
75 }, 'Cache.delete called with a HEAD request');
76
77
78 cache_test(function(cache) {
59 return cache.delete(test_url) 79 return cache.delete(test_url)
60 .then(function(result) { 80 .then(function(result) {
61 assert_false(result, 81 assert_false(result,
62 'Cache.delete should resolve with "false" if there ' + 82 'Cache.delete should resolve with "false" if there ' +
63 'are no matching entries.'); 83 'are no matching entries.');
64 }); 84 });
65 }, 'Cache.delete with a non-existent entry'); 85 }, 'Cache.delete with a non-existent entry');
66 86
67 prepopulated_cache_test(simple_entries, function(cache, entries) { 87 prepopulated_cache_test(simple_entries, function(cache, entries) {
68 return cache.matchAll(entries.a_with_query.request, 88 return cache.matchAll(entries.a_with_query.request,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return cache.matchAll(entries.a_with_query.request, 126 return cache.matchAll(entries.a_with_query.request,
107 { ignoreSearch: true }); 127 { ignoreSearch: true });
108 }) 128 })
109 .then(function(result) { 129 .then(function(result) {
110 assert_response_array_equivalent(result, [ entries.a.response ]); 130 assert_response_array_equivalent(result, [ entries.a.response ]);
111 }); 131 });
112 }, 132 },
113 'Cache.delete with ignoreSearch option (when it is specified as false)'); 133 'Cache.delete with ignoreSearch option (when it is specified as false)');
114 134
115 done(); 135 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698