diff options
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index cc2ec2b8e4a..fad1c7f7877 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1592,6 +1592,11 @@ impl ScriptThread { let category = self.categorize_msg(&msg); let pipeline_id = self.message_to_pipeline(&msg); + let _realm = pipeline_id.and_then(|id| { + let global = self.documents.borrow().find_global(id); + global.map(|global| enter_realm(&*global)) + }); + if self.closing.load(Ordering::SeqCst) { // If we've received the closed signal from the BHM, only handle exit messages. match msg { @@ -1656,6 +1661,8 @@ impl ScriptThread { } let window = document.window(); + let _realm = enter_realm(&*document); + window .upcast::<GlobalScope>() .perform_a_dom_garbage_collection_checkpoint(); @@ -1684,6 +1691,7 @@ impl ScriptThread { } for (_, document) in self.documents.borrow().iter() { + let _realm = enter_realm(&*document); document.animations().send_pending_events(document.window()); } } @@ -1786,7 +1794,7 @@ impl ScriptThread { DispatchStorageEvent(id, ..) => Some(id), ReportCSSError(id, ..) => Some(id), Reload(id, ..) => Some(id), - PaintMetric(..) => None, + PaintMetric(id, ..) => Some(id), ExitFullScreen(id, ..) => Some(id), MediaSessionAction(..) => None, SetWebGPUPort(..) => None, @@ -2070,7 +2078,13 @@ impl ScriptThread { fn handle_msg_from_script(&self, msg: MainThreadScriptMsg) { match msg { - MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, task, _, _)) => task.run_box(), + MainThreadScriptMsg::Common(CommonScriptMsg::Task(_, task, pipeline_id, _)) => { + let _realm = pipeline_id.and_then(|id| { + let global = self.documents.borrow().find_global(id); + global.map(|global| enter_realm(&*global)) + }); + task.run_box() + }, MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(chan)) => { self.collect_reports(chan) }, @@ -3277,6 +3291,8 @@ impl ScriptThread { incomplete.inherited_secure_context, ); + let _realm = enter_realm(&*window); + // Initialize the browsing context for the window. let window_proxy = self.local_window_proxy( &window, @@ -3460,6 +3476,8 @@ impl ScriptThread { ); } + let _realm = enter_realm(&*window); + // Assuming all CompositionEvent are generated by user interactions. ScriptThread::set_user_interacting(true); match event { @@ -3978,7 +3996,7 @@ impl ScriptThread { .documents .borrow() .iter() - .map(|(_id, document)| document.global()) + .map(|(_id, document)| DomRoot::from_ref(document.window().upcast())) .collect(); self.microtask_queue.checkpoint( |