OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>ServiceWorker: navigator.serviceWorker.waiting</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.js"></script> |
| 6 <body> |
| 7 <script> |
| 8 // "waiting" is set |
| 9 async_test(function(t) { |
| 10 var step = t.step_func.bind(t); |
| 11 var url = 'resources/worker-no-op.js'; |
| 12 var scope = 'resources/blank.html'; |
| 13 var frame; |
| 14 |
| 15 navigator.serviceWorker.unregister(scope) |
| 16 .then(step(function() { return with_iframe(scope); }), |
| 17 unreached_rejection(t, 'Unregister should not fail')) |
| 18 .then(step(function(f) { |
| 19 frame = f; |
| 20 return navigator.serviceWorker.register(url, {scope: scope}); |
| 21 })) |
| 22 .then(step(function(serviceWorker) { |
| 23 // FIXME: Replace this with .ready when that supports the in-waiting |
| 24 // Service Worker. |
| 25 return new Promise(step(function(resolve, reject) { |
| 26 serviceWorker.onstatechange = step(function() { |
| 27 if (serviceWorker.state == 'installed') { |
| 28 resolve(); |
| 29 } |
| 30 }); |
| 31 })); |
| 32 }), unreached_rejection(t, 'Registration should not fail')) |
| 33 .then(step(function() { |
| 34 var container = frame.contentWindow.navigator.serviceWorker; |
| 35 assert_equals(container.controller, null); |
| 36 assert_equals(container.waiting.url, normalizeURL(url)); |
| 37 |
| 38 // FIXME: Add a test for a frame created after installation. |
| 39 // Should the existing frame ("frame") block activation? |
| 40 })) |
| 41 .then(step(function() { |
| 42 frame.remove(); |
| 43 return service_worker_unregister_and_done(t, scope); |
| 44 })); |
| 45 }, 'waiting is set'); |
| 46 </script> |
OLD | NEW |