2 <title>Service Worker: Clients.matchAll
</title>
3 <script src=
"../resources/testharness.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
5 <script src=
"resources/test-helpers.js"></script>
7 var scope
= 'resources/blank.html?clients-matchAll';
9 /* visibilityState, focused, url, frameType */
10 ['visible', true, new URL(scope
+ '#1', location
).toString(), 'nested'],
11 ['visible', false, new URL(scope
+ '#2', location
).toString(), 'nested']
13 var expectedSecond
= [
14 /* visibilityState, focused, url, frameType */
15 ['visible', true, new URL(scope
+ '#2', location
).toString(), 'nested'],
16 ['visible', false, new URL(scope
+ '#1', location
).toString(), 'nested']
21 promise_test(function(t
) {
22 return service_worker_unregister_and_register(
23 t
, 'resources/clients-matchall-worker.js', scope
)
24 .then(function(registration
) {
25 worker
= registration
.installing
;
26 return wait_for_state(t
, worker
, 'activated');
28 .then(function() { return with_iframe(scope
+ '#1'); })
31 return with_iframe(scope
+ '#2');
35 return new Promise(function(resolve
) {
37 var channel
= new MessageChannel();
38 channel
.port1
.onmessage
= resolve
;
39 worker
.postMessage({port
:channel
.port2
}, [channel
.port2
]);
42 .then(function(message
) {
43 assert_equals(message
.data
.length
, 2);
44 assert_array_equals(message
.data
[0], expectedFirst
[0]);
45 assert_array_equals(message
.data
[1], expectedFirst
[1]);
46 return new Promise(function(resolve
) {
48 var channel
= new MessageChannel();
49 channel
.port1
.onmessage
= resolve
;
50 worker
.postMessage({port
:channel
.port2
}, [channel
.port2
]);
53 .then(function(message
) {
54 assert_equals(message
.data
.length
, 2);
55 assert_array_equals(message
.data
[0], expectedSecond
[0]);
56 assert_array_equals(message
.data
[1], expectedSecond
[1]);
59 return service_worker_unregister_and_done(t
, scope
);
61 }, 'Test Clients.matchAll()');