summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_jsterm_helper_help.js
blob: e8835088c89e6cc9f622cfe17f2768f3d9c4762d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const TEST_URI =
  "data:text/html,<!DOCTYPE html>Test <code>help()</code> jsterm helper";
const HELP_URL =
  "https://firefox-source-docs.mozilla.org/devtools-user/web_console/helpers/";

add_task(async function () {
  const hud = await openNewTabAndConsole(TEST_URI);

  let openedLinks = 0;
  const oldOpenLink = hud.openLink;
  hud.openLink = url => {
    if (url == HELP_URL) {
      openedLinks++;
    }
  };

  await clearOutput(hud);
  execute(hud, "help()");
  execute(hud, "help");
  execute(hud, "?");
  // Wait for a simple message to be displayed so we know the different help commands
  // were processed.
  await executeAndWaitForResultMessage(hud, "smoke", "");

  const messages = hud.ui.outputNode.querySelectorAll(".message");
  is(messages.length, 5, "There is the expected number of messages");
  const resultMessages = hud.ui.outputNode.querySelectorAll(".result");
  is(
    resultMessages.length,
    1,
    "There is no results shown for the help commands"
  );

  is(openedLinks, 3, "correct number of pages opened by the help calls");
  hud.openLink = oldOpenLink;
});