diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/components/reader/test/browser_readerMode_pocket.js | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/reader/test/browser_readerMode_pocket.js')
-rw-r--r-- | toolkit/components/reader/test/browser_readerMode_pocket.js | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/toolkit/components/reader/test/browser_readerMode_pocket.js b/toolkit/components/reader/test/browser_readerMode_pocket.js deleted file mode 100644 index 43426383ff..0000000000 --- a/toolkit/components/reader/test/browser_readerMode_pocket.js +++ /dev/null @@ -1,136 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -// This test verifies that the Save To Pocket button appears in reader mode, -// and is toggled hidden and visible when pocket is disabled and enabled. - -const TEST_PATH = getRootDirectory(gTestPath).replace( - "chrome://mochitests/content", - "http://example.com" -); - -async function getPocketButtonsCount(browser) { - return SpecialPowers.spawn(browser, [], () => { - return content.document.getElementsByClassName("pocket-button").length; - }); -} - -add_task(async function () { - // set the pocket preference before beginning. - await SpecialPowers.pushPrefEnv({ - set: [["extensions.pocket.enabled", true]], - }); - - var readerButton = document.getElementById("reader-mode-button"); - - let tab1 = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - TEST_PATH + "readerModeArticleShort.html" - ); - - let promiseTabLoad = promiseTabLoadEvent(tab1); - readerButton.click(); - await promiseTabLoad; - - let tab2 = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - TEST_PATH + "readerModeArticleMedium.html" - ); - - promiseTabLoad = promiseTabLoadEvent(tab2); - readerButton.click(); - await promiseTabLoad; - - is( - await getPocketButtonsCount(tab1.linkedBrowser), - 1, - "tab 1 has a pocket button" - ); - is( - await getPocketButtonsCount(tab1.linkedBrowser), - 1, - "tab 2 has a pocket button" - ); - - // Turn off the pocket preference. The Save To Pocket buttons should disappear. - await SpecialPowers.pushPrefEnv({ - set: [["extensions.pocket.enabled", false]], - }); - - is( - await getPocketButtonsCount(tab1.linkedBrowser), - 0, - "tab 1 has no pocket button" - ); - is( - await getPocketButtonsCount(tab1.linkedBrowser), - 0, - "tab 2 has no pocket button" - ); - - // Turn on the pocket preference. The Save To Pocket buttons should reappear again. - await SpecialPowers.pushPrefEnv({ - set: [["extensions.pocket.enabled", true]], - }); - - is( - await getPocketButtonsCount(tab1.linkedBrowser), - 1, - "tab 1 has a pocket button again" - ); - is( - await getPocketButtonsCount(tab1.linkedBrowser), - 1, - "tab 2 has a pocket button again" - ); - - BrowserTestUtils.removeTab(tab1); - BrowserTestUtils.removeTab(tab2); -}); - -/** - * Test that the pocket button toggles the pocket popup successfully - */ -add_task(async function () { - await BrowserTestUtils.withNewTab( - TEST_PATH + "readerModeArticleShort.html", - async function (browser) { - let pageShownPromise = BrowserTestUtils.waitForContentEvent( - browser, - "AboutReaderContentReady" - ); - let readerButton = document.getElementById("reader-mode-button"); - readerButton.click(); - await pageShownPromise; - - await SpecialPowers.spawn(browser, [], async function () { - content.document.querySelector(".pocket-button").click(); - }); - let panel = gBrowser.selectedBrowser.ownerDocument.querySelector( - "#customizationui-widget-panel" - ); - await BrowserTestUtils.waitForMutationCondition( - panel, - { attributes: true }, - () => { - return BrowserTestUtils.isVisible(panel); - } - ); - ok(BrowserTestUtils.isVisible(panel), "Panel buttons are visible"); - - await SpecialPowers.spawn(browser, [], async function () { - content.document.querySelector(".pocket-button").click(); - }); - await BrowserTestUtils.waitForMutationCondition( - panel, - { attributes: true }, - () => { - return BrowserTestUtils.isHidden(panel); - } - ); - - ok(BrowserTestUtils.isHidden(panel), "Panel buttons are hidden"); - } - ); -}); |