aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs18
-rw-r--r--components/script/dom/window.rs21
2 files changed, 31 insertions, 8 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 19901c43796..9fabde71dd9 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1830,13 +1830,17 @@ impl DocumentProgressHandler {
impl Runnable for DocumentProgressHandler {
fn handler(self: Box<DocumentProgressHandler>) {
- match self.task {
- DocumentProgressTask::DOMContentLoaded => {
- self.dispatch_dom_content_loaded();
- }
- DocumentProgressTask::Load => {
- self.set_ready_state_complete();
- self.dispatch_load();
+ let document = self.addr.to_temporary().root();
+ let window = document.r().window().root();
+ if window.r().is_alive() {
+ match self.task {
+ DocumentProgressTask::DOMContentLoaded => {
+ self.dispatch_dom_content_loaded();
+ }
+ DocumentProgressTask::Load => {
+ self.set_ready_state_complete();
+ self.dispatch_load();
+ }
}
}
}
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index f791464366d..b8e0ffb86e7 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -69,6 +69,14 @@ use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
use time;
+/// Current state of the window object
+#[derive(Copy, Clone, Debug, PartialEq)]
+#[jstraceable]
+enum WindowState {
+ Alive,
+ Zombie, // Pipeline is closed, but the window hasn't been GCed yet.
+}
+
/// Extra information concerning the reason for reflowing.
#[derive(Debug)]
pub enum ReflowReason {
@@ -170,7 +178,10 @@ pub struct Window {
pending_reflow_count: Cell<u32>,
/// A channel for communicating results of async scripts back to the webdriver server
- webdriver_script_chan: RefCell<Option<Sender<WebDriverJSResult>>>
+ webdriver_script_chan: RefCell<Option<Sender<WebDriverJSResult>>>,
+
+ /// The current state of the window object
+ current_state: Cell<WindowState>,
}
impl Window {
@@ -179,6 +190,7 @@ impl Window {
unsafe {
*self.js_runtime.borrow_for_script_deallocation() = None;
*self.browser_context.borrow_for_script_deallocation() = None;
+ self.current_state.set(WindowState::Zombie);
}
}
@@ -544,6 +556,7 @@ pub trait WindowHelpers {
fn set_devtools_timeline_marker(self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>);
fn drop_devtools_timeline_markers(self);
fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>);
+ fn is_alive(self) -> bool;
}
pub trait ScriptHelpers {
@@ -595,6 +608,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
// which causes a panic!
self.Gc();
+ self.current_state.set(WindowState::Zombie);
*self.js_runtime.borrow_mut() = None;
*self.browser_context.borrow_mut() = None;
}
@@ -916,6 +930,10 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>) {
*self.webdriver_script_chan.borrow_mut() = chan;
}
+
+ fn is_alive(self) -> bool {
+ self.current_state.get() == WindowState::Alive
+ }
}
impl Window {
@@ -979,6 +997,7 @@ impl Window {
layout_join_port: DOMRefCell::new(None),
window_size: Cell::new(window_size),
pending_reflow_count: Cell::new(0),
+ current_state: Cell::new(WindowState::Alive),
devtools_marker_sender: RefCell::new(None),
devtools_markers: RefCell::new(HashSet::new()),