mshtml: Added more events tests.
This commit is contained in:
parent
4940275d21
commit
516731c861
|
@ -78,12 +78,50 @@ function test_scriptfor() {
|
|||
ok(typeof(div.ontest) === "undefined", "typeof(div.ontest) = " + typeof(div.ontest));
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
function test_handler_this() {
|
||||
document.body.innerHTML = '<div id="d1"><div id="d2"></div></div>';
|
||||
|
||||
var div1 = document.getElementById("d1");
|
||||
var div2 = document.getElementById("d2");
|
||||
var calls = new Array();
|
||||
|
||||
function createHandler(name, node) {
|
||||
return function() {
|
||||
ok(this === node, "this !== node");
|
||||
calls.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
function registerHandler(name, target) {
|
||||
var b = target.attachEvent("onclick", function() {
|
||||
ok(this === window, "this !== window");
|
||||
calls.push(name+"*");
|
||||
});
|
||||
ok(b, "attachEvent failed");
|
||||
}
|
||||
|
||||
registerHandler("div1", div1);
|
||||
registerHandler("div2", div2);
|
||||
registerHandler("body", document.body);
|
||||
div1.onclick = createHandler("div1", div1);
|
||||
div2.onclick = createHandler("div2", div2);
|
||||
document.body.onclick = createHandler("body", document.body);
|
||||
|
||||
div2.click();
|
||||
ok(calls == "div2,div2*,div1,div1*,body,body*", "calls = " + calls);
|
||||
}
|
||||
|
||||
function runTests(t) {
|
||||
try {
|
||||
ok(cnt == 1, "cnt=" + cnt + " exception during loading?");
|
||||
ok(t === window, "t !== window");
|
||||
|
||||
ok(typeof(window.onload) === "function", "typeof(window.onload) = " + typeof(window.onload));
|
||||
ok(document.body.onload === window.onload, "document.body.onload !== window.onload");
|
||||
|
||||
test_scriptfor();
|
||||
ondataavailable_test();
|
||||
test_handler_this();
|
||||
}catch(e) {
|
||||
ok(false, "Got an exception: " + e.message);
|
||||
}
|
||||
|
@ -92,7 +130,7 @@ function runTests() {
|
|||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="runTests()">
|
||||
<body onload="runTests(this)">
|
||||
<div id="divid"></div>
|
||||
<div id="divid2"></div>
|
||||
<script event="onclick" for="divid2">
|
||||
|
|
Loading…
Reference in New Issue