summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework/test/browser_toolbox_toolbar_reorder_by_width.js
blob: 3a8cd61d123c8234651f5e719e9e33905eb12bdc (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// This test will:
//
// * Confirm that currently selected button to access tools will not hide due to overflow.
//   In this case, a button which is located on the left of a currently selected will hide.
// * Confirm that a button to access tool will hide when registering a new panel.
//
// Note that this test is based on the tab ordinal is fixed.
// i.e. After changed by Bug 1226272, this test might fail.

const { Toolbox } = require("resource://devtools/client/framework/toolbox.js");

add_task(async function () {
  const tab = await addTab("about:blank");

  info("Open devtools on the Storage in a sidebar.");
  const toolbox = await openToolboxForTab(
    tab,
    "storage",
    Toolbox.HostType.BOTTOM
  );

  const win = getWindow(toolbox);
  const { outerWidth: originalWindowWidth, outerHeight: originalWindowHeight } =
    win;
  registerCleanupFunction(() => {
    win.resizeTo(originalWindowWidth, originalWindowHeight);
  });

  info("Waiting for the window to be resized");
  await resizeWindow(toolbox, 800);

  info("Wait until the tools menu button is available");
  await waitUntil(() => toolbox.doc.querySelector(".tools-chevron-menu"));

  const toolsMenuButton = toolbox.doc.querySelector(".tools-chevron-menu");
  ok(toolsMenuButton, "The tools menu button is displayed");

  info("Confirm that selected tab is not hidden.");
  const storageButton = toolbox.doc.querySelector("#toolbox-tab-storage");
  ok(storageButton, "The storage tab is on toolbox.");

  // Reset window size for 2nd test.
  await resizeWindow(toolbox, originalWindowWidth);
});

add_task(async function () {
  const tab = await addTab("about:blank");

  info("Open devtools on the Storage in a sidebar.");
  const toolbox = await openToolboxForTab(
    tab,
    "storage",
    Toolbox.HostType.BOTTOM
  );

  info("Resize devtools window to a width that should trigger an overflow");
  await resizeWindow(toolbox, 800);

  info("Regist a new tab");
  const onRegistered = toolbox.once("tool-registered");
  gDevTools.registerTool({
    id: "test-tools",
    label: "Test Tools",
    isMenu: true,
    isToolSupported: () => true,
    build() {},
  });
  await onRegistered;

  info("Open the tools menu button.");
  await openChevronMenu(toolbox);

  info("The registered new tool tab should be in the tools menu.");
  let testToolsButton = toolbox.doc.querySelector(
    "#tools-chevron-menupopup-test-tools"
  );
  ok(testToolsButton, "The tools menu has a registered new tool button.");

  await closeChevronMenu(toolbox);

  info("Unregistering test-tools");
  const onUnregistered = toolbox.once("tool-unregistered");
  gDevTools.unregisterTool("test-tools");
  await onUnregistered;

  info("Open the tools menu button.");
  await openChevronMenu(toolbox);

  info("An unregistered new tool tab should not be in the tools menu.");
  testToolsButton = toolbox.doc.querySelector(
    "#tools-chevron-menupopup-test-tools"
  );
  ok(
    !testToolsButton,
    "The tools menu doesn't have a unregistered new tool button."
  );

  await closeChevronMenu(toolbox);
});