summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-08-13 13:42:52 +0000
committerMoonchild <moonchild@palemoon.org>2020-08-30 09:38:17 +0000
commitc735355ae167b247fa80e03772b657fc34983f49 (patch)
tree4c177d76073a75d7d64f399a526a05b1fbf01419 /dom
parent10a10fd3757374123eb5e3aab1e4720f86575f47 (diff)
downloadUXP-c735355ae167b247fa80e03772b657fc34983f49.tar
UXP-c735355ae167b247fa80e03772b657fc34983f49.tar.gz
UXP-c735355ae167b247fa80e03772b657fc34983f49.tar.lz
UXP-c735355ae167b247fa80e03772b657fc34983f49.tar.xz
UXP-c735355ae167b247fa80e03772b657fc34983f49.zip
Issue #618: Ignore 'event' and 'for' attributes for module scripts.
Because the spec says so.
Diffstat (limited to 'dom')
-rw-r--r--dom/script/ScriptLoader.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp
index 9de9a1d03..903822ef5 100644
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -299,8 +299,12 @@ ScriptLoader::~ScriptLoader()
// <script for=... event=...> element.
static bool
-IsScriptEventHandler(nsIContent* aScriptElement)
+IsScriptEventHandler(ScriptKind kind, nsIContent* aScriptElement)
{
+ if (kind != ScriptKind::Classic) {
+ return false;
+ }
+
if (!aScriptElement->IsHTMLElement()) {
return false;
}
@@ -1198,35 +1202,38 @@ ScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
nsCOMPtr<nsIContent> scriptContent = do_QueryInterface(aElement);
+ // Determine whether this is a classic script or a module script.
+ nsAutoString type;
+ bool hasType = aElement->GetScriptType(type);
+ ScriptKind scriptKind = ScriptKind::Classic;
+ if (ModuleScriptsEnabled() &&
+ !type.IsEmpty() && type.LowerCaseEqualsASCII("module")) {
+ scriptKind = ScriptKind::Module;
+ }
+
// Step 13. Check that the script is not an eventhandler
- if (IsScriptEventHandler(scriptContent)) {
+ if (IsScriptEventHandler(scriptKind, scriptContent)) {
return false;
}
JSVersion version = JSVERSION_DEFAULT;
- // Check the type attribute to determine language and version.
- // If type exists, it trumps the deprecated 'language='
- nsAutoString type;
- bool hasType = aElement->GetScriptType(type);
-
- ScriptKind scriptKind = ScriptKind::Classic;
- if (!type.IsEmpty()) {
- if (ModuleScriptsEnabled() && type.LowerCaseEqualsASCII("module")) {
- scriptKind = ScriptKind::Module;
- } else {
+ // For classic scripts, check the type attribute to determine language and
+ // version. If type exists, it trumps the deprecated 'language='
+ if (scriptKind == ScriptKind::Classic) {
+ if (!type.IsEmpty()) {
NS_ENSURE_TRUE(ParseTypeAttribute(type, &version), false);
- }
- } else if (!hasType) {
- // no 'type=' element
- // "language" is a deprecated attribute of HTML, so we check it only for
- // HTML script elements.
- if (scriptContent->IsHTMLElement()) {
- nsAutoString language;
- scriptContent->GetAttr(kNameSpaceID_None, nsGkAtoms::language, language);
- if (!language.IsEmpty()) {
- if (!nsContentUtils::IsJavaScriptLanguage(language)) {
- return false;
+ } else if (!hasType) {
+ // no 'type=' element
+ // "language" is a deprecated attribute of HTML, so we check it only for
+ // HTML script elements.
+ if (scriptContent->IsHTMLElement()) {
+ nsAutoString language;
+ scriptContent->GetAttr(kNameSpaceID_None, nsGkAtoms::language, language);
+ if (!language.IsEmpty()) {
+ if (!nsContentUtils::IsJavaScriptLanguage(language)) {
+ return false;
+ }
}
}
}