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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 importScripts('worker-testharness.js');
2 importScripts('/resources/testharness-helpers.js');
3
4 var active = new Promise(function(resolve, reject) {
5 self.addEventListener('activate', function() {
6 resolve();
7 });
8 });
9
10
11 // This can't be run in parallel with other successful openWindow tests.
12 promise_test(function(t) {
13 function messagePromise() {
14 return new Promise(function(resolve, reject) {
15 self.onmessage = function(e) {
16 self.onmessage = null;
17 resolve(e.data);
18 };
19 });
20 }
21
22 var client_url = 'serviceworkerclients-openwindow-client.html';
23 var client;
24 var clients;
25 return active
26 .then(function() {
27 return self.clients.getAll();
28 })
29 .then(function(clients) {
30 assert_equals(clients.length, 0,
31 'Should have no clients before opening');
32 })
33 .then(function() {
34 return self.clients.openWindow(client_url);
35 })
36 .then(function(result) {
37 client = result;
38 return self.clients.getAll();
39 })
40 .then(function(result) {
41 clients = result;
42 assert_equals(clients.length, 1,
43 'Should have 1 client after constructing');
44 assert_equals(clients[0].url,
45 String(new URL(client_url, self.location)),
46 'Enumerated client URL should match');
47
48 client.postMessage('message one');
49 return messagePromise();
50 })
51 .then(function(response) {
52 assert_equals(response, 'ack: message one - 1');
53
54 clients[0].postMessage('message two');
55 return messagePromise();
56 })
57 .then(function(response) {
58 assert_equals(response, 'ack: message two - 2');
59 });
60 }, 'ServiceWorkerClients openWindow() vs. getAll()');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698