From a1f7186153792840fe7a564a5bf615986878932d Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Tue, 28 Feb 2023 18:00:59 +0000 Subject: [PATCH] LibWeb: Make BC::set_system_visibility_state use the active doc's global Using main_thread_vm().current_realm() will rely on the dummy execution context if the visibility state changes when no JavaScript is running. --- Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 9ed8e52f74..a89ed290d0 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -1292,7 +1292,13 @@ void BrowsingContext::set_system_visibility_state(VisibilityState visibility_sta // has changed to newState, it must queue a task on the user interaction task source to update // the visibility state of all the Document objects in the top-level browsing context's document family with newState. auto document_family = top_level_browsing_context().document_family(); - queue_global_task(Task::Source::UserInteraction, Bindings::main_thread_vm().current_realm()->global_object(), [visibility_state, document_family = move(document_family)] { + + // From the new navigable version, where it tells us what global object to use here: + // 1. Let document be navigable's active document. + // 2. Queue a global task on the user interaction task source given document's relevant global object to update the visibility state of document with newState. + // FIXME: Update this function to fully match the navigable version. + VERIFY(active_document()); + queue_global_task(Task::Source::UserInteraction, relevant_global_object(*active_document()), [visibility_state, document_family = move(document_family)] { for (auto& document : document_family) { document->update_the_visibility_state(visibility_state); }