summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/tree/test_tabbrowser.xhtml
blob: 401ea1a2b1fa0402b2672cf69d6f79555ec7a68b (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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?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="Accessible XUL tabbrowser hierarchy tests">

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

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

  <script type="application/javascript">
  <![CDATA[
    ////////////////////////////////////////////////////////////////////////////
    // invoker
    function testTabHierarchy()
    {
      this.eventSeq = [
        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 0),
        new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 1)
      ];

      this.invoke = function testTabHierarchy_invoke()
      {
        var docURIs = ["about:license", "about:mozilla"];
        tabBrowser().loadTabs(docURIs, {
          inBackground: false,
          replace: true,
          triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
        });
        // Flush layout, so as to guarantee that the a11y tree is constructed.
        browserDocument().documentElement.getBoundingClientRect();
      }

      this.finalCheck = function testTabHierarchy_finalCheck(aEvent)
      {
        ////////////////////
        // Tab bar
        ////////////////////
        var tabsAccTree = {
          // xul:tabs
          role: ROLE_PAGETABLIST,
          children: [
            // Children depend on application (UI): see below.
          ]
        };

        // SeaMonkey and Firefox tabbrowser UIs differ.
        if (SEAMONKEY) {
          SimpleTest.ok(true, "Testing SeaMonkey tabbrowser UI.");

          tabsAccTree.children.splice(0, 0,
            {
              // xul:toolbarbutton ("Open a new tab")
              role: ROLE_PUSHBUTTON,
              children: []
            },
            {
              // xul:tab ("about:license")
              role: ROLE_PAGETAB,
              children: []
            },
            {
              // tab ("about:mozilla")
              role: ROLE_PAGETAB,
              children: []
            },
            {
              // xul:toolbarbutton ("List all tabs")
              role: ROLE_PUSHBUTTON,
              children: [
                {
                  // xul:menupopup
                  role: ROLE_MENUPOPUP,
                  children: []
                }
              ]
            },
            {
              // xul:toolbarbutton ("Close current tab")
              role: ROLE_PUSHBUTTON,
              children: []
            }
            );
        } else {
          SimpleTest.ok(true, "Testing Firefox tabbrowser UI.");
          let newTabChildren = [];
          if (SpecialPowers.getBoolPref("privacy.userContext.enabled")) {
            newTabChildren = [
              {
                role: ROLE_MENUPOPUP,
                children: []
              }
            ];
          }

          // NB: The (3) buttons are not visible, unless manually hovered,
          //     probably due to size reduction in this test.
          tabsAccTree.children.splice(0, 0,
            {
              // xul:tab ("about:license")
              role: ROLE_PAGETAB,
              children: [
                {
                  // xul:text, i.e. the tab label text
                  role: ROLE_TEXT_LEAF,
                  children: []
                }
              ]
            },
            {
              // tab ("about:mozilla")
              role: ROLE_PAGETAB,
              children: [
                {
                  // xul:text, i.e. the tab label text
                  role: ROLE_TEXT_LEAF,
                  children: []
                }
              ]
            },
            {
              // xul:toolbarbutton ("Open a new tab")
              role: ROLE_PUSHBUTTON,
              children: newTabChildren
            }
            // "List all tabs" dropdown
            // XXX: This child(?) is not present in this test.
            //      I'm not sure why (though probably expected).
            );
        }

        testAccessibleTree(tabBrowser().tabContainer, tabsAccTree);

        ////////////////////
        // Tab contents
        ////////////////////
        var tabboxAccTree = {
          // xul:tabpanels
          role: ROLE_PANE,
          children: [
            {
              // xul:notificationbox
              role: ROLE_PROPERTYPAGE,
              children: [
                {
                  // xul:browser
                  role: ROLE_INTERNAL_FRAME,
                  children: [
                    {
                      // #document ("about:license")
                      role: ROLE_DOCUMENT
                      // children: [ ... ] // Ignore document content.
                    }
                  ]
                }
              ]
            },
            {
              // notificationbox
              role: ROLE_PROPERTYPAGE,
              children: [
                {
                  // browser
                  role: ROLE_INTERNAL_FRAME,
                  children: [
                    {
                      // #document ("about:mozilla")
                      role: ROLE_DOCUMENT
                      // children: [ ... ] // Ignore document content.
                    }
                  ]
                }
              ]
            },
            {
              // notificationbox
              role: ROLE_PROPERTYPAGE,
              children: [
                {
                  // browser
                  role: ROLE_INTERNAL_FRAME,
                  children: [
                    {
                      // #document ("about:newtab" preloaded)
                      role: ROLE_DOCUMENT
                      // children: [ ... ] // Ignore document content.
                    }
                  ]
                }
              ]
            }
          ]
        };

        testAccessibleTree(tabBrowser().tabbox.tabpanels, tabboxAccTree);
      }

      this.getID = function testTabHierarchy_getID()
      {
        return "hierarchy of tabs";
      }
    }

    ////////////////////////////////////////////////////////////////////////////
    // Test
    gA11yEventDumpToConsole = true;
    //enableLogging("tree,verbose,stack");

    var gQueue = null;
    function doTest()
    {
      SimpleTest.requestCompleteLog();

      // Load documents into tabs and wait for docLoadComplete events caused by these
      // documents load before we start the test.
      gQueue = new eventQueue();

      gQueue.push(new testTabHierarchy());
      gQueue.onFinish = function() { closeBrowserWindow(); }
      gQueue.invoke(); // Will call SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    openBrowserWindow(doTest);
  ]]>
  </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=540389"
         title=" WARNING: Bad accessible tree!: [tabbrowser tab] ">
        Mozilla Bug 540389
      </a><br/>
      <a target="_blank"
         href="https://bugzilla.mozilla.org/show_bug.cgi?id=552944"
         title="No relationship between tabs and associated property page in new tabbrowser construct">
        Mozilla Bug 552944
      </a><br/>
      <p id="display"></p>
      <div id="content" style="display: none">
      </div>
      <pre id="test">
      </pre>
    </body>

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

</window>