7 <script id=
"emptyscript"></script>
8 <script id=
"put_text_script">2+
2</script>
11 return external
.ok(b
, msg
);
18 function testWriteScript() {
19 var len
= document
.getElementsByTagName('div').length
;
20 ok(len
=== 3, "init length = " + len
);
22 document
.write("<script>"
23 + "var len = document.getElementsByTagName('div').length;"
24 + "ok(len === 3, 'unexpected length ' + len);"
28 len
= document
.getElementsByTagName('script').length
;
29 ok(len
=== 4, "script col length = " + len
);
30 ok(executed
, "written script not executed");
33 function testPutSrc() {
34 var elem
= document
.getElementById("emptyscript");
36 ok(extern_cnt
=== 0, "extern_cnt = " + extern_cnt
+ " expected 0");
37 elem
.src
= "externscr.js";
38 ok(extern_cnt
=== 0, "extern_cnt = " + extern_cnt
+ " expected 0");
41 function testPutText() {
42 var elem
= document
.getElementById("put_text_script");
45 elem
.text
= "exec_cnt++;";
46 ok(exec_cnt
=== 1, "put_text_script exec_cnt " + exec_cnt
);
49 elem
.text
= "exec_cnt++;";
50 ok(exec_cnt
=== 1, "put_text_script exec_cnt " + exec_cnt
);
58 ok(false, "Got an exception " + e
.message
);
61 function testPutSrc2() {
64 elem
= document
.createElement("script");
65 elem
.src
= "externscr.js";
66 ok(extern_cnt
=== 1, "extern_cnt = " + extern_cnt
+ " expected 1");
67 document
.body
.appendChild(elem
);
68 ok(extern_cnt
=== 2, "extern_cnt = " + extern_cnt
+ " expected 2");
70 elem
= document
.createElement("script");
71 document
.body
.appendChild(elem
);
72 ok(extern_cnt
=== 2, "extern_cnt = " + extern_cnt
+ " expected 2");
73 elem
.src
= "externscr.js";
74 ok(extern_cnt
=== 3, "extern_cnt = " + extern_cnt
+ " expected 3");
76 elem2
= document
.createElement("div");
77 elem
= document
.createElement("script");
78 elem
.src
= "externscr.js";
79 ok(extern_cnt
=== 3, "extern_cnt = " + extern_cnt
+ " expected 3");
80 elem2
.appendChild(elem
);
81 document
.body
.appendChild(elem2
);
82 ok(extern_cnt
=== 4, "extern_cnt = " + extern_cnt
+ " expected 4");
85 function testPutText2() {
88 elem
= document
.createElement("script");
90 elem
.text
= "exec_cnt++;";
91 ok(exec_cnt
=== 0, "script exec_cnt " + exec_cnt
);
93 document
.body
.appendChild(elem
);
94 ok(exec_cnt
=== 1, "script exec_cnt " + exec_cnt
);
96 elem
.text
= "exec_cnt++;";
97 ok(exec_cnt
=== 1, "script exec_cnt " + exec_cnt
);
99 elem
.src
= "externscr.js";
100 ok(extern_cnt
=== 5, "extern_cnt = " + extern_cnt
+ " expected 5");
103 ok(extern_cnt
=== 5, "> extern_cnt = " + extern_cnt
+ " expected 5");
104 elem
.text
= "exec_cnt++;"; /* forces evaluation, but src will be executed */
105 ok(exec_cnt
=== 0, "script exec_cnt " + exec_cnt
);
106 ok(extern_cnt
=== 6, "< extern_cnt = " + extern_cnt
+ " expected 6");
107 elem
.text
= "exec_cnt++;"; /* forces evaluation, but src will be executed */
108 ok(exec_cnt
=== 0, "script exec_cnt " + exec_cnt
);
109 ok(extern_cnt
=== 7, "< extern_cnt = " + extern_cnt
+ " expected 6");
111 elem
= document
.createElement("script");
113 elem
.text
= "exec_cnt++;";
114 ok(exec_cnt
=== 0, "script exec_cnt " + exec_cnt
);
115 elem
.src
= "externscr.js";
116 ok(extern_cnt
=== 7, "extern_cnt = " + extern_cnt
+ " expected 7");
118 document
.body
.appendChild(elem
);
119 ok(exec_cnt
=== 0, "script exec_cnt " + exec_cnt
);
120 ok(extern_cnt
=== 8, "extern_cnt = " + extern_cnt
+ " expected 8");
123 document
.body
.onload = function() {
124 ok(extern_cnt
=== 1, "extern_cnt = " + extern_cnt
);
129 ok(false, "got an exception " + e
.message
);
132 external
.reportSuccess();
136 ok(extern_cnt
=== 1, "extern_cnt = " + extern_cnt
);