Commit 90a162d7 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

Add addressspace tests for module service workers

Add two tests (localhost and 127.0.0.1) for module service workers.

Bug: 954853
Change-Id: Ic530766c58807491e10c6de8b53cd047299891ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880500
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709391}
parent 802978ab
......@@ -16,8 +16,9 @@ async function receiveAddressSpaceMessageFromIFrame(frame) {
});
}
async function addressSpaceServiceWorkerTest(t, origin, expected) {
const url = origin + "/security/cors-rfc1918/resources/post-addressspace-from-serviceworker.html";
async function addressSpaceServiceWorkerTest(t, origin, expected, workerType) {
const path = "/security/cors-rfc1918/resources/post-addressspace-from-serviceworker.html";
const url = origin + path + "?workerType=" + workerType;
const frame = await with_iframe(url);
t.add_cleanup(_ => frame.remove());
......@@ -30,14 +31,30 @@ async function addressSpaceServiceWorkerTest(t, origin, expected) {
promise_test(async t => {
const origin = "https://localhost:8443";
const expected = "local";
await addressSpaceServiceWorkerTest(t, origin, expected);
}, "addressspace: service worker localhost");
const workerType = "classic";
await addressSpaceServiceWorkerTest(t, origin, expected, workerType);
}, "addressspace: service worker classic script localhost");
promise_test(async t => {
const origin = "https://127.0.0.1:8443";
const expected = "local";
await addressSpaceServiceWorkerTest(t, origin, expected);
const workerType = "classic";
await addressSpaceServiceWorkerTest(t, origin, expected, workerType);
}, "addressspace: service worker 127.0.0.1");
promise_test(async t => {
const origin = "https://localhost:8443";
const expected = "local";
const workerType = "module";
await addressSpaceServiceWorkerTest(t, origin, expected, workerType);
}, "addressspace: service worker module script localhost");
promise_test(async t => {
const origin = "https://127.0.0.1:8443";
const expected = "local";
const workerType = "module";
await addressSpaceServiceWorkerTest(t, origin, expected, workerType);
}, "addressspace: service worker module script 127.0.0.1");
</script>
</body>
\ No newline at end of file
......@@ -15,8 +15,12 @@ promise_test(async t => {
const script = "/security/cors-rfc1918/resources/post-addressspace-to-owner-serviceworker.js";
const scope = "/security/cors-rfc1918/resources/post-addressspace-from-serviceworker.html";
const params = new URLSearchParams(location.search);
const workerType = params.get("workerType");
const options = { type: workerType };
const registration = await service_worker_unregister_and_register(
t, script, scope);
t, script, scope, options);
t.add_cleanup(_ => registration.unregister());
await wait_for_state(t, registration.installing, "activated");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment