Skip to content

Commit

Permalink
Bug 1834096 - Rewrite JS language check to use MIME type check r=peterv
Browse files Browse the repository at this point in the history
Rewrote the JS language check util function to use the existing more
robust JS MIME type checker instead of implementing its own checks
(passing "text/{given}").

16 WPT subtests now newly pass.

WPT tests: https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html

Differential Revision: https://phabricator.services.mozilla.com/D178567
  • Loading branch information
CanadaHonk committed May 30, 2023
1 parent a1f73e0 commit b8a7e56
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 57 deletions.
14 changes: 5 additions & 9 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,15 +1559,11 @@ bool nsContentUtils::GetPseudoAttributeValue(const nsString& aSource,
}

bool nsContentUtils::IsJavaScriptLanguage(const nsString& aName) {
return aName.LowerCaseEqualsLiteral("javascript") ||
aName.LowerCaseEqualsLiteral("livescript") ||
aName.LowerCaseEqualsLiteral("mocha") ||
aName.LowerCaseEqualsLiteral("javascript1.0") ||
aName.LowerCaseEqualsLiteral("javascript1.1") ||
aName.LowerCaseEqualsLiteral("javascript1.2") ||
aName.LowerCaseEqualsLiteral("javascript1.3") ||
aName.LowerCaseEqualsLiteral("javascript1.4") ||
aName.LowerCaseEqualsLiteral("javascript1.5");
// Create MIME type as "text/" + given input
nsAutoString mimeType(u"text/");
mimeType.Append(aName);

return IsJavascriptMIMEType(mimeType);
}

void nsContentUtils::SplitMimeType(const nsAString& aValue, nsString& aType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,3 @@
if (os == "android") and fission: [OK, TIMEOUT]
[Script shouldn't run with type=" "]
expected: FAIL
[Script should run with language="ecmascript"]
expected: FAIL
[Script should run with language="jscript"]
expected: FAIL
[Script should run with language="x-ecmascript"]
expected: FAIL
[Script should run with language="x-javascript"]
expected: FAIL
[Script should run with language="ECMASCRIPT"]
expected: FAIL
[Script should run with language="JSCRIPT"]
expected: FAIL
[Script should run with language="X-ECMASCRIPT"]
expected: FAIL
[Script should run with language="X-JAVASCRIPT"]
expected: FAIL
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,3 @@
if (os == "android") and fission: [OK, TIMEOUT]
[Script shouldn't run with type=" "]
expected: FAIL
[Script should run with language="ecmascript"]
expected: FAIL
[Script should run with language="jscript"]
expected: FAIL
[Script should run with language="x-ecmascript"]
expected: FAIL
[Script should run with language="x-javascript"]
expected: FAIL
[Script should run with language="ECMASCRIPT"]
expected: FAIL
[Script should run with language="JSCRIPT"]
expected: FAIL
[Script should run with language="X-ECMASCRIPT"]
expected: FAIL
[Script should run with language="X-JAVASCRIPT"]
expected: FAIL

0 comments on commit b8a7e56

Please sign in to comment.