OLD | NEW |
| (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.matchAll</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/blank.html?clients-matchAll'; | |
13 var expectedFirst = [ | |
14 /* visibilityState, focused, url, frameType */ | |
15 ['visible', true, new URL(scope + '#1', location).toString(), 'nested'], | |
16 ['visible', false, new URL(scope + '#2', location).toString(), 'nested'] | |
17 ]; | |
18 var expectedSecond = [ | |
19 /* visibilityState, focused, url, frameType */ | |
20 ['visible', true, new URL(scope + '#2', location).toString(), 'nested'], | |
21 ['visible', false, new URL(scope + '#1', location).toString(), 'nested'] | |
22 ]; | |
23 | |
24 var frame1, frame2; | |
25 var worker; | |
26 promise_test(function(t) { | |
27 return service_worker_unregister_and_register( | |
28 t, 'resources/clients-matchall-worker.js', scope) | |
29 .then(function(registration) { | |
30 worker = registration.installing; | |
31 return wait_for_state(t, worker, 'activated'); | |
32 }) | |
33 .then(function() { return with_iframe(scope + '#1'); }) | |
34 .then(function(f) { | |
35 frame1 = f; | |
36 return with_iframe(scope + '#2'); | |
37 }) | |
38 .then(function(f) { | |
39 frame2 = f; | |
40 return new Promise(function(resolve) { | |
41 frame1.focus(); | |
42 var channel = new MessageChannel(); | |
43 channel.port1.onmessage = resolve; | |
44 worker.postMessage({port:channel.port2}, [channel.port2]); | |
45 }); | |
46 }) | |
47 .then(function(message) { | |
48 assert_equals(message.data.length, 2); | |
49 assert_array_equals(message.data[0], expectedFirst[0]); | |
50 assert_array_equals(message.data[1], expectedFirst[1]); | |
51 return new Promise(function(resolve) { | |
52 frame2.focus(); | |
53 var channel = new MessageChannel(); | |
54 channel.port1.onmessage = resolve; | |
55 worker.postMessage({port:channel.port2}, [channel.port2]); | |
56 }); | |
57 }) | |
58 .then(function(message) { | |
59 assert_equals(message.data.length, 2); | |
60 assert_array_equals(message.data[0], expectedSecond[0]); | |
61 assert_array_equals(message.data[1], expectedSecond[1]); | |
62 frame1.remove(); | |
63 frame2.remove(); | |
64 return service_worker_unregister_and_done(t, scope); | |
65 }) | |
66 }, 'Test Clients.matchAll()'); | |
67 </script> | |
OLD | NEW |