From 102cf345badebfa2c34294d273a288343b13d100 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Nov 2024 11:22:22 +0100 Subject: [PATCH] LibWeb: Recompute targetStep once more in "apply the history step" This is an ad-hoc change to account for the fact that we may run arbitrary code while waiting for the tasks in this function to complete. Same exact idea as ac48222ed7b497b13343ec79a234ba432ffd29e2, once again. --- Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index fcc18f6c2ee..8c6fe3e90d3 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -798,6 +798,10 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_ // 16. Let completedNonchangingJobs be 0. IGNORE_USE_IN_ESCAPING_LAMBDA auto completed_non_changing_jobs = 0u; + // AD-HOC: We re-compute targetStep here, since it might have changed since the last time we computed it. + // This can happen if navigables are destroyed while we wait for tasks to complete. + target_step = get_the_used_step(step); + // 17. Let (scriptHistoryLength, scriptHistoryIndex) be the result of getting the history object length and index given traversable and targetStep. auto length_and_index = get_the_history_object_length_and_index(target_step); IGNORE_USE_IN_ESCAPING_LAMBDA auto script_history_length = length_and_index.script_history_length;