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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-delete.js

Issue 2790143003: Cache Storage API tests: Fix WPT test bugs, remove redundant local copies (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-delete.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-delete.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-delete.js
index bf7841a7e5f6255e5ae8f4ebdabd2872a6fa9514..3cf9aeb4c23a9f7ad1d5433f2d5f4e46e4e8fdd1 100644
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-delete.js
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-delete.js
@@ -71,10 +71,40 @@ cache_test(function(cache) {
.then(function(result) {
assert_response_equals(result, response,
'Cache.delete should leave non-matching response in the cache.');
+ return cache.delete(new Request(test_url, {method: 'HEAD'}),
+ {ignoreMethod: true});
+ })
+ .then(function(result) {
+ assert_true(result,
+ 'Cache.delete should match a non-GET request ' +
+ ' if ignoreMethod is true.');
});
}, 'Cache.delete called with a HEAD request');
cache_test(function(cache) {
+ var vary_request = new Request('http://example.com/c',
+ {headers: {'Cookies': 'is-for-cookie'}});
+ var vary_response = new Response('', {headers: {'Vary': 'Cookies'}});
+ var mismatched_vary_request = new Request('http://example.com/c');
+
+ return cache.put(vary_request.clone(), vary_response.clone())
+ .then(function() {
+ return cache.delete(mismatched_vary_request.clone());
+ })
+ .then(function(result) {
+ assert_false(result,
+ 'Cache.delete should not delete if vary does not ' +
+ 'match unless ignoreVary is true');
+ return cache.delete(mismatched_vary_request.clone(),
+ {ignoreVary: true});
+ })
+ .then(function(result) {
+ assert_true(result,
+ 'Cache.delete should ignore vary if ignoreVary is true');
+ });
+ }, 'Cache.delete supports ignoreVary');
+
+cache_test(function(cache) {
return cache.delete(test_url)
.then(function(result) {
assert_false(result,
@@ -83,33 +113,52 @@ cache_test(function(cache) {
});
}, 'Cache.delete with a non-existent entry');
-var cache_entries = {
- a: {
- request: new Request('http://example.com/abc'),
- response: new Response('')
+prepopulated_cache_test(simple_entries, function(cache, entries) {
+ return cache.matchAll(entries.a_with_query.request,
+ { ignoreSearch: true })
+ .then(function(result) {
+ assert_response_array_equals(
+ result,
+ [
+ entries.a.response,
+ entries.a_with_query.response
+ ]);
+ return cache.delete(entries.a_with_query.request,
+ { ignoreSearch: true });
+ })
+ .then(function(result) {
+ return cache.matchAll(entries.a_with_query.request,
+ { ignoreSearch: true });
+ })
+ .then(function(result) {
+ assert_response_array_equals(result, []);
+ });
},
+ 'Cache.delete with ignoreSearch option (request with search parameters)');
- b: {
- request: new Request('http://example.com/b'),
- response: new Response('')
+prepopulated_cache_test(simple_entries, function(cache, entries) {
+ return cache.matchAll(entries.a_with_query.request,
+ { ignoreSearch: true })
+ .then(function(result) {
+ assert_response_array_equals(
+ result,
+ [
+ entries.a.response,
+ entries.a_with_query.response
+ ]);
+ // cache.delete()'s behavior should be the same if ignoreSearch is
+ // not provided or if ignoreSearch is false.
+ return cache.delete(entries.a_with_query.request,
+ { ignoreSearch: false });
+ })
+ .then(function(result) {
+ return cache.matchAll(entries.a_with_query.request,
+ { ignoreSearch: true });
+ })
+ .then(function(result) {
+ assert_response_array_equals(result, [ entries.a.response ]);
+ });
},
-
- a_with_query: {
- request: new Request('http://example.com/abc?q=r'),
- response: new Response('')
- }
-};
-
-function prepopulated_cache_test(test_function, description) {
- cache_test(function(cache) {
- return Promise.all(Object.keys(cache_entries).map(function(k) {
- return cache.put(cache_entries[k].request.clone(),
- cache_entries[k].response.clone());
- }))
- .then(function() {
- return test_function(cache);
- });
- }, description);
-}
+ 'Cache.delete with ignoreSearch option (when it is specified as false)');
done();

Powered by Google App Engine
This is Rietveld 408576698