Pier Angelo Vendrame pushed to branch tor-browser-140.3.0esr-15.0-1 at The Tor Project / Applications / Tor Browser

Commits:

4 changed files:

Changes:

  • browser/base/content/browser-addons.js
    ... ... @@ -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
    

  • browser/components/extensions/test/browser/browser-private.toml
    ... ... @@ -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"]

  • browser/components/extensions/test/browser/browser_always_on_pbm_prompt.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
    +});

  • browser/modules/ExtensionsUI.sys.mjs
    ... ... @@ -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(