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

Side by Side Diff: LayoutTests/http/tests/serviceworker/extendable-message-event.html

Issue 1156703003: ServiceWorker: Introduce ExtendableMessageEvent to replace MessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update Created 5 years, 5 months 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/fetch-event-async-respond-with.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: ExtendableMessageEvent</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/extendable-message-event-client';
11 var url = 'resources/extendable-message-event-worker.js';
12 var worker;
13 return service_worker_unregister_and_register(t, url, scope)
14 .then(function(r) {
15 worker = r.installing;
16 var channel = new MessageChannel();
17 return new Promise(function(resolve) {
18 channel.port1.onmessage = t.step_func(function(e) {
19 assert_equals(e.data, 'PASS');
20 resolve();
21 });
22 worker.postMessage({port: channel.port2}, [channel.port2]);
23 worker.postMessage('TEST');
24 });
25 })
26 .then(function() {
27 return service_worker_unregister_and_done(t, scope);
28 })
29 }, 'Test ExtendableMessageEvent sending from client.');
30
31 promise_test(function(t) {
32 var scope = 'resources/blank.html';
33 var sender = 'resources/extendable-message-event-sender-worker.js';
34 var receiver = 'resources/extendable-message-event-worker.js';
35 var frame, saw_message;
36 return service_worker_unregister_and_register(t, receiver, scope)
37 .then(function(r) {
38 var channel = new MessageChannel();
39 saw_message = new Promise(function(resolve) {
40 channel.port1.onmessage = t.step_func(function(e) {
41 assert_equals(e.data, 'PASS');
42 resolve();
43 });
44 r.installing.postMessage({port: channel.port2}, [channel.port2]);
45 });
46 return wait_for_state(t, r.installing, 'activated');
47 })
48 .then(function() {
49 return with_iframe(scope);
50 })
51 .then(function(f) {
52 frame = f;
53 navigator.serviceWorker.register(sender, {scope: scope});
54 return saw_message;
55 })
56 .then(function() {
57 frame.remove();
58 service_worker_unregister_and_done(t, scope);
59 });
60 }, 'Test ExtendableMessageEvent sending from service worker.');
61
62 promise_test(function(t) {
63 var scope = 'resources/extendable-message-event-waituntil';
64 var url = 'resources/extendable-message-event-worker-waituntil.js';
65 var worker, channel;
66 return service_worker_unregister_and_register(t, url, scope)
67 .then(function(r) {
68 worker = r.installing;
69 channel = new MessageChannel();
70 return new Promise(function(resolve) {
71 channel.port1.onmessage = t.step_func(function(e) {
72 assert_equals(e.data, 'ACK',
73 'WAIT message should be acked first');
74 resolve();
75 });
76 worker.postMessage({port: channel.port2}, [channel.port2]);
77 worker.postMessage('WAIT');
78 });
79 })
80 .then(function() {
81 return new Promise(function(resolve) {
82 channel.port1.onmessage = t.step_func(function(e) {
83 assert_equals(e.data, 'PASS',
84 'Previous waitUntil should be resolved');
85 resolve();
86 });
87 worker.postMessage('DONE');
88 });
89 })
90 .then(function() {
91 return service_worker_unregister_and_done(t, scope);
92 });
93 }, 'Test calling waitUntil synchronously.');
94
95 promise_test(function(t) {
96 var scope = 'resources/extendable-message-event-waituntil-async';
97 var url = 'resources/extendable-message-event-worker-waituntil.js';
98 var worker, channel;
99 return service_worker_unregister_and_register(t, url, scope)
100 .then(function(r) {
101 worker = r.installing;
102 channel = new MessageChannel();
103 return new Promise(function(resolve) {
104 channel.port1.onmessage = t.step_func(function(e) {
105 assert_equals(e.data, 'PASS');
106 resolve();
107 });
108 worker.postMessage({port: channel.port2}, [channel.port2]);
109 worker.postMessage('WAIT_ASYNC');
110 });
111 })
112 .then(function() {
113 return service_worker_unregister_and_done(t, scope);
114 });
115 }, 'Test calling waitUntil asynchronously.');
116
117 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/fetch-event-async-respond-with.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698