wine/dlls/mshtml/tests/exectest.html
2012-10-16 20:41:20 +02:00

89 lines
2.3 KiB
HTML

<html>
<body>
Script execution test
<div id="b1"></div>
<div id="b2"></div>
<div id="b3"></div>
<script id="emptyscript"></script>
<script>
function ok(b, msg) {
return external.ok(b, msg);
}
var executed = false;
var extern_cnt = 0;
function testWriteScript() {
var len = document.getElementsByTagName('div').length;
ok(len === 3, "init length = " + len);
document.write("<script>"
+ "var len = document.getElementsByTagName('div').length;"
+ "ok(len === 3, 'unexpected length ' + len);"
+ "executed = true;"
+ "<" + "/script>");
len = document.getElementsByTagName('script').length;
ok(len === 3, "script col length = " + len);
ok(executed, "written script not executed");
}
function testPutSrc() {
var elem = document.getElementById("emptyscript");
ok(extern_cnt === 0, "extern_cnt = " + extern_cnt + " expected 0");
elem.src = "externscr.js";
ok(extern_cnt === 0, "extern_cnt = " + extern_cnt + " expected 0");
}
try {
testWriteScript();
testPutSrc();
}catch(e) {
ok(false, "Got an exception");
}
function testPutSrc2() {
var elem, elem2;
elem = document.createElement("script");
elem.src = "externscr.js";
ok(extern_cnt === 1, "extern_cnt = " + extern_cnt + " expected 1");
document.body.appendChild(elem);
ok(extern_cnt === 2, "extern_cnt = " + extern_cnt + " expected 2");
elem = document.createElement("script");
document.body.appendChild(elem);
ok(extern_cnt === 2, "extern_cnt = " + extern_cnt + " expected 2");
elem.src = "externscr.js";
ok(extern_cnt === 3, "extern_cnt = " + extern_cnt + " expected 3");
elem2 = document.createElement("div");
elem = document.createElement("script");
elem.src = "externscr.js";
ok(extern_cnt === 3, "extern_cnt = " + extern_cnt + " expected 3");
elem2.appendChild(elem);
document.body.appendChild(elem2);
ok(extern_cnt === 4, "extern_cnt = " + extern_cnt + " expected 4");
}
document.body.onload = function() {
ok(extern_cnt === 1, "extern_cnt = " + extern_cnt);
try {
testPutSrc2();
}catch(e) {
ok(false, "got an exception");
}
external.reportSuccess();
}
</script>
<script>
ok(extern_cnt === 1, "extern_cnt = " + extern_cnt);
</script>
<div id="a1"></div>
<div id="a2"></div>
<div id="b3"></div>
</body>
</html>