cache-storage-keys.https.any.js (1156B)
1 // META: title=CacheStorage.keys 2 // META: global=window,worker 3 // META: script=./resources/test-helpers.js 4 // META: timeout=long 5 6 var test_cache_list = 7 ['', 'example', 'Another cache name', 'A', 'a', 'ex ample']; 8 9 promise_test(function(test) { 10 return self.caches.keys() 11 .then(function(keys) { 12 assert_true(Array.isArray(keys), 13 'CacheStorage.keys should return an Array.'); 14 return Promise.all(keys.map(function(key) { 15 return self.caches.delete(key); 16 })); 17 }) 18 .then(function() { 19 return Promise.all(test_cache_list.map(function(key) { 20 return self.caches.open(key); 21 })); 22 }) 23 24 .then(function() { return self.caches.keys(); }) 25 .then(function(keys) { 26 assert_true(Array.isArray(keys), 27 'CacheStorage.keys should return an Array.'); 28 assert_array_equals(keys, 29 test_cache_list, 30 'CacheStorage.keys should only return ' + 31 'existing caches.'); 32 }); 33 }, 'CacheStorage keys'); 34 35 done();