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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-worker.js

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add layout test Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-worker.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..6dcc7b04327dc1c99cf2bbcc31e61a87bead7629
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-worker.js
@@ -0,0 +1,23 @@
+var actual_client_id;
+
+self.onfetch = function(e) {
+ // Get the subresource request from the second iframe.
+ if (e.request.url.indexOf('simple.txt') != -1) {
+ clients.matchAll().then(function(clients) {
+ clients.forEach(function(client) {
+ if (client.frameType == "nested" &&
+ client.url.indexOf('#2') != -1) {
+ actual_client_id = client.id;
+ }
+ });
+ });
+ }
+};
+
+self.onmessage = function(e) {
+ var port = e.data.port;
+
+ clients.get(actual_client_id).then(function(client) {
+ port.postMessage(client.url);
+ });
+};

Powered by Google App Engine
This is Rietveld 408576698