summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-api/navigation-history-entry/sameDocument-after-fragment-navigate.html
blob: a197f825d8eda300250af2961bfd14448cdc3fc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<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(t.step_func_done(() => {
    let entry1 = navigation.currentEntry;
    assert_true(entry1.sameDocument);

    location = "#hash";
    let entry2 = navigation.currentEntry;
    assert_not_equals(entry1, entry2);
    assert_true(entry1.sameDocument);

    history.pushState("push", "", "#push");
    let entry3 = navigation.currentEntry;
    assert_not_equals(entry1, entry3);
    assert_not_equals(entry2, entry3);
    assert_true(entry1.sameDocument);
    assert_true(entry2.sameDocument);

    assert_equals(navigation.entries().length, 3);
    assert_equals(navigation.entries()[0], entry1);
    assert_equals(navigation.entries()[1], entry2);
    assert_equals(navigation.entries()[2], entry3);
  }), 0);
}, "entry.sameDocument after same-document navigations");
</script>