OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
3 importScripts('/resources/testharness-helpers.js'); | 3 importScripts('/resources/testharness-helpers.js'); |
4 importScripts('../resources/test-helpers.js'); | 4 importScripts('../resources/test-helpers.js'); |
5 } | 5 } |
6 | 6 |
7 prepopulated_cache_test(simple_entries, function(cache, entries) { | 7 prepopulated_cache_test(simple_entries, function(cache, entries) { |
8 return cache.matchAll('not-present-in-the-cache') | 8 return cache.matchAll('not-present-in-the-cache') |
9 .then(function(result) { | 9 .then(function(result) { |
10 assert_array_equivalent( | 10 assert_response_array_equivalent( |
11 result, [], | 11 result, [], |
12 'Cache.matchAll should resolve with an empty array on failure.'); | 12 'Cache.matchAll should resolve with an empty array on failure.'); |
13 }); | 13 }); |
14 }, 'Cache.matchAll with no matching entries'); | 14 }, 'Cache.matchAll with no matching entries'); |
15 | 15 |
16 prepopulated_cache_test(simple_entries, function(cache, entries) { | 16 prepopulated_cache_test(simple_entries, function(cache, entries) { |
17 return cache.matchAll(entries.a.request.url) | 17 return cache.matchAll(entries.a.request.url) |
18 .then(function(result) { | 18 .then(function(result) { |
19 assert_array_equivalent(result, [entries.a.response], | 19 assert_response_array_equivalent(result, [entries.a.response], |
20 'Cache.matchAll should match by URL.'); | 20 'Cache.matchAll should match by URL.'); |
21 }); | 21 }); |
22 }, 'Cache.matchAll with URL'); | 22 }, 'Cache.matchAll with URL'); |
23 | 23 |
24 prepopulated_cache_test(simple_entries, function(cache, entries) { | 24 prepopulated_cache_test(simple_entries, function(cache, entries) { |
25 return cache.matchAll(entries.a.request) | 25 return cache.matchAll(entries.a.request) |
26 .then(function(result) { | 26 .then(function(result) { |
27 assert_array_equivalent(result, [entries.a.response], | 27 assert_response_array_equivalent(result, [entries.a.response], |
28 'Cache.matchAll should match by Request.'); | 28 'Cache.matchAll should match by Request.'); |
29 }); | 29 }); |
30 }, 'Cache.matchAll with Request'); | 30 }, 'Cache.matchAll with Request'); |
31 | 31 |
32 prepopulated_cache_test(simple_entries, function(cache, entries) { | 32 prepopulated_cache_test(simple_entries, function(cache, entries) { |
33 return cache.matchAll(new Request(entries.a.request.url)) | 33 return cache.matchAll(new Request(entries.a.request.url)) |
34 .then(function(result) { | 34 .then(function(result) { |
35 assert_array_equivalent(result, [entries.a.response], | 35 assert_response_array_equivalent(result, [entries.a.response], |
36 'Cache.matchAll should match by Request.'); | 36 'Cache.matchAll should match by Request.'); |
37 }); | 37 }); |
38 }, 'Cache.matchAll with new Request'); | 38 }, 'Cache.matchAll with new Request'); |
39 | 39 |
40 prepopulated_cache_test(simple_entries, function(cache, entries) { | 40 prepopulated_cache_test(simple_entries, function(cache, entries) { |
41 return cache.matchAll(entries.a.request, | 41 return cache.matchAll(entries.a.request, |
42 {ignoreSearch: true}) | 42 {ignoreSearch: true}) |
43 .then(function(result) { | 43 .then(function(result) { |
44 assert_array_equivalent( | 44 assert_response_array_equivalent( |
45 result, | 45 result, |
46 [ | 46 [ |
47 entries.a.response, | 47 entries.a.response, |
48 entries.a_with_query.response | 48 entries.a_with_query.response |
49 ], | 49 ], |
50 'Cache.matchAll with ignoreSearch should ignore the ' + | 50 'Cache.matchAll with ignoreSearch should ignore the ' + |
51 'search parameters of cached request.'); | 51 'search parameters of cached request.'); |
52 }); | 52 }); |
53 }, | 53 }, |
54 'Cache.matchAll with ignoreSearch option (request with no search ' + | 54 'Cache.matchAll with ignoreSearch option (request with no search ' + |
55 'parameters)'); | 55 'parameters)'); |
56 | 56 |
57 prepopulated_cache_test(simple_entries, function(cache, entries) { | 57 prepopulated_cache_test(simple_entries, function(cache, entries) { |
58 return cache.matchAll(entries.a_with_query.request, | 58 return cache.matchAll(entries.a_with_query.request, |
59 {ignoreSearch: true}) | 59 {ignoreSearch: true}) |
60 .then(function(result) { | 60 .then(function(result) { |
61 assert_array_equivalent( | 61 assert_response_array_equivalent( |
62 result, | 62 result, |
63 [ | 63 [ |
64 entries.a.response, | 64 entries.a.response, |
65 entries.a_with_query.response | 65 entries.a_with_query.response |
66 ], | 66 ], |
67 'Cache.matchAll with ignoreSearch should ignore the ' + | 67 'Cache.matchAll with ignoreSearch should ignore the ' + |
68 'search parameters of request.'); | 68 'search parameters of request.'); |
69 }); | 69 }); |
70 }, | 70 }, |
71 'Cache.matchAll with ignoreSearch option (request with search parameter)'); | 71 'Cache.matchAll with ignoreSearch option (request with search parameter)'); |
72 | 72 |
73 prepopulated_cache_test(simple_entries, function(cache, entries) { | 73 prepopulated_cache_test(simple_entries, function(cache, entries) { |
74 return cache.matchAll(entries.cat.request.url + '#mouse') | 74 return cache.matchAll(entries.cat.request.url + '#mouse') |
75 .then(function(result) { | 75 .then(function(result) { |
76 assert_array_equivalent( | 76 assert_response_array_equivalent( |
77 result, | 77 result, |
78 [ | 78 [ |
79 entries.cat.response, | 79 entries.cat.response, |
80 ], | 80 ], |
81 'Cache.matchAll should ignore URL fragment.'); | 81 'Cache.matchAll should ignore URL fragment.'); |
82 }); | 82 }); |
83 }, 'Cache.matchAll with URL containing fragment'); | 83 }, 'Cache.matchAll with URL containing fragment'); |
84 | 84 |
85 prepopulated_cache_test(simple_entries, function(cache, entries) { | 85 prepopulated_cache_test(simple_entries, function(cache, entries) { |
86 return cache.matchAll('http') | 86 return cache.matchAll('http') |
87 .then(function(result) { | 87 .then(function(result) { |
88 assert_array_equivalent( | 88 assert_response_array_equivalent( |
89 result, [], | 89 result, [], |
90 'Cache.matchAll should treat query as a URL and not ' + | 90 'Cache.matchAll should treat query as a URL and not ' + |
91 'just a string fragment.'); | 91 'just a string fragment.'); |
92 }); | 92 }); |
93 }, 'Cache.matchAll with string fragment "http" as query'); | 93 }, 'Cache.matchAll with string fragment "http" as query'); |
94 | 94 |
95 prepopulated_cache_test(simple_entries, function(cache, entries) { | 95 prepopulated_cache_test(simple_entries, function(cache, entries) { |
96 return cache.matchAll(entries.secret_cat.request.url) | 96 return cache.matchAll(entries.secret_cat.request.url) |
97 .then(function(result) { | 97 .then(function(result) { |
98 assert_array_equivalent( | 98 assert_response_array_equivalent( |
99 result, [entries.secret_cat.response], | 99 result, [entries.secret_cat.response], |
100 'Cache.matchAll should not ignore embedded credentials'); | 100 'Cache.matchAll should not ignore embedded credentials'); |
101 }); | 101 }); |
102 }, 'Cache.matchAll with URL containing credentials'); | 102 }, 'Cache.matchAll with URL containing credentials'); |
103 | 103 |
104 prepopulated_cache_test(vary_entries, function(cache, entries) { | 104 prepopulated_cache_test(vary_entries, function(cache, entries) { |
105 return cache.matchAll('http://example.com/c') | 105 return cache.matchAll('http://example.com/c') |
106 .then(function(result) { | 106 .then(function(result) { |
107 assert_array_equivalent( | 107 assert_response_array_equivalent( |
108 result, | 108 result, |
109 [ | 109 [ |
110 entries.vary_wildcard.response, | 110 entries.vary_wildcard.response, |
111 entries.vary_cookie_absent.response | 111 entries.vary_cookie_absent.response |
112 ], | 112 ], |
113 'Cache.matchAll should exclude matches if a vary header is ' + | 113 'Cache.matchAll should exclude matches if a vary header is ' + |
114 'missing in the query request, but is present in the cached ' + | 114 'missing in the query request, but is present in the cached ' + |
115 'request.'); | 115 'request.'); |
116 }) | 116 }) |
117 | 117 |
118 .then(function() { | 118 .then(function() { |
119 return cache.matchAll( | 119 return cache.matchAll( |
120 new Request('http://example.com/c', | 120 new Request('http://example.com/c', |
121 {headers: {'Cookies': 'none-of-the-above'}})); | 121 {headers: {'Cookies': 'none-of-the-above'}})); |
122 }) | 122 }) |
123 .then(function(result) { | 123 .then(function(result) { |
124 assert_array_equivalent( | 124 assert_response_array_equivalent( |
125 result, | 125 result, |
126 [ | 126 [ |
127 entries.vary_wildcard.response | 127 entries.vary_wildcard.response |
128 ], | 128 ], |
129 'Cache.matchAll should exclude matches if a vary header is ' + | 129 'Cache.matchAll should exclude matches if a vary header is ' + |
130 'missing in the cached request, but is present in the query ' + | 130 'missing in the cached request, but is present in the query ' + |
131 'request.'); | 131 'request.'); |
132 }) | 132 }) |
133 | 133 |
134 .then(function() { | 134 .then(function() { |
135 return cache.matchAll( | 135 return cache.matchAll( |
136 new Request('http://example.com/c', | 136 new Request('http://example.com/c', |
137 {headers: {'Cookies': 'is-for-cookie'}})); | 137 {headers: {'Cookies': 'is-for-cookie'}})); |
138 }) | 138 }) |
139 .then(function(result) { | 139 .then(function(result) { |
140 assert_array_equivalent( | 140 assert_response_array_equivalent( |
141 result, | 141 result, |
142 [entries.vary_cookie_is_cookie.response], | 142 [entries.vary_cookie_is_cookie.response], |
143 'Cache.matchAll should match the entire header if a vary header ' + | 143 'Cache.matchAll should match the entire header if a vary header ' + |
144 'is present in both the query and cached requests.'); | 144 'is present in both the query and cached requests.'); |
145 }); | 145 }); |
146 }, 'Cache.matchAll with responses containing "Vary" header'); | 146 }, 'Cache.matchAll with responses containing "Vary" header'); |
147 | 147 |
148 prepopulated_cache_test(vary_entries, function(cache, entries) { | 148 prepopulated_cache_test(vary_entries, function(cache, entries) { |
149 return cache.matchAll('http://example.com/c', | 149 return cache.matchAll('http://example.com/c', |
150 {ignoreVary: true}) | 150 {ignoreVary: true}) |
151 .then(function(result) { | 151 .then(function(result) { |
152 assert_array_equivalent( | 152 assert_response_array_equivalent( |
153 result, | 153 result, |
154 [ | 154 [ |
155 entries.vary_cookie_is_cookie.response, | 155 entries.vary_cookie_is_cookie.response, |
156 entries.vary_cookie_is_good.response, | 156 entries.vary_cookie_is_good.response, |
157 entries.vary_cookie_absent.response, | 157 entries.vary_cookie_absent.response, |
158 entries.vary_wildcard.response | 158 entries.vary_wildcard.response |
159 ], | 159 ], |
160 'Cache.matchAll should honor "ignoreVary" parameter.'); | 160 'Cache.matchAll should honor "ignoreVary" parameter.'); |
161 }); | 161 }); |
162 }, 'Cache.matchAll with "ignoreVary" parameter'); | 162 }, 'Cache.matchAll with "ignoreVary" parameter'); |
163 | 163 |
164 done(); | 164 done(); |
OLD | NEW |