OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>ServiceWorker: navigator.serviceWorker.waiting</title> | 2 <title>ServiceWorker: navigator.serviceWorker.waiting</title> |
3 <script src="../resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.js"></script> | 5 <script src="resources/test-helpers.sub.js"></script> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 // "waiting" is set | 8 // "waiting" is set |
9 async_test(function(t) { | 9 async_test(function(t) { |
10 var step = t.step_func.bind(t); | 10 var step = t.step_func.bind(t); |
11 var url = 'resources/empty-worker.js'; | 11 var url = 'resources/empty-worker.js'; |
12 var scope = 'resources/blank.html'; | 12 var scope = 'resources/blank.html'; |
13 var frame; | 13 var frame; |
14 var registration; | 14 var registration; |
15 | 15 |
16 service_worker_unregister(t, scope) | 16 service_worker_unregister(t, scope) |
17 .then(function() { return with_iframe(scope); }) | 17 .then(function() { return with_iframe(scope); }) |
18 .then(function(f) { | 18 .then(function(f) { |
19 frame = f; | 19 frame = f; |
20 return navigator.serviceWorker.register(url, {scope: scope}); | 20 return navigator.serviceWorker.register(url, {scope: scope}); |
21 }) | 21 }) |
22 .then(function(r) { | 22 .then(function(r) { |
23 registration = r; | 23 registration = r; |
24 return wait_for_state(t, r.installing, 'installed'); | 24 return wait_for_state(t, r.installing, 'installed'); |
25 }, unreached_rejection(t, 'Registration should not fail')) | 25 }, unreached_rejection(t, 'Registration should not fail')) |
26 .then(function() { | 26 .then(function() { |
27 var controller = frame.contentWindow.navigator.serviceWorker.controller; | 27 var controller = frame.contentWindow.navigator.serviceWorker.controller; |
28 assert_equals(controller, null); | 28 assert_equals(controller, null); |
29 assert_equals(registration.active, null); | 29 // Nothing in the spec prohibits a worker from going to active |
30 assert_equals(registration.waiting.scriptURL, normalizeURL(url)); | 30 // immediately. |
| 31 // Step 26 of the [[Install]] algorithm |
| 32 // "If registration's waiting worker waitingWorker is not null and |
| 33 // waitingWorker's skip waiting flag is not set, invoke Activate |
| 34 // algorithm, or its equivalent, with registration as its argument." |
| 35 var w = registration.waiting || registration.active; |
| 36 assert_equals(w.scriptURL, normalizeURL(url)); |
31 assert_equals(registration.installing, null); | 37 assert_equals(registration.installing, null); |
32 | |
33 // FIXME: Add a test for a frame created after installation. | |
34 // Should the existing frame ("frame") block activation? | |
35 }) | 38 }) |
36 .then(function() { | 39 .then(function() { |
37 frame.remove(); | 40 frame.remove(); |
38 return service_worker_unregister_and_done(t, scope); | 41 return service_worker_unregister_and_done(t, scope); |
39 }); | 42 }); |
40 }, 'waiting is set'); | 43 }, 'waiting or active is set'); |
41 </script> | 44 </script> |
OLD | NEW |