OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Activation occurs after registration</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/testutils.js"></script> |
| 6 <body> |
| 7 <script> |
| 8 var t = async_test('activation occurs after registration'); |
| 9 t.step(function() { |
| 10 var scope = 'resources/blank.html'; |
| 11 navigator.serviceWorker.unregister(scope).then(doTest, doTest); |
| 12 function doTest() { |
| 13 navigator.serviceWorker.register( |
| 14 'resources/worker-no-op.js', {scope: scope} |
| 15 ).then(t.step_func(onRegister), t.step_func(function(reason) { |
| 16 assert_unreached('Registration should succeed, but failed: ' + reaso
n.name); |
| 17 })); |
| 18 } |
| 19 |
| 20 function onRegister(worker) { |
| 21 assert_equals(worker.state, 'parsed', 'worker should be in the "parsed"
state upon registration'); |
| 22 worker.addEventListener('statechange', t.step_func(function(event) { |
| 23 if (event.target.state == 'active') |
| 24 t.done(); |
| 25 })); |
| 26 } |
| 27 }); |
| 28 </script> |
| 29 </body> |
OLD | NEW |