tor-browser

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

browser_net_columns_last_column.js (1623B)


      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 that last visible column can't be hidden. Note that the column
      8 * header is visible only if there are requests in the list.
      9 */
     10 
     11 add_task(async function () {
     12  const { monitor } = await initNetMonitor(SIMPLE_URL, {
     13    requestCount: 1,
     14  });
     15  info("Starting test... ");
     16 
     17  const { document, store, windowRequire } = monitor.panelWin;
     18  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     19  store.dispatch(Actions.batchEnable(false));
     20 
     21  const wait = waitForNetworkEvents(monitor, 1);
     22  await reloadBrowser();
     23  await wait;
     24 
     25  const initialColumns = store.getState().ui.columns;
     26  for (const column in initialColumns) {
     27    const shown = initialColumns[column];
     28 
     29    const columns = store.getState().ui.columns;
     30    const visibleColumns = [];
     31    for (const c in columns) {
     32      if (columns[c]) {
     33        visibleColumns.push(c);
     34      }
     35    }
     36 
     37    if (visibleColumns.length === 1) {
     38      if (!shown) {
     39        continue;
     40      }
     41      await testLastMenuItem(column);
     42      break;
     43    }
     44 
     45    if (shown) {
     46      await hideColumn(monitor, column);
     47    }
     48  }
     49 
     50  await teardown(monitor);
     51 
     52  async function testLastMenuItem(column) {
     53    EventUtils.sendMouseEvent(
     54      { type: "contextmenu" },
     55      document.querySelector(`#requests-list-${column}-button`)
     56    );
     57 
     58    const menuItem = getContextMenuItem(
     59      monitor,
     60      `request-list-header-${column}-toggle`
     61    );
     62    ok(menuItem.disabled, "Last visible column menu item should be disabled.");
     63  }
     64 });