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 frame_window; | 11 var frame_window; |
12 var controller; | 12 var controller; |
13 var registration; | 13 var registration; |
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(r) { | 16 .then(function(r) { |
17 registration = r; | 17 registration = r; |
18 return wait_for_update(t, registration); | 18 return wait_for_state(t, r.installing, 'activated'); |
19 }) | |
20 .then(function(worker) { | |
21 return wait_for_state(t, worker, 'activated'); | |
22 }) | 19 }) |
23 .then(function() { | 20 .then(function() { |
24 return with_iframe(scope); | 21 return with_iframe(scope); |
25 }) | 22 }) |
26 .then(function(frame) { | 23 .then(function(frame) { |
27 frame_window = frame.contentWindow; | 24 frame_window = frame.contentWindow; |
28 controller = frame_window.navigator.serviceWorker.controller; | 25 controller = frame_window.navigator.serviceWorker.controller; |
29 assert_true(controller instanceof frame_window.ServiceWorker, | 26 assert_true(controller instanceof frame_window.ServiceWorker, |
30 'document should load with a controller'); | 27 'document should load with a controller'); |
31 return registration.unregister(); | 28 return registration.unregister(); |
(...skipping 13 matching lines...) Expand all Loading... |
45 }, 'Unregister does not affect existing controller'); | 42 }, 'Unregister does not affect existing controller'); |
46 | 43 |
47 async_test(function(t) { | 44 async_test(function(t) { |
48 var scope = | 45 var scope = |
49 'resources/unregister-controller-page.html?load-after-unregister'; | 46 'resources/unregister-controller-page.html?load-after-unregister'; |
50 var registration; | 47 var registration; |
51 | 48 |
52 service_worker_unregister_and_register(t, worker_url, scope) | 49 service_worker_unregister_and_register(t, worker_url, scope) |
53 .then(function(r) { | 50 .then(function(r) { |
54 registration = r; | 51 registration = r; |
55 return wait_for_update(t, registration); | 52 return wait_for_state(t, r.installing, 'activated'); |
56 }) | |
57 .then(function(worker) { | |
58 return wait_for_state(t, worker, 'activated'); | |
59 }) | 53 }) |
60 .then(function() { | 54 .then(function() { |
61 return registration.unregister(); | 55 return registration.unregister(); |
62 }) | 56 }) |
63 .then(function() { | 57 .then(function() { |
64 return with_iframe(scope); | 58 return with_iframe(scope); |
65 }) | 59 }) |
66 .then(function(frame) { | 60 .then(function(frame) { |
67 var frame_window = frame.contentWindow; | 61 var frame_window = frame.contentWindow; |
68 assert_equals(frame_window.navigator.serviceWorker.controller, null, | 62 assert_equals(frame_window.navigator.serviceWorker.controller, null, |
69 'document should not have a controller'); | 63 'document should not have a controller'); |
70 return frame_window.fetch_url('simple.txt'); | 64 return frame_window.fetch_url('simple.txt'); |
71 }) | 65 }) |
72 .then(function(response) { | 66 .then(function(response) { |
73 assert_equals(response, 'a simple text file\n', | 67 assert_equals(response, 'a simple text file\n', |
74 'requests should not be intercepted'); | 68 'requests should not be intercepted'); |
75 t.done(); | 69 t.done(); |
76 }) | 70 }) |
77 .catch(unreached_rejection(t)); | 71 .catch(unreached_rejection(t)); |
78 }, 'Unregister prevents control of subsequent navigations'); | 72 }, 'Unregister prevents control of subsequent navigations'); |
79 | 73 |
80 async_test(function(t) { | 74 async_test(function(t) { |
81 var scope = | 75 var scope = |
82 'resources/scope/no-new-controllee-even-if-registration-is-still-used'; | 76 'resources/scope/no-new-controllee-even-if-registration-is-still-used'; |
83 var registration; | 77 var registration; |
84 | 78 |
85 service_worker_unregister_and_register(t, worker_url, scope) | 79 service_worker_unregister_and_register(t, worker_url, scope) |
86 .then(function(r) { | 80 .then(function(r) { |
87 registration = r; | 81 registration = r; |
88 return wait_for_update(t, registration); | 82 return wait_for_state(t, r.installing, 'activated'); |
89 }) | |
90 .then(function(worker) { | |
91 return wait_for_state(t, worker, 'activated'); | |
92 }) | 83 }) |
93 .then(function() { | 84 .then(function() { |
94 return with_iframe(scope); | 85 return with_iframe(scope); |
95 }) | 86 }) |
96 .then(function(frame) { | 87 .then(function(frame) { |
97 return registration.unregister(); | 88 return registration.unregister(); |
98 }) | 89 }) |
99 .then(function() { | 90 .then(function() { |
100 return with_iframe(scope); | 91 return with_iframe(scope); |
101 }) | 92 }) |
102 .then(function(frame) { | 93 .then(function(frame) { |
103 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, | 94 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
104 null, | 95 null, |
105 'document should not have a controller'); | 96 'document should not have a controller'); |
106 t.done(); | 97 t.done(); |
107 }) | 98 }) |
108 .catch(unreached_rejection(t)); | 99 .catch(unreached_rejection(t)); |
109 }, 'Unregister prevents new controllee even if registration is still in use'); | 100 }, 'Unregister prevents new controllee even if registration is still in use'); |
110 </script> | 101 </script> |
OLD | NEW |