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
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>