accessible/tests/mochitest/events/test_contextmenu.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/events/test_contextmenu.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,139 @@
     1.4 +<html>
     1.5 +
     1.6 +<head>
     1.7 +  <title>Context menu tests</title>
     1.8 +
     1.9 +  <link rel="stylesheet" type="text/css"
    1.10 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.11 +
    1.12 +  <script type="application/javascript"
    1.13 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.14 +  <script type="application/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    1.16 +
    1.17 +  <script type="application/javascript"
    1.18 +          src="../common.js"></script>
    1.19 +  <script type="application/javascript"
    1.20 +          src="../role.js"></script>
    1.21 +  <script type="application/javascript"
    1.22 +          src="../states.js"></script>
    1.23 +  <script type="application/javascript"
    1.24 +          src="../events.js"></script>
    1.25 +
    1.26 +  <script type="application/javascript">
    1.27 +    ////////////////////////////////////////////////////////////////////////////
    1.28 +    // Invokers
    1.29 +
    1.30 +    function showContextMenu(aID)
    1.31 +    {
    1.32 +      this.DOMNode = getNode(aID);
    1.33 +
    1.34 +      this.eventSeq = [
    1.35 +        new invokerChecker(EVENT_MENUPOPUP_START, getContextMenuNode()),
    1.36 +      ];
    1.37 +
    1.38 +      this.invoke = function showContextMenu_invoke()
    1.39 +      {
    1.40 +        synthesizeMouse(this.DOMNode, 4, 4, { type: "contextmenu", button: 2 });
    1.41 +      }
    1.42 +
    1.43 +      this.getID = function showContextMenu_getID()
    1.44 +      {
    1.45 +        return "show context menu";
    1.46 +      }
    1.47 +    }
    1.48 +
    1.49 +    function selectMenuItem()
    1.50 +    {
    1.51 +      this.eventSeq = [
    1.52 +        new invokerChecker(EVENT_FOCUS, getFocusedMenuItem)
    1.53 +      ];
    1.54 +
    1.55 +      this.invoke = function selectMenuItem_invoke()
    1.56 +      {
    1.57 +        synthesizeKey("VK_DOWN", { });
    1.58 +      }
    1.59 +
    1.60 +      this.getID = function selectMenuItem_getID()
    1.61 +      {
    1.62 +        return "select first menuitem";
    1.63 +      }
    1.64 +    }
    1.65 +
    1.66 +    function closeContextMenu(aID)
    1.67 +    {
    1.68 +      this.eventSeq = [
    1.69 +        new invokerChecker(EVENT_MENUPOPUP_END,
    1.70 +                           getAccessible(getContextMenuNode()))
    1.71 +      ];
    1.72 +
    1.73 +      this.invoke = function closeContextMenu_invoke()
    1.74 +      {
    1.75 +        synthesizeKey("VK_ESCAPE", { });
    1.76 +      }
    1.77 +
    1.78 +      this.getID = function closeContextMenu_getID()
    1.79 +      {
    1.80 +        return "close context menu";
    1.81 +      }
    1.82 +    }
    1.83 +
    1.84 +    function getContextMenuNode()
    1.85 +    {
    1.86 +      return getRootAccessible().DOMDocument.
    1.87 +        getElementById("contentAreaContextMenu");
    1.88 +    }
    1.89 +
    1.90 +    function getFocusedMenuItem()
    1.91 +    {
    1.92 +      var menu = getAccessible(getAccessible(getContextMenuNode()));
    1.93 +      for (var idx = 0; idx < menu.childCount; idx++) {
    1.94 +        var item = menu.getChildAt(idx);
    1.95 +
    1.96 +        if (hasState(item, STATE_FOCUSED))
    1.97 +          return getAccessible(item);
    1.98 +      }
    1.99 +      return null;
   1.100 +    }
   1.101 +
   1.102 +    ////////////////////////////////////////////////////////////////////////////
   1.103 +    // Do tests
   1.104 +
   1.105 +    var gQueue = null;
   1.106 +    //gA11yEventDumpID = "eventdump"; // debug stuff
   1.107 +    //gA11yEventDumpToConsole = true;
   1.108 +
   1.109 +    function doTests()
   1.110 +    {
   1.111 +      gQueue = new eventQueue();
   1.112 +
   1.113 +      gQueue.push(new showContextMenu("input"));
   1.114 +      gQueue.push(new selectMenuItem());
   1.115 +      gQueue.push(new closeContextMenu());
   1.116 +
   1.117 +      gQueue.invoke(); // Will call SimpleTest.finish();
   1.118 +    }
   1.119 +
   1.120 +    SimpleTest.waitForExplicitFinish();
   1.121 +    addA11yLoadEvent(doTests);
   1.122 +  </script>
   1.123 +</head>
   1.124 +
   1.125 +<body>
   1.126 +
   1.127 +  <a target="_blank"
   1.128 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=580535"
   1.129 +     title="Broken accessibility in context menus">
   1.130 +    Mozilla Bug 580535
   1.131 +  </a><br>
   1.132 +
   1.133 +  <p id="display"></p>
   1.134 +  <div id="content" style="display: none"></div>
   1.135 +  <pre id="test">
   1.136 +  </pre>
   1.137 +
   1.138 +  <input id="input">
   1.139 +
   1.140 +  <div id="eventdump"></div>
   1.141 +</body>
   1.142 +</html>

mercurial