Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/postmessage-to-client.html

Issue 2466513002: Deprecate ServiceWorkerMessageEvent in favor of MessageEvent (Closed)
Patch Set: Rebase and update cross-origin-objects-exceptions-expected.txt Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: postMessage to Client</title> 2 <title>Service Worker: postMessage to Client</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(t => { 8 promise_test(t => {
9 var script = 'resources/postmessage-to-client-worker.js'; 9 var script = 'resources/postmessage-to-client-worker.js';
10 var scope = 'resources/blank.html'; 10 var scope = 'resources/blank.html';
11 var w; 11 var w;
12 12
13 return service_worker_unregister_and_register(t, script, scope) 13 return service_worker_unregister_and_register(t, script, scope)
14 .then(registration => { 14 .then(registration => {
15 add_completion_callback(() => registration.unregister()); 15 add_completion_callback(() => registration.unregister());
16 return wait_for_state(t, registration.installing, 'activated'); 16 return wait_for_state(t, registration.installing, 'activated');
17 }) 17 })
18 .then(() => with_iframe(scope)) 18 .then(() => with_iframe(scope))
19 .then(frame => { 19 .then(frame => {
20 return new Promise(resolve => { 20 return new Promise(resolve => {
21 w = frame.contentWindow; 21 w = frame.contentWindow;
22 w.navigator.serviceWorker.onmessage = resolve; 22 w.navigator.serviceWorker.onmessage = resolve;
23 w.navigator.serviceWorker.controller.postMessage('ping'); 23 w.navigator.serviceWorker.controller.postMessage('ping');
24 }); 24 });
25 }) 25 })
26 .then(e => { 26 .then(e => {
27 var message = e.data; 27 var message = e.data;
28 assert_equals(e.origin, location.origin, 28 assert_equals(e.constructor, w.MessageEvent,
29 'origin of message should be origin of Service Worker'); 29 'message events should use MessageEvent interface.');
30 assert_equals(e.type, 'message', 'type should be "message".');
31 assert_equals(
32 e.origin, location.origin,
33 'origin of message should be origin of Service Worker.');
30 assert_equals(e.lastEventId, '', 34 assert_equals(e.lastEventId, '',
31 'lastEventId should be an empty string'); 35 'lastEventId should be an empty string.');
36 assert_equals(e.source.constructor, w.ServiceWorker,
37 'source should use ServiceWorker interface.');
38 assert_equals(
39 e.source, w.navigator.serviceWorker.controller,
40 'source should be the service worker that sent the message.');
41 assert_equals(e.ports.length, 0, 'ports should be an empty array.');
32 assert_equals(message, 'Sending message via clients'); 42 assert_equals(message, 'Sending message via clients');
33 return new Promise(resolve => { 43 return new Promise(resolve => {
34 w.navigator.serviceWorker.onmessage = resolve; 44 w.navigator.serviceWorker.onmessage = resolve;
35 }); 45 });
36 }) 46 })
37 .then(e => { assert_equals(e.data, 'quit'); }); 47 .then(e => { assert_equals(e.data, 'quit'); });
38 }, 'postMessage from ServiceWorker to Client'); 48 }, 'postMessage from ServiceWorker to Client.');
39 49
40 </script> 50 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698