tor-browser

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

browser_menu_item_02.js (1547B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test RDM menu item is checked when expected, on multiple windows.
      7 
      8 const TEST_URL = "data:text/html;charset=utf-8,";
      9 
     10 const isMenuCheckedFor = ({ document }) => {
     11  const menu = document.getElementById("menu_responsiveUI");
     12  return menu.getAttribute("checked") === "true";
     13 };
     14 
     15 addRDMTask(
     16  null,
     17  async function () {
     18    const window1 = await BrowserTestUtils.openNewBrowserWindow();
     19    const { gBrowser } = window1;
     20 
     21    await BrowserTestUtils.withNewTab(
     22      { gBrowser, url: TEST_URL },
     23      async function (browser) {
     24        const tab = gBrowser.getTabForBrowser(browser);
     25 
     26        is(
     27          window1,
     28          Services.wm.getMostRecentBrowserWindow(),
     29          "The new window is the active one"
     30        );
     31 
     32        ok(!isMenuCheckedFor(window1), "RDM menu item is unchecked by default");
     33 
     34        const { ui } = await openRDM(tab);
     35        await waitForDeviceAndViewportState(ui);
     36 
     37        ok(isMenuCheckedFor(window1), "RDM menu item is checked with RDM open");
     38 
     39        await closeRDM(tab);
     40 
     41        ok(
     42          !isMenuCheckedFor(window1),
     43          "RDM menu item is unchecked with RDM closed"
     44        );
     45      }
     46    );
     47 
     48    await BrowserTestUtils.closeWindow(window1);
     49 
     50    is(
     51      window,
     52      Services.wm.getMostRecentBrowserWindow(),
     53      "The original window is the active one"
     54    );
     55 
     56    ok(!isMenuCheckedFor(window), "RDM menu item is unchecked");
     57  },
     58  { onlyPrefAndTask: true }
     59 );