OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Service Worker: ServiceWorkerMessageEvent</title> | |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharness-helpers.js"></script> | |
5 <script src="../resources/testharnessreport.js"></script> | |
6 <script src="resources/test-helpers.js"></script> | |
7 <script> | |
8 | |
9 promise_test(function(t) { | |
10 var scope = 'resources/blank.html'; | |
11 var url = 'resources/postmessage-to-client-worker.js'; | |
12 return service_worker_unregister_and_register(t, url, scope) | |
13 .then(function(r) { | |
14 return wait_for_state(t, r.installing, 'activated'); | |
15 }) | |
16 .then(function() { | |
17 return with_iframe(scope); | |
18 }) | |
19 .then(function(frame) { | |
20 var w = frame.contentWindow; | |
21 var worker = w.navigator.serviceWorker.controller; | |
22 // Test constructor with ServiceWorker object as source. | |
23 var e = new ServiceWorkerMessageEvent('evenType', {source: worker}); | |
falken
2015/06/25 03:49:35
eventType
xiang
2015/06/29 02:32:24
Done.
| |
24 assert_equals(e.source, worker, | |
25 'Source should equal to the passing service worker'); | |
26 return new Promise(function(resolve) { | |
27 w.navigator.serviceWorker.onmessage = t.step_func(function(e) { | |
28 assert_true( | |
29 e instanceof w.ServiceWorkerMessageEvent, | |
30 'Instance type should be ServiceWorkerMessageEvent'); | |
31 assert_true(e.source instanceof w.ServiceWorker, | |
32 'Source type should be ServiceWorker'); | |
33 assert_equals(e.type, 'message', | |
34 'Event type should be "message"'); | |
35 assert_equals(e.source, worker, | |
36 'Source worker should equal to the controller'); | |
37 resolve(); | |
38 }); | |
39 worker.postMessage('PING'); | |
40 }); | |
41 }) | |
42 .then(function() { | |
43 return service_worker_unregister_and_done(t, scope); | |
44 }); | |
45 }, 'Test ServiceWorkerMessageEvent type.'); | |
46 | |
47 </script> | |
OLD | NEW |