tor-browser

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

browser_details_summary.js (2296B)


      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 /* import-globals-from ../../mochitest/role.js */
      8 /* import-globals-from ../../mochitest/states.js */
      9 loadScripts(
     10  { name: "role.js", dir: MOCHITESTS_DIR },
     11  { name: "states.js", dir: MOCHITESTS_DIR }
     12 );
     13 
     14 /**
     15 * Test details/summary
     16 */
     17 addAccessibleTask(
     18  `<details id="details"><summary id="summary">Foo</summary><p>Bar</p></details>`,
     19  async (browser, accDoc) => {
     20    let details = getNativeInterface(accDoc, "details");
     21    is(
     22      details.getAttributeValue("AXRole"),
     23      "AXGroup",
     24      "Correct role for details"
     25    );
     26    is(
     27      details.getAttributeValue("AXSubrole"),
     28      "AXDetails",
     29      "Correct subrole for details"
     30    );
     31 
     32    let detailsChildren = details.getAttributeValue("AXChildren");
     33    is(detailsChildren.length, 2, "collapsed details has two children");
     34 
     35    let summary = detailsChildren[0];
     36    is(
     37      summary.getAttributeValue("AXRole"),
     38      "AXButton",
     39      "Correct role for summary"
     40    );
     41    is(
     42      summary.getAttributeValue("AXSubrole"),
     43      "AXSummary",
     44      "Correct subrole for summary"
     45    );
     46    is(summary.getAttributeValue("AXExpanded"), 0, "Summary is collapsed");
     47 
     48    let actions = summary.actionNames;
     49    ok(actions.includes("AXPress"), "Summary Has press action");
     50 
     51    let stateChanged = waitForStateChange("summary", STATE_EXPANDED, true);
     52    summary.performAction("AXPress");
     53    // The reorder gecko event notifies us of a tree change.
     54    await stateChanged;
     55    is(summary.getAttributeValue("AXExpanded"), 1, "Summary is expanded");
     56 
     57    detailsChildren = details.getAttributeValue("AXChildren");
     58    is(detailsChildren.length, 2, "expanded details also has two children");
     59 
     60    stateChanged = waitForStateChange("summary", STATE_EXPANDED, false);
     61    summary.performAction("AXPress");
     62    // The reorder gecko event notifies us of a tree change.
     63    await stateChanged;
     64    is(summary.getAttributeValue("AXExpanded"), 0, "Summary is collapsed 2");
     65 
     66    detailsChildren = details.getAttributeValue("AXChildren");
     67    is(detailsChildren.length, 2, "collapsed details has two children");
     68  }
     69 );