diff options
author | CYBAI <cyb.ai.815@gmail.com> | 2019-09-05 12:41:22 +0900 |
---|---|---|
committer | CYBAI <cyb.ai.815@gmail.com> | 2019-09-06 13:35:40 +0900 |
commit | 95ddfb3930debb81653dffcade6c2ea15dd30d9b (patch) | |
tree | ceb0d551d312804762c4944f07aeecde68bf094e /components/script/dom/htmlscriptelement.rs | |
parent | 70c5cfdbdb9c4945a222503fe3873ff774537097 (diff) | |
download | servo-95ddfb3930debb81653dffcade6c2ea15dd30d9b.tar.gz servo-95ddfb3930debb81653dffcade6c2ea15dd30d9b.zip |
Show warning when the script is a module
The warning can be removed in #23545.
Diffstat (limited to 'components/script/dom/htmlscriptelement.rs')
-rw-r--r-- | components/script/dom/htmlscriptelement.rs | 98 |
1 files changed, 60 insertions, 38 deletions
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index fcbf4ebc330..7c9e3ebd42d 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -125,7 +125,7 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[ "text/x-javascript", ]; -#[derive(JSTraceable, MallocSizeOf)] +#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] pub enum ScriptType { Classic, Module, @@ -388,7 +388,7 @@ impl HTMLScriptElement { return; } - let _script_type = if let Some(ty) = self.get_script_type() { + let script_type = if let Some(ty) = self.get_script_type() { ty } else { // Step 7. @@ -493,50 +493,72 @@ impl HTMLScriptElement { }, }; - // Preparation for step 26. - let kind = if element.has_attribute(&local_name!("defer")) && - was_parser_inserted && - !r#async - { - // Step 26.a: classic, has src, has defer, was parser-inserted, is not async. - ExternalScriptKind::Deferred - } else if was_parser_inserted && !r#async { - // Step 26.c: classic, has src, was parser-inserted, is not async. - ExternalScriptKind::ParsingBlocking - } else if !r#async && !self.non_blocking.get() { - // Step 26.d: classic, has src, is not async, is not non-blocking. - ExternalScriptKind::AsapInOrder - } else { - // Step 26.f: classic, has src. - ExternalScriptKind::Asap - }; - - // Step 24.6. - fetch_a_classic_script( - self, - kind, - url, - cors_setting, - integrity_metadata.to_owned(), - encoding, - ); - - // Step 23. - match kind { - ExternalScriptKind::Deferred => doc.add_deferred_script(self), - ExternalScriptKind::ParsingBlocking => { - doc.set_pending_parsing_blocking_script(self, None) + match script_type { + ScriptType::Classic => { + // Preparation for step 26. + let kind = if element.has_attribute(&local_name!("defer")) && + was_parser_inserted && + !r#async + { + // Step 26.a: classic, has src, has defer, was parser-inserted, is not async. + ExternalScriptKind::Deferred + } else if was_parser_inserted && !r#async { + // Step 26.c: classic, has src, was parser-inserted, is not async. + ExternalScriptKind::ParsingBlocking + } else if !r#async && !self.non_blocking.get() { + // Step 26.d: classic, has src, is not async, is not non-blocking. + ExternalScriptKind::AsapInOrder + } else { + // Step 26.f: classic, has src. + ExternalScriptKind::Asap + }; + + // Step 24.6. + fetch_a_classic_script( + self, + kind, + url, + cors_setting, + integrity_metadata.to_owned(), + encoding, + ); + + // 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), + } + }, + ScriptType::Module => { + warn!( + "{} is a module script. It should be fixed after #23545 landed.", + url.clone() + ); }, - ExternalScriptKind::AsapInOrder => doc.push_asap_in_order_script(self), - ExternalScriptKind::Asap => doc.add_asap_script(self), } } else { // Step 25. assert!(!text.is_empty()); + // Step 25-1. - let result = Ok(ScriptOrigin::internal(text, base_url, ScriptType::Classic)); + let result = Ok(ScriptOrigin::internal( + text.clone(), + base_url.clone(), + script_type.clone(), + )); // TODO: Step 25-2. + if let ScriptType::Module = script_type { + warn!( + "{} is a module script. It should be fixed after #23545 landed.", + base_url.clone() + ); + return; + } // Step 26. if was_parser_inserted && |