From 8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 20 Jun 2024 06:02:43 +0200 Subject: Merging upstream version 127.0.1. Signed-off-by: Daniel Baumann --- browser/branding/aurora/branding.nsi | 2 +- browser/branding/nightly/branding.nsi | 2 +- browser/branding/official/branding.nsi | 2 +- browser/branding/unofficial/branding.nsi | 2 +- browser/components/BrowserGlue.sys.mjs | 16 ++- .../shopping/ShoppingSidebarChild.sys.mjs | 3 + .../shopping/ShoppingSidebarParent.sys.mjs | 110 ++++++++++++--------- .../shopping/tests/browser/browser_private_mode.js | 62 +++++++++--- browser/config/version.txt | 2 +- browser/config/version_display.txt | 2 +- 10 files changed, 136 insertions(+), 67 deletions(-) (limited to 'browser') diff --git a/browser/branding/aurora/branding.nsi b/browser/branding/aurora/branding.nsi index f3c573733e..682fa9fda5 100644 --- a/browser/branding/aurora/branding.nsi +++ b/browser/branding/aurora/branding.nsi @@ -24,7 +24,7 @@ # The installer's certificate name and issuer expected by the stub installer !define CertNameDownload "Mozilla Corporation" -!define CertIssuerDownload "DigiCert SHA2 Assured ID Code Signing CA" +!define CertIssuerDownload "DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1" # Dialog units are used so the UI displays correctly with the system's DPI # settings. diff --git a/browser/branding/nightly/branding.nsi b/browser/branding/nightly/branding.nsi index b37853b776..636d2f7824 100644 --- a/browser/branding/nightly/branding.nsi +++ b/browser/branding/nightly/branding.nsi @@ -23,7 +23,7 @@ # The installer's certificate name and issuer expected by the stub installer !define CertNameDownload "Mozilla Corporation" -!define CertIssuerDownload "DigiCert SHA2 Assured ID Code Signing CA" +!define CertIssuerDownload "DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1" # Dialog units are used so the UI displays correctly with the system's DPI # settings. diff --git a/browser/branding/official/branding.nsi b/browser/branding/official/branding.nsi index bbdead7e4a..94ffbaa98f 100644 --- a/browser/branding/official/branding.nsi +++ b/browser/branding/official/branding.nsi @@ -28,7 +28,7 @@ # The installer's certificate name and issuer expected by the stub installer !define CertNameDownload "Mozilla Corporation" -!define CertIssuerDownload "DigiCert SHA2 Assured ID Code Signing CA" +!define CertIssuerDownload "DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1" # Dialog units are used so the UI displays correctly with the system's DPI # settings. These are tweaked to look good with the en-US strings; ideally diff --git a/browser/branding/unofficial/branding.nsi b/browser/branding/unofficial/branding.nsi index 1fc5c12d2a..4c52c1d0c0 100644 --- a/browser/branding/unofficial/branding.nsi +++ b/browser/branding/unofficial/branding.nsi @@ -23,7 +23,7 @@ # The installer's certificate name and issuer expected by the stub installer !define CertNameDownload "Mozilla Corporation" -!define CertIssuerDownload "DigiCert SHA2 Assured ID Code Signing CA" +!define CertIssuerDownload "DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1" # Dialog units are used so the UI displays correctly with the system's DPI # settings. 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); }); diff --git a/browser/config/version.txt b/browser/config/version.txt index 4aea959bf8..29810a755b 100644 --- a/browser/config/version.txt +++ b/browser/config/version.txt @@ -1 +1 @@ -127.0 +127.0.1 diff --git a/browser/config/version_display.txt b/browser/config/version_display.txt index 4aea959bf8..29810a755b 100644 --- a/browser/config/version_display.txt +++ b/browser/config/version_display.txt @@ -1 +1 @@ -127.0 +127.0.1 -- cgit v1.2.3