Bug 1330900 - Implement <script nomodule>

This patch implements:
- noModule getter/setter for HTMLScriptElement
- the nomodule attribute for HTMLScriptElement
- the logic in nsScriptLoader that denies the loading of a nomodule script
- tests

Tag #618
This commit is contained in:
wolfbeast 2018-07-10 13:28:03 +02:00 committed by Roy Tam
commit 10b2e09718
9 changed files with 164 additions and 2 deletions

View file

@ -1459,7 +1459,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
nsCOMPtr<nsIContent> scriptContent = do_QueryInterface(aElement);
// Step 12. Check that the script is not an eventhandler
// Step 13. Check that the script is not an eventhandler
if (IsScriptEventHandler(scriptContent)) {
return false;
}
@ -1493,7 +1493,18 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
}
}
// Step 14. in the HTML5 spec
// "In modern user agents that support module scripts, the script element with
// the nomodule attribute will be ignored".
// "The nomodule attribute must not be specified on module scripts (and will
// be ignored if it is)."
if (ModuleScriptsEnabled() &&
scriptKind == nsScriptKind::Classic &&
scriptContent->IsHTMLElement() &&
scriptContent->HasAttr(kNameSpaceID_None, nsGkAtoms::nomodule)) {
return false;
}
// Step 15. and later in the HTML5 spec
nsresult rv = NS_OK;
RefPtr<nsScriptLoadRequest> request;
if (aElement->GetScriptExternal()) {