Bug 1428745 - Remove support for version parameter from script loader - trimming script type, r=jonco

This commit is contained in:
Andrea Marchesini 2018-01-09 17:00:50 +01:00
Родитель 174498ca29
Коммит 606217325c
3 изменённых файлов: 45 добавлений и 2 удалений

Просмотреть файл

@ -171,9 +171,20 @@ HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& aRv)
// need to be transfered when modifying
bool
HTMLScriptElement::GetScriptType(nsAString& type)
HTMLScriptElement::GetScriptType(nsAString& aType)
{
return GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
nsAutoString type;
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::type, type)) {
return false;
}
// ASCII whitespace https://infra.spec.whatwg.org/#ascii-whitespace:
// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE.
static const char kASCIIWhitespace[] = "\t\n\f\r ";
type.Trim(kASCIIWhitespace);
aType.Assign(type);
return true;
}
void

Просмотреть файл

@ -4,3 +4,4 @@ support-files =
[test_bug1053321.html]
skip-if = os == 'android' # bug 1386644
[test_whitespace.html]

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for ScriptLoader and type with whitespaces</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript">
let passed = false;
let tests = [
[ " application/javascript", true ],
[ "\tapplication/javascript\n\r \t", true ],
];
for (let i = 0; i < tests.length; ++i) {
passed = false;
let script = document.createElement('script');
script.setAttribute('type', tests[i][0]);
script.innerText = "passed = true;";
document.body.appendChild(script);
ok (passed, tests[i][1], "Test " + tests[i][0] + " passed");
}
</script>
</body>
</html>