OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="resources/test-helpers.js"></script> | 4 <script src="resources/test-helpers.js"></script> |
5 <script> | 5 <script> |
6 var worker_url = 'resources/simple-intercept-worker.js'; | 6 var worker_url = 'resources/simple-intercept-worker.js'; |
7 | 7 |
8 async_test(function(t) { | 8 async_test(function(t) { |
9 var scope = | 9 var scope = |
10 'resources/unregister-controller-page.html?load-before-unregister'; | 10 'resources/unregister-controller-page.html?load-before-unregister'; |
11 var worker; | 11 var worker; |
12 var frame_window; | 12 var frame_window; |
13 var controller; | 13 var controller; |
14 | 14 |
15 service_worker_unregister_and_register(t, worker_url, scope) | 15 service_worker_unregister_and_register(t, worker_url, scope) |
16 .then(function(registration) { | |
17 return wait_for_update(t, registration); | |
18 }) | |
16 .then(function(registered_worker) { | 19 .then(function(registered_worker) { |
17 worker = registered_worker; | 20 worker = registered_worker; |
18 return wait_for_state(t, worker, 'activated'); | 21 return wait_for_state(t, worker, 'activated'); |
19 }) | 22 }) |
20 .then(function() { | 23 .then(function() { |
21 return with_iframe(scope); | 24 return with_iframe(scope); |
22 }) | 25 }) |
23 .then(function(frame) { | 26 .then(function(frame) { |
24 frame_window = frame.contentWindow; | 27 frame_window = frame.contentWindow; |
25 controller = frame_window.navigator.serviceWorker.controller; | 28 controller = frame_window.navigator.serviceWorker.controller; |
(...skipping 13 matching lines...) Expand all Loading... | |
39 t.done(); | 42 t.done(); |
40 }) | 43 }) |
41 .catch(unreached_rejection(t)); | 44 .catch(unreached_rejection(t)); |
42 }, 'Unregister does not affect existing controller'); | 45 }, 'Unregister does not affect existing controller'); |
43 | 46 |
44 async_test(function(t) { | 47 async_test(function(t) { |
45 var scope = | 48 var scope = |
46 'resources/unregister-controller-page.html?load-after-unregister'; | 49 'resources/unregister-controller-page.html?load-after-unregister'; |
47 | 50 |
48 service_worker_unregister_and_register(t, worker_url, scope) | 51 service_worker_unregister_and_register(t, worker_url, scope) |
52 .then(function(registration) { | |
53 return wait_for_update(t, registration); | |
falken
2014/08/14 14:23:15
indent
nhiroki
2014/08/14 16:37:54
Done.
| |
54 }) | |
49 .then(function(worker) { | 55 .then(function(worker) { |
50 return wait_for_state(t, worker, 'activated'); | 56 return wait_for_state(t, worker, 'activated'); |
51 }) | 57 }) |
52 .then(function() { | 58 .then(function() { |
53 return navigator.serviceWorker.unregister(scope); | 59 return navigator.serviceWorker.unregister(scope); |
54 }) | 60 }) |
55 .then(function() { | 61 .then(function() { |
56 return with_iframe(scope); | 62 return with_iframe(scope); |
57 }) | 63 }) |
58 .then(function(frame) { | 64 .then(function(frame) { |
59 var frame_window = frame.contentWindow; | 65 var frame_window = frame.contentWindow; |
60 assert_equals(frame_window.navigator.serviceWorker.controller, null, | 66 assert_equals(frame_window.navigator.serviceWorker.controller, null, |
61 'document should not have a controller'); | 67 'document should not have a controller'); |
62 return frame_window.fetch_url('simple.txt'); | 68 return frame_window.fetch_url('simple.txt'); |
63 }) | 69 }) |
64 .then(function(response) { | 70 .then(function(response) { |
65 assert_equals(response, 'a simple text file\n', | 71 assert_equals(response, 'a simple text file\n', |
66 'requests should not be intercepted'); | 72 'requests should not be intercepted'); |
67 t.done(); | 73 t.done(); |
68 }) | 74 }) |
69 .catch(unreached_rejection(t)); | 75 .catch(unreached_rejection(t)); |
70 }, 'Unregister prevents control of subsequent navigations'); | 76 }, 'Unregister prevents control of subsequent navigations'); |
71 | 77 |
72 async_test(function(t) { | 78 async_test(function(t) { |
73 var scope = | 79 var scope = |
74 'scope/no-new-controllee-even-if-registration-is-still-used'; | 80 'scope/no-new-controllee-even-if-registration-is-still-used'; |
75 | 81 |
76 service_worker_unregister_and_register(t, worker_url, scope) | 82 service_worker_unregister_and_register(t, worker_url, scope) |
83 .then(function(registration) { | |
84 return wait_for_update(t, registration); | |
85 }) | |
77 .then(function(registered_worker) { | 86 .then(function(registered_worker) { |
78 return wait_for_state(t, registered_worker, 'activated'); | 87 return wait_for_state(t, registered_worker, 'activated'); |
79 }) | 88 }) |
80 .then(function() { | 89 .then(function() { |
81 return with_iframe(scope); | 90 return with_iframe(scope); |
82 }) | 91 }) |
83 .then(function(frame) { | 92 .then(function(frame) { |
84 return navigator.serviceWorker.unregister(scope); | 93 return navigator.serviceWorker.unregister(scope); |
85 }) | 94 }) |
86 .then(function() { | 95 .then(function() { |
87 return with_iframe(scope); | 96 return with_iframe(scope); |
88 }) | 97 }) |
89 .then(function(frame) { | 98 .then(function(frame) { |
90 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, | 99 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
91 null, | 100 null, |
92 'document should not have a controller'); | 101 'document should not have a controller'); |
93 t.done(); | 102 t.done(); |
94 }) | 103 }) |
95 .catch(unreached_rejection(t)); | 104 .catch(unreached_rejection(t)); |
96 }, 'Unregister prevents new controllee even if registration is still in use'); | 105 }, 'Unregister prevents new controllee even if registration is still in use'); |
97 </script> | 106 </script> |
OLD | NEW |