Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<title>Test for Bug 300691</title>
<script 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=300691">Mozilla Bug 300691</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="text/javascript">
// First, setup. We'll be toggling these variables as we go.
var test1Ran = false;
var test2Ran = false;
var test3Ran = false;
var test4Ran = false;
var test5Ran = false;
var test6Ran = false;
var test7Ran = false;
var test8Ran = false;
var test9Ran = false;
var test10Ran = false;
var test11Ran = false;
var test12Ran = false;
var test13Ran = false;
var test14aRan = false;
var test14bRan = false;
var test15aRan = false;
var test15bRan = false;
</script>
<script id="test1" type="text/javascript">test1Ran = true;</script>
<script id="test2" type="text/javascript"></script>
<script id="test3" type="text/javascript">;</script>
<script id="test4" type="text/javascript"> </script>
<script id="test5" type="text/javascript"></script>
<script id="test6" type="text/javascript"></script>
<script id="test7" type="text/javascript"></script>
<script id="test8" type="text/javascript"></script>
<script id="test9" type="text/javascript"></script>
<script id="test10" type="text/javascript" src="data:text/javascript,">
test10Ran = true;
</script>
<script id="test11" type="text/javascript"
src="data:text/javascript,test11Ran = true">
test11Ran = false;
</script>
<script id="test12" type="text/javascript"></script>
<script id="test13" type="text/javascript"></script>
<script id="test14" type="text/javascript"></script>
<script id="test15" type="text/javascript"></script>
<script class="testbody" type="text/javascript">
/** Test for Bug 300691 **/
$("test2").appendChild(document.createTextNode("test2Ran = true"));
is(test2Ran, true, "Should be 2!");
$("test3").appendChild(document.createTextNode("test3Ran = true"));
is(test3Ran, false, "Should have run already 3!");
$("test4").appendChild(document.createTextNode("test4Ran = true"));
is(test4Ran, false, "Should have run already 4!");
$("test5").appendChild(document.createTextNode(" "));
$("test5").appendChild(document.createTextNode("test5Ran = true"));
is(test5Ran, false, "Should have run already 5!");
$("test6").appendChild(document.createTextNode(" "));
$("test7").appendChild(document.createTextNode(""));
$("test8").appendChild(document.createTextNode(""));
$("test9").appendChild(document.createTextNode(""));
$("test12").src = "data:text/javascript,test12Ran = true;";
is(test12Ran, false, "Not yet 12!");
$("test13").setAttribute("src", "data:text/javascript,test13Ran = true;");
is(test13Ran, false, "Not yet 13!");
$("test14").src = "data:text/javascript,test14aRan = true;";
$("test14").appendChild(document.createTextNode("test14bRan = true"));
is(test14aRan, false, "Not yet 14a!");
is(test14bRan, false, "Not yet 14b!");
$("test15").src = "data:text/javascript,test15aRan = true;";
$("test15").appendChild(document.createTextNode("test15bRan = true"));
$("test15").removeAttribute("src");
is(test15aRan, false, "Not yet 15a!");
is(test15bRan, false, "Not yet 15b!");
</script>
<script type="text/javascript">
// Follow up on some of those
$("test6").appendChild(document.createTextNode("test6Ran = true"));
is(test6Ran, false, "Should have run already 6!");
$("test7").appendChild(document.createTextNode("test7Ran = true"));
is(test7Ran, true, "Should be 7!");
$("test8").insertBefore(document.createTextNode("test8Ran = true"),
$("test8").firstChild);
is(test8Ran, true, "Should be 8!");
$("test9").firstChild.data = "test9Ran = true";
is(test9Ran, true, "Should be 9!");
</script>
<script type="text/javascript">
function done() {
is(test1Ran, true, "Should have run!");
is(test3Ran, false, "Already executed test3 script once");
is(test4Ran, false,
"Should have executed whitespace-only script already");
is(test5Ran, false,
"Should have executed once the whitespace node was added");
is(test6Ran, false,
"Should have executed once the whitespace node was added 2");
is(test10Ran, false, "Has an src; inline part shouldn't run");
is(test11Ran, true, "Script with src should have run");
is(test12Ran, true, "Setting src should execute script");
is(test13Ran, true, "Setting src attribute should execute script");
is(test14aRan, true, "src attribute takes precedence over inline content");
is(test14bRan, false, "src attribute takes precedence over inline content 2");
is(test15aRan, true,
"src attribute load should have started before the attribute got removed");
is(test15bRan, false,
"src attribute still got executed, so this shouldn't have been");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(done);
</script>
</pre>
</body>
</html>