diff options
author | Josh Matthews <josh@joshmatthews.net> | 2017-01-12 12:53:53 -0500 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2017-02-01 12:54:33 -0500 |
commit | b5d2bd757b45aa7f1e61c947d883eb977c6ad7af (patch) | |
tree | a43aaa5c69190004106f8fb49a29a06326cc77d4 /components/script/dom/htmlscriptelement.rs | |
parent | 32d4f84a30035b6b1094f7e68adbe1e6a883bb9b (diff) | |
download | servo-b5d2bd757b45aa7f1e61c947d883eb977c6ad7af.tar.gz servo-b5d2bd757b45aa7f1e61c947d883eb977c6ad7af.zip |
Perform a microtask checkpoint after executing classic scripts and callbacks.
Diffstat (limited to 'components/script/dom/htmlscriptelement.rs')
-rw-r--r-- | components/script/dom/htmlscriptelement.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index e1e8dabac7b..8703a45ea82 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -486,11 +486,7 @@ impl HTMLScriptElement { document.set_current_script(Some(self)); // Step 5.a.2. - let window = window_from_node(self); - let line_number = if script.external { 1 } else { self.line_number as u32 }; - rooted!(in(window.get_cx()) let mut rval = UndefinedValue()); - window.upcast::<GlobalScope>().evaluate_script_on_global_with_result( - &script.text, script.url.as_str(), rval.handle_mut(), line_number); + self.run_a_classic_script(&script); // Step 6. document.set_current_script(old_script.r()); @@ -506,6 +502,24 @@ impl HTMLScriptElement { } } + // https://html.spec.whatwg.org/multipage/#run-a-classic-script + pub fn run_a_classic_script(&self, script: &ClassicScript) { + // TODO use a settings object rather than this element's document/window + // Step 2 + let document = document_from_node(self); + if !document.is_fully_active() || !document.is_scripting_enabled() { + return; + } + + // Steps 4-10 + let window = window_from_node(self); + let line_number = if script.external { 1 } else { self.line_number as u32 }; + rooted!(in(window.get_cx()) let mut rval = UndefinedValue()); + let global = window.upcast::<GlobalScope>(); + global.evaluate_script_on_global_with_result( + &script.text, script.url.as_str(), rval.handle_mut(), line_number); + } + pub fn queue_error_event(&self) { let window = window_from_node(self); window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("error"), &window); |