Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /navigation-api/navigate-event/navigate-multiple-location.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<form id="form" action=""></form>
<script>
async_test(t => {
const expected = [
"navigate #1",
"navigateerror #1",
"navigate #3",
"navigateerror #3",
"navigate #2",
"navigatesuccess #2"
];
const result = [];
navigation.onnavigate = t.step_func(e => {
result.push(`${e.type} ${new URL(e.destination.url).hash}`);
});
navigation.onnavigateerror = t.step_func(e => {
result.push(`${e.type} ${new URL(navigation.currentEntry.url).hash}`);
if (navigation.currentEntry.url.endsWith("#1")) {
location.href = "#3";
}
});
navigation.onnavigatesuccess = t.step_func_done(e => {
result.push(`${e.type} ${new URL(navigation.currentEntry.url).hash}`);
assert_array_equals(result, expected);
});
location.href = "#1";
location.href = "#2";
}, "location.href set multiple times gives correct event order");
</script>