3 <script src='test.js'
></script>
4 <script src='dispatch_context_menu_event.js'
></script>
7 function testContextMenuEvent() {
8 var elem
= document
.querySelector('div');
9 var capturedEvent
= null;
10 elem
.addEventListener('contextmenu', function(e
) { capturedEvent
= e
});
11 var x
= elem
.offsetLeft
+ 1;
12 var y
= elem
.offsetTop
+ 1;
13 dispatchContextMenuEvent(x
, y
, ModifierMask
.CTRL
| ModifierMask
.SHIFT
);
14 assert(capturedEvent
!= null);
15 assertEquals(x
, capturedEvent
.x
);
16 assertEquals(y
, capturedEvent
.y
);
17 assertEquals('contextmenu', capturedEvent
.type
);
18 assertEquals(2, capturedEvent
.button
);
19 assertEquals(true, capturedEvent
.ctrlKey
);
20 assertEquals(true, capturedEvent
.shiftKey
);
21 assertEquals(false, capturedEvent
.altKey
);
22 assertEquals(false, capturedEvent
.metaKey
);
25 function testCannotDispatchEventAtBadLocation() {
27 dispatchContextMenuEvent(-1, -1, 0);