OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Clients.get(id)</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-get'; |
| 8 var expected_client_url = new URL(scope + '#2', location).toString(); |
| 9 |
| 10 var frame1, frame2; |
| 11 var worker; |
| 12 promise_test(function(t) { |
| 13 return service_worker_unregister_and_register( |
| 14 t, 'resources/clients-get-worker.js', scope) |
| 15 .then(function(registration) { |
| 16 worker = registration.installing; |
| 17 return wait_for_state(t, worker, 'activated'); |
| 18 }) |
| 19 .then(function() { return with_iframe(scope + '#1'); }) |
| 20 .then(function(f) { |
| 21 frame1 = f; |
| 22 return with_iframe(scope + '#2'); |
| 23 }) |
| 24 .then(function(f) { |
| 25 frame2 = f; |
| 26 return new Promise(function(resolve) { |
| 27 // Make a subresource request in the second iframe (scope + '#2'). |
| 28 var xhr = new f.contentWindow.XMLHttpRequest(); |
| 29 xhr.onload = function() { |
| 30 resolve(); |
| 31 }; |
| 32 xhr.open('GET', 'simple.txt'); |
| 33 xhr.send(); |
| 34 }); |
| 35 }) |
| 36 .then(function() { |
| 37 return new Promise(function(resolve) { |
| 38 var channel = new MessageChannel(); |
| 39 channel.port1.onmessage = resolve; |
| 40 worker.postMessage({port:channel.port2}, [channel.port2]); |
| 41 }); |
| 42 }) |
| 43 .then(function(message) { |
| 44 assert_array_equals(message.data, expected_client_url); |
| 45 frame1.remove(); |
| 46 frame2.remove(); |
| 47 return service_worker_unregister_and_done(t, scope); |
| 48 }) |
| 49 }, 'Test Clients.get(id)'); |
| 50 </script> |
OLD | NEW |