Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-matchAll.js |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-matchAll.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-matchAll.js |
index feace5a9899db9f171dedfbc63e3bebb33786f77..b7c7bd63785c3b757c325ffab20daa5c848f4a39 100644 |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-matchAll.js |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/script-tests/cache-matchAll.js |
@@ -6,7 +6,7 @@ if (self.importScripts) { |
prepopulated_cache_test(simple_entries, function(cache, entries) { |
return cache.matchAll('not-present-in-the-cache') |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, [], |
'Cache.matchAll should resolve with an empty array on failure.'); |
}); |
@@ -52,7 +52,7 @@ prepopulated_cache_test(simple_entries, function(cache, entries) { |
return cache.matchAll(entries.a.request, |
{ignoreSearch: true}) |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[ |
entries.a.response, |
@@ -69,7 +69,7 @@ prepopulated_cache_test(simple_entries, function(cache, entries) { |
return cache.matchAll(entries.a_with_query.request, |
{ignoreSearch: true}) |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[ |
entries.a.response, |
@@ -79,12 +79,62 @@ prepopulated_cache_test(simple_entries, function(cache, entries) { |
'search parameters of request.'); |
}); |
}, |
- 'Cache.matchAll with ignoreSearch option (request with search parameter)'); |
+ 'Cache.matchAll with ignoreSearch option (request with search parameters)'); |
+ |
+cache_test(function(cache) { |
+ var request = new Request('http://example.com/'); |
+ var head_request = new Request('http://example.com/', {method: 'HEAD'}); |
+ var response = new Response('foo'); |
+ return cache.put(request.clone(), response.clone()) |
+ .then(function() { |
+ return cache.matchAll(head_request.clone()); |
+ }) |
+ .then(function(result) { |
+ assert_response_array_equals( |
+ result, [], |
+ 'Cache.matchAll should resolve with empty array for a ' + |
+ 'mismatched method.'); |
+ return cache.matchAll(head_request.clone(), |
+ {ignoreMethod: true}); |
+ }) |
+ .then(function(result) { |
+ assert_response_array_equals( |
+ result, [response], |
+ 'Cache.matchAll with ignoreMethod should ignore the ' + |
+ 'method of request.'); |
+ }); |
+ }, 'Cache.matchAll supports ignoreMethod'); |
+ |
+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.matchAll(mismatched_vary_request.clone()); |
+ }) |
+ .then(function(result) { |
+ assert_response_array_equals( |
+ result, [], |
+ 'Cache.matchAll should resolve as undefined with a ' + |
+ 'mismatched vary.'); |
+ return cache.matchAll(mismatched_vary_request.clone(), |
+ {ignoreVary: true}); |
+ }) |
+ .then(function(result) { |
+ assert_response_array_equals( |
+ result, [vary_response], |
+ 'Cache.matchAll with ignoreVary should ignore the ' + |
+ 'vary of request.'); |
+ }); |
+ }, 'Cache.matchAll supports ignoreVary'); |
prepopulated_cache_test(simple_entries, function(cache, entries) { |
return cache.matchAll(entries.cat.request.url + '#mouse') |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[ |
entries.cat.response, |
@@ -96,17 +146,40 @@ prepopulated_cache_test(simple_entries, function(cache, entries) { |
prepopulated_cache_test(simple_entries, function(cache, entries) { |
return cache.matchAll('http') |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, [], |
'Cache.matchAll should treat query as a URL and not ' + |
'just a string fragment.'); |
}); |
}, 'Cache.matchAll with string fragment "http" as query'); |
+prepopulated_cache_test(simple_entries, function(cache, entries) { |
+ return cache.matchAll() |
+ .then(function(result) { |
+ assert_response_array_equals( |
+ result, |
+ [ |
+ entries.a.response, |
+ entries.b.response, |
+ entries.a_with_query.response, |
+ entries.A.response, |
+ entries.a_https.response, |
+ entries.a_org.response, |
+ entries.cat.response, |
+ entries.catmandu.response, |
+ entries.cat_num_lives.response, |
+ entries.cat_in_the_hat.response, |
+ entries.non_2xx_response.response, |
+ entries.error_response.response |
+ ], |
+ 'Cache.matchAll without parameters should match all entries.'); |
+ }); |
+ }, 'Cache.matchAll without parameters'); |
+ |
prepopulated_cache_test(vary_entries, function(cache, entries) { |
return cache.matchAll('http://example.com/c') |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[ |
entries.vary_cookie_absent.response |
@@ -122,7 +195,7 @@ prepopulated_cache_test(vary_entries, function(cache, entries) { |
{headers: {'Cookies': 'none-of-the-above'}})); |
}) |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[ |
], |
@@ -137,7 +210,7 @@ prepopulated_cache_test(vary_entries, function(cache, entries) { |
{headers: {'Cookies': 'is-for-cookie'}})); |
}) |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[entries.vary_cookie_is_cookie.response], |
'Cache.matchAll should match the entire header if a vary header ' + |
@@ -149,15 +222,16 @@ prepopulated_cache_test(vary_entries, function(cache, entries) { |
return cache.matchAll('http://example.com/c', |
{ignoreVary: true}) |
.then(function(result) { |
- assert_response_array_equivalent( |
+ assert_response_array_equals( |
result, |
[ |
entries.vary_cookie_is_cookie.response, |
entries.vary_cookie_is_good.response, |
entries.vary_cookie_absent.response |
], |
- 'Cache.matchAll should honor "ignoreVary" parameter.'); |
+ 'Cache.matchAll should support multiple vary request/response ' + |
+ 'pairs.'); |
}); |
- }, 'Cache.matchAll with "ignoreVary" parameter'); |
+ }, 'Cache.matchAll with multiple vary pairs'); |
done(); |