summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_split_close_button.js
blob: aae474cb7a138a0f3bbd090ae5c9e07b3a14d9ed (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const TEST_URI =
  "data:text/html;charset=utf-8,<!DOCTYPE html><p>Web Console test for close button of " +
  "split console";

add_task(async function () {
  const toolbox = await openNewTabAndToolbox(TEST_URI, "inspector");

  info("Check the split console toolbar has a close button.");

  const onSplitConsoleReady = toolbox.once("webconsole-ready");
  toolbox.toggleSplitConsole();
  await onSplitConsoleReady;

  let closeButton = getCloseButton(toolbox);
  ok(closeButton, "The split console has close button.");

  info(
    "Check we can reopen split console after closing split console by using " +
      "the close button"
  );

  let onSplitConsoleChange = toolbox.once("split-console");
  closeButton.click();
  await onSplitConsoleChange;
  ok(!toolbox.splitConsole, "The split console has been closed.");

  onSplitConsoleChange = toolbox.once("split-console");
  toolbox.toggleSplitConsole();
  await onSplitConsoleChange;

  ok(toolbox.splitConsole, "The split console has been displayed.");
  closeButton = getCloseButton(toolbox);
  ok(closeButton, "The split console has the close button after reopening.");

  info("Check the close button is not displayed on console panel.");

  await toolbox.selectTool("webconsole");
  closeButton = getCloseButton(toolbox);
  ok(!closeButton, "The console panel should not have the close button.");

  info("The split console has the close button if back to the inspector.");

  await toolbox.selectTool("inspector");
  ok(
    toolbox.splitConsole,
    "The split console has been displayed with inspector."
  );
  closeButton = getCloseButton(toolbox);
  ok(closeButton, "The split console on the inspector has the close button.");
});

function getCloseButton(toolbox) {
  const hud = toolbox.getPanel("webconsole").hud;
  const doc = hud.ui.outputNode.ownerDocument;
  return doc.getElementById("split-console-close-button");
}