OLD | NEW |
---|---|
(Empty) | |
1 importScripts('worker-test-harness.js'); | |
2 | |
3 promise_test(function(test) { | |
4 return caches.create('foo') | |
5 .then(test.step_func(function(cache) { | |
6 assert_true(cache, | |
dominicc (has gone to gerrit)
2014/08/11 01:57:36
Maybe omit this assertion? You'll get a reasonable
asanka
2014/08/13 01:22:51
Done.
| |
7 'CacheStorage.create should return a valid Cache.'); | |
8 assert_true(cache instanceof Cache, | |
9 'CacheStorage.create should return a valid Cache.'); | |
10 })); | |
11 }, 'CacheStorage.create'); | |
12 | |
13 promise_test(function(test) { | |
14 return caches.create() | |
15 // FIXME: Define the behavior for .create() with an empty or | |
dominicc (has gone to gerrit)
2014/08/11 01:57:36
I do not see any bias in the spec against '' as a
asanka
2014/08/13 01:22:51
Thanks for the reference! I've updated the tests.
| |
16 // non-string cache name. | |
17 .then(test.unreached_func( | |
18 'CacheStorage.create should reject invalid name.'), | |
19 function() {}); | |
20 }, 'CacheStorage.create with invalid cache name'); | |
21 | |
22 promise_test(function(test) { | |
23 return caches.create('bar') | |
24 .then(test.step_func(function() { return caches.has('bar'); })) | |
25 .then(test.step_func(function(result) { | |
26 assert_true(result, | |
27 'CacheStorage.has should return true for ' + | |
28 'existing cache'); | |
29 })); | |
30 }, 'CacheStorage.has with existing cache'); | |
31 | |
32 promise_test(function(test) { | |
33 return caches.has('cheezburger') | |
dominicc (has gone to gerrit)
2014/08/11 01:57:36
Huge +1 to the modest sense of humor.
asanka
2014/08/13 01:22:51
Acknowledged.
| |
34 .then(test.step_func(function(result) { | |
35 assert_false(result, | |
36 'CacheStorage.has should return false for ' + | |
37 'non-existent cache'); | |
38 })); | |
39 }, 'CacheStorage.has with non-existent cache'); | |
40 | |
41 promise_test(function(test) { | |
42 return caches.has() | |
43 // FIXME: Define the behavior for .has() with an invalid or undefined | |
44 // name. Perhaps it should reject instead of returning false. | |
45 .then(test.step_func(function(result) { | |
46 // FIXME: Could fail due to the cache creation with an undefined name | |
47 // above. Tests shouldn't interact since these are all async_tests. | |
48 assert_false(result, | |
49 'CacheStorage.has should return false for invalid ' + | |
50 'cache name.'); | |
51 })); | |
52 }, 'CacheStorage.has with invalid cache name'); | |
53 | |
54 promise_test(function(test) { | |
55 var cache_name = 'to-be-deleted'; | |
56 | |
57 return caches.create(cache_name) | |
58 .then(function() { return caches.delete(cache_name); }) | |
59 .then(function() {}, | |
60 test.unreached_func('CacheStorage.delete should not reject ' + | |
61 'existing cache')) | |
62 | |
63 .then(function() { return caches.has(cache_name); }) | |
64 .then(test.step_func(function(cache_exists) { | |
65 assert_false(cache_exists, | |
66 'CacheStorage.has should not return true after ' + | |
67 'fulfilment of CacheStorage.delete promise'); | |
68 })); | |
69 }, 'CacheStorage.delete with existing cache'); | |
70 | |
71 promise_test(function(test) { | |
72 return caches.delete('cheezburger') | |
73 .then(test.unreached_func('CacheStorage.delete should not fulfil ' + | |
74 'promise to delete non-existent cache.'), | |
75 function() {}); | |
76 }, 'CacheStorage.delete with non-existent cache'); | |
77 | |
78 // FIXME: Define and test behavior for invalid cache name with delete(). | |
dominicc (has gone to gerrit)
2014/08/11 01:57:36
You're free to file GitHub issues against the spec
jsbell
2014/08/11 22:48:34
Yeah, I'm not clear what 'invalid' might mean here
asanka
2014/08/13 01:22:51
Thanks! I'll wait for gavinp to comment.
| |
OLD | NEW |