tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_rootgroup.js (2817B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /**
      8 * Test document with body[role=application] and a top-level group
      9 */
     10 addAccessibleTask(
     11  `<div role="group" id="group"><p>hello</p><p>world</p></div>`,
     12  async (browser, accDoc) => {
     13    let doc = accDoc.nativeInterface.QueryInterface(
     14      Ci.nsIAccessibleMacInterface
     15    );
     16 
     17    is(
     18      doc.getAttributeValue("AXRole"),
     19      "AXWebArea",
     20      "doc still has web area role"
     21    );
     22    is(
     23      doc.getAttributeValue("AXRoleDescription"),
     24      "HTML Content",
     25      "doc has correct role description"
     26    );
     27    ok(
     28      !doc.attributeNames.includes("AXSubrole"),
     29      "sub role not available on web area"
     30    );
     31 
     32    let rootGroup = doc.getAttributeValue("AXChildren")[0];
     33    is(
     34      rootGroup.getAttributeValue("AXIdentifier"),
     35      "root-group",
     36      "Is generated root group"
     37    );
     38    is(
     39      rootGroup.getAttributeValue("AXRole"),
     40      "AXGroup",
     41      "root group has AXGroup role"
     42    );
     43    is(
     44      rootGroup.getAttributeValue("AXSubrole"),
     45      "AXLandmarkApplication",
     46      "root group has application subrole"
     47    );
     48    is(
     49      rootGroup.getAttributeValue("AXRoleDescription"),
     50      "application",
     51      "root group has application role description"
     52    );
     53  },
     54  { contentDocBodyAttrs: { role: "application" } }
     55 );
     56 
     57 /**
     58 * Test document with dialog role and heading
     59 */
     60 addAccessibleTask(
     61  `<body role="dialog" aria-labelledby="h">
     62    <h1 id="h">
     63      We're building a richer search experience
     64    </h1>
     65  </body>`,
     66  async (browser, accDoc) => {
     67    let doc = accDoc.nativeInterface.QueryInterface(
     68      Ci.nsIAccessibleMacInterface
     69    );
     70    let docChildren = doc.getAttributeValue("AXChildren");
     71    is(docChildren.length, 1, "The document contains a root group");
     72 
     73    let rootGroup = docChildren[0];
     74    is(
     75      rootGroup.getAttributeValue("AXIdentifier"),
     76      "root-group",
     77      "Is generated root group"
     78    );
     79 
     80    is(rootGroup.getAttributeValue("AXRole"), "AXGroup", "Inherits role");
     81 
     82    is(
     83      rootGroup.getAttributeValue("AXSubrole"),
     84      "AXApplicationDialog",
     85      "Inherits subrole"
     86    );
     87    let rootGroupChildren = rootGroup.getAttributeValue("AXChildren");
     88    is(rootGroupChildren.length, 1, "Root group has one child");
     89 
     90    is(
     91      rootGroupChildren[0].getAttributeValue("AXRole"),
     92      "AXHeading",
     93      "Heading is child of root group"
     94    );
     95 
     96    // From bottom-up
     97    let heading = getNativeInterface(accDoc, "h");
     98    rootGroup = heading.getAttributeValue("AXParent");
     99    is(
    100      rootGroup.getAttributeValue("AXIdentifier"),
    101      "root-group",
    102      "Parent is generated root group"
    103    );
    104  }
    105 );