tor-browser

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

browser_net_accessibility-01.js (2252B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Tests if focus modifiers work for the Side Menu.
      8 */
      9 
     10 add_task(async function () {
     11  const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, {
     12    requestCount: 1,
     13  });
     14  info("Starting test... ");
     15 
     16  // It seems that this test may be slow on Ubuntu builds running on ec2.
     17  requestLongerTimeout(2);
     18 
     19  const { document, store, windowRequire } = monitor.panelWin;
     20  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     21 
     22  store.dispatch(Actions.batchEnable(false));
     23 
     24  let count = 0;
     25  function check(selectedIndex, panelVisibility) {
     26    info("Performing check " + count++ + ".");
     27 
     28    const requestItems = Array.from(
     29      document.querySelectorAll(".request-list-item")
     30    );
     31    is(
     32      requestItems.findIndex(item => item.matches(".selected")),
     33      selectedIndex,
     34      "The selected item in the requests menu was incorrect."
     35    );
     36    is(
     37      !!document.querySelector(".network-details-bar"),
     38      panelVisibility,
     39      "The network details panel should render correctly."
     40    );
     41  }
     42 
     43  // Execute requests.
     44  await performRequests(monitor, tab, 2);
     45 
     46  check(-1, false);
     47 
     48  store.dispatch(Actions.selectDelta(+Infinity));
     49  check(1, true);
     50  store.dispatch(Actions.selectDelta(-Infinity));
     51  check(0, true);
     52 
     53  store.dispatch(Actions.selectDelta(+1));
     54  check(1, true);
     55  store.dispatch(Actions.selectDelta(-1));
     56  check(0, true);
     57 
     58  store.dispatch(Actions.selectDelta(+10));
     59  check(1, true);
     60  store.dispatch(Actions.selectDelta(-10));
     61  check(0, true);
     62 
     63  // Execute requests.
     64  await performRequests(monitor, tab, 18);
     65 
     66  store.dispatch(Actions.selectDelta(+Infinity));
     67  check(19, true);
     68  store.dispatch(Actions.selectDelta(-Infinity));
     69  check(0, true);
     70 
     71  store.dispatch(Actions.selectDelta(+1));
     72  check(1, true);
     73  store.dispatch(Actions.selectDelta(-1));
     74  check(0, true);
     75 
     76  store.dispatch(Actions.selectDelta(+10));
     77  check(10, true);
     78  store.dispatch(Actions.selectDelta(-10));
     79  check(0, true);
     80 
     81  store.dispatch(Actions.selectDelta(+100));
     82  check(19, true);
     83  store.dispatch(Actions.selectDelta(-100));
     84  check(0, true);
     85 
     86  return teardown(monitor);
     87 });