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