mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Allow microtasks to run if document has been destroyed
187f8c54 made `HTML::Task` runnable for destroyed documents, and this
change aligns microtask behavior with that. This is required for an
upcoming change that switches Fetch to be unbuffered by default. During
navigation, fetching the new document is initiated by the previous
document, which means we need to allow microtasks created in the
previous document's realm to run even after that document has been
destroyed.
This commit is contained in:
parent
cce5197f90
commit
f942fef39b
Notes:
github-actions[bot]
2025-11-20 11:30:58 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: f942fef39b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6839
Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 8 additions and 2 deletions
|
|
@ -125,8 +125,14 @@ EventLoop& EnvironmentSettingsObject::responsible_event_loop()
|
|||
RunScriptDecision can_run_script(JS::Realm const& realm)
|
||||
{
|
||||
// 1. If the global object specified by realm is a Window object whose Document object is not fully active, then return "do not run".
|
||||
if (is<HTML::Window>(realm.global_object()) && !as<HTML::Window>(realm.global_object()).associated_document().is_fully_active())
|
||||
if (auto const* window = as_if<HTML::Window>(realm.global_object())) {
|
||||
auto const& document = window->associated_document();
|
||||
// AD-HOC: We allow tasks for destroyed documents to run so that microtasks queued during the fetch of a new
|
||||
// document in a navigation can still be processed, even after the previous document, the one that
|
||||
// initiated the fetch, has been destroyed.
|
||||
if (!document.has_been_destroyed() && !document.is_fully_active())
|
||||
return RunScriptDecision::DoNotRun;
|
||||
}
|
||||
|
||||
// 2. If scripting is disabled for realm, then return "do not run".
|
||||
if (is_scripting_disabled(realm))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue