Index: LayoutTests/http/tests/serviceworker/resources/cache-storage-keys-test-worker.js |
diff --git a/LayoutTests/http/tests/serviceworker/resources/cache-storage-keys-test-worker.js b/LayoutTests/http/tests/serviceworker/resources/cache-storage-keys-test-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3d16bde230c2f87de247377cfcc1938a54e3f7ce |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/resources/cache-storage-keys-test-worker.js |
@@ -0,0 +1,29 @@ |
+importScripts('worker-test-harness.js'); |
+ |
+var test_cache_list = ['enum-1', 'enum-2', 'enum-3']; |
dominicc (has gone to gerrit)
2014/08/11 01:57:36
Is it worth including interesting names like empty
asanka
2014/08/13 01:22:51
Added some variants. It shouldn't hurt, but the re
|
+ |
+promise_test(function(test) { |
+ return caches.keys() |
+ .then(test.step_func(function(keys) { |
+ assert_equals(keys.length, |
+ 0, |
+ 'CacheStorage.keys should return an empty list for ' + |
+ 'a new ServiceWorker.'); |
+ })) |
+ |
+ .then(function() { |
+ return Promise.all(test_cache_list.map(function(key) { |
+ return caches.create(key); |
+ })); |
+ }) |
+ |
+ .then(function() { return caches.keys(); }) |
+ .then(test.step_func(function(keys) { |
+ assert_true(Array.isArray(keys), |
+ 'CacheStorage.keys should return an Array.'); |
+ assert_array_equals(keys, |
+ test_cache_list, |
+ 'CacheStorage.keys should only return ' + |
+ 'existing caches'); |
dominicc (has gone to gerrit)
2014/08/11 01:57:36
There's inconsistency about ending with a period.
asanka
2014/08/13 01:22:51
I added a '.'. The string put together by the test
|
+ })); |
+ }, 'CacheStorage keys'); |