tor-browser

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

browser_webconsole_reverse_search_toggle.js (2046B)


      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 // Tests showing and hiding the reverse search UI.
      6 
      7 "use strict";
      8 
      9 const TEST_URI = `data:text/html,<!DOCTYPE html><meta charset=utf8>Test reverse search toggle`;
     10 const isMacOS = AppConstants.platform === "macosx";
     11 
     12 add_task(async function () {
     13  const hud = await openNewTabAndConsole(TEST_URI);
     14 
     15  info("Close the reverse search UI with ESC");
     16  await openReverseSearch(hud);
     17  let onReverseSearchUiClose = waitFor(
     18    () => getReverseSearchElement(hud) === null
     19  );
     20  EventUtils.sendKey("ESCAPE");
     21  await onReverseSearchUiClose;
     22  ok(true, "Reverse search was closed with the Esc keyboard shortcut");
     23 
     24  if (isMacOS) {
     25    info("Close the reverse search UI with Ctrl + C on OSX");
     26    await openReverseSearch(hud);
     27    onReverseSearchUiClose = waitFor(
     28      () => getReverseSearchElement(hud) === null
     29    );
     30    EventUtils.synthesizeKey("c", { ctrlKey: true });
     31    await onReverseSearchUiClose;
     32    ok(true, "Reverse search was closed with the Ctrl + C keyboard shortcut");
     33  }
     34 
     35  info("Close the reverse search UI with the close button");
     36  const reverseSearchElement = await openReverseSearch(hud);
     37  const closeButton = reverseSearchElement.querySelector(
     38    ".reverse-search-close-button"
     39  );
     40  ok(closeButton, "The close button is displayed");
     41  is(
     42    closeButton.title,
     43    `Close (Esc${isMacOS ? " | Ctrl + C" : ""})`,
     44    "The close button has the expected tooltip"
     45  );
     46  onReverseSearchUiClose = waitFor(() => getReverseSearchElement(hud) === null);
     47  closeButton.click();
     48  await onReverseSearchUiClose;
     49  ok(true, "Reverse search was closed by clicking on the close button");
     50 
     51  info("Close the reverse search UI by clicking on the output");
     52  await openReverseSearch(hud);
     53  hud.ui.outputNode.querySelector(".jsterm-input-container").click();
     54  ok(true, "Reverse search was closed by clicking in the output");
     55 });