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/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(step(function() { return with_iframe(scope); })) | 17 .then(step(function() { return with_iframe(scope); })) |
18 .then(step(function(f) { | 18 .then(step(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(step(function(r) { | 22 .then(step(function(r) { |
23 registration = r; | 23 registration = r; |
24 return wait_for_update(t, registration); | 24 return wait_for_state(t, r.installing, 'activating'); |
25 })) | |
26 .then(step(function(serviceWorker) { | |
27 return wait_for_state(t, serviceWorker, 'activating'); | |
28 })) | 25 })) |
29 .then(step(function() { | 26 .then(step(function() { |
30 var container = frame.contentWindow.navigator.serviceWorker; | 27 var container = frame.contentWindow.navigator.serviceWorker; |
31 assert_equals( | 28 assert_equals( |
32 container.controller, | 29 container.controller, |
33 null, | 30 null, |
34 'On activating state a document should not have a controller'); | 31 'On activating state a document should not have a controller'); |
35 assert_equals( | 32 assert_equals( |
36 registration.active.scriptURL, | 33 registration.active.scriptURL, |
37 normalizeURL(url), | 34 normalizeURL(url), |
(...skipping 11 matching lines...) Expand all Loading... |
49 // FIXME: Add a test for a frame created after installation. | 46 // FIXME: Add a test for a frame created after installation. |
50 // Should the existing frame ("frame") block activation? | 47 // Should the existing frame ("frame") block activation? |
51 })) | 48 })) |
52 .then(step(function() { | 49 .then(step(function() { |
53 frame.remove(); | 50 frame.remove(); |
54 return service_worker_unregister_and_done(t, scope); | 51 return service_worker_unregister_and_done(t, scope); |
55 })) | 52 })) |
56 .catch(unreached_rejection(t)); | 53 .catch(unreached_rejection(t)); |
57 }, 'active is set'); | 54 }, 'active is set'); |
58 </script> | 55 </script> |
OLD | NEW |