2012-09-13 12:29:05 +02:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script>
|
2012-10-02 15:47:06 +02:00
|
|
|
var testevent_divid2_called = false, cnt=0;
|
|
|
|
|
2012-09-13 12:29:05 +02:00
|
|
|
function ok(b,m) {
|
|
|
|
return external.ok(b, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ondataavailable_test() {
|
|
|
|
var evobj, div, b = false;
|
|
|
|
|
|
|
|
div = document.getElementById("divid");
|
|
|
|
|
|
|
|
function ondataavailableHandler() {
|
|
|
|
b = true;
|
|
|
|
ok(window.event === evobj, "window.event != evobj");
|
|
|
|
|
|
|
|
ok(evobj.srcElement === div, "evobj.srcElement = " + evobj.srcElement);
|
|
|
|
ok(evobj.fromElement === null, "evobj.srcElement = " + evobj.fromElement);
|
|
|
|
ok(evobj.toElement === null, "evobj.srcElement = " + evobj.toElement);
|
|
|
|
ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type);
|
|
|
|
}
|
|
|
|
|
2012-09-13 12:29:17 +02:00
|
|
|
function ondataavailableDocHandler() {
|
|
|
|
b = true;
|
|
|
|
ok(window.event === evobj, "window.event != evobj");
|
|
|
|
|
|
|
|
ok(evobj.srcElement === null, "evobj.srcElement = " + evobj.srcElement);
|
|
|
|
ok(evobj.fromElement === null, "evobj.srcElement = " + evobj.fromElement);
|
|
|
|
ok(evobj.toElement === null, "evobj.srcElement = " + evobj.toElement);
|
|
|
|
ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type);
|
|
|
|
}
|
|
|
|
|
2012-09-13 12:29:05 +02:00
|
|
|
div.attachEvent("ondataavailable", ondataavailableHandler);
|
|
|
|
|
|
|
|
evobj = document.createEventObject();
|
|
|
|
ok(evobj.srcElement === null, "evobj.srcElement = " + evobj.srcElement);
|
|
|
|
ok(evobj.fromElement === null, "evobj.srcElement = " + evobj.fromElement);
|
|
|
|
ok(evobj.toElement === null, "evobj.srcElement = " + evobj.toElement);
|
|
|
|
ok(evobj.type === "", "evobj.type = " + evobj.type);
|
|
|
|
|
|
|
|
div.fireEvent("ondataavailable", evobj);
|
|
|
|
ok(b, "ondataavailable handler not called?");
|
|
|
|
|
|
|
|
ok(evobj.srcElement === div, "evobj.srcElement = " + evobj.srcElement);
|
|
|
|
ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type);
|
2012-09-13 12:29:17 +02:00
|
|
|
|
|
|
|
div.detachEvent("ondataavailable", ondataavailableHandler);
|
|
|
|
|
|
|
|
b = false;
|
|
|
|
div.fireEvent("ondataavailable", evobj);
|
|
|
|
ok(!b, "ondataavailable handler called?");
|
|
|
|
|
|
|
|
ok(evobj.srcElement === div, "evobj.srcElement = " + evobj.srcElement);
|
|
|
|
ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type);
|
|
|
|
|
|
|
|
document.attachEvent("ondataavailable", ondataavailableDocHandler);
|
|
|
|
|
|
|
|
evobj = document.createEventObject();
|
|
|
|
|
|
|
|
document.fireEvent("ondataavailable", evobj);
|
|
|
|
ok(b, "ondataavailable handler not called?");
|
|
|
|
|
|
|
|
ok(evobj.srcElement === null, "evobj.srcElement = " + evobj.srcElement);
|
|
|
|
ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type);
|
2012-09-13 12:29:05 +02:00
|
|
|
}
|
|
|
|
|
2012-10-02 15:47:06 +02:00
|
|
|
function test_scriptfor() {
|
|
|
|
var div = document.getElementById("divid2");
|
|
|
|
ok("onclick" in div, "testevent not in div");
|
|
|
|
ok(typeof(div.onclick) === "function", "typeof(div.onclick) = " + typeof(div.onclick));
|
|
|
|
ok(testevent_divid2_called === false, "testevent_divid2_called = " + testevent_divid2_called);
|
|
|
|
div.click();
|
|
|
|
ok(testevent_divid2_called === true, "testevent_divid2_called = " + testevent_divid2_called);
|
|
|
|
|
|
|
|
ok(!("ontest" in div), "testevent in div");
|
|
|
|
ok(typeof(div.ontest) === "undefined", "typeof(div.ontest) = " + typeof(div.ontest));
|
|
|
|
}
|
|
|
|
|
2012-09-13 12:29:05 +02:00
|
|
|
function runTests() {
|
|
|
|
try {
|
2012-10-02 15:47:06 +02:00
|
|
|
ok(cnt == 1, "cnt=" + cnt + " exception during loading?");
|
|
|
|
|
|
|
|
test_scriptfor();
|
2012-09-13 12:29:05 +02:00
|
|
|
ondataavailable_test();
|
|
|
|
}catch(e) {
|
|
|
|
ok(false, "Got an exception: " + e.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
external.reportSuccess();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="runTests()">
|
|
|
|
<div id="divid"></div>
|
2012-10-02 15:47:06 +02:00
|
|
|
<div id="divid2"></div>
|
|
|
|
<script event="onclick" for="divid2">
|
|
|
|
testevent_divid2_called = true;
|
|
|
|
</script>
|
|
|
|
<script event="ontest" for="divid2">
|
|
|
|
ok(false, "unexpected ontest");
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
(function() {
|
|
|
|
var div = document.getElementById("divid2");
|
|
|
|
ok(div.onclick === null, "div.onclick = null");
|
|
|
|
cnt++;
|
|
|
|
})();
|
|
|
|
</script>
|
2012-09-13 12:29:05 +02:00
|
|
|
</body>
|
|
|
|
</html>
|