mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 12:32:21 +00:00
LibWeb: Process all task source while waiting for document population
"apply the history step" initiated by reloading or back/forward navigation might require doing fetching while populating a document, so it is not possible to restrict spin_until() to process only NavigationAndTraversal task source. "apply the history step" initiated by synchronous navigation keeps processing only NavigationAndTraversal task source because it will never have to populate a document. Another reason to keep synchronous navigation blocking other task sources is that we crash if active SHE changes in the middle of "apply the history step" initiated by sync navigation. The new test is added to makes sure we don't regress that.
This commit is contained in:
parent
600ecdd5f7
commit
d86ad2fcfa
Notes:
sideshowbarker
2024-07-17 11:30:54 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: d86ad2fcfa
Pull-request: https://github.com/SerenityOS/serenity/pull/23923
3 changed files with 32 additions and 1 deletions
|
@ -0,0 +1 @@
|
||||||
|
test done!
|
|
@ -0,0 +1,22 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
asyncTest(done => {
|
||||||
|
let counter = 0;
|
||||||
|
setTimeout(() => {
|
||||||
|
history.replaceState({}, "test", "history-replace-push-state-race-3.html");
|
||||||
|
counter++;
|
||||||
|
if (counter === 2) {
|
||||||
|
println("test done!");
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
setTimeout(() => {
|
||||||
|
history.replaceState({}, "test", "history-replace-push-state-race-3.html");
|
||||||
|
counter++;
|
||||||
|
if (counter === 2) {
|
||||||
|
println("test done!");
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -587,10 +587,18 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
main_thread_event_loop().spin_processing_tasks_with_source_until(Task::Source::NavigationAndTraversal, [&] {
|
auto check_if_document_population_tasks_completed = JS::SafeFunction<bool()>([&] {
|
||||||
return changing_navigable_continuations.size() + completed_change_jobs == total_change_jobs;
|
return changing_navigable_continuations.size() + completed_change_jobs == total_change_jobs;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (synchronous_navigation == SynchronousNavigation::Yes) {
|
||||||
|
// NOTE: Synchronous navigation should never require document population, so it is safe to process only NavigationAndTraversal source.
|
||||||
|
main_thread_event_loop().spin_processing_tasks_with_source_until(Task::Source::NavigationAndTraversal, move(check_if_document_population_tasks_completed));
|
||||||
|
} else {
|
||||||
|
// NOTE: Process all task sources while waiting because reloading or back/forward navigation might require fetching to populate a document.
|
||||||
|
main_thread_event_loop().spin_until(move(check_if_document_population_tasks_completed));
|
||||||
|
}
|
||||||
|
|
||||||
// 13. Let navigablesThatMustWaitBeforeHandlingSyncNavigation be an empty set.
|
// 13. Let navigablesThatMustWaitBeforeHandlingSyncNavigation be an empty set.
|
||||||
Vector<JS::GCPtr<Navigable>> navigables_that_must_wait_before_handling_sync_navigation;
|
Vector<JS::GCPtr<Navigable>> navigables_that_must_wait_before_handling_sync_navigation;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue