| OLD | NEW |
| 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 Loading... |
| 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 }; |
| OLD | NEW |