1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=300691
-->
<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>
|