-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Description
Problem in brief
Changes to the "history entry" URL using history.replaceState() are not correctly reflected to location.hash and in certain conditions also not to location.href.
Reproducing
Below code shows behaviors of HtmlUnit and expected (tested in Chrome).
<!DOCTYPE html>
<html>
<head>
<script>
// Comments below assume 'location.href' is "https://www.example.com/some/path"
history.replaceState(null, '', location.origin + '/abc?def=1#foo');
// Expected:
// --> "href=https://www.example.com/abc?def=1#foo, hash=#foo"
// HtmlUnit without "Cache-Control: no-store":
// --> "href="https://www.example.co/abc?def=1#foo, hash=" -- bad 'hash'
// HtmlUnit with "Cache-Control: no-store":
// --> "href="https://www.example.com/some/path, hash=" -- bad 'href' and 'hash'
console.log("href=" + location.href + ", hash=" + location.hash);
</script>
</head>
<body>
</body>
</html>Some thoughts
history.replaceState()updates the originalWebRequest.url_location.hashis cached inLocation.hash_which is not updated byhistory.replaceState()- We were looking into how this could be fixed and there's some awkwardness because of the lacks a "history entry" URL concept for
history.replaceState()that's separate from the transport layerWebRequest.url_. Possibly adding this new concept toPageorHistory.HistoryEntryorLocationis required. - We also noticed there's some differences when encoding is required for the URL set through
history.replaceState():- e.g.
history.replaceState(null, '', location.href + '?foo=Ż')produces"...?foo=%C5%BB"whenlocation.hrefis viewed through Chrome but"...?foo=Ż"for HtmlUnit.
- e.g.
atnak
Metadata
Metadata
Assignees
Labels
No labels