OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>sync.register() is rejected when the service worker is not active yet</ti
tle> | 4 <title>sync.register() is rejected when the service worker is not active yet</ti
tle> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
7 <script src="../serviceworker/resources/test-helpers.js"></script> | 7 <script src="../serviceworker/resources/test-helpers.js"></script> |
8 </head> | 8 </head> |
9 <body> | 9 <body> |
10 <script> | 10 <script> |
11 async_test(function(test) { | 11 async_test(function(test) { |
12 var workerUrl = 'resources/empty_worker.js'; | 12 var workerUrl = 'resources/empty_worker.js'; |
13 var workerScope = 'resources/scope/' + location.pathname; | 13 var workerScope = 'resources/scope/' + location.pathname; |
14 var swRegistration; | 14 var swRegistration; |
15 service_worker_unregister_and_register(test, workerUrl, workerScope) | 15 service_worker_unregister_and_register(test, workerUrl, workerScope) |
16 .then(function(serviceWorkerRegistration) { | 16 .then(function(serviceWorkerRegistration) { |
17 swRegistration = serviceWorkerRegistration; | 17 swRegistration = serviceWorkerRegistration; |
18 assert_not_equals(swRegistration.installing, null, 'The worker shoul
d be installing'); | 18 assert_not_equals(swRegistration.installing, null, 'The worker shoul
d be installing'); |
19 assert_equals(swRegistration.active, null, 'The worker should not be
active yet'); | 19 assert_equals(swRegistration.active, null, 'The worker should not be
active yet'); |
20 return swRegistration.sync.register(); | 20 return swRegistration.sync.register('abcde'); |
21 }) | 21 }) |
22 .then(function(syncRegistration) { | 22 .then(function(syncRegistration) { |
23 assert_unreached('sync.register() must not succeed without an active
service worker'); | 23 assert_unreached('sync.register() must not succeed without an active
service worker'); |
24 }, function(e) { | 24 }, function(e) { |
25 assert_equals(e.name, 'AbortError'); | 25 assert_equals(e.name, 'AbortError'); |
26 assert_equals(e.message, 'Registration failed - no active Service Wo
rker'); | 26 assert_equals(e.message, 'Registration failed - no active Service Wo
rker'); |
27 return service_worker_unregister_and_done(test, workerScope); | 27 return service_worker_unregister_and_done(test, workerScope); |
28 }) | 28 }) |
29 .catch(unreached_rejection(test)); | 29 .catch(unreached_rejection(test)); |
30 }, 'sync.register() is rejected when the service worker is not active yet'); | 30 }, 'sync.register() is rejected when the service worker is not active yet'); |
31 </script> | 31 </script> |
32 </body> | 32 </body> |
33 </html> | 33 </html> |
OLD | NEW |