accessible/tests/mochitest/events/test_contextmenu.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <html>
michael@0 2
michael@0 3 <head>
michael@0 4 <title>Context menu tests</title>
michael@0 5
michael@0 6 <link rel="stylesheet" type="text/css"
michael@0 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 8
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 13
michael@0 14 <script type="application/javascript"
michael@0 15 src="../common.js"></script>
michael@0 16 <script type="application/javascript"
michael@0 17 src="../role.js"></script>
michael@0 18 <script type="application/javascript"
michael@0 19 src="../states.js"></script>
michael@0 20 <script type="application/javascript"
michael@0 21 src="../events.js"></script>
michael@0 22
michael@0 23 <script type="application/javascript">
michael@0 24 ////////////////////////////////////////////////////////////////////////////
michael@0 25 // Invokers
michael@0 26
michael@0 27 function showContextMenu(aID)
michael@0 28 {
michael@0 29 this.DOMNode = getNode(aID);
michael@0 30
michael@0 31 this.eventSeq = [
michael@0 32 new invokerChecker(EVENT_MENUPOPUP_START, getContextMenuNode()),
michael@0 33 ];
michael@0 34
michael@0 35 this.invoke = function showContextMenu_invoke()
michael@0 36 {
michael@0 37 synthesizeMouse(this.DOMNode, 4, 4, { type: "contextmenu", button: 2 });
michael@0 38 }
michael@0 39
michael@0 40 this.getID = function showContextMenu_getID()
michael@0 41 {
michael@0 42 return "show context menu";
michael@0 43 }
michael@0 44 }
michael@0 45
michael@0 46 function selectMenuItem()
michael@0 47 {
michael@0 48 this.eventSeq = [
michael@0 49 new invokerChecker(EVENT_FOCUS, getFocusedMenuItem)
michael@0 50 ];
michael@0 51
michael@0 52 this.invoke = function selectMenuItem_invoke()
michael@0 53 {
michael@0 54 synthesizeKey("VK_DOWN", { });
michael@0 55 }
michael@0 56
michael@0 57 this.getID = function selectMenuItem_getID()
michael@0 58 {
michael@0 59 return "select first menuitem";
michael@0 60 }
michael@0 61 }
michael@0 62
michael@0 63 function closeContextMenu(aID)
michael@0 64 {
michael@0 65 this.eventSeq = [
michael@0 66 new invokerChecker(EVENT_MENUPOPUP_END,
michael@0 67 getAccessible(getContextMenuNode()))
michael@0 68 ];
michael@0 69
michael@0 70 this.invoke = function closeContextMenu_invoke()
michael@0 71 {
michael@0 72 synthesizeKey("VK_ESCAPE", { });
michael@0 73 }
michael@0 74
michael@0 75 this.getID = function closeContextMenu_getID()
michael@0 76 {
michael@0 77 return "close context menu";
michael@0 78 }
michael@0 79 }
michael@0 80
michael@0 81 function getContextMenuNode()
michael@0 82 {
michael@0 83 return getRootAccessible().DOMDocument.
michael@0 84 getElementById("contentAreaContextMenu");
michael@0 85 }
michael@0 86
michael@0 87 function getFocusedMenuItem()
michael@0 88 {
michael@0 89 var menu = getAccessible(getAccessible(getContextMenuNode()));
michael@0 90 for (var idx = 0; idx < menu.childCount; idx++) {
michael@0 91 var item = menu.getChildAt(idx);
michael@0 92
michael@0 93 if (hasState(item, STATE_FOCUSED))
michael@0 94 return getAccessible(item);
michael@0 95 }
michael@0 96 return null;
michael@0 97 }
michael@0 98
michael@0 99 ////////////////////////////////////////////////////////////////////////////
michael@0 100 // Do tests
michael@0 101
michael@0 102 var gQueue = null;
michael@0 103 //gA11yEventDumpID = "eventdump"; // debug stuff
michael@0 104 //gA11yEventDumpToConsole = true;
michael@0 105
michael@0 106 function doTests()
michael@0 107 {
michael@0 108 gQueue = new eventQueue();
michael@0 109
michael@0 110 gQueue.push(new showContextMenu("input"));
michael@0 111 gQueue.push(new selectMenuItem());
michael@0 112 gQueue.push(new closeContextMenu());
michael@0 113
michael@0 114 gQueue.invoke(); // Will call SimpleTest.finish();
michael@0 115 }
michael@0 116
michael@0 117 SimpleTest.waitForExplicitFinish();
michael@0 118 addA11yLoadEvent(doTests);
michael@0 119 </script>
michael@0 120 </head>
michael@0 121
michael@0 122 <body>
michael@0 123
michael@0 124 <a target="_blank"
michael@0 125 href="https://bugzilla.mozilla.org/show_bug.cgi?id=580535"
michael@0 126 title="Broken accessibility in context menus">
michael@0 127 Mozilla Bug 580535
michael@0 128 </a><br>
michael@0 129
michael@0 130 <p id="display"></p>
michael@0 131 <div id="content" style="display: none"></div>
michael@0 132 <pre id="test">
michael@0 133 </pre>
michael@0 134
michael@0 135 <input id="input">
michael@0 136
michael@0 137 <div id="eventdump"></div>
michael@0 138 </body>
michael@0 139 </html>

mercurial