6 /* @const */ var EventTarget
;
9 EventTarget
= cr
.EventTarget
;
12 function testFunctionListener() {
23 var et
= new EventTarget
;
24 et
.addEventListener('f', f
);
25 et
.addEventListener('g', g
);
27 // Adding again should not cause it to be called twice
28 et
.addEventListener('f', f
);
29 et
.dispatchEvent(new Event('f'));
30 assertEquals(1, fi
, 'Should have been called once');
33 et
.removeEventListener('f', f
);
34 et
.dispatchEvent(new Event('f'));
35 assertEquals(1, fi
, 'Should not have been called again');
37 et
.dispatchEvent(new Event('g'));
38 assertEquals(1, gi
, 'Should have been called once');
41 function testHandleEvent() {
44 handleEvent: function(e
) {
51 handleEvent: function(e
) {
56 var et
= new EventTarget
;
57 et
.addEventListener('f', f
);
58 et
.addEventListener('g', g
);
60 // Adding again should not cause it to be called twice
61 et
.addEventListener('f', f
);
62 et
.dispatchEvent(new Event('f'));
63 assertEquals(1, fi
, 'Should have been called once');
66 et
.removeEventListener('f', f
);
67 et
.dispatchEvent(new Event('f'));
68 assertEquals(1, fi
, 'Should not have been called again');
70 et
.dispatchEvent(new Event('g'));
71 assertEquals(1, gi
, 'Should have been called once');
74 function testPreventDefault() {
86 var et
= new EventTarget
;
87 et
.addEventListener('test', pass
);
89 assertTrue(et
.dispatchEvent(new Event('test', {cancelable
: true})));
92 et
.addEventListener('test', prevent
);
95 assertFalse(et
.dispatchEvent(new Event('test', {cancelable
: true})));
101 function testReturnFalse() {
103 function prevent(e
) {
113 var et
= new EventTarget
;
114 et
.addEventListener('test', pass
);
116 assertTrue(et
.dispatchEvent(new Event('test', {cancelable
: true})));
119 et
.addEventListener('test', prevent
);
121 assertFalse(et
.dispatchEvent(new Event('test', {cancelable
: true})));