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

Unified Diff: LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-enumeration-worker.js

Issue 779133003: [WORK IN PROGRESS] ServiceWorkerClients.openWindow() [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-enumeration-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-enumeration-worker.js b/LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-enumeration-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..0fcc7d4409cd2f746e9910473a0860395fe3c88f
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/resources/serviceworkerclients-openwindow-enumeration-worker.js
@@ -0,0 +1,60 @@
+importScripts('worker-testharness.js');
+importScripts('/resources/testharness-helpers.js');
+
+var active = new Promise(function(resolve, reject) {
+ self.addEventListener('activate', function() {
+ resolve();
+ });
+});
+
+
+// This can't be run in parallel with other successful openWindow tests.
+promise_test(function(t) {
+ function messagePromise() {
+ return new Promise(function(resolve, reject) {
+ self.onmessage = function(e) {
+ self.onmessage = null;
+ resolve(e.data);
+ };
+ });
+ }
+
+ var client_url = 'serviceworkerclients-openwindow-client.html';
+ var client;
+ var clients;
+ return active
+ .then(function() {
+ return self.clients.getAll();
+ })
+ .then(function(clients) {
+ assert_equals(clients.length, 0,
+ 'Should have no clients before opening');
+ })
+ .then(function() {
+ return self.clients.openWindow(client_url);
+ })
+ .then(function(result) {
+ client = result;
+ return self.clients.getAll();
+ })
+ .then(function(result) {
+ clients = result;
+ assert_equals(clients.length, 1,
+ 'Should have 1 client after constructing');
+ assert_equals(clients[0].url,
+ String(new URL(client_url, self.location)),
+ 'Enumerated client URL should match');
+
+ client.postMessage('message one');
+ return messagePromise();
+ })
+ .then(function(response) {
+ assert_equals(response, 'ack: message one - 1');
+
+ clients[0].postMessage('message two');
+ return messagePromise();
+ })
+ .then(function(response) {
+ assert_equals(response, 'ack: message two - 2');
+ });
+}, 'ServiceWorkerClients openWindow() vs. getAll()');

Powered by Google App Engine
This is Rietveld 408576698