diff --git a/dlls/mshtml/tests/events.html b/dlls/mshtml/tests/events.html index b3b6958cd08..131ba19cfda 100644 --- a/dlls/mshtml/tests/events.html +++ b/dlls/mshtml/tests/events.html @@ -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 = '
'; + + 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() { } - +