diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-10 13:28:03 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-10 13:28:03 +0200 |
commit | e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc (patch) | |
tree | a3e4bc52cb2fdce52d8dbf88a4db41d81017c1b8 /dom/base | |
parent | 100c6a7e95b8e9624fc43fabc96d88070635d1ef (diff) | |
download | UXP-e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc.tar UXP-e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc.tar.gz UXP-e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc.tar.lz UXP-e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc.tar.xz UXP-e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc.zip |
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
Diffstat (limited to 'dom/base')
-rw-r--r-- | dom/base/nsGkAtomList.h | 1 | ||||
-rw-r--r-- | dom/base/nsScriptLoader.cpp | 15 |
2 files changed, 14 insertions, 2 deletions
diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 8fefa0e02..73a3a02b1 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -665,6 +665,7 @@ GK_ATOM(noembed, "noembed") GK_ATOM(noframes, "noframes") GK_ATOM(nohref, "nohref") GK_ATOM(noisolation, "noisolation") +GK_ATOM(nomodule, "nomodule") GK_ATOM(nonce, "nonce") GK_ATOM(none, "none") GK_ATOM(noresize, "noresize") diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index 6f8251fc3..61d122386 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -1452,7 +1452,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; } @@ -1486,7 +1486,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()) { |