forked from mirrors/gecko-dev
Automatic update from web-platform-tests Make navigation-api/ tests resilient to starting with extra NavigationHistoryEntries (#42232) When WPT are run in-browser or via wptrunner, there may be additional session history entries when the test starts, so the tests shouldn't assume that they start with navigation.entries().length == 1 or navigation.currentEntry.index == 0. This fixes all directories except navigate-event/ and navigation-methods/, which had enough tests to deserve separate treatment. This is a workaround for https://github.com/web-platform-tests/wpt/issues/33590. Change-Id: Ic60de8ffe247b374ef3a0e0939fc4c1a3427c7e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4903245 Auto-Submit: Nate Chapin <japhet@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Reviewed-by: Weizhong Xia <weizhong@google.com> Cr-Commit-Position: refs/heads/main@{#1204873} Co-authored-by: Nate Chapin <japhet@chromium.org> -- wpt-commits: 0a5ef44bf2e1c9be8f50beee9936771d5adcd35b wpt-pr: 42232
20 lines
742 B
HTML
20 lines
742 B
HTML
<!doctype html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
test(t => {
|
|
let start_index = navigation.currentEntry.index;
|
|
|
|
let oncurrententrychange_called = false;
|
|
let original_currentEntry = navigation.currentEntry;
|
|
navigation.oncurrententrychange = t.step_func(e => {
|
|
oncurrententrychange_called = true;
|
|
assert_equals(e.from, original_currentEntry);
|
|
assert_equals(e.from.index, -1);
|
|
assert_equals(e.navigationType, "replace");
|
|
assert_equals(navigation.currentEntry.index, start_index);
|
|
});
|
|
history.replaceState(1, "", "#1");
|
|
assert_true(oncurrententrychange_called);
|
|
}, "currententrychange fires for history.replaceState()");
|
|
</script>
|