Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / menu-key-context-menu-document.html
blob7b6dceaaa2b1448d677d2adab84fc0c46396b508
1 <!DOCTYPE html>
2 <body>
3 <script src="../../resources/js-test.js"></script>
4 <script src="../dom/resources/event-sender-util.js"></script>
5 <style>
6 #anchor {
7 background-color: orange;
8 height: 100px;
9 margin: 10px;
10 width: 100px;
12 </style>
13 <div id="anchor" tabindex="0">Target</div>
14 <div id="console"></div>
15 <script>
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".');
20 var count = 0;
21 var anchorCount = 0;
22 function handleContextMenu(e) {
23 shouldBe(e.target.id, 'anchor');
24 e.preventDefault();
26 document.addEventListener('contextmenu', handleContextMenu, true);
28 if (!window.eventSender || !window.testRunner) {
29 testFailed('This test needs to run in a test environment.');
30 } else {
31 var anchor = document.getElementById("anchor");
32 mouseMoveToElem(anchor);
33 eventSender.contextClick();
34 // Esc key to hide context menu
35 eventSender.keyDown("escape");
36 anchor.focus();
37 eventSender.keyDown("menu");
39 </script>
40 </body>