aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/settings_stack.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2017-01-12 12:53:53 -0500
committerJosh Matthews <josh@joshmatthews.net>2017-02-01 12:54:33 -0500
commitb5d2bd757b45aa7f1e61c947d883eb977c6ad7af (patch)
treea43aaa5c69190004106f8fb49a29a06326cc77d4 /components/script/dom/bindings/settings_stack.rs
parent32d4f84a30035b6b1094f7e68adbe1e6a883bb9b (diff)
downloadservo-b5d2bd757b45aa7f1e61c947d883eb977c6ad7af.tar.gz
servo-b5d2bd757b45aa7f1e61c947d883eb977c6ad7af.zip
Perform a microtask checkpoint after executing classic scripts and callbacks.
Diffstat (limited to 'components/script/dom/bindings/settings_stack.rs')
-rw-r--r--components/script/dom/bindings/settings_stack.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/components/script/dom/bindings/settings_stack.rs b/components/script/dom/bindings/settings_stack.rs
index 10afc833cb4..dec63924915 100644
--- a/components/script/dom/bindings/settings_stack.rs
+++ b/components/script/dom/bindings/settings_stack.rs
@@ -11,6 +11,7 @@ use js::jsapi::JSTracer;
use js::jsapi::UnhideScriptedCaller;
use js::rust::Runtime;
use std::cell::RefCell;
+use std::thread;
thread_local!(static STACK: RefCell<Vec<StackEntry>> = RefCell::new(Vec::new()));
@@ -36,7 +37,7 @@ pub unsafe fn trace(tracer: *mut JSTracer) {
/// RAII struct that pushes and pops entries from the script settings stack.
pub struct AutoEntryScript {
- global: usize,
+ global: Root<GlobalScope>,
}
impl AutoEntryScript {
@@ -50,7 +51,7 @@ impl AutoEntryScript {
kind: StackEntryKind::Entry,
});
AutoEntryScript {
- global: global as *const _ as usize,
+ global: Root::from_ref(global),
}
})
}
@@ -62,12 +63,17 @@ impl Drop for AutoEntryScript {
STACK.with(|stack| {
let mut stack = stack.borrow_mut();
let entry = stack.pop().unwrap();
- assert_eq!(&*entry.global as *const GlobalScope as usize,
- self.global,
+ assert_eq!(&*entry.global as *const GlobalScope,
+ &*self.global as *const GlobalScope,
"Dropped AutoEntryScript out of order.");
assert_eq!(entry.kind, StackEntryKind::Entry);
trace!("Clean up after running script with {:p}", &*entry.global);
- })
+ });
+
+ // Step 5
+ if !thread::panicking() && incumbent_global().is_none() {
+ self.global.perform_a_microtask_checkpoint();
+ }
}
}