Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-navigation/tentative/crossdoc-001.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Cross-document navigation</title>
<link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async (t) => {
await new Promise(r => window.onload = () => t.step_timeout(r, 0));
let child = document.createElement("iframe");
child.src = "resources/crossdoc-001-helper.html";
document.documentElement.appendChild(child);
await new Promise(r => child.contentWindow.onload = () => t.step_timeout(r, 0));
// Go to a different URL.
child.contentWindow.postMessage("navigate");
let data;
do {
const message = await new Promise(resolve => window.addEventListener("message", resolve));
data = message.data;
assert_false(data.match.from, `"From" route should never match in this test, but did for ${data.msg}`);
switch (data.msg) {
case "source.swap":
case "target.start":
case "target.load":
assert_true(data.match.to, data.msg);
break;
case "source.hide":
case "target.done":
assert_false(data.match.to, data.msg);
break;
}
} while (data.msg != "target.done");
// Now go back.
child.contentWindow.navigation.back();
do {
const message = await new Promise(resolve => window.addEventListener("message", resolve));
data = message.data;
assert_false(data.match.to, `"To" route should never match in this test, but did for ${data.msg}`);
switch (data.msg) {
case "target.swap":
case "target.reveal":
assert_true(data.match.from, data.msg);
break;
case "source.done":
assert_false(data.match.from, data.msg);
break;
};
} while (data.msg != "source.done");
}, "Go to matching route");
</script>