Source code

Revision control

Copy as Markdown

Other Tools

<!--
Any copyright is dedicated to the Public Domain.
-->
<html>
<head>
<meta charset="utf-8" />
<meta name="timeout" content="long" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="testHelpers.js"></script>
<script>
const messageHub = createMotherListener();
async function runTests() {
const params = new URL(window.location.href).searchParams;
const api = params.get("api");
assert_true(!!api);
console.log("Tested API " + api);
const testIdWindow = "SameOriginWindowsWith" + api;
const testIdWorker = "WorkerSameOriginWindowsWith" + api;
const writeWindows = new Map();
const readWindowURL =
const readWindows = new Map();
messageHub.registerReadWindow(testIdWindow);
readWindows.set(
testIdWindow,
window.open(readWindowURL + "?id=" + testIdWindow)
);
messageHub.registerReadWindow(testIdWorker);
readWindows.set(
testIdWorker,
window.open(readWindowURL + "?id=" + testIdWorker)
);
const setup = { readWindows, writeWindows };
await messageHub.getReadWindow(testIdWindow);
async_test(t => {
messageHub.registerWindow(t, testIdWindow, api, "allow", setup);
writeWindows.set(
testIdWindow,
window.open(
testIdWindow
)
);
}, "Access allowed for two iframes with the same origin " + api);
await messageHub.getReadWindow(testIdWorker);
async_test(t => {
messageHub.registerWorker(t, testIdWorker, api, "allow", setup);
writeWindows.set(
testIdWorker,
window.open(
testIdWorker
)
);
}, "Worker access allowed for two iframes with the same origin " + api);
}
</script>
</head>
<body onload="runTests();"></body>
</html>