blob: 7a4a37db4216fbbe928cd25d422aca8bf2fd3967 [file] [log] [blame]
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="i" src="/common/blank.html"></iframe>
<script>
async_test(t => {
// Wait for after the load event so that the navigation doesn't get converted
// into a replace navigation.
window.onload = () => t.step_timeout(() => {
assert_equals(appHistory.entries().length, 1);
assert_equals(i.contentWindow.appHistory.entries().length, 1);
appHistory.navigate("#top");
assert_equals(appHistory.entries().length, 2);
assert_equals(i.contentWindow.appHistory.entries().length, 1);
i.contentWindow.appHistory.navigate("#1");
assert_equals(appHistory.entries().length, 2);
assert_equals(i.contentWindow.appHistory.entries().length, 2);
assert_equals(appHistory.current.index, 1);
assert_equals(i.contentWindow.appHistory.current.index, 1);
assert_true(appHistory.canGoBack);
assert_true(i.contentWindow.appHistory.canGoBack);
// There are 2 joint session history entries containing the iframe's
// previous key. Navigate to the nearest one (which navigates the iframe
// but not the top window).
i.contentWindow.appHistory.back().committed.then(t.step_func_done(() => {
assert_equals(appHistory.current.index, 1);
assert_equals(i.contentWindow.appHistory.current.index, 0);
}));
}, 0);
}, "appHistory.back() goes to the nearest back entry");
</script>