summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/general/browser_test_doc_creation.js
blob: 7ee07f63fdf58cd6d52f68a506bf151f603bf579 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

const tab1URL = `data:text/html,
  <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8"/>
      <title>First tab to be loaded</title>
    </head>
    <body>
      <butotn>JUST A BUTTON</butotn>
    </body>
  </html>`;

const tab2URL = `data:text/html,
  <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <meta charset="utf-8"/>
      <title>Second tab to be loaded</title>
    </head>
    <body>
      <butotn>JUST A BUTTON</butotn>
    </body>
  </html>`;

// Checking that, if there are open windows before accessibility was started,
// root accessibles for open windows are created so that all root accessibles
// are stored in application accessible children array.
add_task(async function testDocumentCreation() {
  let tab1 = await openNewTab(tab1URL);
  let tab2 = await openNewTab(tab2URL);
  let accService = await initAccessibilityService();

  info("Verifying that each tab content document is in accessible cache.");
  for (const browser of [...gBrowser.browsers]) {
    await SpecialPowers.spawn(browser, [], async () => {
      let accServiceContent = Cc[
        "@mozilla.org/accessibilityService;1"
      ].getService(Ci.nsIAccessibilityService);
      Assert.ok(
        !!accServiceContent.getAccessibleFromCache(content.document),
        "Document accessible is in cache."
      );
    });
  }

  BrowserTestUtils.removeTab(tab1);
  BrowserTestUtils.removeTab(tab2);

  accService = null; // eslint-disable-line no-unused-vars
  await shutdownAccessibilityService();
});