diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-20 04:01:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-20 04:01:56 +0000 |
commit | 350be0cc3025f133a0a81533188c81ac26d624e8 (patch) | |
tree | ce8a294f8c00a3f91a1781428ab72592754ea779 /browser/components/shopping/tests | |
parent | Adding debian version 127.0-1. (diff) | |
download | firefox-350be0cc3025f133a0a81533188c81ac26d624e8.tar.xz firefox-350be0cc3025f133a0a81533188c81ac26d624e8.zip |
Merging upstream version 127.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/shopping/tests')
-rw-r--r-- | browser/components/shopping/tests/browser/browser_private_mode.js | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/browser/components/shopping/tests/browser/browser_private_mode.js b/browser/components/shopping/tests/browser/browser_private_mode.js index 16d7ee733b..9877f4a34b 100644 --- a/browser/components/shopping/tests/browser/browser_private_mode.js +++ b/browser/components/shopping/tests/browser/browser_private_mode.js @@ -3,33 +3,63 @@ "use strict"; -// This test verifies that the shopping sidebar is not initialized if the +// These tests verify that the shopping sidebar is not initialized if the // user visits a shopping product page while in private browsing mode. -add_task(async function test_private_window_disabled() { - let privateWindow = await BrowserTestUtils.openNewBrowserWindow({ - private: true, - }); - - let browser = privateWindow.gBrowser.selectedBrowser; - BrowserTestUtils.startLoadingURIString( - browser, - "https://example.com/product/B09TJGHL5F" - ); - await BrowserTestUtils.browserLoaded(browser); +const PRODUCT_PAGE = "https://example.com/product/Y4YM0Z1LL4"; - let shoppingButton = privateWindow.document.getElementById( - "shopping-sidebar-button" - ); +let verifyButtonNotShown = win => { + let shoppingButton = win.document.getElementById("shopping-sidebar-button"); ok( BrowserTestUtils.isHidden(shoppingButton), "Shopping Button should not be visible on a product page" ); +}; +let verifySidebarNotShown = win => { ok( - !privateWindow.document.querySelector("shopping-sidebar"), + !win.document.querySelector("shopping-sidebar"), "Shopping sidebar does not exist" ); +}; + +add_task(async function test_private_window_disabled() { + let privateWindow = await BrowserTestUtils.openNewBrowserWindow({ + private: true, + }); + + let browser = privateWindow.gBrowser.selectedBrowser; + BrowserTestUtils.startLoadingURIString(browser, PRODUCT_PAGE); + await BrowserTestUtils.browserLoaded(browser); + + verifyButtonNotShown(privateWindow); + verifySidebarNotShown(privateWindow); + + await BrowserTestUtils.closeWindow(privateWindow); +}); + +// If a product page is open in a private window, and the feature is +// preffed on, the sidebar and button should not be shown in the private +// window (bug 1901979). +add_task(async function test_bug_1901979_pref_toggle_private_windows() { + let privateWindow = await BrowserTestUtils.openNewBrowserWindow({ + private: true, + }); + + let browser = privateWindow.gBrowser.selectedBrowser; + BrowserTestUtils.startLoadingURIString(browser, PRODUCT_PAGE); + await BrowserTestUtils.browserLoaded(browser); + + verifyButtonNotShown(privateWindow); + verifySidebarNotShown(privateWindow); + + // Flip the prefs to trigger the bug. + Services.prefs.setBoolPref("browser.shopping.experience2023.enabled", false); + Services.prefs.setBoolPref("browser.shopping.experience2023.enabled", true); + + // Verify we still haven't displayed the button or sidebar. + verifyButtonNotShown(privateWindow); + verifySidebarNotShown(privateWindow); await BrowserTestUtils.closeWindow(privateWindow); }); |