Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cb85ec022a1a15a5311178bf5379b39fa080d3b3 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html |
| @@ -0,0 +1,50 @@ |
| +<!DOCTYPE html> |
| +<title>Service Worker: Clients.get across origins</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/get-host-info.js"></script> |
| +<script src="resources/test-helpers.js"></script> |
| +<script> |
| +var host_info = get_host_info(); |
| + |
| +var scope = 'resources/clients-get-frame.html'; |
| +var t = async_test('Test Clients.get() cross origin'); |
| +var other_origin_iframe = host_info['HTTP_REMOTE_ORIGIN'] + base_path() + |
| + '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-
|
| +var myOriginClientId; |
|
nhiroki
2016/02/17 02:40:28
my_origin_client_id
jungkees
2016/02/17 14:01:12
Done.
|
| +t.step(function() { |
| + service_worker_unregister_and_register( |
| + t, 'resources/clients-get-worker.js', scope) |
| + .then(function(registration) { |
| + add_completion_callback(function() { registration.unregister(); }); |
| + return wait_for_state(t, registration.installing, 'activated'); |
| + }) |
| + .then(function() { |
| + return with_iframe(scope); |
| + }) |
| + .then(function(frame1) { |
| + add_completion_callback(function() { frame1.remove(); }); |
| + return new Promise(function(resolve, reject) { |
| + function get_client_id(e) { |
| + window.removeEventListener('message', get_client_id); |
| + resolve(e.data.clientId); |
| + } |
| + window.addEventListener('message', get_client_id, false); |
| + }); |
| + }) |
| + .then(function(clientId) { |
|
nhiroki
2016/02/17 02:40:28
client_id
jungkees
2016/02/17 14:01:12
Done.
|
| + myOriginClientId = clientId; |
| + return with_iframe(other_origin_iframe); |
| + }) |
| + .then(function(frame2) { |
| + add_completion_callback(function() { frame2.remove(); }); |
| + window.addEventListener('message', function(e) { |
| + assert_equals(e.data.result, undefined); |
| + t.done(); |
| + }); |
| + frame2.contentWindow.postMessage( |
| + {clientId: myOriginClientId}, host_info['HTTP_REMOTE_ORIGIN']); |
| + }) |
| + .catch(unreached_rejection(t)); |
| + }); |
| +</script> |