3 <script src="../../resources/js-test.js"></script>
4 <script src="../dom/resources/event-sender-util.js"></script>
7 background-color: orange;
13 <div id="anchor" tabindex="0">Target</div>
14 <div id="console"></div>
16 description('This test checks if contextmenu event target is correct when handled at the document level. To test' +
17 ' manually, first right-click on the "Target" text in the orange box, then press the menu key. Both' +
18 ' interactions should result in the message: "PASS anchor is anchor".');
22 function handleContextMenu(e) {
23 shouldBe(e.target.id, 'anchor');
26 document.addEventListener('contextmenu', handleContextMenu, true);
28 if (!window.eventSender || !window.testRunner) {
29 testFailed('This test needs to run in a test environment.');
31 var anchor = document.getElementById("anchor");
32 mouseMoveToElem(anchor);
33 eventSender.contextClick();
34 // Esc key to hide context menu
35 eventSender.keyDown(String.fromCharCode(0x001B));
37 eventSender.keyDown("menu");