summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/events/test_focus_general.xhtml
blob: c446359b3268efb30e5b04e3857c6ca18b9223d7 (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
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml"
        title="Accessible focus event testing">

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>

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

  <script type="application/javascript">
    //gA11yEventDumpID = "eventdump"; // debug stuff
    //gA11yEventDumpToConsole = true; // debug stuff

    var gQueue = null;
    function doTests()
    {
      // Test focus events.
      gQueue = new eventQueue();

      gQueue.push(new synthFocus("textbox",
                                 new focusChecker(getNode("textbox"))));
      gQueue.push(new synthFocusOnFrame("editabledoc"));
      gQueue.push(new synthFocus("radioclothes",
                                 new focusChecker("radiosweater")));
      gQueue.push(new synthDownKey("radiosweater",
                                   new focusChecker("radiojacket")));
      gQueue.push(new synthFocus("checkbox"));
      gQueue.push(new synthFocus("button"));
      gQueue.push(new synthFocus("checkbutton"));
      gQueue.push(new synthFocus("radiobutton"));

      // focus menubutton
      gQueue.push(new synthFocus("menubutton"));
      // click menubutton, open popup, focus stays on menu button
      gQueue.push(new synthClick("menubutton", new nofocusChecker()));
      // select first menu item ("item 1"), focus on menu item
      gQueue.push(new synthDownKey("menubutton", new focusChecker("mb_item1")));
      // choose select menu item, focus gets back to menubutton
      gQueue.push(new synthEnterKey("mb_item1", new focusChecker("menubutton")));
      // press enter to open popup, focus stays on menubutton
      gQueue.push(new synthEnterKey("menubutton", new nofocusChecker()));
      // select second menu item ("item 2"), focus on menu item
      gQueue.push(new synthUpKey("menubutton", new focusChecker("mb_item2")));
      // close the popup
      gQueue.push(new synthEscapeKey("menubutton", new focusChecker("menubutton")));

      // clicking on button having associated popup doesn't change focus
      gQueue.push(new synthClick("popupbutton", [
        new nofocusChecker(),
        new invokerChecker("popupshown", "backpopup")
      ]));

      // select first menu item ("item 1"), focus on menu item
      gQueue.push(new synthDownKey("popupbutton", new focusChecker("bp_item1")));
      // choose select menu item, focus gets back to menubutton
      gQueue.push(new synthEnterKey("bp_item1", new focusChecker("menubutton")));
      // show popup again for the next test
      gQueue.push(new synthClick("popupbutton", new nofocusChecker()));

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

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

  <hbox flex="1" style="overflow: auto;">
    <body xmlns="http://www.w3.org/1999/xhtml">
      <a target="_blank"
         href="https://bugzilla.mozilla.org/show_bug.cgi?id=552368"
         title=" fire focus event on document accessible whenever the root or body element is focused">
        Mozilla Bug 552368
      </a>
      <p id="display"></p>
      <div id="content" style="display: none"></div>
      <pre id="test">
      </pre>
    </body>

    <vbox flex="1">
      <html:input id="textbox" value="hello"/>
      <iframe id="editabledoc" src="focus.html"/>
      <radiogroup id="radioclothes">
        <radio id="radiosweater" label="radiosweater"/>
        <radio id="radiocap" label="radiocap" disabled="true"/>
        <radio id="radiojacket" label="radiojacket"/>
      </radiogroup>
      <checkbox id="checkbox" label="checkbox"/>
      <button id="button" label="button"/>

      <button id="menubutton" type="menu" label="menubutton">
        <menupopup>
          <menuitem id="mb_item1" label="item1"/>
          <menuitem id="mb_item2" label="item2"/>
        </menupopup>
      </button>

      <button id="checkbutton" type="checkbox" label="checkbutton"/>
      <button id="radiobutton" type="radio" group="rbgroup" label="radio1"/>

      <popupset>
        <menupopup id="backpopup" position="after_start">
          <menuitem id="bp_item1" label="Page 1"/>
          <menuitem id="bp_item2" label="Page 2"/>
        </menupopup>
      </popupset>
      <button id="popupbutton" label="Pop Me Up" popup="backpopup"/>

      <vbox id="eventdump"/>
    </vbox>
  </hbox>
</window>