tor-browser

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

browser_jsterm_helper_help.js (1220B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_URI =
      7  "data:text/html,<!DOCTYPE html>Test <code>help()</code> jsterm helper";
      8 const HELP_URL =
      9  "https://firefox-source-docs.mozilla.org/devtools-user/web_console/helpers/";
     10 
     11 add_task(async function () {
     12  const hud = await openNewTabAndConsole(TEST_URI);
     13 
     14  let openedLinks = 0;
     15  const oldOpenLink = hud.openLink;
     16  hud.openLink = url => {
     17    if (url == HELP_URL) {
     18      openedLinks++;
     19    }
     20  };
     21 
     22  await clearOutput(hud);
     23  execute(hud, "help()");
     24  execute(hud, "help");
     25  execute(hud, "?");
     26  // Wait for a simple message to be displayed so we know the different help commands
     27  // were processed.
     28  await executeAndWaitForResultMessage(hud, "smoke", "");
     29 
     30  const messages = hud.ui.outputNode.querySelectorAll(".message");
     31  is(messages.length, 5, "There is the expected number of messages");
     32  const resultMessages = hud.ui.outputNode.querySelectorAll(".result");
     33  is(
     34    resultMessages.length,
     35    1,
     36    "There is no results shown for the help commands"
     37  );
     38 
     39  is(openedLinks, 3, "correct number of pages opened by the help calls");
     40  hud.openLink = oldOpenLink;
     41 });