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

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

Issue 776373003: ServiceWorker cleanup: remove wait_for_update() in favor of r.installing in most tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Tests that postMessage works during and after terminating a service worke r</title> 2 <title>Tests that postMessage works during and after terminating a service worke r</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/testharness-helpers.js"></script> 5 <script src="../../resources/testharness-helpers.js"></script>
6 <script src="../resources/test-helpers.js"></script> 6 <script src="../resources/test-helpers.js"></script>
7 <script> 7 <script>
8 function send_ping(worker) { 8 function send_ping(worker) {
9 return new Promise(function(resolve) { 9 return new Promise(function(resolve) {
10 var channel = new MessageChannel(); 10 var channel = new MessageChannel();
11 channel.port1.onmessage = function(message) { 11 channel.port1.onmessage = function(message) {
12 resolve(message.data); 12 resolve(message.data);
13 }; 13 };
14 worker.postMessage({port: channel.port2}, [channel.port2]); 14 worker.postMessage({port: channel.port2}, [channel.port2]);
15 }); 15 });
16 } 16 }
17 17
18 promise_test(function(test) { 18 promise_test(function(test) {
19 var worker = 'resources/ping-worker.js'; 19 var worker = 'resources/ping-worker.js';
20 var scope = 'resources/blank.html'; 20 var scope = 'resources/blank.html';
21 var sw; 21 var sw;
22 return service_worker_unregister_and_register(test, worker, scope) 22 return service_worker_unregister_and_register(test, worker, scope)
23 .then(function(registration) { 23 .then(function(registration) {
24 return wait_for_update(test, registration); 24 sw = registration.installing;
25 })
26 .then(function(worker) {
27 sw = worker;
28 return send_ping(sw); 25 return send_ping(sw);
29 }) 26 })
30 .then(function(reply) { 27 .then(function(reply) {
31 assert_equals(reply, 0); 28 assert_equals(reply, 0);
32 return internals.terminateServiceWorker(sw); 29 return internals.terminateServiceWorker(sw);
33 }) 30 })
34 .then(function() { 31 .then(function() {
35 return send_ping(sw); 32 return send_ping(sw);
36 }) 33 })
37 .then(function(reply) { 34 .then(function(reply) {
38 assert_equals(reply, 0); 35 assert_equals(reply, 0);
39 return send_ping(sw); 36 return send_ping(sw);
40 }) 37 })
41 .then(function(reply) { 38 .then(function(reply) {
42 assert_equals(reply, 1); 39 assert_equals(reply, 1);
43 return service_worker_unregister_and_done(test, scope); 40 return service_worker_unregister_and_done(test, scope);
44 }); 41 });
45 }, 'postMessage to a terminated service worker.'); 42 }, 'postMessage to a terminated service worker.');
46 </script> 43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698