2 <script src=
"/resources/testharness.js"></script>
3 <script src=
"/resources/testharnessreport.js"></script>
4 <iframe id=
"i" src=
"/common/blank.html"></iframe>
7 // Wait for after the load event so that the navigation doesn't get converted
8 // into a replace navigation.
9 window
.onload
= () => t
.step_timeout(() => {
10 assert_equals(navigation
.entries().length
, 1);
11 assert_equals(i
.contentWindow
.navigation
.entries().length
, 1);
12 navigation
.navigate("#top");
13 assert_equals(navigation
.entries().length
, 2);
14 assert_equals(i
.contentWindow
.navigation
.entries().length
, 1);
15 i
.contentWindow
.navigation
.navigate("#1");
16 assert_equals(navigation
.entries().length
, 2);
17 assert_equals(i
.contentWindow
.navigation
.entries().length
, 2);
18 assert_equals(navigation
.currentEntry
.index
, 1);
19 assert_equals(i
.contentWindow
.navigation
.currentEntry
.index
, 1);
20 assert_true(navigation
.canGoBack
);
21 assert_true(i
.contentWindow
.navigation
.canGoBack
);
23 i
.contentWindow
.navigation
.back().committed
.then(t
.step_func(() => {
24 assert_equals(navigation
.currentEntry
.index
, 1);
25 assert_equals(i
.contentWindow
.navigation
.currentEntry
.index
, 0);
26 navigation
.back().committed
.then(t
.step_func(() => {
27 assert_equals(navigation
.currentEntry
.index
, 0);
28 assert_equals(i
.contentWindow
.navigation
.currentEntry
.index
, 0);
29 // There are 2 joint session history entries containing the top window's
30 // final key. Navigate to the nearest one (which navigates only the
32 navigation
.forward().committed
.then(t
.step_func_done(() => {
33 assert_equals(navigation
.currentEntry
.index
, 1);
34 assert_equals(i
.contentWindow
.navigation
.currentEntry
.index
, 0);
39 }, "navigation.forward() goes to the nearest forward entry");