Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/browsers/browsing-the-web/history-traversal/hash-empty-string.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help"
<link rel="author" title="Zach Hoffman" href="mailto:zach@zrhoffman.net">
<script>
let popstateTriggered = false;
window.addEventListener("popstate", () => popstateTriggered = true);
let hashchangeTriggered = false;
window.addEventListener("hashchange", () => hashchangeTriggered = true);
test(() => {
assert_equals(location.href.indexOf("#"), -1)
}, "URL has no hash")
location.hash = "";
test(() => {
assert_false(popstateTriggered);
}, "changing the hash from an empty string to an empty string does not trigger a popstate event")
promise_test(async () => {
// hashchange is fired async
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
assert_false(hashchangeTriggered);
}, "changing the hash from an empty string to an empty string does not trigger a hashchange event")
</script>