1 <p>This page tests event listener fire order for a few objects that had it wrong in the past.
</p>
2 <p>If the test passes, you'll see a series of PASS messages below.
</p>
4 <pre id=
"console"></pre>
10 testRunner
.dumpAsText();
14 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\n"));
32 event
.target
.removeEventListener(event
.type
, f3
, false); // Removed: should not fire.
33 event
.target
.addEventListener(event
.type
, f4
, false); // Added after dispatch began: should not fire.
46 function reportResult(name
, expected
)
49 var end
= result
.length
> expected
.length
? result
.length
: expected
.length
;
50 for (var i
= 0; i
< end
; ++i
) {
51 if (result
[i
] != expected
[i
]) {
52 log("FAIL: " + name
+ " result[" + i
+ "] should be " + expected
[i
] + " but instead is " + result
[i
] + ".");
57 log("PASS: result should be " + expected
+ " and is.");
64 var x
= document
.getElementById("div");
65 x
.addEventListener("click", f1
, false);
67 x
.addEventListener("click", f3
, false);
69 var event
= document
.createEvent("MouseEvent");
70 event
.initMouseEvent("click", true, true, document
.defaultView
, 1, 0, 0, 0, 0, false, false, false, false, 0, document
);
71 x
.dispatchEvent(event
);
73 reportResult(arguments
.callee
.name
, [ "f1", "f2" ]);
79 var x
= new XMLHttpRequest
;
80 x
.addEventListener("readystatechange", f1
, false);
81 x
.onreadystatechange
= f2
;
82 x
.addEventListener("readystatechange", f3
, false);
84 x
.open("GET", "resources/does-not-exist");
86 reportResult(arguments
.callee
.name
, [ "f1", "f2" ]);
89 function testXHRUpload()
92 var x
= new XMLHttpRequest
;
93 x
.upload
.addEventListener("abort", f1
, false);
94 x
.upload
.onabort
= f2
;
95 x
.upload
.addEventListener("abort", f3
, false);
97 x
.open("POST", "resources/does-not-exist");
101 reportResult(arguments
.callee
.name
, [ "f1", "f2" ]);
105 for (var i
= 0; i
< tests
.length
; ++i
)