<!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>
