OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>ServiceWorker: navigator.serviceWorker.active</title> | 2 <title>ServiceWorker: navigator.serviceWorker.active</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.js"></script> |
6 <body> | 6 <body> |
7 <script> | 7 <script> |
8 // "active" is set | 8 // "active" 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/worker-no-op.js'; | 11 var url = 'resources/worker-no-op.js'; |
12 var scope = 'resources/blank.html'; | 12 var scope = 'resources/blank.html'; |
13 var frame; | 13 var frame; |
| 14 var registration; |
14 | 15 |
15 navigator.serviceWorker.unregister(scope) | 16 navigator.serviceWorker.unregister(scope) |
16 .then(step(function() { return with_iframe(scope); })) | 17 .then(step(function() { return with_iframe(scope); })) |
17 .then(step(function(f) { | 18 .then(step(function(f) { |
18 frame = f; | 19 frame = f; |
19 return navigator.serviceWorker.register(url, {scope: scope}); | 20 return navigator.serviceWorker.register(url, {scope: scope}); |
20 })) | 21 })) |
| 22 .then(step(function(r) { |
| 23 registration = r; |
| 24 return wait_for_update(t, registration); |
| 25 })) |
21 .then(step(function(serviceWorker) { | 26 .then(step(function(serviceWorker) { |
22 return wait_for_state(t, serviceWorker, 'activating'); | 27 return wait_for_state(t, serviceWorker, 'activating'); |
23 })) | 28 })) |
24 .then(step(function() { | 29 .then(step(function() { |
25 var container = frame.contentWindow.navigator.serviceWorker; | 30 var container = frame.contentWindow.navigator.serviceWorker; |
26 assert_equals( | 31 assert_equals( |
27 container.controller, | 32 container.controller, |
28 null, | 33 null, |
29 'On activating state a document should not have a controller'); | 34 'On activating state a document should not have a controller'); |
30 assert_equals( | 35 assert_equals( |
31 container.active.scriptURL, | 36 registration.active.scriptURL, |
32 normalizeURL(url), | 37 normalizeURL(url), |
33 'On activating state a document should have an active worker '); | 38 'On activating state a document should have an active worker '); |
34 assert_equals( | 39 assert_equals( |
35 container.waiting, | 40 registration.waiting, |
36 null, | 41 null, |
37 'On activating state a document should not have a waiting worker'); | 42 'On activating state a document should not have a waiting worker'); |
38 assert_equals( | 43 assert_equals( |
39 container.installing, | 44 registration.installing, |
40 null, | 45 null, |
41 'On activating state a document should not have an installing ' + | 46 'On activating state a document should not have an installing ' + |
42 'worker'); | 47 'worker'); |
43 | 48 |
44 // FIXME: Add a test for a frame created after installation. | 49 // FIXME: Add a test for a frame created after installation. |
45 // Should the existing frame ("frame") block activation? | 50 // Should the existing frame ("frame") block activation? |
46 })) | 51 })) |
47 .then(step(function() { | 52 .then(step(function() { |
48 frame.remove(); | 53 frame.remove(); |
49 return service_worker_unregister_and_done(t, scope); | 54 return service_worker_unregister_and_done(t, scope); |
50 })) | 55 })) |
51 .catch(unreached_rejection(t)); | 56 .catch(unreached_rejection(t)); |
52 }, 'active is set'); | 57 }, 'active is set'); |
53 </script> | 58 </script> |
OLD | NEW |