1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 21:37:34 +00:00

LibWeb: Call process_session_history_traversal_queue on history update

Spec declares that the updates to history should be synchronous on
initial page load and on history pushState/replaceState.
This commit is contained in:
Vladimir Shakhov 2023-12-14 11:38:45 +01:00 committed by Alexander Kalenik
parent 9793d69d4f
commit e2391105a1
4 changed files with 20 additions and 3 deletions

View file

@ -0,0 +1 @@
test done!

View file

@ -0,0 +1,16 @@
<script src="../include.js"></script>
<script>
asyncTest(done => {
history.replaceState({}, "hello", "history-replace-push-state-race.html");
history.replaceState({}, "hello", "history-replace-push-state-race.html");
// this test checks a regression for a crash in `finalize_a_same_document_navigation`
// when `target_navigable->get_session_history_entries()` does not contain `entry_to_replace` exactly.
//
// history.replaceState is one possible trigger for the crash.
println("test done!");
done();
});
</script>

View file

@ -1877,6 +1877,9 @@ void perform_url_and_history_update_steps(DOM::Document& document, AK::URL new_u
// 1. Finalize a same-document navigation given traversable, navigable, newEntry, and entryToReplace.
finalize_a_same_document_navigation(*traversable, *navigable, new_entry, entry_to_replace);
});
// FIXME: Implement synchronous session history steps.
traversable->process_session_history_traversal_queue();
}
void Navigable::scroll_offset_did_change()

View file

@ -214,9 +214,6 @@ Optional<AK::URL> NavigableContainer::shared_attribute_processing_steps_for_ifra
// 4. If url matches about:blank and initialInsertion is true, then perform the URL and history update steps given element's content navigable's active document and url.
if (url_matches_about_blank(url) && initial_insertion) {
perform_url_and_history_update_steps(*m_content_navigable->active_document(), url);
// NOTE: Not in the spec but we need to make sure that "apply the history step" for initial navigation to about:blank
// is applied before subsequent navigation.
navigable()->traversable_navigable()->process_session_history_traversal_queue();
}
// 5. Return url.