diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html b/testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html new file mode 100644 index 000000000..a505e8722 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/client-navigate.https.html @@ -0,0 +1,117 @@ +<!doctype html> +<meta charset=utf-8> +<title>Service Worker: WindowClient.navigate</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src="resources/get-host-info.sub.js"></script> +<script src="resources/test-helpers.sub.js"></script> +<script> + function wait_for_message(msg) { + return new Promise(function(resolve, reject) { + var get_message_data = function get_message_data(e) { + window.removeEventListener("message", get_message_data); + resolve(e.data); + } + window.addEventListener("message", get_message_data, false); + }); + } + + function run_test(controller, clientId, test) { + return new Promise(function(resolve, reject) { + var channel = new MessageChannel(); + channel.port1.onmessage = function(e) { + resolve(e.data); + }; + var message = { + port: channel.port2, + test: test, + clientId: clientId, + }; + controller.postMessage( + message, [channel.port2]); + }); + } + + promise_test(function(t) { + var worker = "resources/client-navigate-worker.js"; + var scope = "resources/client-navigate-frame.html"; + var controller, frame, clientId; + + return service_worker_unregister_and_register(t, worker, scope) + .then(reg => wait_for_state(t, reg.installing, "activated")) + .then(___ => with_iframe(scope)) + .then(f => { + frame = f; + controller = frame.contentWindow.navigator.serviceWorker.controller; + fetch_tests_from_worker(controller); + return wait_for_message() + }) + .then(({id}) => clientId = id) + .then(___ => run_test(controller, clientId, "test_client_navigate_success")) + .then(({result, url}) => { + assert_equals(result, "test_client_navigate_success"); + assert_equals( + url, new URL("resources/client-navigated-frame.html", + location).toString()); + assert_equals( + frame.contentWindow.location.href, + new URL("resources/client-navigated-frame.html", + location).toString()); + }) + .catch(unreached_rejection(t)) + .then(___ => service_worker_unregister(t, scope)); + }, "Frame location should update on successful navigation"); + + promise_test(function(t) { + var worker = "resources/client-navigate-worker.js"; + var scope = "resources/client-navigate-frame.html"; + var controller, frame, clientId; + + return service_worker_unregister_and_register(t, worker, scope) + .then(reg => wait_for_state(t, reg.installing, "activated")) + .then(___ => with_iframe(scope)) + .then(f => { + frame = f; + controller = frame.contentWindow.navigator.serviceWorker.controller; + fetch_tests_from_worker(controller); + return wait_for_message() + }) + .then(({id}) => clientId = id) + .then(___ => run_test(controller, clientId, "test_client_navigate_redirect")) + .then(({result, url}) => { + assert_equals(result, "test_client_navigate_redirect"); + assert_equals(url, ""); + assert_throws(null, function() { return frame.contentWindow.location.href }); + }) + .catch(unreached_rejection(t)) + .then(___ => service_worker_unregister(t, scope)); + }, "Frame location should not be accessible after redirect"); + + promise_test(function(t) { + var worker = "resources/client-navigate-worker.js"; + var scope = "resources/client-navigate-frame.html"; + var controller, frame, clientId; + + return service_worker_unregister_and_register(t, worker, scope) + .then(reg => wait_for_state(t, reg.installing, "activated")) + .then(___ => with_iframe(scope)) + .then(f => { + frame = f; + controller = frame.contentWindow.navigator.serviceWorker.controller; + fetch_tests_from_worker(controller); + return wait_for_message() + }) + .then(({id}) => clientId = id) + .then(___ => run_test(controller, clientId, "test_client_navigate_failure")) + .then(({result, url}) => { + assert_equals(result, "test_client_navigate_failure"); + assert_equals( + frame.contentWindow.location.href, + new URL("resources/client-navigate-frame.html", + location).toString()); + frame.contentWindow.document.body.style = "background-color: green" + }) + .catch(unreached_rejection(t)) + .then(___ => service_worker_unregister(t, scope)); + }, "Frame location should not update on failed navigation"); +</script> |