summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/events/test_focus_general.html
blob: e881a5a4f807e0ecd7f45d2276c008aabe2e73bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<html>

<head>
  <title>Accessible focus testing</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="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>
  <script type="application/javascript"
          src="../states.js"></script>

  <script type="application/javascript">
    function focusElmWhileSubdocIsFocused(aID)
    {
      this.DOMNode = getNode(aID);

      this.invoke = function focusElmWhileSubdocIsFocused_invoke()
      {
        this.DOMNode.focus();
      }

      this.eventSeq = [
        new focusChecker(this.DOMNode)
      ];

      this.unexpectedEventSeq = [
        new invokerChecker(EVENT_FOCUS, this.DOMNode.ownerDocument)
      ];

      this.getID = function focusElmWhileSubdocIsFocused_getID()
      {
        return "Focus element while subdocument is focused " + prettyName(aID);
      }
    }

    function imageMapChecker(aID)
    {
      var node = getNode(aID);
      this.type = EVENT_FOCUS;
      this.match = function imageMapChecker_match(aEvent)
      {
        return aEvent.DOMNode == node;
      }
    }

    function topMenuChecker()
    {
      this.type = EVENT_FOCUS;
      this.match = function topMenuChecker_match(aEvent)
      {
        return aEvent.accessible.role == ROLE_PARENT_MENUITEM;
      }
    }

    function contextMenuChecker()
    {
      this.type = EVENT_MENUPOPUP_START;
      this.match = function contextMenuChecker_match(aEvent)
      {
        return aEvent.accessible.role == ROLE_MENUPOPUP;
      }
    }

    function focusContextMenuItemChecker()
    {
      this.__proto__ = new focusChecker();

      this.match = function focusContextMenuItemChecker_match(aEvent)
      {
        return aEvent.accessible.role == ROLE_MENUITEM;
      }
    }

    /**
     * Do tests.
     */

    //gA11yEventDumpID = "eventdump"; // debug stuff
    //gA11yEventDumpToConsole = true;

    var gQueue = null;

    function doTests()
    {
      var frameDoc = document.getElementById("iframe").contentDocument;

      var editableDoc = document.getElementById('editabledoc').contentDocument;
      editableDoc.designMode = 'on';

      gQueue = new eventQueue();

      gQueue.push(new synthFocus("editablearea"));
      gQueue.push(new synthFocus("navarea"));
      gQueue.push(new synthTab("navarea", new focusChecker(frameDoc)));
      gQueue.push(new focusElmWhileSubdocIsFocused("link"));

      gQueue.push(new synthTab(editableDoc, new focusChecker(editableDoc)));
      if (WIN || LINUX) {
        // Alt key is used to active menubar and focus menu item on Windows,
        // other platforms requires setting a ui.key.menuAccessKeyFocuses
        // preference.
        gQueue.push(new toggleTopMenu(editableDoc, new topMenuChecker()));
        gQueue.push(new toggleTopMenu(editableDoc, new focusChecker(editableDoc)));
      }
      gQueue.push(new synthContextMenu(editableDoc, new contextMenuChecker()));
      gQueue.push(new synthDownKey(editableDoc, new focusContextMenuItemChecker()));
      gQueue.push(new synthEscapeKey(editableDoc, new focusChecker(editableDoc)));
      if (SEAMONKEY) {
        todo(false, "shift tab from editable document fails on (Windows) SeaMonkey! (Bug 718235)");
      } else {
      if (LINUX || MAC)
        todo(false, "shift tab from editable document fails on linux and Mac, bug 746519!");
      else
        gQueue.push(new synthShiftTab("link", new focusChecker("link")));
      } // ! SEAMONKEY

      gQueue.push(new synthFocus("a", new imageMapChecker("a")));
      gQueue.push(new synthFocus("b", new imageMapChecker("b")));

      gQueue.invoke(); // Will call SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTests);
  </script>
</head>

<body>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=352220"
     title="Inconsistent focus events when returning to a document frame">
    Mozilla Bug 352220
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=550338"
     title="Broken focus when returning to editable documents from menus">
    Mozilla Bug 550338
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
     title="Rework accessible focus handling">
    Mozilla Bug 673958
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=961696"
     title="Accessible object:state-changed:focused events for imagemap links are broken">
    Mozilla Bug 961696
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <div id="editablearea" contentEditable="true">editable area</div>
  <div id="navarea" tabindex="0">navigable area</div>
  <iframe id="iframe" src="data:text/html,<html></html>"></iframe>
  <a id="link" href="">link</a>
  <iframe id="editabledoc" src="about:blank"></iframe>

  <map name="atoz_map">
    <area id="a" coords="0,0,13,14" shape="rect">
    <area id="b" coords="17,0,30,14" shape="rect">
  </map>
  <img width="447" height="15" usemap="#atoz_map" src="../letters.gif">

  <div id="eventdump"></div>
</body>
</html>