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.sub.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 var frame; |
14 | 15 |
15 service_worker_unregister_and_register(t, worker_url, scope) | 16 service_worker_unregister_and_register(t, worker_url, scope) |
16 .then(function(r) { | 17 .then(function(r) { |
17 registration = r; | 18 registration = r; |
18 return wait_for_state(t, r.installing, 'activated'); | 19 return wait_for_state(t, r.installing, 'activated'); |
19 }) | 20 }) |
20 .then(function() { | 21 .then(function() { |
21 return with_iframe(scope); | 22 return with_iframe(scope); |
22 }) | 23 }) |
23 .then(function(frame) { | 24 .then(function(f) { |
| 25 frame = f; |
24 frame_window = frame.contentWindow; | 26 frame_window = frame.contentWindow; |
25 controller = frame_window.navigator.serviceWorker.controller; | 27 controller = frame_window.navigator.serviceWorker.controller; |
26 assert_true(controller instanceof frame_window.ServiceWorker, | 28 assert_true(controller instanceof frame_window.ServiceWorker, |
27 'document should load with a controller'); | 29 'document should load with a controller'); |
28 return registration.unregister(); | 30 return registration.unregister(); |
29 }) | 31 }) |
30 .then(function() { | 32 .then(function() { |
31 assert_equals(frame_window.navigator.serviceWorker.controller, | 33 assert_equals(frame_window.navigator.serviceWorker.controller, |
32 controller, | 34 controller, |
33 'unregistration should not modify controller'); | 35 'unregistration should not modify controller'); |
34 return frame_window.fetch_url('simple.txt'); | 36 return frame_window.fetch_url('simple.txt'); |
35 }) | 37 }) |
36 .then(function(response) { | 38 .then(function(response) { |
37 assert_equals(response, 'intercepted by service worker', | 39 assert_equals(response, 'intercepted by service worker', |
38 'controller should intercept requests'); | 40 'controller should intercept requests'); |
| 41 frame.remove(); |
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 var registration; | 50 var registration; |
| 51 var frame; |
48 | 52 |
49 service_worker_unregister_and_register(t, worker_url, scope) | 53 service_worker_unregister_and_register(t, worker_url, scope) |
50 .then(function(r) { | 54 .then(function(r) { |
51 registration = r; | 55 registration = r; |
52 return wait_for_state(t, r.installing, 'activated'); | 56 return wait_for_state(t, r.installing, 'activated'); |
53 }) | 57 }) |
54 .then(function() { | 58 .then(function() { |
55 return registration.unregister(); | 59 return registration.unregister(); |
56 }) | 60 }) |
57 .then(function() { | 61 .then(function() { |
58 return with_iframe(scope); | 62 return with_iframe(scope); |
59 }) | 63 }) |
60 .then(function(frame) { | 64 .then(function(f) { |
| 65 frame = f; |
61 var frame_window = frame.contentWindow; | 66 var frame_window = frame.contentWindow; |
62 assert_equals(frame_window.navigator.serviceWorker.controller, null, | 67 assert_equals(frame_window.navigator.serviceWorker.controller, null, |
63 'document should not have a controller'); | 68 'document should not have a controller'); |
64 return frame_window.fetch_url('simple.txt'); | 69 return frame_window.fetch_url('simple.txt'); |
65 }) | 70 }) |
66 .then(function(response) { | 71 .then(function(response) { |
67 assert_equals(response, 'a simple text file\n', | 72 assert_equals(response, 'a simple text file\n', |
68 'requests should not be intercepted'); | 73 'requests should not be intercepted'); |
| 74 frame.remove(); |
69 t.done(); | 75 t.done(); |
70 }) | 76 }) |
71 .catch(unreached_rejection(t)); | 77 .catch(unreached_rejection(t)); |
72 }, 'Unregister prevents control of subsequent navigations'); | 78 }, 'Unregister prevents control of subsequent navigations'); |
73 | 79 |
74 async_test(function(t) { | 80 async_test(function(t) { |
75 var scope = | 81 var scope = |
76 'resources/scope/no-new-controllee-even-if-registration-is-still-used'; | 82 'resources/scope/no-new-controllee-even-if-registration-is-still-used'; |
77 var registration; | 83 var registration; |
78 | 84 |
79 service_worker_unregister_and_register(t, worker_url, scope) | 85 service_worker_unregister_and_register(t, worker_url, scope) |
80 .then(function(r) { | 86 .then(function(r) { |
81 registration = r; | 87 registration = r; |
82 return wait_for_state(t, r.installing, 'activated'); | 88 return wait_for_state(t, r.installing, 'activated'); |
83 }) | 89 }) |
84 .then(function() { | 90 .then(function() { |
85 return with_iframe(scope); | 91 return with_iframe(scope); |
86 }) | 92 }) |
87 .then(function(frame) { | 93 .then(function(frame) { |
88 return registration.unregister(); | 94 return registration.unregister(); |
89 }) | 95 }) |
90 .then(function() { | 96 .then(function() { |
91 return with_iframe(scope); | 97 return with_iframe(scope); |
92 }) | 98 }) |
93 .then(function(frame) { | 99 .then(function(frame) { |
94 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, | 100 assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
95 null, | 101 null, |
96 'document should not have a controller'); | 102 'document should not have a controller'); |
| 103 frame.remove(); |
97 t.done(); | 104 t.done(); |
98 }) | 105 }) |
99 .catch(unreached_rejection(t)); | 106 .catch(unreached_rejection(t)); |
100 }, 'Unregister prevents new controllee even if registration is still in use'); | 107 }, 'Unregister prevents new controllee even if registration is still in use'); |
101 </script> | 108 </script> |
OLD | NEW |