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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/postmessage-after-terminate.html

Issue 695643002: Add terminateServiceWorker method for layout tests - blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/ping-worker.js » ('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>Tests that postMessage works during and after terminating a service worke r</title>
3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../../resources/testharness-helpers.js"></script>
6 <script src="../resources/test-helpers.js"></script>
7 <script>
8 function send_ping(worker) {
9 return new Promise(function(resolve) {
10 var channel = new MessageChannel();
11 channel.port1.onmessage = function(message) {
12 resolve(message.data);
13 };
14 worker.postMessage({port: channel.port2}, [channel.port2]);
15 });
16 }
17
18 promise_test(function(test) {
19 var worker = 'resources/ping-worker.js';
20 var scope = 'resources/blank.html';
21 var sw;
22 return service_worker_unregister_and_register(test, worker, scope)
23 .then(function(registration) {
24 return wait_for_update(test, registration);
25 })
26 .then(function(worker) {
27 sw = worker;
28 return send_ping(sw);
29 })
30 .then(function(reply) {
31 assert_equals(reply, 0);
32 return internals.terminateServiceWorker(sw);
33 })
34 .then(function() {
35 return send_ping(sw);
36 })
37 .then(function(reply) {
38 assert_equals(reply, 0);
39 return send_ping(sw);
40 })
41 .then(function(reply) {
42 assert_equals(reply, 1);
43 return service_worker_unregister_and_done(test, scope);
44 });
45 }, 'postMessage to a terminated service worker.');
46 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/ping-worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698