Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / events / menu-key-context-menu-document.html
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;
11 }
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".');
19
20 var count = 0;
21 var anchorCount = 0;
22 function handleContextMenu(e) {
23     shouldBe(e.target.id, 'anchor');
24     e.preventDefault();
25 }
26 document.addEventListener('contextmenu', handleContextMenu, true);
27
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(String.fromCharCode(0x001B));
36     anchor.focus();
37     eventSender.keyDown("menu");
38 }
39 </script>
40 </body>