Source code

Revision control

Copy as Markdown

Other Tools

<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="i" src="/common/blank.html"></iframe>
<script>
// Resolves after the load event so that the next navigation isn't converted to
// a replace navigation.
function navigateAndWaitForLoad(t, iframe, navigate) {
return new Promise(resolve => {
iframe.onload = () => t.step_timeout(resolve, 0);
navigate();
});
}
promise_test(async t => {
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
await navigateAndWaitForLoad(t, i, () => i.contentWindow.navigation.navigate("?1"));
const keys = i.contentWindow.navigation.entries().map(e => e.key);
await navigateAndWaitForLoad(t, i, () => i.contentWindow.navigation.back());
assert_true(i.contentWindow.navigation.canGoForward);
await navigateAndWaitForLoad(t, i, () => i.src = "javascript:'new content'");
const nav = i.contentWindow.navigation;
assert_array_equals(nav.entries().map(e => e.key), keys);
assert_equals(nav.currentEntry.index, 0);
assert_true(nav.canGoForward);
}, "entries() keeps forward entries after navigation to a javascript: URL");
</script>