Bug 702560 - add a11y mochitest for HTML 5 contextmenu r?surkov draft
authorLeni Kadali <lenikmutungi@gmail.com>
Tue, 11 Apr 2017 19:48:06 +0300
changeset 560615 080fc75b83b003fdcdb0237669e958f7df0ec1aa
parent 559023 794adb67ec4a6d8ebcf786c9b9a0d8207bd5b2c4
child 570582 3523c7137a8111d0b479869512482d2513b3447f
child 571347 79f0cdc8cda4f835c0da58bbf0c80f305909b38d
push id53474
push userbmo:lenikmutungi@gmail.com
push dateTue, 11 Apr 2017 17:10:04 +0000
reviewerssurkov
bugs702560
milestone55.0a1
Bug 702560 - add a11y mochitest for HTML 5 contextmenu r?surkov Here's the sample test_context.menu.html file. user: Leni Kadali <lenikmutungi@gmail.com> branch 'default' added accessible/tests/mochitest/tree/test_contextmenu.html MozReview-Commit-ID: 5jsz1iJdI9h
accessible/tests/mochitest/tree/test_contextmenu.html
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/tree/test_contextmenu.html
@@ -0,0 +1,136 @@
+<!DOCTYPE html>
+<html>
+<head>
+            <title>Test Context Menu</title>
+            <link rel="stylesheet" type="text/css"
+                    href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+            <script type="application/javascript"
+                    src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+            <script type="application/javascript"
+                    src="../common.js"></script>
+            <script type="application/javascript"
+                    src="../role.js"></script>
+            <script type="application/javascript"
+                    src="../states.js"></script>
+
+            <script type="application/javascript">
+                
+                //Gets the context menu
+                function getContextMenuNode()
+                    {
+                        return getRootAccessible().DOMDocument.
+                            getElementById("contentAreaContextMenu");
+                    }
+                
+                //Shows the context menu
+                function showContextMenu(aID)
+                    {
+                        this.DOMNode = getNode(aID);
+
+                        this.eventSeq = [
+                            new invokerChecker(EVENT_MENUPOPUP_START, getContextMenuNode()),
+                        ];
+
+                        this.invoke = function showContextMenu_invoke()
+                            {
+                                synthesizeMouse(this.DOMNode, 4, 4, { type: "contextmenu", button: 2 });
+                            }
+
+                        this.getID = function showContextMenu_getID()
+                            {
+                                return "show context menu";
+                            }
+                    }
+
+                //Selects a Menu Item
+                function selectMenuItem()
+                    {
+                        this.eventSeq = [
+                            new invokerChecker(EVENT_FOCUS, getFocusedMenuItem)
+                        ];
+
+                        this.invoke = function selectMenuItem_invoke()
+                        {
+                            synthesizeKey("VK_DOWN", { });
+                        }
+
+                        this.getID = function selectMenuItem_getID()
+                        {
+                            return "select first menuitem";
+                        }
+                    }
+
+                //Tests the tree    
+                function doTest()
+                    {
+                        var tree =
+                            { SECTION: [
+                            { SECTION: [ // div 
+                                { TEXT_LEAF: [ ] }, // 'Z'
+                                { TEXT_LEAF: [ ] } // ' '
+                            ] }
+                            ] };
+                            testAccessibleTree("container", tree);
+
+                            SimpleTest.finish();
+                    }
+
+                SimpleTest.waitForExplicitFinish();
+                addA11yLoadEvent(doTest);
+                
+                //Closes the context menu
+                function closeContextMenu(aID)
+                {
+                        this.eventSeq = [
+                            new invokerChecker(EVENT_MENUPOPUP_END,
+                            getAccessible(getContextMenuNode()))
+                        ];
+
+                        this.invoke = function closeContextMenu_invoke()
+                        {
+                            synthesizeKey("VK_ESCAPE", { });
+                        }
+
+                        this.getID = function closeContextMenu_getID()
+                        {
+                            return "close context menu";
+                        }
+                }
+    // Do tests
+
+    var gQueue = null;
+    //gA11yEventDumpID = "eventdump"; // debug stuff
+    //gA11yEventDumpToConsole = true;
+
+
+            </script>
+</head>
+
+<body>
+    <a target="_blank"
+        href="https://bugzilla.mozilla.org/show_bug.cgi?id=702560"
+        title="add a11y mochitest for HTML 5 contextmenu">
+        Mozilla Bug 702560
+    </a>
+    <p id="display"></p>
+    <div id="content" style="display: none"></div>
+    <pre id="test">
+    </pre>
+
+  
+    <div id="container" contextmenu="supermenu">
+<!-- What does the text "Heaven" do. In Murali's original patch, he used "Murali", his name-->
+    <div>Heaven<span> </span><span></span></div>
+    </div>
+    <menu type="context" id="supermenu">
+    <menu label="alerts">
+        <menuitem label="foo alert" onclick="alert('foo')"></menuitem>
+        <menuitem label="bar alert" onclick="alert('bar')"></menuitem>
+    </menu>
+    </menu>
+
+    </div>
+</body>
+</html>