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

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: Created 6 years, 1 month 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
(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 var properties = {timeout: 2500};
9
10 function sendPing(worker) {
11 return new Promise(function(resolve) {
12 var channel = new MessageChannel();
dominicc (has gone to gerrit) 2014/11/17 02:25:26 Could you indent this slightly differently, follow
Marijn Kruisselbrink 2014/11/17 23:18:44 Done (at least I think so).
13 channel.port1.onmessage = function(message) {
14 resolve(message.data);
15 };
16 worker.postMessage({port: channel.port2}, [channel.port2]);
17 });
18 }
19
20 function delay(ms) {
21 return new Promise(function(resolve) {
22 window.setTimeout(resolve, ms);
23 });
24 }
25
26 promise_test(function(test) {
27 var worker = 'resources/ping-worker.js';
28 var scope = 'resources/blank.html';
29 var sw;
30 return service_worker_unregister_and_register(test, worker, scope)
31 .then(function(registration) {
32 return wait_for_update(test, registration);
33 }).then(function(worker) {
34 sw = worker;
35 return sendPing(sw);
36 }).then(function(reply) {
37 assert_equals(reply, 1);
38 return internals.terminateServiceWorker(sw);
dominicc (has gone to gerrit) 2014/11/17 02:25:25 What if the Service Worker terminated itself, perh
Marijn Kruisselbrink 2014/11/17 23:18:44 I suppose I could change the test to have the work
39 }).then(function() {
40 //return delay(500);
Marijn Kruisselbrink 2014/11/04 23:11:54 This test currently only passes when this delay is
dominicc (has gone to gerrit) 2014/11/17 02:25:25 Let's not add a test that is known to be broken. O
Marijn Kruisselbrink 2014/11/17 23:18:44 Well, the test is not broken, it just doesn't curr
41 }).then(function() {
42 return sendPing(sw);
43 }).then(function(reply) {
44 assert_equals(reply, 1);
45 return sendPing(sw);
dominicc (has gone to gerrit) 2014/11/17 02:25:25 Are two subsequent pings necessary?
Marijn Kruisselbrink 2014/11/17 23:18:44 Not really, just a simple sanity check to make sur
46 }).then(function(reply) {
47 assert_equals(reply, 2);
48 return service_worker_unregister_and_done(test, scope);
49 });
50 }, 'Terminate terminates the worker.', properties);
dominicc (has gone to gerrit) 2014/11/17 02:25:25 Is the test really about that? It's about postMess
Marijn Kruisselbrink 2014/11/17 23:18:44 Well, it's more about both. I started writing this
51
52 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698