OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: getRegistrations()</title> | 2 <title>Service Worker: getRegistrations()</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/testharness-helpers.js"></script> | 5 <script src="../resources/testharness-helpers.js"></script> |
6 <script src="resources/test-helpers.js"></script> | 6 <script src="resources/test-helpers.js"></script> |
7 <script src="../resources/get-host-info.js"></script> | 7 <script src="../resources/get-host-info.js"></script> |
8 <script> | 8 <script> |
9 // Purge the existing registrations for the origin. | 9 // Purge the existing registrations for the origin. |
10 // getRegistrations() is used in order to avoid adding additional complexity | 10 // getRegistrations() is used in order to avoid adding additional complexity |
(...skipping 27 matching lines...) Expand all Loading... |
38 promise_test(function(t) { | 38 promise_test(function(t) { |
39 var scope = 'resources/scope/getregistrations/normal'; | 39 var scope = 'resources/scope/getregistrations/normal'; |
40 var script = 'resources/empty-worker.js'; | 40 var script = 'resources/empty-worker.js'; |
41 var registrations = []; | 41 var registrations = []; |
42 return service_worker_unregister_and_register(t, script, scope) | 42 return service_worker_unregister_and_register(t, script, scope) |
43 .then(function(r) { | 43 .then(function(r) { |
44 registrations.push(r); | 44 registrations.push(r); |
45 return navigator.serviceWorker.getRegistrations(); | 45 return navigator.serviceWorker.getRegistrations(); |
46 }) | 46 }) |
47 .then(function(value) { | 47 .then(function(value) { |
48 assert_array_equals( | 48 assert_registration_array_equals( |
49 value, | 49 value, |
50 registrations, | 50 registrations, |
51 'getRegistrations should resolve with array of registrations.'); | 51 'getRegistrations should resolve with array of registrations.'); |
52 return service_worker_unregister(t, scope); | 52 return service_worker_unregister(t, scope); |
53 }); | 53 }); |
54 }, 'Register then getRegistrations'); | 54 }, 'Register then getRegistrations'); |
55 | 55 |
56 promise_test(function(t) { | 56 promise_test(function(t) { |
57 var scope1 = 'resources/scope/getregistrations/scope1'; | 57 var scope1 = 'resources/scope/getregistrations/scope1'; |
58 var scope2 = 'resources/scope/getregistrations/scope2'; | 58 var scope2 = 'resources/scope/getregistrations/scope2'; |
59 var script = 'resources/empty-worker.js'; | 59 var script = 'resources/empty-worker.js'; |
60 var registrations = []; | 60 var registrations = []; |
61 return service_worker_unregister_and_register(t, script, scope1) | 61 return service_worker_unregister_and_register(t, script, scope1) |
62 .then(function(r) { | 62 .then(function(r) { |
63 registrations.push(r); | 63 registrations.push(r); |
64 return service_worker_unregister_and_register(t, script, scope2); | 64 return service_worker_unregister_and_register(t, script, scope2); |
65 }) | 65 }) |
66 .then(function(r) { | 66 .then(function(r) { |
67 registrations.push(r); | 67 registrations.push(r); |
68 return navigator.serviceWorker.getRegistrations(); | 68 return navigator.serviceWorker.getRegistrations(); |
69 }) | 69 }) |
70 .then(function(value) { | 70 .then(function(value) { |
71 assert_array_equals( | 71 assert_registration_array_equals( |
72 value, | 72 value, |
73 registrations, | 73 registrations, |
74 'getRegistrations should resolve with array of registrations.'); | 74 'getRegistrations should resolve with array of registrations.'); |
75 return service_worker_unregister(t, scope1); | 75 return service_worker_unregister(t, scope1); |
76 }) | 76 }) |
77 .then(function() { | 77 .then(function() { |
78 return service_worker_unregister(t, scope2); | 78 return service_worker_unregister(t, scope2); |
79 }); | 79 }); |
80 }, 'Register multiple times then getRegistrations'); | 80 }, 'Register multiple times then getRegistrations'); |
81 | 81 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Frame's registration is registered. | 121 // Frame's registration is registered. |
122 if (e.data == 'registered') { | 122 if (e.data == 'registered') { |
123 // Top-level window registers a registration scoped | 123 // Top-level window registers a registration scoped |
124 // http://127.0.0.1:8000/serviceworker/resources/scope-for-getregi
strations. | 124 // http://127.0.0.1:8000/serviceworker/resources/scope-for-getregi
strations. |
125 service_worker_unregister_and_register(t, script, scope) | 125 service_worker_unregister_and_register(t, script, scope) |
126 .then(function(r) { | 126 .then(function(r) { |
127 registrations.push(r); | 127 registrations.push(r); |
128 return navigator.serviceWorker.getRegistrations(); | 128 return navigator.serviceWorker.getRegistrations(); |
129 }) | 129 }) |
130 .then(function(value) { | 130 .then(function(value) { |
131 assert_array_equals(value, registrations, | 131 assert_registration_array_equals(value, registrations, |
132 'getRegistrations should return only the same origin ' + | 132 'getRegistrations should return only the same origin ' + |
133 'registrations.'); | 133 'registrations.'); |
134 channel.port1.postMessage('unregister'); | 134 channel.port1.postMessage('unregister'); |
135 }); | 135 }); |
136 } else if (e.data == 'unregistered') { | 136 } else if (e.data == 'unregistered') { |
137 resolve(); | 137 resolve(); |
138 } | 138 } |
139 }; | 139 }; |
140 frame.contentWindow.postMessage('register', '*', [channel.port2]); | 140 frame.contentWindow.postMessage('register', '*', [channel.port2]); |
141 return p; | 141 return p; |
142 }) | 142 }) |
143 .then(function() { | 143 .then(function() { |
144 frame.remove(); | 144 frame.remove(); |
145 return service_worker_unregister(t, scope); | 145 return service_worker_unregister(t, scope); |
146 }); | 146 }); |
147 }, 'getRegistrations promise resolves only with same origin registrations.'); | 147 }, 'getRegistrations promise resolves only with same origin registrations.'); |
148 | 148 |
149 done(); | 149 done(); |
150 </script> | 150 </script> |
OLD | NEW |