tor-browser

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

browser_test_visibility_2.js (4329B)


      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 tables, table rows are reported on screen, even if some cells of a given row are
      9 * offscreen.
     10 */
     11 addAccessibleTask(
     12  `
     13  <table id="table" style="width:150vw;" border><tr id="row"><td id="one" style="width:50vw;">one</td><td style="width:50vw;" id="two">two</td><td id="three">three</td></tr></table>
     14  `,
     15  async function (browser, accDoc) {
     16    const table = findAccessibleChildByID(accDoc, "table");
     17    const row = findAccessibleChildByID(accDoc, "row");
     18    const one = findAccessibleChildByID(accDoc, "one");
     19    const two = findAccessibleChildByID(accDoc, "two");
     20    const three = findAccessibleChildByID(accDoc, "three");
     21 
     22    await untilCacheOk(
     23      () => testVisibility(table, false, false),
     24      "table should be on screen and visible"
     25    );
     26    await untilCacheOk(
     27      () => testVisibility(row, false, false),
     28      "row should be on screen and visible"
     29    );
     30    await untilCacheOk(
     31      () => testVisibility(one, false, false),
     32      "one should be on screen and visible"
     33    );
     34    await untilCacheOk(
     35      () => testVisibility(two, false, false),
     36      "two should be on screen and visible"
     37    );
     38    await untilCacheOk(
     39      () => testVisibility(three, true, false),
     40      "three should be off screen and visible"
     41    );
     42  },
     43  { chrome: true, iframe: true, remoteIframe: true }
     44 );
     45 
     46 /**
     47 * Test rows and cells outside of the viewport are reported as offscreen.
     48 */
     49 addAccessibleTask(
     50  `
     51  <table id="table" style="height:150vh;" border><tr style="height:100vh;" id="rowA"><td id="one">one</td></tr><tr id="rowB"><td id="two">two</td></tr></table>
     52  `,
     53  async function (browser, accDoc) {
     54    const table = findAccessibleChildByID(accDoc, "table");
     55    const rowA = findAccessibleChildByID(accDoc, "rowA");
     56    const one = findAccessibleChildByID(accDoc, "one");
     57    const rowB = findAccessibleChildByID(accDoc, "rowB");
     58    const two = findAccessibleChildByID(accDoc, "two");
     59 
     60    await untilCacheOk(
     61      () => testVisibility(table, false, false),
     62      "table should be on screen and visible"
     63    );
     64    await untilCacheOk(
     65      () => testVisibility(rowA, false, false),
     66      "rowA should be on screen and visible"
     67    );
     68    await untilCacheOk(
     69      () => testVisibility(one, false, false),
     70      "one should be on screen and visible"
     71    );
     72    await untilCacheOk(
     73      () => testVisibility(rowB, true, false),
     74      "rowB should be off screen and visible"
     75    );
     76    await untilCacheOk(
     77      () => testVisibility(two, true, false),
     78      "two should be off screen and visible"
     79    );
     80  },
     81  { chrome: true, iframe: true, remoteIframe: true }
     82 );
     83 
     84 addAccessibleTask(
     85  `
     86  <div id="div">hello</div>
     87  `,
     88  async function (browser, accDoc) {
     89    let textLeaf = findAccessibleChildByID(accDoc, "div").firstChild;
     90    await untilCacheOk(
     91      () => testVisibility(textLeaf, false, false),
     92      "text should be on screen and visible"
     93    );
     94    let p = waitForEvent(EVENT_TEXT_INSERTED, "div");
     95    await invokeContentTask(browser, [], () => {
     96      content.document.getElementById("div").textContent = "goodbye";
     97    });
     98    await p;
     99    textLeaf = findAccessibleChildByID(accDoc, "div").firstChild;
    100    await untilCacheOk(
    101      () => testVisibility(textLeaf, false, false),
    102      "text should be on screen and visible"
    103    );
    104  },
    105  { chrome: true, iframe: true, remoteIframe: true }
    106 );
    107 
    108 /**
    109 * Overlapping, opaque divs with the same bounds should not be considered
    110 * offscreen.
    111 */
    112 addAccessibleTask(
    113  `
    114  <style>div { height: 5px; width: 5px; background: green; }</style>
    115  <div id="outer" role="group"><div style="background:blue;" id="inner" role="group">hi</div></div>
    116  `,
    117  async function (browser, accDoc) {
    118    const outer = findAccessibleChildByID(accDoc, "outer");
    119    const inner = findAccessibleChildByID(accDoc, "inner");
    120 
    121    await untilCacheOk(
    122      () => testVisibility(outer, false, false),
    123      "outer should be on screen and visible"
    124    );
    125    await untilCacheOk(
    126      () => testVisibility(inner, false, false),
    127      "inner should be on screen and visible"
    128    );
    129  },
    130  { chrome: true, iframe: true, remoteIframe: true }
    131 );