| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>Service Worker: Clients.get across origins</title> | |
| 3 <script src="../resources/testharness.js"></script> | |
| 4 <script src="../resources/testharnessreport.js"></script> | |
| 5 <script src="../resources/get-host-info.js"></script> | |
| 6 <script src="resources/test-helpers.js"></script> | |
| 7 <script> | |
| 8 var host_info = get_host_info(); | |
| 9 | |
| 10 var scope = 'resources/clients-get-frame.html'; | |
| 11 var other_origin_iframe = host_info['HTTP_REMOTE_ORIGIN'] + base_path() + | |
| 12 'resources/clients-get-cross-origin-frame.html'; | |
| 13 var my_origin_client_id; | |
| 14 promise_test(function(t) { | |
| 15 return service_worker_unregister_and_register( | |
| 16 t, 'resources/clients-get-worker.js', scope) | |
| 17 .then(function(registration) { | |
| 18 add_completion_callback(function() { registration.unregister(); }); | |
| 19 return wait_for_state(t, registration.installing, 'activated'); | |
| 20 }) | |
| 21 .then(function() { | |
| 22 return with_iframe(scope); | |
| 23 }) | |
| 24 .then(function(frame1) { | |
| 25 add_completion_callback(function() { frame1.remove(); }); | |
| 26 return new Promise(function(resolve, reject) { | |
| 27 function get_client_id(e) { | |
| 28 window.removeEventListener('message', get_client_id); | |
| 29 resolve(e.data.clientId); | |
| 30 } | |
| 31 window.addEventListener('message', get_client_id, false); | |
| 32 }); | |
| 33 }) | |
| 34 .then(function(client_id) { | |
| 35 my_origin_client_id = client_id; | |
| 36 return with_iframe(other_origin_iframe); | |
| 37 }) | |
| 38 .then(function(frame2) { | |
| 39 add_completion_callback(function() { frame2.remove(); }); | |
| 40 window.addEventListener('message', function(e) { | |
| 41 assert_equals(e.data.result, undefined); | |
| 42 t.done(); | |
| 43 }); | |
| 44 frame2.contentWindow.postMessage( | |
| 45 {clientId: my_origin_client_id}, host_info['HTTP_REMOTE_ORIGIN']); | |
| 46 }); | |
| 47 }, 'Test Clients.get() cross origin'); | |
| 48 </script> | |
| OLD | NEW |