Show warning when the script is a module

The warning can be removed in #23545.
This commit is contained in:
CYBAI 2019-09-05 12:41:22 +09:00
parent 70c5cfdbdb
commit 95ddfb3930

View file

@ -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,6 +493,8 @@ impl HTMLScriptElement {
},
};
match script_type {
ScriptType::Classic => {
// Preparation for step 26.
let kind = if element.has_attribute(&local_name!("defer")) &&
was_parser_inserted &&
@ -530,13 +532,33 @@ impl HTMLScriptElement {
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()
);
},
}
} 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 &&