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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/resources/sw-test-helpers.js

Issue 1056973003: Revert of Revert of ServiceWorker: Remove Clients.getAll() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Test helper that is meant as a mini test framework to be used from a service 1 // Test helper that is meant as a mini test framework to be used from a service
2 // worker that runs some tests and send results back to its client. 2 // worker that runs some tests and send results back to its client.
3 // 3 //
4 // A simple usage of this framework would consist of calling initialize() to 4 // A simple usage of this framework would consist of calling initialize() to
5 // setup then runNextTestOrQuit() in order to start running the methods defined 5 // setup then runNextTestOrQuit() in order to start running the methods defined
6 // by TESTS. Then, tests can start sending messages back to the client using 6 // by TESTS. Then, tests can start sending messages back to the client using
7 // postMessage(). 7 // postMessage().
8 // 8 //
9 // Example: 9 // Example:
10 // var TESTS = [ 10 // var TESTS = [
11 // function simpleTest() { 11 // function simpleTest() {
12 // self.postMessage('you will receive this first'); 12 // self.postMessage('you will receive this first');
13 // }, 13 // },
14 // function secondTest() { 14 // function secondTest() {
15 // self.postMessage('secondTest done!'); 15 // self.postMessage('secondTest done!');
16 // runNextTestOrQuit(); 16 // runNextTestOrQuit();
17 // } 17 // }
18 // ]; 18 // ];
19 // 19 //
20 // initialize().runNextTestOrQuit(); 20 // initialize().runNextTestOrQuit();
21 // 21 //
22 // In addition, there is a helper method meant to synthesized notificationclick 22 // In addition, there is a helper method meant to synthesized notificationclick
23 // events sent to a service worker, see synthesizeNotificationClick. 23 // events sent to a service worker, see synthesizeNotificationClick.
24 24
25 var client = null; 25 var client = null;
26 var currentTest = -1; 26 var currentTest = -1;
27 27
28 self.initialize = function() { 28 self.initialize = function() {
29 return self.clients.getAll().then(function(clients) { 29 return self.clients.matchAll().then(function(clients) {
30 client = clients[0]; 30 client = clients[0];
31 }); 31 });
32 } 32 }
33 33
34 self.postMessage = function(msg) { 34 self.postMessage = function(msg) {
35 client.postMessage(msg); 35 client.postMessage(msg);
36 } 36 }
37 37
38 // Run the next test in TESTS if any. Otherwise sends a 'quit' message. and 38 // Run the next test in TESTS if any. Otherwise sends a 'quit' message. and
39 // stops. 39 // stops.
(...skipping 23 matching lines...) Expand all
63 resolve(e); 63 resolve(e);
64 e.notification.close(); 64 e.notification.close();
65 self.removeEventListener('notificationclick', handler); 65 self.removeEventListener('notificationclick', handler);
66 }; 66 };
67 67
68 self.addEventListener('notificationclick', handler); 68 self.addEventListener('notificationclick', handler);
69 }); 69 });
70 70
71 return promise; 71 return promise;
72 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698