Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: ServiceWorkerMessageEvent</title> | 2 <title>Service Worker: ServiceWorkerMessageEvent</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 scope = 'resources/blank.html'; | 9 var scope = 'resources/blank.html'; |
| 10 var url = 'resources/postmessage-to-client-worker.js'; | 10 var url = 'resources/postmessage-to-client-worker.js'; |
| 11 return service_worker_unregister_and_register(t, url, scope) | 11 return service_worker_unregister_and_register(t, url, scope) |
| 12 .then(function(r) { | 12 .then(function(r) { |
| 13 return wait_for_state(t, r.installing, 'activated'); | 13 return wait_for_state(t, r.installing, 'activated'); |
| 14 }) | 14 }) |
| 15 .then(function() { | 15 .then(function() { |
| 16 return with_iframe(scope); | 16 return with_iframe(scope); |
| 17 }) | 17 }) |
| 18 .then(function(frame) { | 18 .then(function(frame) { |
| 19 var w = frame.contentWindow; | 19 var w = frame.contentWindow; |
| 20 var worker = w.navigator.serviceWorker.controller; | 20 var worker = w.navigator.serviceWorker.controller; |
| 21 // Test constructor with ServiceWorker object as source. | 21 assert_equals( |
| 22 var e = new ServiceWorkerMessageEvent('eventType', {source: worker}); | 22 self.ServiceWorkerMessageEvent, undefined, |
| 23 assert_equals(e.source, worker, | 23 'ServiceWorkerMessageEvent should not be defined.'); |
| 24 'Source should equal to the passing service worker'); | |
| 25 return new Promise(function(resolve) { | 24 return new Promise(function(resolve) { |
| 26 w.navigator.serviceWorker.onmessage = t.step_func(function(e) { | 25 w.navigator.serviceWorker.onmessage = t.step_func(function(e) { |
| 27 assert_true(e instanceof w.ServiceWorkerMessageEvent); | 26 assert_true( |
| 27 e instanceof w.MessageEvent, | |
| 28 'message events should use MessageEvent interface.'); | |
| 28 assert_true(e.source instanceof w.ServiceWorker); | 29 assert_true(e.source instanceof w.ServiceWorker); |
| 29 assert_equals(e.type, 'message'); | 30 assert_equals(e.type, 'message'); |
| 30 assert_equals(e.source, worker, | 31 assert_equals(e.source, worker, |
| 31 'Source worker should equal to the controller'); | 32 'source should equal to the controller.'); |
| 32 assert_equals(e.ports.length, 0); | 33 assert_equals(e.ports.length, 0); |
| 33 resolve(); | 34 resolve(); |
|
nhiroki
2016/11/14 05:48:55
Can we merge this test into postmessage-to-client.
jungkees
2016/11/14 14:17:11
I merged the relevant asserts into postmessage-to-
| |
| 34 }); | 35 }); |
| 35 worker.postMessage('PING'); | 36 worker.postMessage('PING'); |
| 36 }); | 37 }); |
| 37 }) | 38 }) |
| 38 .then(function() { | 39 .then(function() { |
| 39 return service_worker_unregister_and_done(t, scope); | 40 return service_worker_unregister_and_done(t, scope); |
| 40 }); | 41 }); |
| 41 }, 'Test ServiceWorkerMessageEvent type.'); | 42 }, 'Test MessageEvent supplants ServiceWorkerMessageEvent.'); |
| 42 | 43 |
| 43 </script> | 44 </script> |
| OLD | NEW |