| 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..5f11ec5abaa2ae79aff789b98979e5dc221e0ac6
|
| --- /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-cross-origin-frame.html';
|
| +var my_origin_client_id;
|
| +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(client_id) {
|
| + my_origin_client_id = client_id;
|
| + 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: my_origin_client_id}, host_info['HTTP_REMOTE_ORIGIN']);
|
| + })
|
| + .catch(unreached_rejection(t));
|
| + });
|
| +</script>
|
|
|