1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

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.
This commit is contained in:
Luke Wilde 2023-02-28 18:00:59 +00:00 committed by Linus Groh
parent 9acc542059
commit a1f7186153

View file

@ -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);
}