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> | |
6 async_test(function(t) { | |
7 var documentURL = 'no-such-worker'; | |
8 navigator.serviceWorker.getRegistration(documentURL) | |
9 .then(function(value) { | |
10 assert_equals(value, undefined, | |
11 'getRegistration should resolve with undefined'); | |
12 t.done(); | |
13 }) | |
14 .catch(unreached_rejection(t)); | |
15 }, 'getRegistration'); | |
16 | |
17 async_test(function(t) { | |
18 var scope = 'scope/worker/'; | |
19 var registration; | |
20 navigator.serviceWorker.register('resources/empty-worker.js', | |
nhiroki
2014/09/11 11:30:34
Can you use service_worker_unregister_and_register
Kunihiko Sakamoto
2014/09/12 01:32:13
Done.
| |
21 {scope: scope}) | |
22 .then(function(r) { | |
23 registration = r; | |
24 return navigator.serviceWorker.getRegistration(scope); | |
25 }) | |
26 .then(function(value) { | |
27 assert_equals(value, registration, | |
28 'getRegistration should resolve with registration'); | |
29 t.done(); | |
nhiroki
2014/09/11 11:30:34
To unregister the registration before finishing th
Kunihiko Sakamoto
2014/09/12 01:32:13
Done.
| |
30 }) | |
31 .catch(unreached_rejection(t)); | |
32 }, 'Register then getRegistration'); | |
33 | |
34 async_test(function(t) { | |
35 var documentURL = 'http://example.com/'; | |
36 navigator.serviceWorker.getRegistration(documentURL) | |
37 .then(function() { | |
38 assert_unreached('getRegistration with an out of origin URL should fail' ); | |
nhiroki
2014/09/11 11:30:34
nit: +2-space indents
nit: please wrap this at 80-
Kunihiko Sakamoto
2014/09/12 01:32:13
Done.
| |
39 }, function(reason) { | |
40 assert_equals(reason.name, 'SecurityError', | |
41 'getRegistration with an out of origin URL should fail'); | |
42 t.done(); | |
43 }) | |
44 .catch(unreached_rejection(t)); | |
45 }, 'getRegistration with a cross origin URL'); | |
46 | |
47 async_test(function(t) { | |
48 var registration; | |
49 navigator.serviceWorker.register('resources/empty-worker.js', | |
50 {scope: location.href}) | |
nhiroki
2014/09/11 11:30:34
Why do you use |location.href|?
We'd prefer to av
Kunihiko Sakamoto
2014/09/12 01:32:13
Wanted to test that getRegistration() gets a regis
nhiroki
2014/09/12 02:23:26
I see. Probably you can make an iframe for |scope|
| |
51 .then(function(r) { | |
52 registration = r; | |
53 return navigator.serviceWorker.getRegistration(); | |
54 }) | |
55 .then(function(value) { | |
56 assert_equals(value, registration, | |
57 'getRegistration should resolve with registration'); | |
58 t.done(); | |
nhiroki
2014/09/11 11:30:34
ditto (service_worker_unregister_and_done)
| |
59 }) | |
60 .catch(unreached_rejection(t)); | |
61 }, 'getRegistration without argument'); | |
62 | |
63 async_test(function(t) { | |
64 var scope = 'scope/worker/'; | |
65 navigator.serviceWorker.register('resources/empty-worker.js', | |
66 {scope: scope}) | |
67 .then(function(registration) { | |
68 return registration.unregister(); | |
69 }) | |
70 .then(function() { | |
71 return navigator.serviceWorker.getRegistration(scope); | |
72 }) | |
73 .then(function(value) { | |
74 assert_equals(value, undefined, | |
75 'getRegistration should resolve with undefined'); | |
76 t.done(); | |
77 }) | |
78 .catch(unreached_rejection(t)); | |
79 }, 'Register then Unregister then getRegistration'); | |
80 | |
81 </script> | |
OLD | NEW |