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'); | |
4 importScripts('../resources/test-helpers.js'); | 3 importScripts('../resources/test-helpers.js'); |
5 } | 4 } |
6 | 5 |
7 promise_test(function(t) { | 6 promise_test(function(t) { |
8 var cache_name = 'cache-storage/foo'; | 7 var cache_name = 'cache-storage/foo'; |
9 return self.caches.delete(cache_name) | 8 return self.caches.delete(cache_name) |
10 .then(function() { | 9 .then(function() { |
11 return self.caches.open(cache_name); | 10 return self.caches.open(cache_name); |
12 }) | 11 }) |
13 .then(function(cache) { | 12 .then(function(cache) { |
(...skipping 10 matching lines...) Expand all Loading... |
24 .then(function() { | 23 .then(function() { |
25 return self.caches.open(cache_name); | 24 return self.caches.open(cache_name); |
26 }) | 25 }) |
27 .then(function(cache) { | 26 .then(function(cache) { |
28 assert_true(cache instanceof Cache, | 27 assert_true(cache instanceof Cache, |
29 'CacheStorage.open should accept an empty name.'); | 28 'CacheStorage.open should accept an empty name.'); |
30 }); | 29 }); |
31 }, 'CacheStorage.open with an empty name'); | 30 }, 'CacheStorage.open with an empty name'); |
32 | 31 |
33 promise_test(function(t) { | 32 promise_test(function(t) { |
34 return assert_promise_rejects( | 33 return promise_rejects( |
| 34 t, |
| 35 new TypeError(), |
35 self.caches.open(), | 36 self.caches.open(), |
36 new TypeError(), | |
37 'CacheStorage.open should throw TypeError if called with no arguments.'); | 37 'CacheStorage.open should throw TypeError if called with no arguments.'); |
38 }, 'CacheStorage.open with no arguments'); | 38 }, 'CacheStorage.open with no arguments'); |
39 | 39 |
40 promise_test(function(t) { | 40 promise_test(function(t) { |
41 var test_cases = [ | 41 var test_cases = [ |
42 { | 42 { |
43 name: 'cache-storage/lowercase', | 43 name: 'cache-storage/lowercase', |
44 should_not_match: | 44 should_not_match: |
45 [ | 45 [ |
46 'cache-storage/Lowercase', | 46 'cache-storage/Lowercase', |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 promise_test(function(t) { | 162 promise_test(function(t) { |
163 return self.caches.delete('cheezburger') | 163 return self.caches.delete('cheezburger') |
164 .then(function(result) { | 164 .then(function(result) { |
165 assert_false(result, | 165 assert_false(result, |
166 'CacheStorage.delete should return false for a ' + | 166 'CacheStorage.delete should return false for a ' + |
167 'nonexistent cache.'); | 167 'nonexistent cache.'); |
168 }); | 168 }); |
169 }, 'CacheStorage.delete with nonexistent cache'); | 169 }, 'CacheStorage.delete with nonexistent cache'); |
170 | 170 |
171 promise_test(function(t) { | 171 promise_test(function(t) { |
172 var bad_name = 'unpaired\uD800'; | 172 var unpaired_name = 'unpaired\uD800'; |
173 var converted_name = 'unpaired\uFFFD'; // Don't create cache with this name. | 173 var converted_name = 'unpaired\uFFFD'; |
174 return self.caches.has(converted_name) | 174 |
| 175 // The test assumes that a cache with converted_name does not |
| 176 // exist, but if the implementation fails the test then such |
| 177 // a cache will be created. Start off in a fresh state by |
| 178 // deleting all caches. |
| 179 return delete_all_caches() |
| 180 .then(function() { |
| 181 return self.caches.has(converted_name); |
| 182 }) |
175 .then(function(cache_exists) { | 183 .then(function(cache_exists) { |
176 assert_false(cache_exists, | 184 assert_false(cache_exists, |
177 'Test setup failure: cache should not exist'); | 185 'Test setup failure: cache should not exist'); |
178 }) | 186 }) |
179 .then(function() { return self.caches.open(bad_name); }) | 187 .then(function() { return self.caches.open(unpaired_name); }) |
180 .then(function() { return self.caches.keys(); }) | 188 .then(function() { return self.caches.keys(); }) |
181 .then(function(keys) { | 189 .then(function(keys) { |
182 assert_true(keys.indexOf(bad_name) !== -1, | 190 assert_true(keys.indexOf(unpaired_name) !== -1, |
183 'keys should include cache with bad name'); | 191 'keys should include cache with bad name'); |
184 }) | 192 }) |
185 .then(function() { return self.caches.has(bad_name); }) | 193 .then(function() { return self.caches.has(unpaired_name); }) |
186 .then(function(cache_exists) { | 194 .then(function(cache_exists) { |
187 assert_true(cache_exists, | 195 assert_true(cache_exists, |
188 'CacheStorage names should be not be converted.'); | 196 'CacheStorage names should be not be converted.'); |
189 }) | 197 }) |
190 .then(function() { return self.caches.has(converted_name); }) | 198 .then(function() { return self.caches.has(converted_name); }) |
191 .then(function(cache_exists) { | 199 .then(function(cache_exists) { |
192 assert_false(cache_exists, | 200 assert_false(cache_exists, |
193 'CacheStorage names should be not be converted.'); | 201 'CacheStorage names should be not be converted.'); |
194 }); | 202 }); |
195 }, 'CacheStorage names are DOMStrings not USVStrings'); | 203 }, 'CacheStorage names are DOMStrings not USVStrings'); |
196 | 204 |
197 done(); | 205 done(); |
OLD | NEW |