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

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

Issue 1604893002: ServiceWorker: Rewrite windowclient-navigate.html test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var port = null; 1 var port = null;
2 var in_scope_but_not_controlled = null;
3
4 self.oninstall = function(e) {
5 clients.matchAll({ includeUncontrolled : true }).then(function(cs) {
6 return cs[0].navigate('blank.html');
7 })
8 .catch(function(e) {
9 in_scope_but_not_controlled = e.name.toString();
nhiroki 2016/01/20 03:56:34 This might not work because there should be only a
zino 2016/01/20 17:24:05 Good catch!
10 });
11 };
2 12
3 self.onmessage = function(e) { 13 self.onmessage = function(e) {
4 port = e.data.port; 14 port = e.data.port;
5 port.onmessage = on_message; 15 port.onmessage = on_message;
6 port.postMessage('ready'); 16 port.postMessage(in_scope_but_not_controlled);
7 }; 17 };
8 18
9 function on_message(e) { 19 function on_message(e) {
10 var url = e.data; 20 var url = e.data;
11 var client; 21 var client;
12 22
13 self.clients.matchAll({ includeUncontrolled : true }).then(function(cs) { 23 clients.matchAll({ includeUncontrolled : true }).then(function(cs) {
14 cs.forEach(function(c) { c.frameType == 'nested' && (client = c); }); 24 cs.forEach(function(c) { c.frameType == 'nested' && (client = c); });
15 return client.navigate(url); 25 return client.navigate(url);
16 }) 26 })
17 .then(function(c) { 27 .then(function(c) {
18 if (!c) 28 if (!c)
19 port.postMessage(c); 29 port.postMessage(c);
20 else 30 else
21 port.postMessage(c.url); 31 port.postMessage(c.url);
22 }) 32 })
23 .catch(function(e) { 33 .catch(function(e) {
24 port.postMessage(e.name); 34 port.postMessage(e.name);
25 }); 35 });
26 } 36 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/windowclient-navigate.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698