OLD | NEW |
(Empty) | |
| 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('/resources/testharness-helpers.js'); |
| 4 importScripts('../resources/test-helpers.js'); |
| 5 } |
| 6 |
| 7 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 8 return cache.keys('not-present-in-the-cache') |
| 9 .then(function(result) { |
| 10 assert_request_array_equivalent( |
| 11 result, [], |
| 12 'Cache.keys should resolve with an empty array on failure.'); |
| 13 }); |
| 14 }, 'Cache.keys with no matching entries'); |
| 15 |
| 16 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 17 return cache.keys(entries.a.request.url) |
| 18 .then(function(result) { |
| 19 assert_request_array_equals(result, [entries.a.request], |
| 20 'Cache.keys should match by URL.'); |
| 21 }); |
| 22 }, 'Cache.keys with URL'); |
| 23 |
| 24 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 25 return cache.keys(entries.a.request) |
| 26 .then(function(result) { |
| 27 assert_request_array_equals( |
| 28 result, [entries.a.request], |
| 29 'Cache.keys should match by Request.'); |
| 30 }); |
| 31 }, 'Cache.keys with Request'); |
| 32 |
| 33 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 34 return cache.keys(new Request(entries.a.request.url)) |
| 35 .then(function(result) { |
| 36 assert_request_array_equals( |
| 37 result, [entries.a.request], |
| 38 'Cache.keys should match by Request.'); |
| 39 }); |
| 40 }, 'Cache.keys with new Request'); |
| 41 |
| 42 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 43 return cache.keys(entries.a.request, |
| 44 {ignoreSearch: true}) |
| 45 .then(function(result) { |
| 46 assert_request_array_equivalent( |
| 47 result, |
| 48 [ |
| 49 entries.a.request, |
| 50 entries.a_with_query.request |
| 51 ], |
| 52 'Cache.keys with ignoreSearch should ignore the ' + |
| 53 'search parameters of cached request.'); |
| 54 }); |
| 55 }, |
| 56 'Cache.keys with ignoreSearch option (request with no search ' + |
| 57 'parameters)'); |
| 58 |
| 59 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 60 return cache.keys(entries.a_with_query.request, |
| 61 {ignoreSearch: true}) |
| 62 .then(function(result) { |
| 63 assert_request_array_equivalent( |
| 64 result, |
| 65 [ |
| 66 entries.a.request, |
| 67 entries.a_with_query.request |
| 68 ], |
| 69 'Cache.keys with ignoreSearch should ignore the ' + |
| 70 'search parameters of request.'); |
| 71 }); |
| 72 }, |
| 73 'Cache.keys with ignoreSearch option (request with search parameters)'); |
| 74 |
| 75 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 76 return cache.keys(entries.cat.request.url + '#mouse') |
| 77 .then(function(result) { |
| 78 assert_request_array_equivalent( |
| 79 result, |
| 80 [ |
| 81 entries.cat.request, |
| 82 ], |
| 83 'Cache.keys should ignore URL fragment.'); |
| 84 }); |
| 85 }, 'Cache.keys with URL containing fragment'); |
| 86 |
| 87 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 88 return cache.keys('http') |
| 89 .then(function(result) { |
| 90 assert_request_array_equivalent( |
| 91 result, [], |
| 92 'Cache.keys should treat query as a URL and not ' + |
| 93 'just a string fragment.'); |
| 94 }); |
| 95 }, 'Cache.keys with string fragment "http" as query'); |
| 96 |
| 97 prepopulated_cache_test(simple_entries, function(cache, entries) { |
| 98 return cache.keys() |
| 99 .then(function(result) { |
| 100 assert_request_array_equivalent( |
| 101 result, |
| 102 [ |
| 103 entries.a.request, |
| 104 entries.b.request, |
| 105 entries.a_with_query.request, |
| 106 entries.A.request, |
| 107 entries.a_https.request, |
| 108 entries.a_org.request, |
| 109 entries.cat.request, |
| 110 entries.catmandu.request, |
| 111 entries.cat_num_lives.request, |
| 112 entries.cat_in_the_hat.request, |
| 113 entries.non_2xx_response.request, |
| 114 entries.error_response.request |
| 115 ], |
| 116 'Cache.keys without parameters should match all entries.'); |
| 117 }); |
| 118 }, 'Cache.keys without parameters'); |
| 119 |
| 120 done(); |
OLD | NEW |