diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_thisfirefox.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_thisfirefox.js')
-rw-r--r-- | devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_thisfirefox.js | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_thisfirefox.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_thisfirefox.js new file mode 100644 index 0000000000..3f673df758 --- /dev/null +++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_thisfirefox.js @@ -0,0 +1,121 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const EXPECTED_TARGET_PANES = [ + "Tabs", + "Temporary Extensions", + "Extensions", + "Service Workers", + "Shared Workers", + "Other Workers", +]; + +/** + * Check that the This Firefox runtime page contains the expected categories if + * the preference to enable local tab debugging is true. + */ +add_task(async function testThisFirefoxWithLocalTab() { + const { document, tab, window } = await openAboutDebugging({ + enableLocalTabs: true, + }); + await selectThisFirefoxPage(document, window.AboutDebugging.store); + + // Expect all target panes to be displayed including tabs. + await checkThisFirefoxTargetPanes(document, EXPECTED_TARGET_PANES); + + await removeTab(tab); +}); + +/** + * Check that the This Firefox runtime page contains the expected categories if + * the preference to enable local tab debugging is false. + */ +add_task(async function testThisFirefoxWithoutLocalTab() { + const { document, tab, window } = await openAboutDebugging({ + enableLocalTabs: false, + }); + await selectThisFirefoxPage(document, window.AboutDebugging.store); + + // Expect all target panes but tabs to be displayed. + const expectedTargetPanesWithoutTabs = EXPECTED_TARGET_PANES.filter( + p => p !== "Tabs" + ); + await checkThisFirefoxTargetPanes(document, expectedTargetPanesWithoutTabs); + + await removeTab(tab); +}); + +/** + * Check that the tab which is discarded keeps the state after open the aboutdebugging. + */ +add_task(async function testThisFirefoxKeepDiscardedTab() { + const targetTab = await addTab("https://example.com/"); + const blankTab = await addTab("about:blank"); + targetTab.ownerGlobal.gBrowser.discardBrowser(targetTab); + + const { document, tab, window } = await openAboutDebugging({ + enableLocalTabs: false, + }); + await selectThisFirefoxPage(document, window.AboutDebugging.store); + + ok(!targetTab.linkedPanel, "The target tab is still discarded"); + + await removeTab(blankTab); + await removeTab(targetTab); + await removeTab(tab); +}); + +/** + * Check that the Temporary Extensions is hidden if "xpinstall.enabled" is set to false. + */ +add_task(async function testThisFirefoxWithXpinstallDisabled() { + await pushPref("xpinstall.enabled", false); + + const { document, tab, window } = await openAboutDebugging(); + await selectThisFirefoxPage(document, window.AboutDebugging.store); + + // Expect all target panes but temporary extensions to be displayed. + const expectedTargetPanesWithXpinstallDisabled = EXPECTED_TARGET_PANES.filter( + p => p !== "Temporary Extensions" + ); + await checkThisFirefoxTargetPanes( + document, + expectedTargetPanesWithXpinstallDisabled + ); + + await removeTab(tab); +}); + +async function checkThisFirefoxTargetPanes(doc, expectedTargetPanes) { + const win = doc.ownerGlobal; + // Check that the selected sidebar item is "This Firefox"/"This Nightly"/... + const selectedSidebarItem = doc.querySelector(".qa-sidebar-item-selected"); + ok(selectedSidebarItem, "An item is selected in the sidebar"); + + const thisFirefoxString = getThisFirefoxString(win); + is( + selectedSidebarItem.textContent, + thisFirefoxString, + "The selected sidebar item is " + thisFirefoxString + ); + + const paneTitlesEls = doc.querySelectorAll(".qa-debug-target-pane-title"); + is( + paneTitlesEls.length, + expectedTargetPanes.length, + "This Firefox has the expected number of debug target categories" + ); + + const paneTitles = [...paneTitlesEls].map(el => el.textContent); + + for (let i = 0; i < expectedTargetPanes.length; i++) { + const expectedPaneTitle = expectedTargetPanes[i]; + const actualPaneTitle = paneTitles[i]; + ok( + actualPaneTitle.startsWith(expectedPaneTitle), + `Expected debug target category found: ${expectedPaneTitle}` + ); + } +} |