Files
sousa-gecko/devtools/client/framework/test/browser_toolbox_popups_debugging.js
Nicolas Chevobbe e4546eac5f Bug 2055840 - [devtools] toolbox-host.js refactoring. r=devtools-reviewers,ochameau.
Use shared classes for all toolbox iframes and splitters, and then have
specific classes when the iframe/splitter is docked to the left/right/bottom,
so they're easier to work with.
Use Element#append and Element#remove instead of appendChild/removeChild

Differential Revision: https://phabricator.services.mozilla.com/D312252
2026-07-20 07:33:15 +00:00

59 lines
2.0 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test opening toolboxes against a tab and its popup
const TEST_URL =
"https://example.com/browser/devtools/client/framework/test/doc_popups_debugging.html";
const POPUP_URL =
"https://example.com/browser/devtools/client/framework/test/doc_popups_debugging_popup.html";
const POPUP_DEBUG_PREF = "devtools.popups.debug";
add_task(async function () {
const isPopupDebuggingEnabled = Services.prefs.getBoolPref(POPUP_DEBUG_PREF);
info("Open a tab and debug it");
const tab = await addTab(TEST_URL);
const toolbox = await gDevTools.showToolboxForTab(tab, {
toolId: "webconsole",
});
info("Open a popup");
const onTabOpened = once(gBrowser.tabContainer, "TabOpen");
const onToolboxSwitchedToTab = toolbox.once("switched-host-to-tab");
await SpecialPowers.spawn(tab.linkedBrowser, [POPUP_URL], url => {
content.open(url);
});
const tabOpenEvent = await onTabOpened;
const popupTab = tabOpenEvent.target;
const popupToolbox = await gDevTools.showToolboxForTab(popupTab);
if (isPopupDebuggingEnabled) {
ok(
!popupToolbox,
"When popup debugging is enabled, the popup should be debugged via the same toolbox as the original tab"
);
info("Wait for internal event notifying about the toolbox being moved");
await onToolboxSwitchedToTab;
const browserContainer = gBrowser.getBrowserContainer(
popupTab.linkedBrowser
);
const iframe = browserContainer.querySelector(
".devtools-toolbox-iframe.bottom-host"
);
ok(iframe, "The original tab's toolbox moved to the popup tab");
} else {
ok(popupToolbox, "We were able to spawn a toolbox for the popup");
info("Close the popup toolbox and its tab");
await popupToolbox.destroy();
}
info("Close the popup tab");
gBrowser.removeCurrentTab();
info("Close the original tab toolbox and itself");
await toolbox.destroy();
gBrowser.removeCurrentTab();
});