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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/resources/windowclient-focus.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 // This helper will setup a small test framework that will use TESTS and run 1 // This helper will setup a small test framework that will use TESTS and run
2 // them sequentially and call self.postMessage('quit') when done. 2 // them sequentially and call self.postMessage('quit') when done.
3 // This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|, 3 // This helper also exposes |client|, |postMessage()|, |runNextTestOrQuit()|,
4 // |synthesizeNotificationClick()| and |initialize()|. 4 // |synthesizeNotificationClick()| and |initialize()|.
5 importScripts('sw-test-helpers.js'); 5 importScripts('sw-test-helpers.js');
6 6
7 // Clients nested inside the main client (|client|) used in this test. 7 // Clients nested inside the main client (|client|) used in this test.
8 var nestedClients = []; 8 var nestedClients = [];
9 9
10 // Override self.initialize() from sw-test-helpers.js 10 // Override self.initialize() from sw-test-helpers.js
11 self.initialize = function() { 11 self.initialize = function() {
12 return self.clients.getAll().then(function(clients) { 12 return self.clients.matchAll().then(function(clients) {
13 clients.forEach(function(c) { 13 clients.forEach(function(c) {
14 // All clients are iframes but one of them embeds the other ones. We 14 // All clients are iframes but one of them embeds the other ones. We
15 // want to use that one as the main |client|. 15 // want to use that one as the main |client|.
16 // Its url ends with '.html' while the others ends with '.html?X' 16 // Its url ends with '.html' while the others ends with '.html?X'
17 if (c.url.endsWith('.html')) 17 if (c.url.endsWith('.html'))
18 client = c; 18 client = c;
19 else 19 else
20 nestedClients.push(c); 20 nestedClients.push(c);
21 }); 21 });
22 }); 22 });
23 }; 23 };
24 24
25 function getNumberOfFocusedClients() { 25 function getNumberOfFocusedClients() {
26 return self.clients.getAll().then(function(clients) { 26 return self.clients.matchAll().then(function(clients) {
27 var focusedClients = 0; 27 var focusedClients = 0;
28 clients.forEach(function(c) { 28 clients.forEach(function(c) {
29 if (c.focused) 29 if (c.focused)
30 ++focusedClients; 30 ++focusedClients;
31 }); 31 });
32 return focusedClients; 32 return focusedClients;
33 }); 33 });
34 } 34 }
35 35
36 var TESTS = [ 36 var TESTS = [
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 self.onmessage = function(e) { 127 self.onmessage = function(e) {
128 if (e.data == 'start') { 128 if (e.data == 'start') {
129 initialize().then(runNextTestOrQuit); 129 initialize().then(runNextTestOrQuit);
130 } else { 130 } else {
131 initialize().then(function() { 131 initialize().then(function() {
132 self.postMessage('received unexpected message'); 132 self.postMessage('received unexpected message');
133 self.postMessage('quit'); 133 self.postMessage('quit');
134 }); 134 });
135 } 135 }
136 }; 136 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698