| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Clients.matchAll with various clientTypes</title> | 2 <title>Service Worker: Clients.matchAll with various clientTypes</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-matchall-client-types'; | 7 var scope = 'resources/clients-matchall-client-types'; |
| 8 var iframe_url = scope + '-iframe.html'; | 8 var iframe_url = scope + '-iframe.html'; |
| 9 var shared_worker_url = scope + '-shared-worker.js'; | 9 var shared_worker_url = scope + '-shared-worker.js'; |
| 10 var dedicated_worker_url = scope + '-dedicated-worker.js'; |
| 10 | 11 |
| 11 /* visibilityState, focused, url, type, frameType */ | 12 /* visibilityState, focused, url, type, frameType */ |
| 12 var expected_only_window = [ | 13 var expected_only_window = [ |
| 13 ['visible', true, new URL(iframe_url, location).href, 'window', 'nested'] | 14 ['visible', true, new URL(iframe_url, location).href, 'window', 'nested'] |
| 14 ]; | 15 ]; |
| 15 var expected_only_shared_worker = [ | 16 var expected_only_shared_worker = [ |
| 16 [undefined, undefined, new URL(shared_worker_url, location).href, 'sharedwor
ker', 'none'] | 17 [undefined, undefined, new URL(shared_worker_url, location).href, 'sharedwor
ker', 'none'] |
| 17 ]; | 18 ]; |
| 18 var expected_window_and_shared_worker = [ | 19 var expected_only_dedicated_worker = [ |
| 19 expected_only_window[0], expected_only_shared_worker[0] | 20 [undefined, undefined, new URL(dedicated_worker_url, location).href, 'worker
', 'none'] |
| 21 ]; |
| 22 var expected_all_clients = [ |
| 23 expected_only_window[0], expected_only_shared_worker[0], |
| 24 expected_only_dedicated_worker[0] |
| 20 ]; | 25 ]; |
| 21 | 26 |
| 22 function test_matchall(frame, expected, query_options) { | 27 function test_matchall(frame, expected, query_options) { |
| 23 // Make sure the frame gets focus. | 28 // Make sure the frame gets focus. |
| 24 frame.focus(); | 29 frame.focus(); |
| 25 return new Promise(function(resolve, reject) { | 30 return new Promise(function(resolve, reject) { |
| 26 var channel = new MessageChannel(); | 31 var channel = new MessageChannel(); |
| 27 channel.port1.onmessage = function(e) { resolve(e.data); }; | 32 channel.port1.onmessage = function(e) { resolve(e.data); }; |
| 28 frame.contentWindow.navigator.serviceWorker.controller.postMessage( | 33 frame.contentWindow.navigator.serviceWorker.controller.postMessage( |
| 29 {port:channel.port2, options:query_options}, | 34 {port:channel.port2, options:query_options}, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 }) | 77 }) |
| 73 .then(function() { return with_iframe(iframe_url); }) | 78 .then(function() { return with_iframe(iframe_url); }) |
| 74 .then(function(f) { | 79 .then(function(f) { |
| 75 frame = f; | 80 frame = f; |
| 76 return new Promise(function(resolve, reject) { | 81 return new Promise(function(resolve, reject) { |
| 77 var w = new SharedWorker(shared_worker_url); | 82 var w = new SharedWorker(shared_worker_url); |
| 78 w.port.onmessage = resolve; | 83 w.port.onmessage = resolve; |
| 79 }); | 84 }); |
| 80 }) | 85 }) |
| 81 .then(function() { | 86 .then(function() { |
| 87 return new Promise(function(resolve, reject) { |
| 88 var w = new Worker(dedicated_worker_url); |
| 89 w.onmessage = resolve; |
| 90 w.postMessage('Start'); |
| 91 }); |
| 92 }) |
| 93 .then(function() { |
| 82 return test_matchall(frame, expected_only_window, {}); | 94 return test_matchall(frame, expected_only_window, {}); |
| 83 }) | 95 }) |
| 84 .then(function() { | 96 .then(function() { |
| 85 return test_matchall(frame, expected_only_window, {type:'window'}); | 97 return test_matchall(frame, expected_only_window, {type:'window'}); |
| 86 }) | 98 }) |
| 87 .then(function() { | 99 .then(function() { |
| 88 return test_matchall(frame, expected_only_shared_worker, | 100 return test_matchall(frame, expected_only_shared_worker, |
| 89 {type:'sharedworker'}); | 101 {type:'sharedworker'}); |
| 90 }) | 102 }) |
| 91 .then(function() { | 103 .then(function() { |
| 92 return test_matchall(frame, expected_window_and_shared_worker, {type:'
all'}); | 104 return test_matchall(frame, expected_only_dedicated_worker, |
| 105 {type:'worker'}); |
| 106 }) |
| 107 .then(function() { |
| 108 return test_matchall(frame, expected_all_clients, {type:'all'}); |
| 93 }) | 109 }) |
| 94 .then(function() { | 110 .then(function() { |
| 95 frame.remove(); | 111 frame.remove(); |
| 96 return service_worker_unregister_and_done(t, scope); | 112 return service_worker_unregister_and_done(t, scope); |
| 97 }); | 113 }); |
| 98 }, 'Verify matchAll() with window and sharedworker client types'); | 114 }, 'Verify matchAll() with {window, sharedworker, worker} client types'); |
| 99 | 115 |
| 100 </script> | 116 </script> |
| OLD | NEW |