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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/clients-get-client-types.html

Issue 2881743002: [ServiceWorker] Revise wpt tests for Client.type (Closed)
Patch Set: Revise code comments 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
(Empty)
1 <!DOCTYPE html>
2 <!-- This is in chromium/ because the equivalent version available in Web
3 Platform Tests also asserts the presence of the Client's `type` attribute.
4 This less precise version (and its resources) should be maintained only to
5 preserve test coverage until the attribute is implemented. See
6 https://crbug.com/705685 -->
7 <title>Service Worker: Clients.get with window and worker clients</title>
8 <script src="../../resources/testharness.js"></script>
9 <script src="../../resources/testharnessreport.js"></script>
10 <script src="../resources/test-helpers.js"></script>
11 <script>
12 var scope = 'resources/clients-get-client-types';
13 var frame_url = scope + '-frame.html';
14 var shared_worker_url = scope + '-shared-worker.js';
15 var client_ids = [];
16 var frame;
17 promise_test(function(t) {
18 return service_worker_unregister_and_register(
19 t, 'resources/clients-get-worker.js', scope)
20 .then(function(registration) {
21 add_completion_callback(function() { registration.unregister(); });
22 return wait_for_state(t, registration.installing, 'activated');
23 })
24 .then(function() {
25 return with_iframe(frame_url);
26 })
27 .then(function(f) {
28 frame = f;
29 add_completion_callback(function() { frame.remove(); });
30 frame.focus();
31 return wait_for_clientId();
32 })
33 .then(function(client_id) {
34 client_ids.push(client_id);
35 return new Promise(function(resolve) {
36 var w = new SharedWorker(shared_worker_url);
37 w.port.onmessage = function(e) {
38 resolve(e.data.clientId);
39 };
40 });
41 })
42 .then(function(client_id) {
43 client_ids.push(client_id);
44 var channel = new MessageChannel();
45 var saw_message = new Promise(function(resolve) {
46 channel.port1.onmessage = resolve;
47 });
48 frame.contentWindow.navigator.serviceWorker.controller.postMessage(
49 {port: channel.port2, clientIds: client_ids}, [channel.port2]);
50 return saw_message;
51 })
52 .then(function(e) {
53 assert_equals(e.data.length, 2);
54 assert_array_equals(e.data[0], expected[0]);
55 assert_array_equals(e.data[1], expected[1]);
56 });
57 }, 'Test Clients.get() with window and worker clients');
58
59 function wait_for_clientId() {
60 return new Promise(function(resolve) {
61 function get_client_id(e) {
62 window.removeEventListener('message', get_client_id);
63 resolve(e.data.clientId);
64 }
65 window.addEventListener('message', get_client_id, false);
66 });
67 }
68
69 var expected = [
70 /* visibilityState, focused, url, frameType */
71 ['visible', true, normalizeURL(scope) + '-frame.html', 'nested'],
72 [undefined, undefined, normalizeURL(scope) + '-shared-worker.js', 'none']
73 ];
74 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698