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 /browser/components/pocket/test/browser_pocket_home_panel.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 'browser/components/pocket/test/browser_pocket_home_panel.js')
-rw-r--r-- | browser/components/pocket/test/browser_pocket_home_panel.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/browser/components/pocket/test/browser_pocket_home_panel.js b/browser/components/pocket/test/browser_pocket_home_panel.js new file mode 100644 index 0000000000..d58f3e44c7 --- /dev/null +++ b/browser/components/pocket/test/browser_pocket_home_panel.js @@ -0,0 +1,53 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +add_task(async function () { + // The recent saves feature makes an external call to api.getpocket.com. + // External calls are not permitted in tests. + // however, we're not testing the content of the panel, + // we're just testing that the right panel is used for certain urls, + // so we can turn recent saves off for this test. + await SpecialPowers.pushPrefEnv({ + set: [["extensions.pocket.refresh.hideRecentSaves.enabled", true]], + }); + // Home panel is used on about: pages, so we use about:robots to test. + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:robots" + ); + + const stub = sinon.stub(pktApi, "isUserLoggedIn").callsFake(() => true); + + info("clicking on pocket button in toolbar"); + let pocketButton = document.getElementById("save-to-pocket-button"); + // The panel is created on the fly, so we can't simply wait for focus + // inside it. + let pocketPanelShowing = BrowserTestUtils.waitForEvent( + document, + "popupshowing", + true + ); + pocketButton.click(); + await pocketPanelShowing; + + let pocketPanel = document.getElementById("customizationui-widget-panel"); + let pocketFrame = pocketPanel.querySelector("browser"); + + await TestUtils.waitForCondition( + () => pocketFrame.src.startsWith("about:pocket-home?"), + "pocket home panel is showing" + ); + + info("closing pocket panel"); + let pocketPanelHidden = BrowserTestUtils.waitForEvent( + pocketPanel, + "popuphidden" + ); + pocketPanel.hidePopup(); + await pocketPanelHidden; + checkElements(false, ["customizationui-widget-panel"]); + + stub.restore(); + BrowserTestUtils.removeTab(tab); +}); |