servo: Merge #17827 - Update step annotations in script's prepare method (from cynicaldevil:fix-step-annotations); r=jdm
authorNikhil Shagrithaya <nikhilshagri@gmail.com>
Sun, 23 Jul 2017 12:45:22 -0700
changeset 419185 de668ab058ff8614980481e459fce96c44cb9342
parent 419184 ac0b38e566148e36369e7a7b987ba7b15b70e2ae
child 419186 37c161b31cf5e7c2f460b0e37b372c45cfb57904
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs17827
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17827 - Update step annotations in script's prepare method (from cynicaldevil:fix-step-annotations); r=jdm <!-- Please describe your changes on the following line: --> The step annotations in the code were outdated, and did not match the spec: https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script Source-Repo: https://github.com/servo/servo Source-Revision: 548d65dc7a08805bb941d83304c30a12c834ca90
servo/components/script/dom/htmlscriptelement.rs
--- a/servo/components/script/dom/htmlscriptelement.rs
+++ b/servo/components/script/dom/htmlscriptelement.rs
@@ -337,19 +337,21 @@ impl HTMLScriptElement {
             return;
         }
 
         // Step 10.
         if !doc.is_scripting_enabled() {
             return;
         }
 
-        // TODO(#4577): Step 11: CSP.
+        // TODO: Step 11: nomodule content attribute
 
-        // Step 12.
+        // TODO(#4577): Step 12: CSP.
+
+        // Step 13.
         let for_attribute = element.get_attribute(&ns!(), &local_name!("for"));
         let event_attribute = element.get_attribute(&ns!(), &local_name!("event"));
         match (for_attribute.r(), event_attribute.r()) {
             (Some(for_attribute), Some(event_attribute)) => {
                 let for_value = for_attribute.value().to_ascii_lowercase();
                 let for_value = for_value.trim_matches(HTML_SPACE_CHARACTERS);
                 if for_value != "window" {
                     return;
@@ -359,103 +361,103 @@ impl HTMLScriptElement {
                 let event_value = event_value.trim_matches(HTML_SPACE_CHARACTERS);
                 if event_value != "onload" && event_value != "onload()" {
                     return;
                 }
             },
             (_, _) => (),
         }
 
-        // Step 13.
+        // Step 14.
         let encoding = element.get_attribute(&ns!(), &local_name!("charset"))
                               .and_then(|charset| encoding_from_whatwg_label(&charset.value()))
                               .unwrap_or_else(|| doc.encoding());
 
-        // Step 14.
+        // Step 15.
         let cors_setting = cors_setting_for_element(element);
 
-        // TODO: Step 15: Module script credentials mode.
+        // TODO: Step 16: Module script credentials mode.
 
-        // TODO: Step 16: Nonce.
+        // TODO: Step 17: Nonce.
 
-        // Step 17: Integrity metadata.
+        // Step 18: Integrity metadata.
         let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity"));
         let integrity_val = im_attribute.r().map(|a| a.value());
         let integrity_metadata = match integrity_val {
             Some(ref value) => &***value,
             None => "",
         };
 
-        // TODO: Step 18: parser state.
+        // TODO: Step 19: parser state.
 
-        // TODO: Step 19: environment settings object.
+        // TODO: Step 20: environment settings object.
 
         let base_url = doc.base_url();
         if let Some(src) = element.get_attribute(&ns!(), &local_name!("src")) {
-            // Step 20.
+            // Step 21.
 
-            // Step 20.1.
+            // Step 21.1.
             let src = src.value();
 
-            // Step 20.2.
+            // Step 21.2.
             if src.is_empty() {
                 self.queue_error_event();
                 return;
             }
 
-            // Step 20.3: The "from an external file"" flag is stored in ClassicScript.
+            // Step 21.3: The "from an external file"" flag is stored in ClassicScript.
 
-            // Step 20.4-20.5.
+            // Step 21.4-21.5.
             let url = match base_url.join(&src) {
                 Ok(url) => url,
                 Err(_) => {
                     warn!("error parsing URL for script {}", &**src);
                     self.queue_error_event();
                     return;
                 },
             };
 
-            // Preparation for step 22.
+            // Preparation for step 23.
             let kind = if element.has_attribute(&local_name!("defer")) && was_parser_inserted && !async {
-                // Step 22.a: classic, has src, has defer, was parser-inserted, is not async.
+                // Step 23.a: classic, has src, has defer, was parser-inserted, is not async.
                 ExternalScriptKind::Deferred
             } else if was_parser_inserted && !async {
-                // Step 22.b: classic, has src, was parser-inserted, is not async.
+                // Step 23.c: classic, has src, was parser-inserted, is not async.
                 ExternalScriptKind::ParsingBlocking
             } else if !async && !self.non_blocking.get() {
-                // Step 22.c: classic, has src, is not async, is not non-blocking.
+                // Step 23.d: classic, has src, is not async, is not non-blocking.
                 ExternalScriptKind::AsapInOrder
             } else {
-                // Step 22.d: classic, has src.
+                // Step 23.f: classic, has src.
                 ExternalScriptKind::Asap
             };
 
-            // Step 20.6.
+            // Step 21.6.
             fetch_a_classic_script(self, kind, url, cors_setting, integrity_metadata.to_owned(), encoding);
 
-            // Step 22.
+            // Step 23.
             match kind {
                 ExternalScriptKind::Deferred => doc.add_deferred_script(self),
                 ExternalScriptKind::ParsingBlocking => doc.set_pending_parsing_blocking_script(self, None),
                 ExternalScriptKind::AsapInOrder => doc.push_asap_in_order_script(self),
                 ExternalScriptKind::Asap => doc.add_asap_script(self),
             }
         } else {
-            // Step 21.
+            // Step 22.
             assert!(!text.is_empty());
             let result = Ok(ClassicScript::internal(text, base_url));
 
-            // Step 22.
+            // Step 23.
             if was_parser_inserted &&
                doc.get_current_parser().map_or(false, |parser| parser.script_nesting_level() <= 1) &&
                doc.get_script_blocking_stylesheets_count() > 0 {
-                // Step 22.e: classic, has no src, was parser-inserted, is blocked on stylesheet.
+                // Step 23.h: classic, has no src, was parser-inserted, is blocked on stylesheet.
                 doc.set_pending_parsing_blocking_script(self, Some(result));
             } else {
-                // Step 22.f: otherwise.
+                // Step 23.i: otherwise.
                 self.execute(result);
             }
         }
     }
 
     fn unminify_js(&self, script: &mut ClassicScript) {
         if !opts::get().unminify_js {
             return;