From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../components/preferences/dialogs/connection.js | 7 +- .../preferences/dialogs/syncChooseWhatToSync.xhtml | 1 - browser/components/preferences/fxaPairDevice.xhtml | 1 - browser/components/preferences/main.inc.xhtml | 14 +++- browser/components/preferences/main.js | 43 ++++++++---- browser/components/preferences/preferences.js | 9 ++- browser/components/preferences/preferences.xhtml | 3 +- browser/components/preferences/privacy.inc.xhtml | 6 ++ browser/components/preferences/privacy.js | 78 +++++++++++++++++----- browser/components/preferences/tests/browser.toml | 5 +- .../preferences/tests/browser_bug731866.js | 9 +++ .../tests/browser_connection_system_wpad.js | 40 +++++++++++ .../preferences/tests/browser_keyboardfocus.js | 36 +++++----- .../preferences/tests/browser_primaryPassword.js | 3 + .../tests/browser_search_quickactions.js | 26 +++++--- 15 files changed, 214 insertions(+), 67 deletions(-) create mode 100644 browser/components/preferences/tests/browser_connection_system_wpad.js (limited to 'browser/components/preferences') diff --git a/browser/components/preferences/dialogs/connection.js b/browser/components/preferences/dialogs/connection.js index 33e8deb279..6d2623d65f 100644 --- a/browser/components/preferences/dialogs/connection.js +++ b/browser/components/preferences/dialogs/connection.js @@ -132,10 +132,11 @@ var gConnectionsDialog = { if ("@mozilla.org/system-proxy-settings;1" in Cc) { document.getElementById("systemPref").removeAttribute("hidden"); - var systemWpadAllowed = Preferences.get( - "network.proxy.system_wpad.allowed" + var systemWpadAllowed = Services.prefs.getBoolPref( + "network.proxy.system_wpad.allowed", + false ); - if (systemWpadAllowed && Services.appinfo.OS == "WINNT") { + if (systemWpadAllowed && AppConstants.platform == "win") { document.getElementById("systemWpad").removeAttribute("hidden"); } } diff --git a/browser/components/preferences/dialogs/syncChooseWhatToSync.xhtml b/browser/components/preferences/dialogs/syncChooseWhatToSync.xhtml index 2b041c4802..83bd09c0c3 100644 --- a/browser/components/preferences/dialogs/syncChooseWhatToSync.xhtml +++ b/browser/components/preferences/dialogs/syncChooseWhatToSync.xhtml @@ -26,7 +26,6 @@ rel="localization" href="browser/preferences/preferences.ftl" /> - + + + + + + { + return new Localization(["branding/brand.ftl", "browser/aboutLogins.ftl"]); +}); + XPCOMUtils.defineLazyServiceGetter( lazy, "gParentalControlsService", @@ -67,13 +71,6 @@ XPCOMUtils.defineLazyServiceGetter( "nsIParentalControlsService" ); -XPCOMUtils.defineLazyPreferenceGetter( - this, - "OS_AUTH_ENABLED", - "signon.management.page.os-auth.enabled", - true -); - XPCOMUtils.defineLazyPreferenceGetter( this, "gIsFirstPartyIsolated", @@ -1053,6 +1050,7 @@ var gPrivacyPane = { this._initPasswordGenerationUI(); this._initRelayIntegrationUI(); this._initMasterPasswordUI(); + this._initOSAuthentication(); this.initListenersForExtensionControllingPasswordManager(); @@ -2863,8 +2861,7 @@ var gPrivacyPane = { // OS reauthenticate functionality is not available on Linux yet (bug 1527745) if ( !LoginHelper.isPrimaryPasswordSet() && - OS_AUTH_ENABLED && - OSKeyStore.canReauth() + LoginHelper.getOSAuthEnabled(LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF) ) { // Uses primary-password-os-auth-dialog-message-win and // primary-password-os-auth-dialog-message-macosx via concatenation: @@ -2961,6 +2958,54 @@ var gPrivacyPane = { this._updateRelayIntegrationUI(); }, + async _toggleOSAuth() { + let osReauthCheckbox = document.getElementById("osReauthCheckbox"); + + const messageText = await lazy.AboutLoginsL10n.formatValue( + "about-logins-os-auth-dialog-message" + ); + const captionText = await lazy.AboutLoginsL10n.formatValue( + "about-logins-os-auth-dialog-caption" + ); + let win = + osReauthCheckbox.ownerGlobal.docShell.chromeEventHandler.ownerGlobal; + + // Calling OSKeyStore.ensureLoggedIn() instead of LoginHelper.verifyOSAuth() + // since we want to authenticate user each time this stting is changed. + let isAuthorized = ( + await OSKeyStore.ensureLoggedIn(messageText, captionText, win, false) + ).authenticated; + if (!isAuthorized) { + osReauthCheckbox.checked = !osReauthCheckbox.checked; + return; + } + + // If osReauthCheckbox is checked enable osauth. + LoginHelper.setOSAuthEnabled( + LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF, + osReauthCheckbox.checked + ); + }, + + _initOSAuthentication() { + let osReauthCheckbox = document.getElementById("osReauthCheckbox"); + if (!OSKeyStore.canReauth()) { + osReauthCheckbox.hidden = true; + return; + } + + osReauthCheckbox.setAttribute( + "checked", + LoginHelper.getOSAuthEnabled(LoginHelper.OS_AUTH_FOR_PASSWORDS_PREF) + ); + + setEventListener( + "osReauthCheckbox", + "command", + gPrivacyPane._toggleOSAuth.bind(gPrivacyPane) + ); + }, + /** * Shows the sites where the user has saved passwords and the associated login * information. @@ -3227,8 +3272,8 @@ var gPrivacyPane = { initDataCollection() { if ( !AppConstants.MOZ_DATA_REPORTING && - !NimbusFeatures.majorRelease2022.getVariable( - "feltPrivacyShowPreferencesSection" + !Services.prefs.getBoolPref( + "browser.privacySegmentation.preferences.show" ) ) { // Nothing to control in the data collection section, remove it. @@ -3255,16 +3300,19 @@ var gPrivacyPane = { // Section visibility let section = document.getElementById("privacySegmentationSection"); let updatePrivacySegmentationSectionVisibilityState = () => { - section.hidden = !NimbusFeatures.majorRelease2022.getVariable( - "feltPrivacyShowPreferencesSection" + section.hidden = !Services.prefs.getBoolPref( + "browser.privacySegmentation.preferences.show" ); }; - NimbusFeatures.majorRelease2022.onUpdate( + Services.prefs.addObserver( + "browser.privacySegmentation.preferences.show", updatePrivacySegmentationSectionVisibilityState ); + window.addEventListener("unload", () => { - NimbusFeatures.majorRelease2022.offUpdate( + Services.prefs.removeObserver( + "browser.privacySegmentation.preferences.show", updatePrivacySegmentationSectionVisibilityState ); }); diff --git a/browser/components/preferences/tests/browser.toml b/browser/components/preferences/tests/browser.toml index 523110dbc9..07d9cc2880 100644 --- a/browser/components/preferences/tests/browser.toml +++ b/browser/components/preferences/tests/browser.toml @@ -72,6 +72,9 @@ skip-if = [ "verify && debug && os == 'mac'", ] +["browser_connection_system_wpad.js"] +run-if = ["os == 'win'"] + ["browser_connection_valid_hostname.js"] ["browser_containers_name_input.js"] @@ -293,4 +296,4 @@ support-files = [ ["browser_warning_permanent_private_browsing.js"] ["browser_windows_launch_on_login.js"] -run-if = ["os == 'win'"] +run-if = ["(os == 'win' && !msix)"] # Disabled for MSIX due to https://bugzilla.mozilla.org/show_bug.cgi?id=1888263 diff --git a/browser/components/preferences/tests/browser_bug731866.js b/browser/components/preferences/tests/browser_bug731866.js index b090535a49..e9ecd08a81 100644 --- a/browser/components/preferences/tests/browser_bug731866.js +++ b/browser/components/preferences/tests/browser_bug731866.js @@ -7,6 +7,9 @@ const browserContainersGroupDisabled = !SpecialPowers.getBoolPref( const cookieBannerHandlingDisabled = !SpecialPowers.getBoolPref( "cookiebanners.ui.desktop.enabled" ); +const backupGroupDisabled = !SpecialPowers.getBoolPref( + "browser.backup.preferences.ui.enabled" +); const updatePrefContainers = ["updatesCategory", "updateApp"]; const updateContainersGroupDisabled = AppConstants.platform === "win" && @@ -60,6 +63,12 @@ function checkElements(expectedPane) { continue; } + // Backup is currently disabled by default. (bug 1895791) + if (element.id == "dataBackupGroup" && backupGroupDisabled) { + is_element_hidden(element, "Disabled dataBackupGroup should be hidden"); + continue; + } + let attributeValue = element.getAttribute("data-category"); let suffix = " (id=" + element.id + ")"; if (attributeValue == "pane" + expectedPane) { diff --git a/browser/components/preferences/tests/browser_connection_system_wpad.js b/browser/components/preferences/tests/browser_connection_system_wpad.js new file mode 100644 index 0000000000..87a3dbebae --- /dev/null +++ b/browser/components/preferences/tests/browser_connection_system_wpad.js @@ -0,0 +1,40 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function test_system_wpad() { + await openPreferencesViaOpenPreferencesAPI("general", { leaveOpen: true }); + const connectionURL = + "chrome://browser/content/preferences/dialogs/connection.xhtml"; + + registerCleanupFunction(function () { + Services.prefs.clearUserPref("network.proxy.system_wpad.allowed"); + }); + + Services.prefs.setBoolPref("network.proxy.system_wpad.allowed", true); + let dialog = await openAndLoadSubDialog(connectionURL); + let dialogElement = dialog.document.getElementById("ConnectionsDialog"); + let systemWpad = dialog.document.getElementById("systemWpad"); + Assert.ok(!systemWpad.hidden, "Use system WPAD checkbox should be visible"); + let dialogClosingPromise = BrowserTestUtils.waitForEvent( + dialogElement, + "dialogclosing" + ); + dialogElement.cancelDialog(); + await dialogClosingPromise; + + Services.prefs.setBoolPref("network.proxy.system_wpad.allowed", false); + dialog = await openAndLoadSubDialog(connectionURL); + dialogElement = dialog.document.getElementById("ConnectionsDialog"); + systemWpad = dialog.document.getElementById("systemWpad"); + Assert.ok(systemWpad.hidden, "Use system WPAD checkbox should be hidden"); + dialogClosingPromise = BrowserTestUtils.waitForEvent( + dialogElement, + "dialogclosing" + ); + dialogElement.cancelDialog(); + await dialogClosingPromise; + + gBrowser.removeCurrentTab(); +}); diff --git a/browser/components/preferences/tests/browser_keyboardfocus.js b/browser/components/preferences/tests/browser_keyboardfocus.js index bed452b679..89576b926a 100644 --- a/browser/components/preferences/tests/browser_keyboardfocus.js +++ b/browser/components/preferences/tests/browser_keyboardfocus.js @@ -13,40 +13,42 @@ add_task(async function () { let checkbox = gBrowser.contentDocument.querySelector( "#useFullKeyboardNavigation" ); - Assert.ok( - !Services.prefs.getIntPref("accessibility.tabfocus", undefined), - "no pref value should exist" + Assert.equal( + Services.prefs.getIntPref("accessibility.tabfocus"), + 7, + "default should be full keyboard access" ); Assert.ok( - !checkbox.checked, - "checkbox should be unchecked before clicking on checkbox" + checkbox.checked, + "checkbox should be checked before clicking on checkbox" ); checkbox.click(); Assert.equal( Services.prefs.getIntPref("accessibility.tabfocus"), - 7, + 1, "Prefstore should reflect checkbox's associated numeric value" ); Assert.ok( - checkbox.checked, - "checkbox should be checked after clicking on checkbox" + !checkbox.checked, + "checkbox should be unchecked after clicking on checkbox" ); checkbox.click(); Assert.ok( - !checkbox.checked, - "checkbox should be unchecked after clicking on checkbox" + checkbox.checked, + "checkbox should be checked after clicking on checkbox" ); - Assert.ok( - !Services.prefs.getIntPref("accessibility.tabfocus", undefined), - "No pref value should exist" + Assert.equal( + Services.prefs.getIntPref("accessibility.tabfocus"), + 7, + "Should restore default value" ); BrowserTestUtils.removeTab(gBrowser.selectedTab); - SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 4]] }); + await SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 4]] }); await launchPreferences(); checkbox = gBrowser.contentDocument.querySelector( "#useFullKeyboardNavigation" @@ -57,20 +59,20 @@ add_task(async function () { "checkbox should stay unchecked after setting non-7 pref value" ); Assert.equal( - Services.prefs.getIntPref("accessibility.tabfocus", 0), + Services.prefs.getIntPref("accessibility.tabfocus"), 4, "pref should have value in store" ); BrowserTestUtils.removeTab(gBrowser.selectedTab); - SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 7]] }); + await SpecialPowers.pushPrefEnv({ set: [["accessibility.tabfocus", 7]] }); await launchPreferences(); checkbox = gBrowser.contentDocument.querySelector( "#useFullKeyboardNavigation" ); Assert.equal( - Services.prefs.getIntPref("accessibility.tabfocus", 0), + Services.prefs.getIntPref("accessibility.tabfocus"), 7, "Pref value should update after modification" ); diff --git a/browser/components/preferences/tests/browser_primaryPassword.js b/browser/components/preferences/tests/browser_primaryPassword.js index 1162ca1290..2c42bd8d91 100644 --- a/browser/components/preferences/tests/browser_primaryPassword.js +++ b/browser/components/preferences/tests/browser_primaryPassword.js @@ -30,6 +30,9 @@ add_task(async function () { isPrimaryPasswordSet() { return primaryPasswordSet; }, + getOSAuthEnabled() { + return true; // Since enabled by default. + }, }; let checkbox = doc.querySelector("#useMasterPassword"); diff --git a/browser/components/preferences/tests/browser_search_quickactions.js b/browser/components/preferences/tests/browser_search_quickactions.js index db938035ae..70799b5002 100644 --- a/browser/components/preferences/tests/browser_search_quickactions.js +++ b/browser/components/preferences/tests/browser_search_quickactions.js @@ -6,26 +6,26 @@ "use strict"; ChromeUtils.defineESModuleGetters(this, { - UrlbarProviderQuickActions: - "resource:///modules/UrlbarProviderQuickActions.sys.mjs", + ActionsProviderQuickActions: + "resource:///modules/ActionsProviderQuickActions.sys.mjs", UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.sys.mjs", }); add_setup(async function setup() { await SpecialPowers.pushPrefEnv({ set: [ - ["browser.urlbar.suggest.quickactions", true], + ["browser.urlbar.secondaryActions.featureGate", true], ["browser.urlbar.quickactions.enabled", true], ], }); - UrlbarProviderQuickActions.addAction("testaction", { + ActionsProviderQuickActions.addAction("testaction", { commands: ["testaction"], label: "quickactions-downloads2", }); registerCleanupFunction(() => { - UrlbarProviderQuickActions.removeAction("testaction"); + ActionsProviderQuickActions.removeAction("testaction"); }); }); @@ -61,15 +61,23 @@ add_task(async function test_show_prefs() { await BrowserTestUtils.removeTab(tab); }); -async function testActionIsShown(window) { +async function testActionIsShown(window, name) { await UrlbarTestUtils.promiseAutocompleteResultPopup({ window, value: "testact", waitForFocus: SimpleTest.waitForFocus, }); try { - let { result } = await UrlbarTestUtils.getDetailsOfResultAt(window, 1); - return result.providerName == "quickactions"; + await BrowserTestUtils.waitForMutationCondition( + window.document, + {}, + () => + !!window.document.querySelector( + `.urlbarView-action-btn[data-action=${name}]` + ) + ); + Assert.ok(true, `We found action "${name}"`); + return true; } catch (e) { return false; } @@ -100,7 +108,7 @@ add_task(async function test_prefs() { }); Assert.ok( - await testActionIsShown(window), + await testActionIsShown(window, "testaction"), "Actions are shown after user clicks checkbox" ); -- cgit v1.2.3