summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_devtoolstoolbox_reload.js
blob: 3eba6bcd7e322cf40e77b6ad8bb3b44935ad653e (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test can run for a long time on debug platforms.
requestLongerTimeout(5);

/* import-globals-from helper-collapsibilities.js */
Services.scriptloader.loadSubScript(
  CHROME_URL_ROOT + "helper-collapsibilities.js",
  this
);

const TOOLS = [
  "inspector",
  "webconsole",
  "jsdebugger",
  "styleeditor",
  "memory",
  "netmonitor",
  "storage",
  "accessibility",
];

/**
 * Test whether about:devtools-toolbox display correctly after reloading.
 */
add_task(async function () {
  info("Force all debug target panes to be expanded");
  prepareCollapsibilitiesTest();

  for (const toolId of TOOLS) {
    await testReloadAboutDevToolsToolbox(toolId);
  }
});

async function testReloadAboutDevToolsToolbox(toolId) {
  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);
  // We set the options panel to be the default one because slower panels might lead to
  // race conditions which create leaks in debug mode.
  await pushPref("devtools.toolbox.selectedTool", "options");
  const { devtoolsBrowser, devtoolsTab, devtoolsWindow } =
    await openAboutDevtoolsToolbox(document, tab, window);

  info(`Select tool: ${toolId}`);
  const toolbox = getToolbox(devtoolsWindow);
  await toolbox.selectTool(toolId);

  info("Wait for requests to settle before reloading");
  await toolbox.commands.client.waitForRequestsToSettle();

  info("Reload about:devtools-toolbox page");
  devtoolsBrowser.reload();
  await gDevTools.once("toolbox-ready");
  ok(true, "Toolbox is re-created again");

  // Check that about:devtools-toolbox is still selected tab. See Bug 1570692.
  is(
    devtoolsBrowser,
    gBrowser.selectedBrowser,
    "about:devtools-toolbox is still selected"
  );

  info("Check whether about:devtools-toolbox page displays correctly");
  ok(
    devtoolsBrowser.contentDocument.querySelector(".debug-target-info"),
    "about:devtools-toolbox page displays correctly"
  );

  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
  await removeTab(tab);
}