Implement throw-on-dynamic-markup-insertion-counter

This commit is contained in:
Connor Brewster 2017-12-02 18:35:39 -06:00 committed by Josh Matthews
parent 43526c80bb
commit 4593195b49
2 changed files with 26 additions and 6 deletions

View file

@ -364,6 +364,8 @@ pub struct Document {
tti_window: DomRefCell<InteractiveWindow>, tti_window: DomRefCell<InteractiveWindow>,
/// RAII canceller for Fetch /// RAII canceller for Fetch
canceller: FetchCanceller, canceller: FetchCanceller,
/// https://html.spec.whatwg.org/multipage/#throw-on-dynamic-markup-insertion-counter
throw_on_dynamic_markup_insertion_counter: Cell<u64>,
} }
#[derive(JSTraceable, MallocSizeOf)] #[derive(JSTraceable, MallocSizeOf)]
@ -2053,6 +2055,16 @@ impl Document {
let global_scope = self.window.upcast::<GlobalScope>(); let global_scope = self.window.upcast::<GlobalScope>();
global_scope.script_to_constellation_chan().send(msg).unwrap(); global_scope.script_to_constellation_chan().send(msg).unwrap();
} }
pub fn increment_throw_on_dynamic_markup_insertion_counter(&self) {
let counter = self.throw_on_dynamic_markup_insertion_counter.get();
self.throw_on_dynamic_markup_insertion_counter.set(counter + 1);
}
pub fn decrement_throw_on_dynamic_markup_insertion_counter(&self) {
let counter = self.throw_on_dynamic_markup_insertion_counter.get();
self.throw_on_dynamic_markup_insertion_counter.set(counter - 1);
}
} }
#[derive(MallocSizeOf, PartialEq)] #[derive(MallocSizeOf, PartialEq)]
@ -2294,6 +2306,7 @@ impl Document {
interactive_time: DomRefCell::new(interactive_time), interactive_time: DomRefCell::new(interactive_time),
tti_window: DomRefCell::new(InteractiveWindow::new()), tti_window: DomRefCell::new(InteractiveWindow::new()),
canceller: canceller, canceller: canceller,
throw_on_dynamic_markup_insertion_counter: Cell::new(0),
} }
} }
@ -3717,7 +3730,9 @@ impl DocumentMethods for Document {
} }
// Step 2. // Step 2.
// TODO: handle throw-on-dynamic-markup-insertion counter. if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
return Err(Error::InvalidState);
}
if !self.is_active() { if !self.is_active() {
// Step 3. // Step 3.
@ -3863,7 +3878,10 @@ impl DocumentMethods for Document {
} }
// Step 2. // Step 2.
// TODO: handle throw-on-dynamic-markup-insertion counter. if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
return Err(Error::InvalidState);
}
if !self.is_active() { if !self.is_active() {
// Step 3. // Step 3.
return Ok(()); return Ok(());
@ -3910,7 +3928,9 @@ impl DocumentMethods for Document {
} }
// Step 2. // Step 2.
// TODO: handle throw-on-dynamic-markup-insertion counter. if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
return Err(Error::InvalidState);
}
let parser = match self.get_current_parser() { let parser = match self.get_current_parser() {
Some(ref parser) if parser.is_script_created() => DomRoot::from_ref(&**parser), Some(ref parser) if parser.is_script_created() => DomRoot::from_ref(&**parser),

View file

@ -1000,7 +1000,7 @@ fn create_element_for_token(
// Step 6. // Step 6.
if will_execute_script { if will_execute_script {
// Step 6.1. // Step 6.1.
// TODO: handle throw-on-dynamic-markup-insertion counter. document.increment_throw_on_dynamic_markup_insertion_counter();
// Step 6.2 // Step 6.2
if is_execution_stack_empty() { if is_execution_stack_empty() {
document.window().upcast::<GlobalScope>().perform_a_microtask_checkpoint(); document.window().upcast::<GlobalScope>().perform_a_microtask_checkpoint();
@ -1025,9 +1025,9 @@ fn create_element_for_token(
// Step 9. // Step 9.
if will_execute_script { if will_execute_script {
// Steps 9.1 - 9.2. // Steps 9.1 - 9.2.
ScriptThread::pop_current_element_queue() ScriptThread::pop_current_element_queue();
// Step 9.3. // Step 9.3.
// TODO: handle throw-on-dynamic-markup-insertion counter. document.decrement_throw_on_dynamic_markup_insertion_counter();
} }
// TODO: Step 10. // TODO: Step 10.