tor-browser

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

browser_outline_xul.js (7237B)


      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/attributes.js */
      8 loadScripts({ name: "attributes.js", dir: MOCHITESTS_DIR });
      9 
     10 addAccessibleTask(
     11  "mac/doc_tree.xhtml",
     12  async (browser, accDoc) => {
     13    const tree = getNativeInterface(accDoc, "tree");
     14    is(
     15      tree.getAttributeValue("AXRole"),
     16      "AXOutline",
     17      "Found tree with role outline"
     18    );
     19    // XUL trees store all rows as direct children of the outline,
     20    // so we should see nine here instead of just three:
     21    // (Groceries, Fruits, Veggies)
     22    const treeChildren = tree.getAttributeValue("AXChildren");
     23    is(treeChildren.length, 9, "Found nine direct children");
     24 
     25    const treeCols = tree.getAttributeValue("AXColumns");
     26    is(treeCols.length, 1, "Found one column in tree");
     27 
     28    // Here, we should get only outline rows, not the title
     29    const treeRows = tree.getAttributeValue("AXRows");
     30    is(treeRows.length, 8, "Found 8 total rows");
     31 
     32    is(
     33      treeRows[0].getAttributeValue("AXDescription"),
     34      "Fruits",
     35      "Located correct first row, row has correct desc"
     36    );
     37    is(
     38      treeRows[0].getAttributeValue("AXDisclosing"),
     39      1,
     40      "Fruits is disclosing"
     41    );
     42    is(
     43      treeRows[0].getAttributeValue("AXDisclosedByRow"),
     44      null,
     45      "Fruits is disclosed by outline"
     46    );
     47    is(
     48      treeRows[0].getAttributeValue("AXDisclosureLevel"),
     49      0,
     50      "Fruits is level zero"
     51    );
     52    let disclosedRows = treeRows[0].getAttributeValue("AXDisclosedRows");
     53    is(disclosedRows.length, 2, "Fruits discloses two rows");
     54    is(
     55      disclosedRows[0].getAttributeValue("AXDescription"),
     56      "Apple",
     57      "fruits discloses apple"
     58    );
     59    is(
     60      disclosedRows[1].getAttributeValue("AXDescription"),
     61      "Orange",
     62      "fruits discloses orange"
     63    );
     64 
     65    is(
     66      treeRows[1].getAttributeValue("AXDescription"),
     67      "Apple",
     68      "Located correct second row, row has correct desc"
     69    );
     70    is(
     71      treeRows[1].getAttributeValue("AXDisclosing"),
     72      0,
     73      "Apple is not disclosing"
     74    );
     75    is(
     76      treeRows[1]
     77        .getAttributeValue("AXDisclosedByRow")
     78        .getAttributeValue("AXDescription"),
     79      "Fruits",
     80      "Apple is disclosed by fruits"
     81    );
     82    is(
     83      treeRows[1].getAttributeValue("AXDisclosureLevel"),
     84      1,
     85      "Apple is level one"
     86    );
     87    is(
     88      treeRows[1].getAttributeValue("AXDisclosedRows").length,
     89      0,
     90      "Apple does not disclose rows"
     91    );
     92 
     93    is(
     94      treeRows[2].getAttributeValue("AXDescription"),
     95      "Orange",
     96      "Located correct third row, row has correct desc"
     97    );
     98    is(
     99      treeRows[2].getAttributeValue("AXDisclosing"),
    100      0,
    101      "Orange is not disclosing"
    102    );
    103    is(
    104      treeRows[2]
    105        .getAttributeValue("AXDisclosedByRow")
    106        .getAttributeValue("AXDescription"),
    107      "Fruits",
    108      "Orange is disclosed by fruits"
    109    );
    110    is(
    111      treeRows[2].getAttributeValue("AXDisclosureLevel"),
    112      1,
    113      "Orange is level one"
    114    );
    115    is(
    116      treeRows[2].getAttributeValue("AXDisclosedRows").length,
    117      0,
    118      "Orange does not disclose rows"
    119    );
    120 
    121    is(
    122      treeRows[3].getAttributeValue("AXDescription"),
    123      "Veggies",
    124      "Located correct fourth row, row has correct desc"
    125    );
    126    is(
    127      treeRows[3].getAttributeValue("AXDisclosing"),
    128      1,
    129      "Veggies is disclosing"
    130    );
    131    is(
    132      treeRows[3].getAttributeValue("AXDisclosedByRow"),
    133      null,
    134      "Veggies is disclosed by outline"
    135    );
    136    is(
    137      treeRows[3].getAttributeValue("AXDisclosureLevel"),
    138      0,
    139      "Veggies is level zero"
    140    );
    141    disclosedRows = treeRows[3].getAttributeValue("AXDisclosedRows");
    142    is(disclosedRows.length, 2, "Veggies discloses two rows");
    143    is(
    144      disclosedRows[0].getAttributeValue("AXDescription"),
    145      "Green Veggies",
    146      "Veggies discloses green veggies"
    147    );
    148    is(
    149      disclosedRows[1].getAttributeValue("AXDescription"),
    150      "Squash",
    151      "Veggies discloses squash"
    152    );
    153 
    154    is(
    155      treeRows[4].getAttributeValue("AXDescription"),
    156      "Green Veggies",
    157      "Located correct fifth row, row has correct desc"
    158    );
    159    is(
    160      treeRows[4].getAttributeValue("AXDisclosing"),
    161      1,
    162      "Green veggies is disclosing"
    163    );
    164    is(
    165      treeRows[4]
    166        .getAttributeValue("AXDisclosedByRow")
    167        .getAttributeValue("AXDescription"),
    168      "Veggies",
    169      "Green Veggies is disclosed by veggies"
    170    );
    171    is(
    172      treeRows[4].getAttributeValue("AXDisclosureLevel"),
    173      1,
    174      "Green veggies is level one"
    175    );
    176    disclosedRows = treeRows[4].getAttributeValue("AXDisclosedRows");
    177    is(disclosedRows.length, 2, "Green veggies has two rows");
    178    is(
    179      disclosedRows[0].getAttributeValue("AXDescription"),
    180      "Spinach",
    181      "Green veggies discloses spinach"
    182    );
    183    is(
    184      disclosedRows[1].getAttributeValue("AXDescription"),
    185      "Peas",
    186      "Green veggies discloses peas"
    187    );
    188 
    189    is(
    190      treeRows[5].getAttributeValue("AXDescription"),
    191      "Spinach",
    192      "Located correct sixth row, row has correct desc"
    193    );
    194    is(
    195      treeRows[5].getAttributeValue("AXDisclosing"),
    196      0,
    197      "Spinach is not disclosing"
    198    );
    199    is(
    200      treeRows[5]
    201        .getAttributeValue("AXDisclosedByRow")
    202        .getAttributeValue("AXDescription"),
    203      "Green Veggies",
    204      "Spinach is disclosed by green veggies"
    205    );
    206    is(
    207      treeRows[5].getAttributeValue("AXDisclosureLevel"),
    208      2,
    209      "Spinach is level two"
    210    );
    211    is(
    212      treeRows[5].getAttributeValue("AXDisclosedRows").length,
    213      0,
    214      "Spinach does not disclose rows"
    215    );
    216 
    217    is(
    218      treeRows[6].getAttributeValue("AXDescription"),
    219      "Peas",
    220      "Located correct seventh row, row has correct desc"
    221    );
    222    is(
    223      treeRows[6].getAttributeValue("AXDisclosing"),
    224      0,
    225      "Peas is not disclosing"
    226    );
    227    is(
    228      treeRows[6]
    229        .getAttributeValue("AXDisclosedByRow")
    230        .getAttributeValue("AXDescription"),
    231      "Green Veggies",
    232      "Peas is disclosed by green veggies"
    233    );
    234    is(
    235      treeRows[6].getAttributeValue("AXDisclosureLevel"),
    236      2,
    237      "Peas is level two"
    238    );
    239    is(
    240      treeRows[6].getAttributeValue("AXDisclosedRows").length,
    241      0,
    242      "Peas does not disclose rows"
    243    );
    244 
    245    is(
    246      treeRows[7].getAttributeValue("AXDescription"),
    247      "Squash",
    248      "Located correct eighth row, row has correct desc"
    249    );
    250    is(
    251      treeRows[7].getAttributeValue("AXDisclosing"),
    252      0,
    253      "Squash is not disclosing"
    254    );
    255    is(
    256      treeRows[7]
    257        .getAttributeValue("AXDisclosedByRow")
    258        .getAttributeValue("AXDescription"),
    259      "Veggies",
    260      "Squash is disclosed by veggies"
    261    );
    262    is(
    263      treeRows[7].getAttributeValue("AXDisclosureLevel"),
    264      1,
    265      "Squash is level one"
    266    );
    267    is(
    268      treeRows[7].getAttributeValue("AXDisclosedRows").length,
    269      0,
    270      "Squash does not disclose rows"
    271    );
    272  },
    273  { topLevel: false, chrome: true }
    274 );