Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
promise_test(async t => {
let i = document.createElement("iframe");
i.src = "resources/" + token();
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
let original_iframe_url = i.contentWindow.location.href;
// Do a cross-document push navigation in the iframe.
await new Promise(resolve => i.onload = resolve);
// Go back. This will trigger a cross-origin redirect, but the navigate event
// should still fire, and the event url should be the pre-redirect url (which
// is same-origin).
let navigate_event_url = await new Promise(resolve => i.contentWindow.navigation.onnavigate = e => {
await new Promise(resolve => i.onload = resolve);
assert_equals(navigate_event_url, original_iframe_url);
}, "A traversal that redirects from same-origin to cross-origin fires the navigate event");