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/empty-worker.js'; | 6 var worker_url = 'resources/empty-worker.js'; |
7 | 7 |
8 async_test(function(t) { | 8 async_test(function(t) { |
9 var scope = 'resources/scope/re-register-resolves-to-new-value'; | 9 var scope = 'resources/scope/re-register-resolves-to-new-value'; |
10 var iframe; | 10 var iframe; |
11 var registration; | 11 var registration; |
12 | 12 |
13 service_worker_unregister_and_register(t, worker_url, scope) | 13 service_worker_unregister_and_register(t, worker_url, scope) |
14 .then(function(r) { | 14 .then(function(r) { |
15 registration = r; | 15 registration = r; |
16 return wait_for_update(t, registration); | 16 return wait_for_state(t, r.installing, 'activated'); |
17 }) | |
18 .then(function(worker) { | |
19 return wait_for_state(t, worker, 'activated'); | |
20 }) | 17 }) |
21 .then(function() { | 18 .then(function() { |
22 return registration.unregister(); | 19 return registration.unregister(); |
23 }) | 20 }) |
24 .then(function() { | 21 .then(function() { |
25 return navigator.serviceWorker.register(worker_url, { scope: scope }); | 22 return navigator.serviceWorker.register(worker_url, { scope: scope }); |
26 }) | 23 }) |
27 .then(function(new_registration) { | 24 .then(function(new_registration) { |
28 assert_not_equals(registration, new_registration, | 25 assert_not_equals(registration, new_registration, |
29 'register should resolve to a new value'); | 26 'register should resolve to a new value'); |
30 service_worker_unregister_and_done(t, scope); | 27 service_worker_unregister_and_done(t, scope); |
31 }) | 28 }) |
32 .catch(unreached_rejection(t)); | 29 .catch(unreached_rejection(t)); |
33 }, 'Unregister then register resolves to a new value'); | 30 }, 'Unregister then register resolves to a new value'); |
34 | 31 |
35 async_test(function(t) { | 32 async_test(function(t) { |
36 var scope = 'resources/scope/re-register-while-old-registration-in-use'; | 33 var scope = 'resources/scope/re-register-while-old-registration-in-use'; |
37 var registration; | 34 var registration; |
38 | 35 |
39 service_worker_unregister_and_register(t, worker_url, scope) | 36 service_worker_unregister_and_register(t, worker_url, scope) |
40 .then(function(r) { | 37 .then(function(r) { |
41 registration = r; | 38 registration = r; |
42 return wait_for_update(t, registration); | 39 return wait_for_state(t, r.installing, 'activated'); |
43 }) | |
44 .then(function(worker) { | |
45 return wait_for_state(t, worker, 'activated'); | |
46 }) | 40 }) |
47 .then(function() { | 41 .then(function() { |
48 return with_iframe(scope); | 42 return with_iframe(scope); |
49 }) | 43 }) |
50 .then(function(frame) { | 44 .then(function(frame) { |
51 return registration.unregister(); | 45 return registration.unregister(); |
52 }) | 46 }) |
53 .then(function() { | 47 .then(function() { |
54 return navigator.serviceWorker.register(worker_url, { scope: scope }); | 48 return navigator.serviceWorker.register(worker_url, { scope: scope }); |
55 }) | 49 }) |
56 .then(function(new_registration) { | 50 .then(function(new_registration) { |
57 assert_equals(registration, new_registration, | 51 assert_equals(registration, new_registration, |
58 'register should resolve to the same value'); | 52 'register should resolve to the same value'); |
59 service_worker_unregister_and_done(t, scope); | 53 service_worker_unregister_and_done(t, scope); |
60 }) | 54 }) |
61 .catch(unreached_rejection(t)); | 55 .catch(unreached_rejection(t)); |
62 }, 'Unregister then register resolves to the original value if the ' + | 56 }, 'Unregister then register resolves to the original value if the ' + |
63 'registration is in use.'); | 57 'registration is in use.'); |
64 | 58 |
65 async_test(function(t) { | 59 async_test(function(t) { |
66 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee
'; | 60 var scope = 'resources/scope/re-register-does-not-affect-existing-controllee
'; |
67 var iframe; | 61 var iframe; |
68 var registration; | 62 var registration; |
69 var controller; | 63 var controller; |
70 | 64 |
71 service_worker_unregister_and_register(t, worker_url, scope) | 65 service_worker_unregister_and_register(t, worker_url, scope) |
72 .then(function(r) { | 66 .then(function(r) { |
73 registration = r; | 67 registration = r; |
74 return wait_for_update(t, registration); | 68 return wait_for_state(t, r.installing, 'activated'); |
75 }) | |
76 .then(function(worker) { | |
77 return wait_for_state(t, worker, 'activated'); | |
78 }) | 69 }) |
79 .then(function() { | 70 .then(function() { |
80 return with_iframe(scope); | 71 return with_iframe(scope); |
81 }) | 72 }) |
82 .then(function(frame) { | 73 .then(function(frame) { |
83 iframe = frame; | 74 iframe = frame; |
84 controller = iframe.contentWindow.navigator.serviceWorker.controller; | 75 controller = iframe.contentWindow.navigator.serviceWorker.controller; |
85 return registration.unregister(); | 76 return registration.unregister(); |
86 }) | 77 }) |
87 .then(function() { | 78 .then(function() { |
(...skipping 13 matching lines...) Expand all Loading... |
101 }, 'Unregister then register does not affect existing controllee'); | 92 }, 'Unregister then register does not affect existing controllee'); |
102 | 93 |
103 async_test(function(t) { | 94 async_test(function(t) { |
104 var scope = 'resources/scope/resurrection'; | 95 var scope = 'resources/scope/resurrection'; |
105 var iframe; | 96 var iframe; |
106 var registration; | 97 var registration; |
107 | 98 |
108 service_worker_unregister_and_register(t, worker_url, scope) | 99 service_worker_unregister_and_register(t, worker_url, scope) |
109 .then(function(r) { | 100 .then(function(r) { |
110 registration = r; | 101 registration = r; |
111 return wait_for_update(t, registration); | 102 return wait_for_state(t, r.installing, 'activated'); |
112 }) | |
113 .then(function(worker) { | |
114 return wait_for_state(t, worker, 'activated'); | |
115 }) | 103 }) |
116 .then(function() { | 104 .then(function() { |
117 return with_iframe(scope); | 105 return with_iframe(scope); |
118 }) | 106 }) |
119 .then(function(frame) { | 107 .then(function(frame) { |
120 iframe = frame; | 108 iframe = frame; |
121 return registration.unregister(); | 109 return registration.unregister(); |
122 }) | 110 }) |
123 .then(function() { | 111 .then(function() { |
124 return navigator.serviceWorker.register(worker_url, { scope: scope }); | 112 return navigator.serviceWorker.register(worker_url, { scope: scope }); |
125 }) | 113 }) |
126 .then(function() { | 114 .then(function() { |
127 return unload_iframe(iframe); | 115 return unload_iframe(iframe); |
128 }) | 116 }) |
129 .then(function() { | 117 .then(function() { |
130 return with_iframe(scope); | 118 return with_iframe(scope); |
131 }) | 119 }) |
132 .then(function(frame) { | 120 .then(function(frame) { |
133 // FIXME: When crbug.com/400602 is fixed, assert that controller | 121 // FIXME: When crbug.com/400602 is fixed, assert that controller |
134 // equals the original worker. | 122 // equals the original worker. |
135 assert_not_equals( | 123 assert_not_equals( |
136 frame.contentWindow.navigator.serviceWorker.controller, null, | 124 frame.contentWindow.navigator.serviceWorker.controller, null, |
137 'document should have a controller'); | 125 'document should have a controller'); |
138 service_worker_unregister_and_done(t, scope); | 126 service_worker_unregister_and_done(t, scope); |
139 }) | 127 }) |
140 .catch(unreached_rejection(t)); | 128 .catch(unreached_rejection(t)); |
141 }, 'Unregister then register resurrects the registration'); | 129 }, 'Unregister then register resurrects the registration'); |
142 </script> | 130 </script> |
OLD | NEW |