OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>ServiceWorkerGlobalScope: ExtendableMessageEvent</title> | 2 <title>ServiceWorkerGlobalScope: ExtendableMessageEvent</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/test-helpers.js'></script> | 5 <script src='../resources/test-helpers.js'></script> |
6 <script> | 6 <script> |
7 | 7 |
8 promise_test(function(t) { | 8 promise_test(function(t) { |
9 var script = 'resources/extendable-message-event-constructor-worker.js'; | 9 var script = 'resources/extendable-message-event-constructor-worker.js'; |
10 var scope = 'resources/scope/extendable-message-event-constructor'; | 10 var scope = 'resources/scope/extendable-message-event-constructor'; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ' event.source.frameType: nested', | 96 ' event.source.frameType: nested', |
97 ' event.source.visibilityState: visible', | 97 ' event.source.visibilityState: visible', |
98 ' event.source.focused: false', | 98 ' event.source.focused: false', |
99 ' event.ports: ', | 99 ' event.ports: ', |
100 ]; | 100 ]; |
101 assert_array_equals(results, expected_results); | 101 assert_array_equals(results, expected_results); |
102 }); | 102 }); |
103 }, 'Post an extendable message from a nested client'); | 103 }, 'Post an extendable message from a nested client'); |
104 | 104 |
105 promise_test(function(t) { | 105 promise_test(function(t) { |
106 var script = 'resources/extendable-message-event-worker.js'; | |
107 var scope = 'resources/extendable-message-event-sandboxed-iframe.html'; | |
108 | |
109 return service_worker_unregister_and_register(t, script, scope) | |
110 .then(function(registration) { | |
111 add_completion_callback(function() { registration.unregister(); }); | |
112 return wait_for_state(t, registration.installing, 'activated'); | |
113 }) | |
114 .then(function() { return with_iframe(scope); }) | |
115 .then(function(frame) { | |
116 add_completion_callback(function() { frame.remove(); }); | |
117 var saw_message = new Promise(function(resolve) { | |
118 onmessage = function(event) { | |
119 resolve(event.data); | |
120 } | |
121 }); | |
122 frame.contentWindow.postMessage('', '*'); | |
123 return saw_message; | |
124 }) | |
125 .then(function(results) { | |
126 // 'origin' and 'url' should be hided. | |
127 var expected_results = [ | |
128 'Client message: [object ExtendableMessageEvent]', | |
129 ' event.origin: ', | |
130 ' event.lastEventId: ', | |
131 ' event.source: [object WindowClient]', | |
132 ' event.source.url: ', | |
133 ' event.source.frameType: nested', | |
134 ' event.source.visibilityState: visible', | |
135 ' event.source.focused: false', | |
136 ' event.ports: ', | |
137 ]; | |
138 assert_array_equals(results, expected_results); | |
139 }); | |
140 }, 'Post an extendable message from a sandboxed client'); | |
141 | |
142 promise_test(function(t) { | |
143 var script = 'resources/extendable-message-event-loopback-worker.js'; | 106 var script = 'resources/extendable-message-event-loopback-worker.js'; |
144 var scope = 'resources/scope/extendable-message-event-loopback'; | 107 var scope = 'resources/scope/extendable-message-event-loopback'; |
145 var registration; | 108 var registration; |
146 | 109 |
147 return service_worker_unregister_and_register(t, script, scope) | 110 return service_worker_unregister_and_register(t, script, scope) |
148 .then(function(r) { | 111 .then(function(r) { |
149 registration = r; | 112 registration = r; |
150 add_completion_callback(function() { registration.unregister(); }); | 113 add_completion_callback(function() { registration.unregister(); }); |
151 return wait_for_state(t, registration.installing, 'activated'); | 114 return wait_for_state(t, registration.installing, 'activated'); |
152 }) | 115 }) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 ' event.source: [object ServiceWorker]', | 206 ' event.source: [object ServiceWorker]', |
244 ' event.source.scriptURL: ' + normalizeURL(script2), | 207 ' event.source.scriptURL: ' + normalizeURL(script2), |
245 ' event.source.state: installed', | 208 ' event.source.state: installed', |
246 ' event.ports: ', | 209 ' event.ports: ', |
247 ]; | 210 ]; |
248 assert_array_equals(results, expected_results); | 211 assert_array_equals(results, expected_results); |
249 }); | 212 }); |
250 }, 'Post extendable messages among service workers'); | 213 }, 'Post extendable messages among service workers'); |
251 | 214 |
252 </script> | 215 </script> |
OLD | NEW |