summaryrefslogtreecommitdiffstats
path: root/browser/components
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-20 04:02:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-20 04:02:43 +0000
commit8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd (patch)
tree16a27151176f80644677f4007d17dbd5f4d0f204 /browser/components
parentReleasing progress-linux version 127.0-1~progress7.99u1. (diff)
downloadfirefox-8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd.tar.xz
firefox-8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd.zip
Merging upstream version 127.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components')
-rw-r--r--browser/components/BrowserGlue.sys.mjs16
-rw-r--r--browser/components/shopping/ShoppingSidebarChild.sys.mjs3
-rw-r--r--browser/components/shopping/ShoppingSidebarParent.sys.mjs110
-rw-r--r--browser/components/shopping/tests/browser/browser_private_mode.js62
4 files changed, 130 insertions, 61 deletions
diff --git a/browser/components/BrowserGlue.sys.mjs b/browser/components/BrowserGlue.sys.mjs
index b6ae665df0..81889db040 100644
--- a/browser/components/BrowserGlue.sys.mjs
+++ b/browser/components/BrowserGlue.sys.mjs
@@ -4474,7 +4474,21 @@ BrowserGlue.prototype = {
// This is achieved by converting them into a string pref and encrypting the values
// stored inside it.
- if (!AppConstants.NIGHTLY_BUILD) {
+ // Note: we don't run this on nightly builds and we also do not run this
+ // for users with primary password enabled. That means both these sets of
+ // users will have the features turned on by default. For Nightly this is
+ // an intentional product decision; for primary password this is because
+ // we cannot encrypt the opt-out value without asking for the primary
+ // password, which in turn means we cannot migrate without doing so. It
+ // is also very difficult to postpone this migration because there is no
+ // way to know when the user has put in the primary password. We will
+ // probably reconsider some of this architecture in future, but for now
+ // this is the least-painful method considering the alternatives, cf.
+ // bug 1901899.
+ if (
+ !AppConstants.NIGHTLY_BUILD &&
+ !lazy.LoginHelper.isPrimaryPasswordSet()
+ ) {
const hasRunBetaMigration = Services.prefs
.getCharPref("browser.startup.homepage_override.mstone", "")
.startsWith("127.0");
diff --git a/browser/components/shopping/ShoppingSidebarChild.sys.mjs b/browser/components/shopping/ShoppingSidebarChild.sys.mjs
index ff80086d5d..1ffeb914e3 100644
--- a/browser/components/shopping/ShoppingSidebarChild.sys.mjs
+++ b/browser/components/shopping/ShoppingSidebarChild.sys.mjs
@@ -85,6 +85,9 @@ export class ShoppingSidebarChild extends RemotePageChild {
#product = null;
receiveMessage(message) {
+ if (this.browsingContext.usePrivateBrowsing) {
+ throw new Error("We should never be invoked in PBM.");
+ }
switch (message.name) {
case "ShoppingSidebar:UpdateProductURL":
let { url, isReload } = message.data;
diff --git a/browser/components/shopping/ShoppingSidebarParent.sys.mjs b/browser/components/shopping/ShoppingSidebarParent.sys.mjs
index a7733c9a28..e0208a818d 100644
--- a/browser/components/shopping/ShoppingSidebarParent.sys.mjs
+++ b/browser/components/shopping/ShoppingSidebarParent.sys.mjs
@@ -43,6 +43,9 @@ export class ShoppingSidebarParent extends JSWindowActorParent {
}
async receiveMessage(message) {
+ if (this.browsingContext.usePrivateBrowsing) {
+ throw new Error("We should never be invoked in PBM.");
+ }
switch (message.name) {
case "GetProductURL":
let sidebarBrowser = this.browsingContext.top.embedderElement;
@@ -168,6 +171,12 @@ class ShoppingSidebarManagerClass {
#initialized = false;
#everyWindowCallbackId = `shopping-${Services.uuid.generateUUID()}`;
+ // Public API methods - these check that we are not in private browsing
+ // mode. (It might be nice to eventually shift pref checks to the public
+ // API, too.)
+ //
+ // Note that any refactoring should preserve the PBM checks in public APIs.
+
ensureInitialized() {
if (this.#initialized) {
return;
@@ -220,6 +229,10 @@ class ShoppingSidebarManagerClass {
this.enabled = lazy.NimbusFeatures.shopping2023.getVariable("enabled");
for (let window of lazy.BrowserWindowTracker.orderedWindows) {
+ let isPBM = lazy.PrivateBrowsingUtils.isWindowPrivate(window);
+ if (isPBM) {
+ continue;
+ }
this.updateSidebarVisibilityForWindow(window);
}
}
@@ -233,6 +246,11 @@ class ShoppingSidebarManagerClass {
return;
}
+ let isPBM = lazy.PrivateBrowsingUtils.isWindowPrivate(window);
+ if (isPBM) {
+ return;
+ }
+
let document = window.document;
if (!this.isActive) {
@@ -254,6 +272,54 @@ class ShoppingSidebarManagerClass {
this._maybeToggleSidebar(selectedBrowser, currentURI, 0, false);
}
+ /**
+ * Called by TabsProgressListener whenever any browser navigates from one
+ * URL to another.
+ * Note that this includes hash changes / pushState navigations, because
+ * those can be significant for us.
+ */
+ onLocationChange(aBrowser, aLocationURI, aFlags) {
+ let isPBM = lazy.PrivateBrowsingUtils.isWindowPrivate(aBrowser.ownerGlobal);
+ if (isPBM) {
+ return;
+ }
+
+ lazy.ShoppingUtils.onLocationChange(aLocationURI, aFlags);
+
+ this._maybeToggleButton(aBrowser.getTabBrowser());
+ this._maybeToggleSidebar(aBrowser, aLocationURI, aFlags, true);
+ }
+
+ handleEvent(event) {
+ switch (event.type) {
+ case "TabSelect": {
+ if (!this.enabled) {
+ return;
+ }
+ this.updateSidebarVisibility();
+ if (event.detail?.previousTab.linkedBrowser) {
+ this._updateBCActiveness(event.detail.previousTab.linkedBrowser);
+ }
+ break;
+ }
+ case "visibilitychange": {
+ if (!this.enabled) {
+ return;
+ }
+ let { gBrowser } = event.target.ownerGlobal.top;
+ if (!gBrowser) {
+ return;
+ }
+ this.updateSidebarVisibilityForWindow(event.target.ownerGlobal.top);
+ this._updateBCActiveness(gBrowser.selectedBrowser);
+ }
+ }
+ }
+
+ // Private API methods - these assume we are not in private browsing
+ // mode. (It might be nice to eventually shift pref checks to the public
+ // API, too.)
+
_maybeToggleSidebar(aBrowser, aLocationURI, aFlags, aIsNavigation) {
let gBrowser = aBrowser.getTabBrowser();
let document = aBrowser.ownerDocument;
@@ -380,50 +446,6 @@ class ShoppingSidebarManagerClass {
: "shopping-sidebar-open-button2";
document.l10n.setAttributes(button, l10nId);
}
-
- /**
- * Called by TabsProgressListener whenever any browser navigates from one
- * URL to another.
- * Note that this includes hash changes / pushState navigations, because
- * those can be significant for us.
- */
- onLocationChange(aBrowser, aLocationURI, aFlags) {
- let isPBM = lazy.PrivateBrowsingUtils.isWindowPrivate(aBrowser.ownerGlobal);
- if (isPBM) {
- return;
- }
-
- lazy.ShoppingUtils.onLocationChange(aLocationURI, aFlags);
-
- this._maybeToggleButton(aBrowser.getTabBrowser());
- this._maybeToggleSidebar(aBrowser, aLocationURI, aFlags, true);
- }
-
- handleEvent(event) {
- switch (event.type) {
- case "TabSelect": {
- if (!this.enabled) {
- return;
- }
- this.updateSidebarVisibility();
- if (event.detail?.previousTab.linkedBrowser) {
- this._updateBCActiveness(event.detail.previousTab.linkedBrowser);
- }
- break;
- }
- case "visibilitychange": {
- if (!this.enabled) {
- return;
- }
- let { gBrowser } = event.target.ownerGlobal.top;
- if (!gBrowser) {
- return;
- }
- this.updateSidebarVisibilityForWindow(event.target.ownerGlobal.top);
- this._updateBCActiveness(gBrowser.selectedBrowser);
- }
- }
- }
}
const ShoppingSidebarManager = new ShoppingSidebarManagerClass();
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);
});