tor-browser

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

browser_contextmenu_inspect.js (1967B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 add_setup(async function () {
      7  await SpecialPowers.pushPrefEnv({
      8    set: [["test.wait300msAfterTabSwitch", true]],
      9  });
     10 });
     11 
     12 /**
     13 * Check that we show the inspect item(s) as appropriate.
     14 */
     15 add_task(async function test_contextmenu_inspect() {
     16  await SpecialPowers.pushPrefEnv({
     17    set: [
     18      ["devtools.selfxss.count", 0],
     19      ["devtools.everOpened", false],
     20    ],
     21  });
     22  let contextMenu = document.getElementById("contentAreaContextMenu");
     23  await BrowserTestUtils.withNewTab("about:blank", async browser => {
     24    for (let [pref, value, expectation] of [
     25      ["devtools.selfxss.count", 10, true],
     26      ["devtools.selfxss.count", 0, false],
     27      ["devtools.everOpened", false, false],
     28      ["devtools.everOpened", true, true],
     29    ]) {
     30      await SpecialPowers.pushPrefEnv({
     31        set: [["devtools.selfxss.count", value]],
     32      });
     33      is(contextMenu.state, "closed", "checking if popup is closed");
     34      let promisePopupShown = BrowserTestUtils.waitForEvent(
     35        contextMenu,
     36        "popupshown"
     37      );
     38      let promisePopupHidden = BrowserTestUtils.waitForEvent(
     39        contextMenu,
     40        "popuphidden"
     41      );
     42      await BrowserTestUtils.synthesizeMouse(
     43        "body",
     44        2,
     45        2,
     46        { type: "contextmenu", button: 2 },
     47        browser
     48      );
     49      await promisePopupShown;
     50      let inspectItem = document.getElementById("context-inspect");
     51      ok(
     52        !inspectItem.hidden,
     53        `Inspect should be shown (pref ${pref} is ${value}).`
     54      );
     55      let inspectA11y = document.getElementById("context-inspect-a11y");
     56      is(
     57        inspectA11y.hidden,
     58        !expectation,
     59        `A11y should be ${
     60          expectation ? "visible" : "hidden"
     61        } (pref ${pref} is ${value}).`
     62      );
     63      contextMenu.hidePopup();
     64      await promisePopupHidden;
     65    }
     66  });
     67 });