Chromium Code Reviews| 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 t = async_test('Test Clients.get() cross origin'); | |
| 12 var other_origin_iframe = host_info['HTTP_REMOTE_ORIGIN'] + base_path() + | |
| 13 'resources/clients-get-other-origin.html'; | |
|
nhiroki
2016/02/17 02:40:28
For improving consistency, can you rename this fil
jungkees
2016/02/17 14:01:12
Yes, that's better. I renamed them so with *cross-
| |
| 14 var myOriginClientId; | |
|
nhiroki
2016/02/17 02:40:28
my_origin_client_id
jungkees
2016/02/17 14:01:12
Done.
| |
| 15 t.step(function() { | |
| 16 service_worker_unregister_and_register( | |
| 17 t, 'resources/clients-get-worker.js', scope) | |
| 18 .then(function(registration) { | |
| 19 add_completion_callback(function() { registration.unregister(); }); | |
| 20 return wait_for_state(t, registration.installing, 'activated'); | |
| 21 }) | |
| 22 .then(function() { | |
| 23 return with_iframe(scope); | |
| 24 }) | |
| 25 .then(function(frame1) { | |
| 26 add_completion_callback(function() { frame1.remove(); }); | |
| 27 return new Promise(function(resolve, reject) { | |
| 28 function get_client_id(e) { | |
| 29 window.removeEventListener('message', get_client_id); | |
| 30 resolve(e.data.clientId); | |
| 31 } | |
| 32 window.addEventListener('message', get_client_id, false); | |
| 33 }); | |
| 34 }) | |
| 35 .then(function(clientId) { | |
|
nhiroki
2016/02/17 02:40:28
client_id
jungkees
2016/02/17 14:01:12
Done.
| |
| 36 myOriginClientId = clientId; | |
| 37 return with_iframe(other_origin_iframe); | |
| 38 }) | |
| 39 .then(function(frame2) { | |
| 40 add_completion_callback(function() { frame2.remove(); }); | |
| 41 window.addEventListener('message', function(e) { | |
| 42 assert_equals(e.data.result, undefined); | |
| 43 t.done(); | |
| 44 }); | |
| 45 frame2.contentWindow.postMessage( | |
| 46 {clientId: myOriginClientId}, host_info['HTTP_REMOTE_ORIGIN']); | |
| 47 }) | |
| 48 .catch(unreached_rejection(t)); | |
| 49 }); | |
| 50 </script> | |
| OLD | NEW |