summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/events/test_focus_browserui.xul
blob: bd621ebf2a459a57af8581a7059b8b850b19be78 (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
<?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"
        title="Accessibility Loading Document Events Test.">

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
  <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="../states.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>
  <script type="application/javascript"
          src="../browser.js"></script>

  <script type="application/javascript">
  <![CDATA[
    ////////////////////////////////////////////////////////////////////////////
    // Helpers

    function inputInDocument()
    {
      var tabdoc = currentTabDocument();
      return tabdoc.getElementById("input");
    }

    ////////////////////////////////////////////////////////////////////////////
    // Invokers

    function loadURI(aURI)
    {
      this.invoke = function loadURI_invoke()
      {
        tabBrowser().loadURI(aURI);
      }

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

      this.getID = function loadURI_getID()
      {
        return "load uri " + aURI;
      }
    }

    function goBack()
    {
      this.invoke = function goBack_invoke()
      {
        tabBrowser().goBack();
      }

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

      this.getID = function goBack_getID()
      {
        return "go back one page in history ";
      }
    }

    ////////////////////////////////////////////////////////////////////////////
    // Testing

    var gInputDocURI = "data:text/html,<html><input id='input'></html>";
    var gButtonDocURI = "data:text/html,<html><input id='input' type='button' value='button'></html>";

    //gA11yEventDumpToConsole = true; // debug

    var gQueue = null;
    function doTests()
    {
      gQueue = new eventQueue();

      var tabDocument = currentTabDocument();
      var input = inputInDocument();

      // move focus to input inside tab document
      gQueue.push(new synthTab(tabDocument, new focusChecker(input),
                               browserWindow()));

      // open new url, focus moves to new document
      gQueue.push(new loadURI(gButtonDocURI));

      // back one page in history, moves moves on input of tab document
      gQueue.push(new goBack());

      // open new tab, focus moves to urlbar
      gQueue.push(new synthKey(tabDocument, "t", { accelKey: true, window: browserWindow() },
                               new focusChecker(urlbarInput)));

      // close open tab, focus goes on input of tab document
      gQueue.push(new synthKey(tabDocument, "w", { accelKey: true, window: browserWindow() },
                               new focusChecker(inputInDocument)));

      gQueue.onFinish = function()
      {
        closeBrowserWindow();
      }
      gQueue.invoke();
    }

    if (navigator.oscpu.startsWith("Windows NT 6.1") || navigator.oscpu.startsWith("Windows NT 6.2")) {
      todo(false, "fix the leak!");
      } else {
      SimpleTest.waitForExplicitFinish();
      openBrowserWindow(doTests, gInputDocURI);
    }
  ]]>
  </script>

  <vbox 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=644452"
       title="Focus not set when switching to cached document with back or forward if anything other than the document was last focused">
      Mozilla Bug 644452
    </a>
    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=665412"
       title="Broken focus when returning to editable text field after closing a tab while focused in the Navigation toolbar">
      Mozilla Bug 665412
    </a>
    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=673958"
       title="Rework accessible focus handling">
      Mozilla Bug 673958
    </a>
    <p id="display"></p>
    <div id="content" style="display: none">
    </div>
    <pre id="test">
    </pre>
  </body>

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