4 var testevent_divid2_called
= false, testevent_document_called
= false, cnt
=0;
7 return external
.ok(b
, m
);
10 function ondataavailable_test() {
11 var evobj
, div
, b
= false;
13 div
= document
.getElementById("divid");
15 function ondataavailableHandler() {
17 ok(window
.event
=== evobj
, "window.event != evobj");
19 ok(evobj
.srcElement
=== div
, "evobj.srcElement = " + evobj
.srcElement
);
20 ok(evobj
.fromElement
=== null, "evobj.srcElement = " + evobj
.fromElement
);
21 ok(evobj
.toElement
=== null, "evobj.srcElement = " + evobj
.toElement
);
22 ok(evobj
.type
=== "dataavailable", "evobj.type = " + evobj
.type
);
25 function ondataavailableDocHandler() {
27 ok(window
.event
=== evobj
, "window.event != evobj");
29 ok(evobj
.srcElement
=== null, "evobj.srcElement = " + evobj
.srcElement
);
30 ok(evobj
.fromElement
=== null, "evobj.srcElement = " + evobj
.fromElement
);
31 ok(evobj
.toElement
=== null, "evobj.srcElement = " + evobj
.toElement
);
32 ok(evobj
.type
=== "dataavailable", "evobj.type = " + evobj
.type
);
35 div
.attachEvent("ondataavailable", ondataavailableHandler
);
37 evobj
= document
.createEventObject();
38 ok(evobj
.srcElement
=== null, "evobj.srcElement = " + evobj
.srcElement
);
39 ok(evobj
.fromElement
=== null, "evobj.srcElement = " + evobj
.fromElement
);
40 ok(evobj
.toElement
=== null, "evobj.srcElement = " + evobj
.toElement
);
41 ok(evobj
.type
=== "", "evobj.type = " + evobj
.type
);
43 div
.fireEvent("ondataavailable", evobj
);
44 ok(b
, "ondataavailable handler not called?");
46 ok(evobj
.srcElement
=== div
, "evobj.srcElement = " + evobj
.srcElement
);
47 ok(evobj
.type
=== "dataavailable", "evobj.type = " + evobj
.type
);
49 div
.detachEvent("ondataavailable", ondataavailableHandler
);
52 div
.fireEvent("ondataavailable", evobj
);
53 ok(!b
, "ondataavailable handler called?");
55 ok(evobj
.srcElement
=== div
, "evobj.srcElement = " + evobj
.srcElement
);
56 ok(evobj
.type
=== "dataavailable", "evobj.type = " + evobj
.type
);
58 document
.attachEvent("ondataavailable", ondataavailableDocHandler
);
60 evobj
= document
.createEventObject();
62 document
.fireEvent("ondataavailable", evobj
);
63 ok(b
, "ondataavailable handler not called?");
65 ok(evobj
.srcElement
=== null, "evobj.srcElement = " + evobj
.srcElement
);
66 ok(evobj
.type
=== "dataavailable", "evobj.type = " + evobj
.type
);
69 function test_scriptfor() {
70 var div
= document
.getElementById("divid2");
71 ok("onclick" in div
, "testevent not in div");
72 ok(typeof(div
.onclick
) === "function", "typeof(div.onclick) = " + typeof(div
.onclick
));
73 ok(testevent_divid2_called
=== false, "testevent_divid2_called = " + testevent_divid2_called
);
74 ok(typeof(document
.onclick
) === "function", "typeof(document.onclick) = " + typeof(document
.onclick
));
75 ok(testevent_document_called
=== false, "testevent_document_called = " + testevent_document_called
);
77 ok(testevent_divid2_called
=== true, "testevent_divid2_called = " + testevent_divid2_called
);
78 ok(testevent_document_called
=== true, "testevent_document_called = " + testevent_document_called
);
80 ok(!("ontest" in div
), "testevent in div");
81 ok(typeof(div
.ontest
) === "undefined", "typeof(div.ontest) = " + typeof(div
.ontest
));
84 function test_handler_this() {
85 document
.body
.innerHTML
= '<div id="d1"><div id="d2"></div></div>';
87 var div1
= document
.getElementById("d1");
88 var div2
= document
.getElementById("d2");
89 var calls
= new Array();
91 function createHandler(name
, node
) {
93 ok(this === node
, "this !== node");
98 function registerHandler(name
, target
) {
99 var b
= target
.attachEvent("onclick", function() {
100 ok(this === window
, "this !== window");
101 calls
.push(name
+"*");
103 ok(b
, "attachEvent failed");
106 registerHandler("div1", div1
);
107 registerHandler("div2", div2
);
108 registerHandler("body", document
.body
);
109 div1
.onclick
= createHandler("div1", div1
);
110 div2
.onclick
= createHandler("div2", div2
);
111 document
.body
.onclick
= createHandler("body", document
.body
);
114 ok(calls
== "div2,div2*,div1,div1*,body,body*", "calls = " + calls
);
117 window
.onload = function() {
119 ok(cnt
== 1, "cnt=" + cnt
+ " exception during loading?");
120 ok(this === window
, "this !== window");
122 ok(typeof(window
.onload
) === "function", "typeof(window.onload) = " + typeof(window
.onload
));
123 ok(document
.body
.onload
=== window
.onload
, "document.body.onload !== window.onload");
125 ok(img_onload_called
, "img.onload not called before window.onload");
128 ondataavailable_test();
131 ok(false, "Got an exception: " + e
.message
);
134 external
.reportSuccess();
138 var img
= document
.createElement("img");
139 img
.src
= "http://test.winehq.org/tests/winehq_snapshot/index_files/winehq_logo_glass.png";
141 var img_onload_called
= false;
142 img
.onload = function() {
143 external
.trace("img.onload");
144 img_onload_called
= true;
149 <div id=
"divid"></div>
150 <div id=
"divid2"></div>
151 <script event=
"onclick" for=
"divid2">
152 testevent_divid2_called = true;
154 <script event=
"onclick" for=
"document">
155 testevent_document_called = true;
157 <script event=
"ontest" for=
"divid2">
158 ok(false,
"unexpected ontest");
162 var div
= document
.getElementById("divid2");
163 ok(div
.onclick
=== null, "div.onclick = null");
168 document
.body
.appendChild(img
);