Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/windowclient-navigate-worker.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/windowclient-navigate-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/windowclient-navigate-worker.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b155d62f92a725a13da45f4fc94aeb58615e8641 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/windowclient-navigate-worker.js |
@@ -0,0 +1,26 @@ |
+var port = null; |
+ |
+self.onmessage = function(e) { |
+ port = e.data.port; |
+ port.onmessage = on_message; |
+ port.postMessage('ready'); |
+}; |
+ |
+function on_message(e) { |
+ var url = e.data; |
+ var client; |
+ |
+ self.clients.matchAll({ includeUncontrolled : true }).then(function(cs) { |
+ cs.forEach(function(c) { c.frameType == 'nested' && (client = c); }); |
+ return client.navigate(url); |
+ }) |
+ .then(function(c) { |
+ if (!c) |
+ port.postMessage(c); |
+ else |
+ port.postMessage(c.url); |
+ }) |
+ .catch(function(e) { |
+ port.postMessage(e.name); |
+ }); |
+} |