mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 01:26:22 +00:00
LibWeb: Update document url after same-document back/forward navigation
Seems like a specification bug, but other browsers update url before popstate event is fired and so should we. Fixes back/forward navigation on GitHub.
This commit is contained in:
parent
08aaf4fb07
commit
23d683cf6b
Notes:
sideshowbarker
2024-07-17 17:49:11 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 23d683cf6b
Pull-request: https://github.com/SerenityOS/serenity/pull/24052
3 changed files with 8 additions and 3 deletions
|
@ -1,8 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
window.history.pushState({}, '', '');
|
window.history.pushState({}, '', window.location.href + '#test');
|
||||||
|
|
||||||
window.addEventListener('popstate', (e) => {
|
window.addEventListener('popstate', (e) => {
|
||||||
parent.postMessage('popstate event from iframe', '*');
|
const url = new URL(window.location.href);
|
||||||
|
const pathWithHash = url.pathname.split('/').pop() + url.hash;
|
||||||
|
parent.postMessage(`popstate event from iframe new_path=${pathWithHash}`, '*');
|
||||||
});
|
});
|
||||||
|
|
||||||
window.history.back();
|
window.history.back();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
popstate event from iframe
|
popstate event from iframe new_path=iframe-popstate-event.html
|
||||||
|
|
|
@ -4070,6 +4070,9 @@ void Document::update_for_history_step_application(JS::NonnullGCPtr<HTML::Sessio
|
||||||
|
|
||||||
// 5. If documentIsNew is false, then:
|
// 5. If documentIsNew is false, then:
|
||||||
if (!document_is_new) {
|
if (!document_is_new) {
|
||||||
|
// NOTE: Not in the spec, but otherwise document's url won't be updated in case of a same-document back/forward navigation.
|
||||||
|
set_url(entry->url());
|
||||||
|
|
||||||
// AD HOC: Skip this in situations the spec steps don't account for
|
// AD HOC: Skip this in situations the spec steps don't account for
|
||||||
if (update_navigation_api) {
|
if (update_navigation_api) {
|
||||||
// 1. Update the navigation API entries for a same-document navigation given navigation, entry, and "traverse".
|
// 1. Update the navigation API entries for a same-document navigation given navigation, entry, and "traverse".
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue