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

Commits:

2 changed files:

Changes:

  • browser/components/resistfingerprinting/test/browser/browser_bug1975753_site_specific_zoom_level.js
    ... ... @@ -3,10 +3,14 @@
    3 3
     const PATH_NET = TEST_PATH + "file_dummy.html";
    
    4 4
     const PATH_ORG = PATH_NET.replace("example.net", "example.org");
    
    5 5
     
    
    6
    -add_task(async function () {
    
    6
    +async function runTest(defaultZoom) {
    
    7 7
       let tab1, tab1Zoom;
    
    8 8
     
    
    9 9
       tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
    
    10
    +
    
    11
    +  tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
    
    12
    +  is(tab1Zoom, defaultZoom, "We are starting with the default zoom.");
    
    13
    +
    
    10 14
       await FullZoom.setZoom(1.25, tab1.linkedBrowser);
    
    11 15
       tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
    
    12 16
     
    
    ... ... @@ -46,7 +50,7 @@ add_task(async function () {
    46 50
     
    
    47 51
       is(
    
    48 52
         tab1Zoom,
    
    49
    -    1.0,
    
    53
    +    defaultZoom,
    
    50 54
         "privacy.resistFingerprinting is true, site-specific zoom should be reset when clearing FPP state for tab1"
    
    51 55
       );
    
    52 56
     
    
    ... ... @@ -55,4 +59,29 @@ add_task(async function () {
    55 59
       BrowserTestUtils.removeTab(tab1);
    
    56 60
     
    
    57 61
       await SpecialPowers.popPrefEnv();
    
    62
    +}
    
    63
    +
    
    64
    +add_task(async function () {
    
    65
    +  await runTest(1.0);
    
    66
    +
    
    67
    +  let defaultZoom = 1.5;
    
    68
    +  let context = Cu.createLoadContext();
    
    69
    +  let cps2 = Cc["@mozilla.org/content-pref/service;1"].getService(
    
    70
    +    Ci.nsIContentPrefService2
    
    71
    +  );
    
    72
    +  let { promise, resolve, reject } = Promise.withResolvers();
    
    73
    +  cps2.setGlobal(FullZoom.name, defaultZoom, context, {
    
    74
    +    handleError(error) {
    
    75
    +      reject(error);
    
    76
    +    },
    
    77
    +    handleCompletion() {
    
    78
    +      resolve();
    
    79
    +    },
    
    80
    +  });
    
    81
    +  await promise;
    
    82
    +  try {
    
    83
    +    await runTest(defaultZoom);
    
    84
    +  } finally {
    
    85
    +    cps2.removeGlobal(FullZoom.name, context);
    
    86
    +  }
    
    58 87
     });

  • toolkit/components/cleardata/ClearDataService.sys.mjs
    ... ... @@ -415,11 +415,7 @@ const CookieBannerExecutedRecordCleaner = {
    415 415
     
    
    416 416
     // A cleaner for cleaning fingerprinting protection states.
    
    417 417
     const FingerprintingProtectionStateCleaner = {
    
    418
    -  async _maybeClearSiteSpecificZoom(
    
    419
    -    deleteAll,
    
    420
    -    aSchemelessSite,
    
    421
    -    aOriginAttributes = {}
    
    422
    -  ) {
    
    418
    +  async _maybeClearSiteSpecificZoom(aSchemelessSite, aOriginAttributes = {}) {
    
    423 419
         if (
    
    424 420
           !ChromeUtils.shouldResistFingerprinting("SiteSpecificZoom", null, true)
    
    425 421
         ) {
    
    ... ... @@ -432,8 +428,24 @@ const FingerprintingProtectionStateCleaner = {
    432 428
         const ZOOM_PREF_NAME = "browser.content.full-zoom";
    
    433 429
     
    
    434 430
         await new Promise((aResolve, aReject) => {
    
    435
    -      if (deleteAll) {
    
    436
    -        cps2.removeByName(ZOOM_PREF_NAME, null, {
    
    431
    +      aOriginAttributes =
    
    432
    +        ChromeUtils.fillNonDefaultOriginAttributes(aOriginAttributes);
    
    433
    +
    
    434
    +      let loadContext;
    
    435
    +      if (
    
    436
    +        aOriginAttributes.privateBrowsingId ==
    
    437
    +        Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID
    
    438
    +      ) {
    
    439
    +        loadContext = Cu.createLoadContext();
    
    440
    +      } else {
    
    441
    +        loadContext = Cu.createPrivateLoadContext();
    
    442
    +      }
    
    443
    +
    
    444
    +      cps2.removeBySubdomainAndName(
    
    445
    +        aSchemelessSite,
    
    446
    +        ZOOM_PREF_NAME,
    
    447
    +        loadContext,
    
    448
    +        {
    
    437 449
               handleCompletion: aReason => {
    
    438 450
                 if (aReason === cps2.COMPLETE_ERROR) {
    
    439 451
                   aReject();
    
    ... ... @@ -441,50 +453,19 @@ const FingerprintingProtectionStateCleaner = {
    441 453
                   aResolve();
    
    442 454
                 }
    
    443 455
               },
    
    444
    -        });
    
    445
    -      } else {
    
    446
    -        aOriginAttributes =
    
    447
    -          ChromeUtils.fillNonDefaultOriginAttributes(aOriginAttributes);
    
    448
    -
    
    449
    -        let loadContext;
    
    450
    -        if (
    
    451
    -          aOriginAttributes.privateBrowsingId ==
    
    452
    -          Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID
    
    453
    -        ) {
    
    454
    -          loadContext = Cu.createLoadContext();
    
    455
    -        } else {
    
    456
    -          loadContext = Cu.createPrivateLoadContext();
    
    457 456
             }
    
    458
    -
    
    459
    -        cps2.removeBySubdomainAndName(
    
    460
    -          aSchemelessSite,
    
    461
    -          ZOOM_PREF_NAME,
    
    462
    -          loadContext,
    
    463
    -          {
    
    464
    -            handleCompletion: aReason => {
    
    465
    -              if (aReason === cps2.COMPLETE_ERROR) {
    
    466
    -                aReject();
    
    467
    -              } else {
    
    468
    -                aResolve();
    
    469
    -              }
    
    470
    -            },
    
    471
    -          }
    
    472
    -        );
    
    473
    -      }
    
    457
    +      );
    
    474 458
         });
    
    475 459
       },
    
    476 460
     
    
    477 461
       async deleteAll() {
    
    478 462
         Services.rfp.cleanAllRandomKeys();
    
    479
    -
    
    480
    -    await this._maybeClearSiteSpecificZoom(true);
    
    481 463
       },
    
    482 464
     
    
    483 465
       async deleteByPrincipal(aPrincipal) {
    
    484 466
         Services.rfp.cleanRandomKeyByPrincipal(aPrincipal);
    
    485 467
     
    
    486 468
         await this._maybeClearSiteSpecificZoom(
    
    487
    -      false,
    
    488 469
           aPrincipal.host,
    
    489 470
           aPrincipal.originAttributes
    
    490 471
         );
    
    ... ... @@ -497,7 +478,6 @@ const FingerprintingProtectionStateCleaner = {
    497 478
         );
    
    498 479
     
    
    499 480
         await this._maybeClearSiteSpecificZoom(
    
    500
    -      false,
    
    501 481
           aSchemelessSite,
    
    502 482
           aOriginAttributesPattern
    
    503 483
         );
    
    ... ... @@ -509,11 +489,7 @@ const FingerprintingProtectionStateCleaner = {
    509 489
           JSON.stringify(aOriginAttributesPattern)
    
    510 490
         );
    
    511 491
     
    
    512
    -    await this._maybeClearSiteSpecificZoom(
    
    513
    -      false,
    
    514
    -      aHost,
    
    515
    -      aOriginAttributesPattern
    
    516
    -    );
    
    492
    +    await this._maybeClearSiteSpecificZoom(aHost, aOriginAttributesPattern);
    
    517 493
       },
    
    518 494
     
    
    519 495
       async deleteByOriginAttributes(aOriginAttributesString) {