diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /toolkit/mozapps/extensions | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions')
17 files changed, 204 insertions, 58 deletions
diff --git a/toolkit/mozapps/extensions/AddonManager.sys.mjs b/toolkit/mozapps/extensions/AddonManager.sys.mjs index e4e51885cf..c69cf4029e 100644 --- a/toolkit/mozapps/extensions/AddonManager.sys.mjs +++ b/toolkit/mozapps/extensions/AddonManager.sys.mjs @@ -1610,10 +1610,10 @@ var AddonManagerInternal = { // Temporary hack until bug 520124 lands. // We can get here during synchronous startup, at which point it's - // considered unsafe (and therefore disallowed by AddonManager.jsm) to + // considered unsafe (and therefore disallowed by AddonManager.sys.mjs) to // access providers that haven't been initialized yet. Since this is when // XPIProvider is starting up, XPIProvider can't access itself via APIs - // going through AddonManager.jsm. Thankfully, this is the only use + // going through AddonManager.sys.mjs. Thankfully, this is the only use // of this API, and we know it's safe to use this API with both // providers; so we have this hack to allow bypassing the normal // safetey guard. diff --git a/toolkit/mozapps/extensions/content/aboutaddons.css b/toolkit/mozapps/extensions/content/aboutaddons.css index 3f4e80797a..2f5157bea3 100644 --- a/toolkit/mozapps/extensions/content/aboutaddons.css +++ b/toolkit/mozapps/extensions/content/aboutaddons.css @@ -643,12 +643,18 @@ panel-item[action="report"]::part(button) { text-decoration: none; } -.inline-options-stack { - /* If the options browser triggers an alert we need room to show it. */ - min-height: 250px; +.addon-inline-options { width: 100%; background-color: white; margin-block: 4px; + /* + * Makes sure the browser minimal height is going to be the same as when + * this browser element was wrapper in a stack and a min-height was necessary + * for the prompts to fit inside the browser element. + * That stack element has been removed as part of Bug 1881055, but keeping + * the min-height unchanged to avoid potential regressions in the short term. + */ + min-height: 250px; } addon-permissions-list > .addon-detail-row { diff --git a/toolkit/mozapps/extensions/content/aboutaddons.js b/toolkit/mozapps/extensions/content/aboutaddons.js index 37687a8be7..39c4656210 100644 --- a/toolkit/mozapps/extensions/content/aboutaddons.js +++ b/toolkit/mozapps/extensions/content/aboutaddons.js @@ -1423,10 +1423,23 @@ class SidebarFooter extends HTMLElement { labelL10nId: "addons-settings-button", onClick: e => { e.preventDefault(); - windowRoot.ownerGlobal.switchToTabHavingURI("about:preferences", true, { - ignoreFragment: "whenComparing", - triggeringPrincipal: systemPrincipal, - }); + let hasAboutSettings = windowRoot.ownerGlobal.switchToTabHavingURI( + "about:settings", + false, + { + ignoreFragment: "whenComparing", + } + ); + if (!hasAboutSettings) { + windowRoot.ownerGlobal.switchToTabHavingURI( + "about:preferences", + true, + { + ignoreFragment: "whenComparing", + triggeringPrincipal: systemPrincipal, + } + ); + } }, }); @@ -1695,6 +1708,7 @@ class InlineOptionsBrowser extends HTMLElement { browser.setAttribute("disableglobalhistory", "true"); browser.setAttribute("messagemanagergroup", "webext-browsers"); browser.setAttribute("id", "addon-inline-options"); + browser.setAttribute("class", "addon-inline-options"); browser.setAttribute("transparent", "true"); browser.setAttribute("forcemessagemanager", "true"); browser.setAttribute("autocompletepopup", "PopupAutoComplete"); @@ -1731,10 +1745,7 @@ class InlineOptionsBrowser extends HTMLElement { readyPromise = promiseEvent("load", browser, true); } - let stack = document.createXULElement("stack"); - stack.classList.add("inline-options-stack"); - stack.appendChild(browser); - this.appendChild(stack); + this.appendChild(browser); this.browser = browser; // Force bindings to apply synchronously. diff --git a/toolkit/mozapps/extensions/content/aboutaddonsCommon.js b/toolkit/mozapps/extensions/content/aboutaddonsCommon.js index 739e7629d7..9315e35861 100644 --- a/toolkit/mozapps/extensions/content/aboutaddonsCommon.js +++ b/toolkit/mozapps/extensions/content/aboutaddonsCommon.js @@ -237,7 +237,11 @@ async function installAddonsFromFilePicker() { ]); const nsIFilePicker = Ci.nsIFilePicker; var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); - fp.init(window, dialogTitle.value, nsIFilePicker.modeOpenMultiple); + fp.init( + window.browsingContext, + dialogTitle.value, + nsIFilePicker.modeOpenMultiple + ); try { fp.appendFilter(filterName.value, "*.xpi;*.jar;*.zip"); fp.appendFilters(nsIFilePicker.filterAll); diff --git a/toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs b/toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs index e854e04b3c..e53e4af7a4 100644 --- a/toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs +++ b/toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs @@ -78,7 +78,7 @@ import { Log } from "resource://gre/modules/Log.sys.mjs"; const LOGGER_ID = "addons.repository"; // Create a new logger for use by the Addons Repository -// (Requires AddonManager.jsm) +// (Requires AddonManager.sys.mjs) var logger = Log.repository.getLogger(LOGGER_ID); function convertHTMLToPlainText(html) { diff --git a/toolkit/mozapps/extensions/internal/AddonTestUtils.sys.mjs b/toolkit/mozapps/extensions/internal/AddonTestUtils.sys.mjs index 7b30daa0e2..f53d32092d 100644 --- a/toolkit/mozapps/extensions/internal/AddonTestUtils.sys.mjs +++ b/toolkit/mozapps/extensions/internal/AddonTestUtils.sys.mjs @@ -298,7 +298,7 @@ export var AddonTestUtils = { // And scan for changes at startup Services.prefs.setIntPref("extensions.startupScanScopes", 15); - // By default, don't cache add-ons in AddonRepository.jsm + // By default, don't cache add-ons in AddonRepository.sys.mjs Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", false); // Point update checks to the local machine for fast failures @@ -567,7 +567,7 @@ export var AddonTestUtils = { }, overrideCertDB() { - let verifyCert = async (file, result, cert, callback) => { + let verifyCert = async (file, result, signatureInfos, callback) => { if ( result == Cr.NS_ERROR_SIGNED_JAR_NOT_SIGNED && !this.useRealCertChecks && @@ -606,7 +606,16 @@ export var AddonTestUtils = { }; } - return [callback, Cr.NS_OK, fakeCert]; + return [ + callback, + Cr.NS_OK, + [ + { + signerCert: fakeCert, + signatureAlgorithm: Ci.nsIAppSignatureInfo.COSE_WITH_SHA256, + }, + ], + ]; } catch (e) { // If there is any error then just pass along the original results } finally { @@ -621,7 +630,7 @@ export var AddonTestUtils = { } } - return [callback, result, cert]; + return [callback, result, signatureInfos]; }; let FakeCertDB = { @@ -644,10 +653,14 @@ export var AddonTestUtils = { this._genuine.openSignedAppFileAsync( root, file, - (result, zipReader, cert) => { - verifyCert(file.clone(), result, cert, callback).then( - ([callback, result, cert]) => { - callback.openSignedAppFileFinished(result, zipReader, cert); + (result, zipReader, signatureInfos) => { + verifyCert(file.clone(), result, signatureInfos, callback).then( + ([callback, result, signatureInfos]) => { + callback.openSignedAppFileFinished( + result, + zipReader, + signatureInfos + ); } ); } @@ -1730,7 +1743,7 @@ export var AddonTestUtils = { * @param {object} extension * The return value of ExtensionTestUtils.loadExtension. * For browser tests, see mochitest/tests/SimpleTest/ExtensionTestUtils.js - * For xpcshell tests, see toolkit/components/extensions/ExtensionXPCShellUtils.jsm + * For xpcshell tests, see toolkit/components/extensions/ExtensionXPCShellUtils.sys.mjs * @param {object} [options] * Optional options. * @param {boolean} [options.expectPending = false] diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.sys.mjs b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.sys.mjs index a3935a26f9..5b7b10a764 100644 --- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.sys.mjs +++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.sys.mjs @@ -26,7 +26,7 @@ import { Log } from "resource://gre/modules/Log.sys.mjs"; const LOGGER_ID = "addons.update-checker"; // Create a new logger for use by the Addons Update Checker -// (Requires AddonManager.jsm) +// (Requires AddonManager.sys.mjs) var logger = Log.repository.getLogger(LOGGER_ID); /** diff --git a/toolkit/mozapps/extensions/internal/SitePermsAddonProvider.sys.mjs b/toolkit/mozapps/extensions/internal/SitePermsAddonProvider.sys.mjs index ccac484a1e..7ca952dc8a 100644 --- a/toolkit/mozapps/extensions/internal/SitePermsAddonProvider.sys.mjs +++ b/toolkit/mozapps/extensions/internal/SitePermsAddonProvider.sys.mjs @@ -148,20 +148,30 @@ class SitePermsAddonWrapper { }); } - get creator() {} + get creator() { + return undefined; + } - get homepageURL() {} + get homepageURL() { + return undefined; + } - get description() {} + get description() { + return undefined; + } - get fullDescription() {} + get fullDescription() { + return undefined; + } get version() { // We consider the previous implementation attempt (signed addons) to be the initial version, // hence the 2.0 for this approach. return "2.0"; } - get updateDate() {} + get updateDate() { + return undefined; + } get isActive() { return true; @@ -273,8 +283,6 @@ class SitePermsAddonWrapper { } class SitePermsAddonInstalling extends SitePermsAddonWrapper { - #install = null; - /** * @param {string} siteOriginNoSuffix: The origin this addon is installed * for, WITHOUT the suffix generated from @@ -293,7 +301,6 @@ class SitePermsAddonInstalling extends SitePermsAddonWrapper { }; super(siteOriginNoSuffix, [permission]); - this.#install = install; } get existingAddon() { diff --git a/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs b/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs index 5d1d2c1970..af0b02444a 100644 --- a/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs +++ b/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs @@ -117,7 +117,7 @@ const nsIFile = Components.Constructor( ); // Create a new logger for use by the Addons XPI Provider Utils -// (Requires AddonManager.jsm) +// (Requires AddonManager.sys.mjs) var logger = Log.repository.getLogger(LOGGER_ID); const FILE_JSON_DB = "extensions.json"; diff --git a/toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs b/toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs index 1a80407ad2..0402c2f2ca 100644 --- a/toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs +++ b/toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs @@ -99,6 +99,17 @@ const PREF_SELECTED_THEME = "extensions.activeThemeID"; const TOOLKIT_ID = "toolkit@mozilla.org"; +ChromeUtils.defineLazyGetter(lazy, "MOZ_UNSIGNED_SCOPES", () => { + let result = 0; + if (AppConstants.MOZ_UNSIGNED_APP_SCOPE) { + result |= AddonManager.SCOPE_APPLICATION; + } + if (AppConstants.MOZ_UNSIGNED_SYSTEM_SCOPE) { + result |= AddonManager.SCOPE_SYSTEM; + } + return result; +}); + /** * Returns a nsIFile instance for the given path, relative to the given * base file, if provided. @@ -168,7 +179,7 @@ import { Log } from "resource://gre/modules/Log.sys.mjs"; const LOGGER_ID = "addons.xpi"; // Create a new logger for use by all objects in this Addons XPI Provider module -// (Requires AddonManager.jsm) +// (Requires AddonManager.sys.mjs) var logger = Log.repository.getLogger(LOGGER_ID); // Stores the ID of the theme which was selected during the last session, @@ -316,13 +327,22 @@ XPIPackage = class XPIPackage extends Package { verifySignedStateForRoot(addonId, root) { return new Promise(resolve => { let callback = { - openSignedAppFileFinished(aRv, aZipReader, aCert) { + openSignedAppFileFinished(aRv, aZipReader, aSignatureInfos) { + // aSignatureInfos is an array of nsIAppSignatureInfo. + // In the future, this code can iterate through the array to + // determine if one of the verified signatures used a satisfactory + // algorithm and signing certificate. + // For now, any verified signature is acceptable. + let cert; + if (aRv == Cr.NS_OK && aSignatureInfos.length) { + cert = aSignatureInfos[0].signerCert; + } if (aZipReader) { aZipReader.close(); } resolve({ - signedState: getSignedStatus(aRv, aCert, addonId), - cert: aCert, + signedState: getSignedStatus(aRv, cert, addonId), + cert, }); }, }; @@ -872,10 +892,7 @@ function shouldVerifySignedState(aAddonType, aLocation) { return true; } - if ( - aLocation.isBuiltin || - aLocation.scope & AppConstants.MOZ_UNSIGNED_SCOPES - ) { + if (aLocation.isBuiltin || aLocation.scope & lazy.MOZ_UNSIGNED_SCOPES) { return false; } diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.sys.mjs b/toolkit/mozapps/extensions/internal/XPIProvider.sys.mjs index d5ffd06d11..12d4fa1172 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.sys.mjs +++ b/toolkit/mozapps/extensions/internal/XPIProvider.sys.mjs @@ -185,7 +185,7 @@ import { Log } from "resource://gre/modules/Log.sys.mjs"; const LOGGER_ID = "addons.xpi"; // Create a new logger for use by all objects in this Addons XPI Provider module -// (Requires AddonManager.jsm) +// (Requires AddonManager.sys.mjs) var logger = Log.repository.getLogger(LOGGER_ID); /** diff --git a/toolkit/mozapps/extensions/test/browser/browser.toml b/toolkit/mozapps/extensions/test/browser/browser.toml index 1daf6211f8..0b4a2d8f0a 100644 --- a/toolkit/mozapps/extensions/test/browser/browser.toml +++ b/toolkit/mozapps/extensions/test/browser/browser.toml @@ -156,6 +156,8 @@ https_first_disabled = true ["browser_sidebar_hidden_categories.js"] +["browser_sidebar_preferences_button.js"] + ["browser_sidebar_restore_category.js"] ["browser_subframe_install.js"] diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_options_ui.js b/toolkit/mozapps/extensions/test/browser/browser_html_options_ui.js index c5bfa1022f..efe28cf218 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_html_options_ui.js +++ b/toolkit/mozapps/extensions/test/browser/browser_html_options_ui.js @@ -115,13 +115,7 @@ add_task(async function testInlineOptions() { "The browser has the expected options URL" ); is(url, card.addon.optionsURL, "Browser has the expected options URL loaded"); - let stack = browser.closest("stack"); - is( - browser.clientWidth, - stack.clientWidth, - "Browser should be the same width as its direct parent" - ); - Assert.greater(stack.clientWidth, 0, "The stack has a width"); + Assert.greater(browser.clientWidth, 0, "The browser has a width"); ok( card.querySelector('[action="preferences"]').hidden, "The preferences option is hidden now" @@ -163,8 +157,7 @@ add_task(async function testInlineOptions() { info("Switch back, check browser is shown"); prefsBtn.click(); - is(browser.clientWidth, stack.clientWidth, "The browser width is set again"); - Assert.greater(stack.clientWidth, 0, "The stack has a width"); + Assert.greater(browser.clientWidth, 0, "The browser has a width"); await closeView(win); await extension.unload(); diff --git a/toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js b/toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js index 5007731927..7bc7c08345 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js +++ b/toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js @@ -5,7 +5,7 @@ // Tests bug 567127 - Add install button to the add-ons manager var MockFilePicker = SpecialPowers.MockFilePicker; -MockFilePicker.init(window); +MockFilePicker.init(window.browsingContext); async function checkInstallConfirmation(...names) { let notificationCount = 0; diff --git a/toolkit/mozapps/extensions/test/browser/browser_sidebar_preferences_button.js b/toolkit/mozapps/extensions/test/browser/browser_sidebar_preferences_button.js new file mode 100644 index 0000000000..91a631bca2 --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_sidebar_preferences_button.js @@ -0,0 +1,73 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +add_task(async function testNoOtherTabsPresent() { + let addonsWin = await loadInitialView("extension"); + let preferencesButton = + addonsWin.document.querySelector("#preferencesButton"); + + let preferencesPromise = BrowserTestUtils.waitForNewTab( + gBrowser, + "about:preferences" + ); + + preferencesButton.click(); + + let preferencesTab = await preferencesPromise; + + is( + gBrowser.currentURI.spec, + "about:preferences", + "about:preferences should open if neither it nor about:settings are present" + ); + + gBrowser.removeTab(preferencesTab); + + await closeView(addonsWin); +}); + +async function ensurePreferencesButtonFocusesTab(expectedUri) { + let addonsWin = await loadInitialView("extension"); + let preferencesButton = + addonsWin.document.querySelector("#preferencesButton"); + + let tabCountBeforeClick = gBrowser.tabCount; + preferencesButton.click(); + let tabCountAfterClick = gBrowser.tabCount; + + is( + tabCountAfterClick, + tabCountBeforeClick, + "preferences button should not open new tabs" + ); + is( + gBrowser.currentURI.spec, + expectedUri, + "the correct tab should be focused" + ); + + addonsWin.focus(); + await closeView(addonsWin); +} + +add_task(async function testAboutPreferencesPresent() { + await BrowserTestUtils.withNewTab("about:preferences", async () => { + await ensurePreferencesButtonFocusesTab("about:preferences"); + }); +}); + +add_task(async function testAboutSettingsPresent() { + await BrowserTestUtils.withNewTab("about:settings", async () => { + await ensurePreferencesButtonFocusesTab("about:settings"); + }); +}); + +add_task(async function testAboutSettingsAndPreferencesPresent() { + await BrowserTestUtils.withNewTab("about:settings", async () => { + await BrowserTestUtils.withNewTab("about:preferences", async () => { + await ensurePreferencesButtonFocusesTab("about:settings"); + }); + }); +}); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js index 727c643763..33e81c13bd 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js @@ -196,7 +196,7 @@ add_task(async function test_after_corruption() { await Assert.rejects( promiseShutdownManager(), - /NotAllowedError: Could not open the file at .+ for writing/ + /NotAllowedError: Could not write to `.+'/ ); }); @@ -211,6 +211,6 @@ add_task(async function test_after_second_restart() { await Assert.rejects( promiseShutdownManager(), - /NotAllowedError: Could not open the file at .+ for writing/ + /NotAllowedError: Could not write to `.+'/ ); }); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js index d36b97a3cc..e25890515f 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_update_enterprisepolicy.js @@ -44,12 +44,32 @@ const TEST_CONDITIONS = { add_task(async function test_update_disabled_by_policy() { await setupSystemAddonConditions(TEST_CONDITIONS, distroDir); + const TEST_POLICY_DATA = { + DisableSystemAddonUpdate: true, + }; await EnterprisePolicyTesting.setupPolicyEngineWithJson({ - policies: { - DisableSystemAddonUpdate: true, - }, + policies: TEST_POLICY_DATA, }); + Assert.deepEqual( + Services.policies.getActivePolicies(), + TEST_POLICY_DATA, + "Got the expected test policy data as the active policy " + + "(if this assertions fails, check your system for enterprise policies installed at system level)" + ); + + Assert.equal( + Services.policies.isAllowed("SysAddonUpdate"), + false, + "Expected SysAddonUpdate feature to be disabled by policies" + ); + + Assert.equal( + Services.prefs.getBoolPref("extensions.systemAddon.update.enabled"), + true, + "Expected system addon updates to not be already disabled through prefs" + ); + await updateAllSystemAddons( buildSystemAddonUpdates([ { |