OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../resources/testharness.js"></script> | |
3 <script src="../resources/testharnessreport.js"></script> | |
4 <script src="resources/test-helpers.js"></script> | |
5 <script> | |
falken
2015/05/25 00:43:02
This will be racy since async tests including prom
jungkees
2015/05/27 08:06:46
I gave it a try with sequential_promise_test, but
| |
6 promise_test(function(t) { | |
7 navigator.serviceWorker.getRegistrations() | |
8 .then(function(value) { | |
9 assert_array_equals( | |
10 value, | |
11 [], | |
12 'getRegistrations should resolve with an empty array.'); | |
13 t.done(); | |
14 }) | |
15 .catch(unreached_rejection(t)); | |
falken
2015/05/25 00:43:02
for a promise_test, you only need to return a prom
| |
16 }, 'getRegistrations'); | |
17 | |
18 promise_test(function(t) { | |
19 var scope = 'resources/scope/getregistrations/normal'; | |
20 var script = 'resources/empty-worker.js'; | |
21 var registrations = []; | |
22 service_worker_unregister_and_register(t, script, scope) | |
23 .then(function(r) { | |
24 registrations.push(r); | |
25 return navigator.serviceWorker.getRegistrations(); | |
26 }) | |
27 .then(function(value) { | |
28 assert_array_equals( | |
29 value, | |
30 registrations, | |
31 'getRegistrations should resolve with array of registrations.'); | |
32 service_worker_unregister_and_done(t, scope); | |
33 }) | |
34 .catch(unreached_rejection(t)); | |
35 }, 'Register then getRegistrations'); | |
36 | |
37 promise_test(function(t) { | |
38 var scope1 = 'resources/scope/getregistrations/scope1'; | |
39 var scope2 = 'resources/scope/getregistrations/scope2'; | |
40 var script = 'resources/empty-worker.js'; | |
41 var registrations = []; | |
42 service_worker_unregister_and_register(t, script, scope1) | |
43 .then(function(r) { | |
44 registrations.push(r); | |
45 return service_worker_unregister_and_register(t, script, scope2); | |
46 }) | |
47 .then(function(r) { | |
48 registrations.push(r); | |
49 return navigator.serviceWorker.getRegistrations(); | |
50 }) | |
51 .then(function(value) { | |
52 assert_array_equals( | |
53 value, | |
54 registrations, | |
55 'getRegistrations should resolve with array of registrations.'); | |
56 service_worker_unregister(t, scope1); | |
57 service_worker_unregister_and_done(t, scope2); | |
58 }) | |
59 .catch(unreached_rejection(t)); | |
60 }, 'Register multiple times then getRegistrations'); | |
61 | |
62 promise_test(function(t) { | |
63 var scope = 'resources/scope/getregistrations/register-unregister'; | |
64 var script = 'resources/empty-worker.js'; | |
65 service_worker_unregister_and_register(t, script, scope) | |
66 .then(function(registration) { | |
67 return registration.unregister(); | |
68 }) | |
69 .then(function() { | |
70 return navigator.serviceWorker.getRegistrations(); | |
71 }) | |
72 .then(function(value) { | |
73 assert_array_equals( | |
74 value, | |
75 [], | |
76 'getRegistrations should resolve with an empty array.'); | |
77 t.done(); | |
78 }) | |
79 .catch(unreached_rejection(t)); | |
80 }, 'Register then Unregister then getRegistrations'); | |
81 | |
82 </script> | |
OLD | NEW |