3 <p>Tests for
<a href=
"https://bugs.webkit.org/show_bug.cgi?id=11053"> bug
11053</a> -
4 XMLHttpRequest should be an EventTarget.
</p>
7 testRunner
.dumpAsText();
9 var console_messages
= document
.createElement("ul");
10 document
.body
.appendChild(console_messages
);
14 var item
= document
.createElement("li");
15 item
.appendChild(document
.createTextNode(message
));
16 console_messages
.appendChild(item
);
21 log("onload: this = " + this);
22 req
.removeEventListener("load", eventListener4
, false);
25 function eventListener() { log("eventListener: this = " + this); }
27 function eventListener2() {
28 log("eventListener2: this = " + this);
29 // Removing this event listener should prevent it from firing.
30 req
.removeEventListener("load", eventListener3
, false);
33 function eventListener3() { log("eventListener3: this = " + this); }
35 // This listener is removed before it gets a chance to fire.
36 function eventListener4() { log("eventListener4: this = " + this); }
38 function fooListener() { log("fooListener: this = " + this); }
41 req
= new XMLHttpRequest
;
43 req
.addEventListener("load", eventListener
, false);
44 req
.addEventListener("load", eventListener2
, false);
45 req
.addEventListener("load", eventListener
, false); // eventListener must not be called twice, but it does in Mozilla 1.8.
46 req
.addEventListener("load", eventListener3
, false);
48 // XMLHttpRequest.dispatchEvent is not implemeted in Mozilla 1.8
49 // Furthermore, they raise an exception when trying to add any event listener except for "load" and "error".
51 event
= document
.createEvent("Event");
52 event
.initEvent("foo", false, false);
53 req
.addEventListener("foo", fooListener
, false);
54 req
.dispatchEvent(event
);
59 req
.open("GET", "resources/reply.xml", false);
62 // WebKit doesn't remove event listeners when re-opening a request, unlike Mozilla.
63 req
.open("GET", "resources/reply.xml", false);