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.sub.js"></script> |
| 6 <script src="resources/test-helpers.sub.js"></script> |
| 7 <script> |
| 8 var host_info = get_host_info(); |
| 9 |
| 10 var scope = 'resources/blank.html?clients-get'; |
| 11 var t = async_test('Test Clients.get() cross origin'); |
| 12 var other_origin_iframe = host_info['HTTPS_REMOTE_ORIGIN'] + base_path() + |
| 13 'resources/clients-get-other-origin.html'; |
| 14 var myOriginClientId; |
| 15 t.step(function() { |
| 16 service_worker_unregister_and_register( |
| 17 t, 'resources/clients-get-worker.js', scope) |
| 18 .then(function(registration) { |
| 19 return wait_for_state(t, registration.installing, 'activated'); |
| 20 }) |
| 21 .then(function() { |
| 22 return with_iframe(scope); |
| 23 }) |
| 24 .then(function(frame1) { |
| 25 myOriginClientId = frame1.contentDocument.body.textContent; |
| 26 return with_iframe(other_origin_iframe); |
| 27 }) |
| 28 .then(function(frame2) { |
| 29 window.addEventListener('message', on_message_other_origin, false); |
| 30 frame2.contentWindow.postMessage( |
| 31 {clientId: myOriginClientId, |
| 32 message: 'get_client_id'}, |
| 33 host_info['HTTPS_REMOTE_ORIGIN']); |
| 34 }) |
| 35 .catch(unreached_rejection(t)); |
| 36 }); |
| 37 |
| 38 function on_message_other_origin(e) { |
| 39 assert_equals(e.data.result, undefined); |
| 40 t.done(); |
| 41 } |
| 42 </script> |
OLD | NEW |