Bug 749367 - script type=texttemplate content parsed as JavaScript (+E4X), r=jst, f=ms2ger, mbrubeck, jdm

This commit is contained in:
Mark Capella 2012-05-09 07:24:24 -07:00
parent 9c68958e38
commit d3f72cbbfb
6 changed files with 73 additions and 21 deletions

View File

@ -465,18 +465,8 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
}
}
if (isJavaScript)
typeID = nsIProgrammingLanguage::JAVASCRIPT;
else {
// Use the object factory to locate a matching language.
nsCOMPtr<nsIScriptRuntime> runtime;
rv = NS_GetJSRuntime(getter_AddRefs(runtime));
if (NS_FAILED(rv) || runtime == nsnull) {
// Failed to get the explicitly specified language
NS_WARNING("Failed to find a scripting language");
typeID = nsIProgrammingLanguage::UNKNOWN;
} else
typeID = nsIProgrammingLanguage::JAVASCRIPT;
if (!isJavaScript) {
typeID = nsIProgrammingLanguage::UNKNOWN;
}
if (typeID != nsIProgrammingLanguage::UNKNOWN) {

View File

@ -578,6 +578,7 @@ _TEST_FILES2 = \
test_bug719533.html \
test_bug737087.html \
test_bug433662.html \
test_bug749367.html \
$(NULL)
_CHROME_FILES = \

View File

@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=749367
-->
<head>
<title>Test for Bug 749367</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=749367">Mozilla Bug 749367</a>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="text/template">
ok(false, "Shouldn't execute");
</script>
<script type="text/javascript">
ok(true, "Should execute");
</script>
</pre>
</body>
</html>

View File

@ -46,6 +46,7 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_bug486990.xul \
test_bug749367.xul \
$(NULL)
_CHROME_FILES = \

View File

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=749367
-->
<window title="Mozilla Bug 749367"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="setTimeout(runTests, 0);">
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=486990"
target="_blank">Mozilla Bug 486990</a>
</body>
<!-- test code goes here -->
<script type="text/template">
<![CDATA[
SimpleTest.waitForExplicitFinish();
function runTests() {
ok(false, "Shouldn't execute");
SimpleTest.finish();
}
]]>
</script>
<script type="text/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
function runTests() {
ok(true, "Should execute");
SimpleTest.finish();
}
]]>
</script>
</window>

View File

@ -928,15 +928,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
langID = nsIProgrammingLanguage::JAVASCRIPT;
version = JSVERSION_LATEST;
} else {
// Use the script object factory to locate the language.
nsCOMPtr<nsIScriptRuntime> runtime;
rv = NS_GetJSRuntime(getter_AddRefs(runtime));
if (NS_FAILED(rv) || runtime == nsnull) {
// Failed to get the explicitly specified language
NS_WARNING("Failed to find a scripting language");
langID = nsIProgrammingLanguage::UNKNOWN;
} else
langID = nsIProgrammingLanguage::JAVASCRIPT;
langID = nsIProgrammingLanguage::UNKNOWN;
}
if (langID != nsIProgrammingLanguage::UNKNOWN) {