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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/windowclient-navigate-worker.js

Issue 2906963002: Upstream service wrkr "window client" test to WPT (Closed)
Patch Set: Incorporate review feedback Created 3 years, 6 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
(Empty)
1 function match_query(query_string) {
2 return self.location.search.substr(1) == query_string;
3 }
4
5 function receive_event(event_name) {
6 return new Promise(function(resolve) {
7 self.addEventListener(event_name, resolve, false);
8 });
9 }
10
11 function navigate_test(e) {
12 var port = e.data.port;
13 var url = e.data.url;
14
15 return clients.matchAll({ includeUncontrolled : true })
16 .then(function(client_list) {
17 for (var i = 0; i < client_list.length; i++) {
18 var client = client_list[i];
19 if (client.frameType == 'nested') {
20 return client.navigate(url);
21 }
22 }
23 port.postMessage('Could not found window client.');
24 })
25 .then(function(new_client) {
26 if (new_client === null)
27 port.postMessage(new_client);
28 else
29 port.postMessage(new_client.url);
30 })
31 .catch(function(error) {
32 port.postMessage(error.name);
33 });
34 }
35 if (match_query('installing')) {
36 // If the query string is "?installing", then do test on installing worker.
37 // This is only for in-scope-but-not-controlled test.
38 receive_event('install').then(function(e) {
39 e.waitUntil(receive_event('message').then(navigate_test));
40 });
41 } else {
42 receive_event('message').then(function(e) {
43 e.waitUntil(navigate_test(e));
44 });
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698