Skip to content
Permalink
Browse files

Add a check for when the js execution stack is empty

  • Loading branch information
cbrewster authored and jdm committed Jan 11, 2018
1 parent 87475b1 commit 43526c80bb09ff2f2ea152dfd99ce6e0314a4a46
Showing with 10 additions and 1 deletion.
  1. +6 −0 components/script/dom/bindings/settings_stack.rs
  2. +4 −1 components/script/dom/servoparser/mod.rs
@@ -35,6 +35,12 @@ pub unsafe fn trace(tracer: *mut JSTracer) {
})
}

pub fn is_execution_stack_empty() -> bool {
STACK.with(|stack| {
stack.borrow().is_empty()
})
}

/// RAII struct that pushes and pops entries from the script settings stack.
pub struct AutoEntryScript {
global: DomRoot<GlobalScope>,
@@ -13,6 +13,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
use dom::bindings::settings_stack::is_execution_stack_empty;
use dom::bindings::str::DOMString;
use dom::characterdata::CharacterData;
use dom::comment::Comment;
@@ -1001,7 +1002,9 @@ fn create_element_for_token(
// Step 6.1.
// TODO: handle throw-on-dynamic-markup-insertion counter.
// Step 6.2
// TODO: If the JavaScript execution context stack is empty, then perform a microtask checkpoint.
if is_execution_stack_empty() {
document.window().upcast::<GlobalScope>().perform_a_microtask_checkpoint();
}
// Step 6.3
ScriptThread::push_new_element_queue()
}

0 comments on commit 43526c8

Please sign in to comment.
You can’t perform that action at this time.