Pier Angelo Vendrame pushed to branch mullvad-browser-140.3.0esr-15.0-1 at The Tor Project / Applications / Mullvad Browser
Commits:
-
22bbf08b
by Pier Angelo Vendrame at 2025-10-08T21:50:39+02:00
-
6aa07685
by Pier Angelo Vendrame at 2025-10-08T21:50:41+02:00
-
c381b8e6
by John M. Schanck at 2025-10-08T21:50:41+02:00
-
ccff7add
by Pier Angelo Vendrame at 2025-10-08T21:50:41+02:00
-
cb4aeda9
by Pier Angelo Vendrame at 2025-10-08T21:50:42+02:00
9 changed files:
- browser/base/content/browser-addons.js
- browser/components/extensions/test/browser/browser-private.toml
- + browser/components/extensions/test/browser/browser_always_on_pbm_prompt.js
- browser/components/search/SearchUIUtils.sys.mjs
- browser/modules/ExtensionsUI.sys.mjs
- modules/libpref/init/StaticPrefList.yaml
- toolkit/components/search/OpenSearchLoader.sys.mjs
- toolkit/components/search/SearchUtils.sys.mjs
- tools/@types/generated/lib.gecko.xpcom.d.ts
Changes:
| ... | ... | @@ -20,7 +20,6 @@ ChromeUtils.defineESModuleGetters(lazy, { |
| 20 | 20 | ExtensionPermissions: "resource://gre/modules/ExtensionPermissions.sys.mjs",
|
| 21 | 21 | OriginControls: "resource://gre/modules/ExtensionPermissions.sys.mjs",
|
| 22 | 22 | PERMISSION_L10N: "resource://gre/modules/ExtensionPermissionMessages.sys.mjs",
|
| 23 | - PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
|
| 24 | 23 | SITEPERMS_ADDON_TYPE:
|
| 25 | 24 | "resource://gre/modules/addons/siteperms-addon-utils.sys.mjs",
|
| 26 | 25 | });
|
| ... | ... | @@ -467,9 +466,7 @@ customElements.define( |
| 467 | 466 | this.notification.options.customElementOptions;
|
| 468 | 467 | |
| 469 | 468 | let checkboxEl = this.ownerDocument.createElement("moz-checkbox");
|
| 470 | - checkboxEl.checked =
|
|
| 471 | - grantPrivateBrowsingAllowed ||
|
|
| 472 | - lazy.PrivateBrowsingUtils.permanentPrivateBrowsing;
|
|
| 469 | + checkboxEl.checked = grantPrivateBrowsingAllowed;
|
|
| 473 | 470 | checkboxEl.addEventListener("change", () => {
|
| 474 | 471 | // NOTE: the popupnotification instances will be reused
|
| 475 | 472 | // and so the callback function is destructured here to
|
| ... | ... | @@ -6,6 +6,8 @@ tags = "webextensions" |
| 6 | 6 | prefs = ["browser.privatebrowsing.autostart=true"]
|
| 7 | 7 | support-files = ["head.js"]
|
| 8 | 8 | |
| 9 | +["browser_always_on_pbm_prompt.js"]
|
|
| 10 | + |
|
| 9 | 11 | ["browser_ext_tabs_cookieStoreId_private.js"]
|
| 10 | 12 | |
| 11 | 13 | ["browser_ext_tabs_newtab_private.js"] |
| 1 | +/* Any copyright is dedicated to the Public Domain.
|
|
| 2 | + http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
| 3 | + |
|
| 4 | +"use strict";
|
|
| 5 | + |
|
| 6 | +const { AddonTestUtils } = ChromeUtils.importESModule(
|
|
| 7 | + "resource://testing-common/AddonTestUtils.sys.mjs"
|
|
| 8 | +);
|
|
| 9 | + |
|
| 10 | +AddonTestUtils.initMochitest(this);
|
|
| 11 | + |
|
| 12 | +const addonId = "test@pbm-checkbox";
|
|
| 13 | +let xpi;
|
|
| 14 | + |
|
| 15 | +async function testCheckbox(allowPbm, expectedCheckboxValue) {
|
|
| 16 | + const readyPromise = AddonTestUtils.promiseWebExtensionStartup(addonId);
|
|
| 17 | + |
|
| 18 | + window.gURLBar.value = xpi.path;
|
|
| 19 | + window.gURLBar.focus();
|
|
| 20 | + EventUtils.synthesizeKey("KEY_Enter", {}, window);
|
|
| 21 | + |
|
| 22 | + const panel = await promisePopupNotificationShown("addon-webext-permissions");
|
|
| 23 | + const checkbox = panel.querySelector(
|
|
| 24 | + "li.webext-perm-privatebrowsing > moz-checkbox"
|
|
| 25 | + );
|
|
| 26 | + ok(checkbox, "We found the PBM checkbox");
|
|
| 27 | + |
|
| 28 | + is(
|
|
| 29 | + checkbox.checked,
|
|
| 30 | + expectedCheckboxValue,
|
|
| 31 | + `We expected the PBM checkbox ${expectedCheckboxValue ? "" : "not "}to be checked for this test case.`
|
|
| 32 | + );
|
|
| 33 | + |
|
| 34 | + if (checkbox.checked != allowPbm) {
|
|
| 35 | + let { promise, resolve } = Promise.withResolvers();
|
|
| 36 | + checkbox.addEventListener("change", resolve, { once: true });
|
|
| 37 | + checkbox.click();
|
|
| 38 | + await promise;
|
|
| 39 | + }
|
|
| 40 | + |
|
| 41 | + is(checkbox.checked, allowPbm, "The checkbox matches allowPbm.");
|
|
| 42 | + |
|
| 43 | + // Accept the installation
|
|
| 44 | + panel.button.click();
|
|
| 45 | + |
|
| 46 | + await readyPromise;
|
|
| 47 | + |
|
| 48 | + let policy = WebExtensionPolicy.getByID(addonId);
|
|
| 49 | + is(
|
|
| 50 | + policy.privateBrowsingAllowed,
|
|
| 51 | + allowPbm,
|
|
| 52 | + `Private browsing permission has ${allowPbm ? "" : "not "}been granted`
|
|
| 53 | + );
|
|
| 54 | +}
|
|
| 55 | + |
|
| 56 | +async function uninstall() {
|
|
| 57 | + const addon = await AddonManager.getAddonByID(addonId);
|
|
| 58 | + await addon.uninstall();
|
|
| 59 | +}
|
|
| 60 | + |
|
| 61 | +add_task(async function () {
|
|
| 62 | + is(
|
|
| 63 | + PrivateBrowsingUtils.permanentPrivateBrowsing,
|
|
| 64 | + true,
|
|
| 65 | + "We are in permanent PBM for this test"
|
|
| 66 | + );
|
|
| 67 | + |
|
| 68 | + xpi = AddonTestUtils.createTempWebExtensionFile({
|
|
| 69 | + manifest: {
|
|
| 70 | + browser_specific_settings: { gecko: { id: addonId } },
|
|
| 71 | + },
|
|
| 72 | + });
|
|
| 73 | + |
|
| 74 | + await BrowserTestUtils.withNewTab({ gBrowser: window.gBrowser }, async () => {
|
|
| 75 | + // First run: install the addon for the first time. We do not let it run in
|
|
| 76 | + // PBM.
|
|
| 77 | + await testCheckbox(false, true);
|
|
| 78 | + // Second run: reinstall the already installed addon, to check the
|
|
| 79 | + // permission denial prevails on being in always-on PBM.
|
|
| 80 | + await testCheckbox(false, false);
|
|
| 81 | + });
|
|
| 82 | + |
|
| 83 | + await uninstall();
|
|
| 84 | + |
|
| 85 | + await BrowserTestUtils.withNewTab({ gBrowser: window.gBrowser }, async () => {
|
|
| 86 | + // Third run: install the addon for the first time, and let it run also in
|
|
| 87 | + // PBM.
|
|
| 88 | + await testCheckbox(true, true);
|
|
| 89 | + // Fourth run: reinstall the already installed addon, to check permission
|
|
| 90 | + // approval is persisted.
|
|
| 91 | + await testCheckbox(true, true);
|
|
| 92 | + });
|
|
| 93 | + |
|
| 94 | + await uninstall();
|
|
| 95 | +}); |
| ... | ... | @@ -184,7 +184,7 @@ export var SearchUIUtils = { |
| 184 | 184 | await Services.search.addOpenSearchEngine(
|
| 185 | 185 | locationURL,
|
| 186 | 186 | image,
|
| 187 | - browsingContext?.originAttributes
|
|
| 187 | + browsingContext?.embedderElement?.contentPrincipal?.originAttributes
|
|
| 188 | 188 | );
|
| 189 | 189 | } catch (ex) {
|
| 190 | 190 | let titleMsgName;
|
| ... | ... | @@ -15,6 +15,7 @@ ChromeUtils.defineESModuleGetters(lazy, { |
| 15 | 15 | AppMenuNotifications: "resource://gre/modules/AppMenuNotifications.sys.mjs",
|
| 16 | 16 | ExtensionData: "resource://gre/modules/Extension.sys.mjs",
|
| 17 | 17 | ExtensionPermissions: "resource://gre/modules/ExtensionPermissions.sys.mjs",
|
| 18 | + PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
|
| 18 | 19 | OriginControls: "resource://gre/modules/ExtensionPermissions.sys.mjs",
|
| 19 | 20 | QuarantinedDomains: "resource://gre/modules/ExtensionPermissions.sys.mjs",
|
| 20 | 21 | });
|
| ... | ... | @@ -413,7 +414,8 @@ export var ExtensionsUI = { |
| 413 | 414 | !!strings.dataCollectionPermissions?.collectsTechnicalAndInteractionData;
|
| 414 | 415 | |
| 415 | 416 | const incognitoPermissionName = "internal:privateBrowsingAllowed";
|
| 416 | - let grantPrivateBrowsingAllowed = false;
|
|
| 417 | + let grantPrivateBrowsingAllowed =
|
|
| 418 | + lazy.PrivateBrowsingUtils.permanentPrivateBrowsing;
|
|
| 417 | 419 | if (showIncognitoCheckbox) {
|
| 418 | 420 | let { permissions } = await lazy.ExtensionPermissions.get(addon.id);
|
| 419 | 421 | grantPrivateBrowsingAllowed = permissions.includes(
|
| ... | ... | @@ -14999,11 +14999,7 @@ |
| 14999 | 14999 | # Has no effect unless security.tls.enable_kyber is true.
|
| 15000 | 15000 | - name: network.http.http3.enable_kyber
|
| 15001 | 15001 | type: RelaxedAtomicBool
|
| 15002 | -#ifdef ANDROID
|
|
| 15003 | - value: @IS_NIGHTLY_BUILD@
|
|
| 15004 | -#else
|
|
| 15005 | 15002 | value: true
|
| 15006 | -#endif
|
|
| 15007 | 15003 | mirror: always
|
| 15008 | 15004 | rust: true
|
| 15009 | 15005 | |
| ... | ... | @@ -17061,11 +17057,7 @@ |
| 17061 | 17057 | |
| 17062 | 17058 | - name: security.tls.enable_kyber
|
| 17063 | 17059 | type: RelaxedAtomicBool
|
| 17064 | -#ifdef ANDROID
|
|
| 17065 | - value: @IS_NIGHTLY_BUILD@
|
|
| 17066 | -#else
|
|
| 17067 | 17060 | value: true
|
| 17068 | -#endif
|
|
| 17069 | 17061 | mirror: always
|
| 17070 | 17062 | rust: true
|
| 17071 | 17063 |
| ... | ... | @@ -98,8 +98,9 @@ const MOZSEARCH_LOCALNAME = "SearchPlugin"; |
| 98 | 98 | * @param {string} [lastModified]
|
| 99 | 99 | * The UTC date when the engine was last updated, if any.
|
| 100 | 100 | * @param {object} [originAttributes]
|
| 101 | - * The first party domain of the site loading that manifest. The domain of the
|
|
| 102 | - * manifest will be used if not provided.
|
|
| 101 | + * The origin attributes of the site loading the manifest. If none are
|
|
| 102 | + * specified, the origin attributes will be formed of the first party domain
|
|
| 103 | + * based on the domain of the manifest.
|
|
| 103 | 104 | * @returns {Promise<OpenSearchProperties>}
|
| 104 | 105 | * The properties of the loaded OpenSearch engine.
|
| 105 | 106 | */
|
| ... | ... | @@ -165,7 +166,8 @@ function loadEngineXML(sourceURI, lastModified, originAttributes = null) { |
| 165 | 166 | sourceURI,
|
| 166 | 167 | // OpenSearchEngine is loading a definition file for a search engine,
|
| 167 | 168 | // TYPE_DOCUMENT captures that load best.
|
| 168 | - Ci.nsIContentPolicy.TYPE_DOCUMENT
|
|
| 169 | + Ci.nsIContentPolicy.TYPE_DOCUMENT,
|
|
| 170 | + originAttributes
|
|
| 169 | 171 | );
|
| 170 | 172 | |
| 171 | 173 | // we collect https telemetry for all top-level (document) loads.
|
| ... | ... | @@ -173,17 +175,6 @@ function loadEngineXML(sourceURI, lastModified, originAttributes = null) { |
| 173 | 175 | ? Ci.nsILoadInfo.ALREADY_HTTPS
|
| 174 | 176 | : Ci.nsILoadInfo.NO_UPGRADE;
|
| 175 | 177 | |
| 176 | - if (!originAttributes) {
|
|
| 177 | - originAttributes = {};
|
|
| 178 | - try {
|
|
| 179 | - originAttributes.firstPartyDomain =
|
|
| 180 | - Services.eTLD.getSchemelessSite(sourceURI);
|
|
| 181 | - } catch (ex) {
|
|
| 182 | - console.error("Failed to get first party domain for the manifest", ex);
|
|
| 183 | - }
|
|
| 184 | - }
|
|
| 185 | - chan.loadInfo.originAttributes = originAttributes;
|
|
| 186 | - |
|
| 187 | 178 | if (lastModified && chan instanceof Ci.nsIHttpChannel) {
|
| 188 | 179 | chan.setRequestHeader("If-Modified-Since", lastModified, false);
|
| 189 | 180 | }
|
| ... | ... | @@ -244,19 +244,34 @@ export var SearchUtils = { |
| 244 | 244 | * The URL string from which to create an nsIChannel.
|
| 245 | 245 | * @param {nsContentPolicyType} contentPolicyType
|
| 246 | 246 | * The type of document being loaded.
|
| 247 | + * @param {object} [originAttributes]
|
|
| 248 | + * The origin attributes to associate to this channel.
|
|
| 247 | 249 | * @returns {nsIChannel}
|
| 248 | 250 | * an nsIChannel object, or null if the url is invalid.
|
| 249 | 251 | */
|
| 250 | - makeChannel(url, contentPolicyType) {
|
|
| 252 | + makeChannel(url, contentPolicyType, originAttributes = null) {
|
|
| 251 | 253 | if (!contentPolicyType) {
|
| 252 | 254 | throw new Error("makeChannel called with invalid content policy type");
|
| 253 | 255 | }
|
| 254 | 256 | try {
|
| 255 | 257 | let uri = typeof url == "string" ? Services.io.newURI(url) : url;
|
| 256 | - let principal =
|
|
| 257 | - uri.scheme == "moz-extension"
|
|
| 258 | - ? Services.scriptSecurityManager.createContentPrincipal(uri, {})
|
|
| 259 | - : Services.scriptSecurityManager.createNullPrincipal({});
|
|
| 258 | + let principal;
|
|
| 259 | + if (uri.scheme == "moz-extension") {
|
|
| 260 | + principal = Services.scriptSecurityManager.createContentPrincipal(
|
|
| 261 | + uri,
|
|
| 262 | + {}
|
|
| 263 | + );
|
|
| 264 | + } else {
|
|
| 265 | + if (!originAttributes) {
|
|
| 266 | + originAttributes = {};
|
|
| 267 | + try {
|
|
| 268 | + originAttributes.firstPartyDomain =
|
|
| 269 | + Services.eTLD.getSchemelessSite(uri);
|
|
| 270 | + } catch {}
|
|
| 271 | + }
|
|
| 272 | + principal =
|
|
| 273 | + Services.scriptSecurityManager.createNullPrincipal(originAttributes);
|
|
| 274 | + }
|
|
| 260 | 275 | |
| 261 | 276 | return Services.io.newChannelFromURI(
|
| 262 | 277 | uri,
|
| ... | ... | @@ -11613,7 +11613,7 @@ interface nsISearchService extends nsISupports, Enums<typeof nsISearchService_Op |
| 11613 | 11613 | readonly hasSuccessfullyInitialized: boolean;
|
| 11614 | 11614 | runBackgroundChecks(): Promise<any>;
|
| 11615 | 11615 | resetToAppDefaultEngine(): void;
|
| 11616 | - addOpenSearchEngine(engineURL: string, iconURL: string): Promise<any>;
|
|
| 11616 | + addOpenSearchEngine(engineURL: string, iconURL: string, originAttributes?: any): Promise<any>;
|
|
| 11617 | 11617 | addUserEngine(formInfo: any): Promise<any>;
|
| 11618 | 11618 | addEnginesFromExtension(extension: any): Promise<any>;
|
| 11619 | 11619 | restoreDefaultEngines(): void;
|