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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/clients-get-client-types.https.html

Issue 2884843004: [ServiceWorker] Add wpt tests to verify Client.type as 'worker' (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Clients.get with window and worker clients</title> 2 <title>Service Worker: Clients.get with window and worker clients</title>
3 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.sub.js"></script> 5 <script src="resources/test-helpers.sub.js"></script>
6 <script> 6 <script>
7 var scope = 'resources/clients-get-client-types'; 7 var scope = 'resources/clients-get-client-types';
8 var frame_url = scope + '-frame.html'; 8 var frame_url = scope + '-frame.html';
9 var shared_worker_url = scope + '-shared-worker.js'; 9 var shared_worker_url = scope + '-shared-worker.js';
10 var client_ids = []; 10 var client_ids = [];
(...skipping 19 matching lines...) Expand all
30 return new Promise(function(resolve) { 30 return new Promise(function(resolve) {
31 var w = new SharedWorker(shared_worker_url); 31 var w = new SharedWorker(shared_worker_url);
32 w.port.onmessage = function(e) { 32 w.port.onmessage = function(e) {
33 resolve(e.data.clientId); 33 resolve(e.data.clientId);
34 }; 34 };
35 }); 35 });
36 }) 36 })
37 .then(function(client_id) { 37 .then(function(client_id) {
38 client_ids.push(client_id); 38 client_ids.push(client_id);
39 var channel = new MessageChannel(); 39 var channel = new MessageChannel();
40 frame.contentWindow.postMessage('StartWorker', '*', [channel.port2]);
leonhsl(Using Gerrit) 2017/05/16 03:07:56 Let frame(controlled by our sw) start the worker,
falken 2017/05/16 04:51:35 I see. We shouldn't add this workaround for a Chro
leonhsl(Using Gerrit) 2017/05/18 09:36:30 Got it and I agree such process. I will do so once
41 return new Promise(function(resolve) {
42 channel.port1.onmessage = function(e) {
43 resolve(e.data.clientId);
44 };
45 });
46 })
47 .then(function(client_id) {
48 client_ids.push(client_id);
49 var channel = new MessageChannel();
40 var saw_message = new Promise(function(resolve) { 50 var saw_message = new Promise(function(resolve) {
41 channel.port1.onmessage = resolve; 51 channel.port1.onmessage = resolve;
42 }); 52 });
43 frame.contentWindow.navigator.serviceWorker.controller.postMessage( 53 frame.contentWindow.navigator.serviceWorker.controller.postMessage(
44 {port: channel.port2, clientIds: client_ids}, [channel.port2]); 54 {port: channel.port2, clientIds: client_ids}, [channel.port2]);
45 return saw_message; 55 return saw_message;
46 }) 56 })
47 .then(function(e) { 57 .then(function(e) {
48 assert_equals(e.data.length, 2); 58 assert_equals(e.data.length, 3);
leonhsl(Using Gerrit) 2017/05/16 03:07:56 The current problem is that we always get e.data a
falken 2017/05/16 04:51:35 It sounds like it could be a bug. I'm confused why
leonhsl(Using Gerrit) 2017/05/18 09:36:29 I'm checking around this, found that console.log()
49 assert_array_equals(e.data[0], expected[0]); 59 assert_array_equals(e.data[0], expected[0]);
50 assert_array_equals(e.data[1], expected[1]); 60 assert_array_equals(e.data[1], expected[1]);
61 assert_array_equals(e.data[2], expected[2]);
51 }); 62 });
52 }, 'Test Clients.get() with window and worker clients'); 63 }, 'Test Clients.get() with window and worker clients');
53 64
54 function wait_for_clientId() { 65 function wait_for_clientId() {
55 return new Promise(function(resolve) { 66 return new Promise(function(resolve) {
56 function get_client_id(e) { 67 function get_client_id(e) {
57 window.removeEventListener('message', get_client_id); 68 window.removeEventListener('message', get_client_id);
58 resolve(e.data.clientId); 69 resolve(e.data.clientId);
59 } 70 }
60 window.addEventListener('message', get_client_id, false); 71 window.addEventListener('message', get_client_id, false);
61 }); 72 });
62 } 73 }
63 74
64 var expected = [ 75 var expected = [
65 // visibilityState, focused, url, type, frameType 76 // visibilityState, focused, url, type, frameType
66 ['visible', true, normalizeURL(scope) + '-frame.html', 'window', 'nested'], 77 ['visible', true, normalizeURL(scope) + '-frame.html', 'window', 'nested'],
67 [undefined, undefined, normalizeURL(scope) + '-shared-worker.js', 'sharedwor ker', 'none'] 78 [undefined, undefined, normalizeURL(scope) + '-shared-worker.js', 'sharedwor ker', 'none']
79 [undefined, undefined, normalizeURL(scope) + '-frame-worker.js', 'worker', ' none']
68 ]; 80 ];
69 </script> 81 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/clients-get-client-types-frame.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698