OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Current on load</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.js"></script> |
| 6 <script src="resources/testutils.js"></script> |
| 7 <body> |
| 8 <script> |
| 9 var t = async_test('current is set for a controlled document'); |
| 10 t.step(function() { |
| 11 var scope = 'resources/blank.html' |
| 12 navigator.serviceWorker.unregister(scope).then( |
| 13 doTest, |
| 14 unreached_rejection(t, 'Unregister should not fail') |
| 15 ); |
| 16 |
| 17 function doTest() { |
| 18 navigator.serviceWorker.register( |
| 19 'resources/worker-no-op.js', {scope: scope} |
| 20 ).then( |
| 21 onRegister, |
| 22 unreached_rejection(t, 'Registration should succeed, but failed') |
| 23 ); |
| 24 } |
| 25 |
| 26 function onRegister(worker) { |
| 27 worker.addEventListener('statechange', t.step_func(function(event) { |
| 28 if (event.target.state == 'active') |
| 29 onActive(); |
| 30 })); |
| 31 } |
| 32 |
| 33 function onActive() { |
| 34 withIframe(scope, t.step_func(function(frame) { |
| 35 var w = frame.contentWindow; |
| 36 assert_true(w.navigator.serviceWorker.current instanceof w.ServiceWo
rker, |
| 37 'current should be a ServiceWorker object'); |
| 38 t.done(); |
| 39 })); |
| 40 } |
| 41 }); |
| 42 </script> |
| 43 </body> |
OLD | NEW |