summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_proton_moreTools_panel.js
blob: d78cf946f8846918136bfef786e61fa28fe25427 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

XPCOMUtils.defineLazyGetter(this, "DevToolsStartup", () => {
  return Cc["@mozilla.org/devtools/startup-clh;1"].getService(
    Ci.nsICommandLineHandler
  ).wrappedJSObject;
});

// Test activating the developer button shows the More Tools panel.
add_task(async function testDevToolsPanelInToolbar() {
  // We need to force DevToolsStartup to rebuild the developer tool toggle so that
  // proton prefs are applied to the new browser window for this test.
  DevToolsStartup.developerToggleCreated = false;
  CustomizableUI.destroyWidget("developer-button");

  const win = await BrowserTestUtils.openNewBrowserWindow();

  CustomizableUI.addWidgetToArea(
    "developer-button",
    CustomizableUI.AREA_NAVBAR
  );

  // Test the developer tools panel is showing.
  let button = document.getElementById("developer-button");
  let devToolsView = PanelMultiView.getViewNode(
    document,
    "PanelUI-developer-tools"
  );
  let devToolsShownPromise = BrowserTestUtils.waitForEvent(
    devToolsView,
    "ViewShown"
  );

  EventUtils.synthesizeMouseAtCenter(button, {});
  await devToolsShownPromise;
  ok(true, "Dev Tools view is showing");
  is(
    devToolsView.children.length,
    1,
    "Dev tools subview is the only child of panel"
  );
  is(
    devToolsView.children[0].id,
    "PanelUI-developer-tools-view",
    "Dev tools child has correct id"
  );

  // Cleanup
  await BrowserTestUtils.closeWindow(win);
  CustomizableUI.reset();
});