From 45ec250b0a989643865880734ff898de4b15bd7d Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Thu, 5 Sep 2019 16:12:52 +0800 Subject: improve spec compliance of discarding BCs do not handle compositor input events when BC is being discarded prevent firing of timers for discarded BCs return null for opener is BC has been discarded bundle discard BC steps into window method return null in window.opener, if BC has already been discarded move the window closed check pre-event to script-thread --- components/script/script_thread.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 440de991ceb..b4363f5ada3 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1973,7 +1973,15 @@ impl ScriptThread { let window = self.documents.borrow().find_window(pipeline_id); let window = match window { - Some(w) => w, + Some(w) => { + if w.Closed() { + return warn!( + "Received fire timer msg for a discarded browsing context whose pipeline is pending exit {}.", + pipeline_id + ); + } + w + }, None => { return warn!( "Received fire timer msg for a closed pipeline {}.", @@ -2848,7 +2856,7 @@ impl ScriptThread { // to avoid running layout on detached iframes. let window = document.window(); if discard_bc == DiscardBrowsingContext::Yes { - window.window_proxy().discard_browsing_context(); + window.discard_browsing_context(); } window.clear_js_runtime(); } @@ -3378,9 +3386,26 @@ impl ScriptThread { /// /// TODO: Actually perform DOM event dispatch. fn handle_event(&self, pipeline_id: PipelineId, event: CompositorEvent) { + // Do not handle events if the pipeline exited. + let window = match { self.documents.borrow().find_window(pipeline_id) } { + Some(win) => win, + None => { + return warn!( + "Compositor event sent to a pipeline that already exited {}.", + pipeline_id + ) + }, + }; + // Do not handle events if the BC has been, or is being, discarded + if window.Closed() { + return warn!( + "Compositor event sent to a pipeline with a closed window {}.", + pipeline_id + ); + } + // Assuming all CompositionEvent are generated by user interactions. ScriptThread::set_user_interacting(true); - match event { ResizeEvent(new_size, size_type) => { self.handle_resize_event(pipeline_id, new_size, size_type); -- cgit v1.2.3