| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 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> | |
| 6 <script> | |
| 7 var scope = 'resources/blank.html?clients-matchAll'; | |
| 8 var expectedFirst = [ | |
| 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'] | |
| 12 ]; | |
| 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'] | |
| 17 ]; | |
| 18 | |
| 19 var frame1, frame2; | |
| 20 var worker; | |
| 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'); | |
| 27 }) | |
| 28 .then(function() { return with_iframe(scope + '#1'); }) | |
| 29 .then(function(f) { | |
| 30 frame1 = f; | |
| 31 return with_iframe(scope + '#2'); | |
| 32 }) | |
| 33 .then(function(f) { | |
| 34 frame2 = f; | |
| 35 return new Promise(function(resolve) { | |
| 36 frame1.focus(); | |
| 37 var channel = new MessageChannel(); | |
| 38 channel.port1.onmessage = resolve; | |
| 39 worker.postMessage({port:channel.port2}, [channel.port2]); | |
| 40 }); | |
| 41 }) | |
| 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) { | |
| 47 frame2.focus(); | |
| 48 var channel = new MessageChannel(); | |
| 49 channel.port1.onmessage = resolve; | |
| 50 worker.postMessage({port:channel.port2}, [channel.port2]); | |
| 51 }); | |
| 52 }) | |
| 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]); | |
| 57 frame1.remove(); | |
| 58 frame2.remove(); | |
| 59 return service_worker_unregister_and_done(t, scope); | |
| 60 }) | |
| 61 }, 'Test Clients.matchAll()'); | |
| 62 </script> | |
| OLD | NEW |