tor-browser

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

browser_hierarchy.js (1878B)


      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 AXIndexForChildUIElement
      9 */
     10 addAccessibleTask(
     11  `<p id="p">Hello <a href="#" id="link">strange</a> world`,
     12  (browser, accDoc) => {
     13    let p = getNativeInterface(accDoc, "p");
     14 
     15    let children = p.getAttributeValue("AXChildren");
     16    is(children.length, 3, "p has 3 children");
     17    is(
     18      children[1].getAttributeValue("AXDOMIdentifier"),
     19      "link",
     20      "second child is link"
     21    );
     22 
     23    let index = p.getParameterizedAttributeValue(
     24      "AXIndexForChildUIElement",
     25      children[1]
     26    );
     27    is(index, 1, "link is second child");
     28  }
     29 );
     30 
     31 /**
     32 * Test textbox with more than one child
     33 */
     34 addAccessibleTask(
     35  `<div id="textbox" role="textbox">Hello <a href="#">strange</a> world</div>`,
     36  (browser, accDoc) => {
     37    let textbox = getNativeInterface(accDoc, "textbox");
     38 
     39    is(
     40      textbox.getAttributeValue("AXChildren").length,
     41      3,
     42      "textbox has 3 children"
     43    );
     44  }
     45 );
     46 
     47 /**
     48 * Test textbox with one child
     49 */
     50 addAccessibleTask(
     51  `<div id="textbox" role="textbox">Hello </div>`,
     52  async (browser, accDoc) => {
     53    let textbox = getNativeInterface(accDoc, "textbox");
     54 
     55    is(
     56      textbox.getAttributeValue("AXChildren").length,
     57      0,
     58      "textbox with one child is pruned"
     59    );
     60 
     61    let reorder = waitForEvent(EVENT_REORDER, "textbox");
     62    await SpecialPowers.spawn(browser, [], () => {
     63      let link = content.document.createElement("a");
     64      link.textContent = "World";
     65      content.document.getElementById("textbox").appendChild(link);
     66    });
     67    await reorder;
     68 
     69    is(
     70      textbox.getAttributeValue("AXChildren").length,
     71      2,
     72      "textbox with two child is not pruned"
     73    );
     74  }
     75 );