Skip to content

Commit a66ce57

Browse files
author
Sandor Molnar
committed
Revert "Bug 1975753 - Force site specific zoom when RFPTarget::SiteSpecificZoom is active. r=timhuang,tabbrowser-reviewers,dao" for causing bc failures @ browser_ext_tabs_zoom.js
This reverts commit 213240f.
1 parent bdbd7ec commit a66ce57

File tree

5 files changed

+101
-147
lines changed

5 files changed

+101
-147
lines changed

browser/components/resistfingerprinting/test/browser/browser.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ support-files = [
5858

5959
["browser_block_mozAddonManager.js"]
6060

61-
["browser_bug1975753_site_specific_zoom_level.js"]
61+
["browser_bug1369357_site_specific_zoom_level.js"]
6262
https_first_disabled = true
6363

6464
["browser_canvas_iframes.js"]
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"use strict";
2+
3+
const PATH_NET = TEST_PATH + "file_dummy.html";
4+
const PATH_ORG = PATH_NET.replace("example.net", "example.org");
5+
6+
add_task(async function () {
7+
let tab1, tab1Zoom, tab2, tab2Zoom, tab3, tab3Zoom;
8+
9+
tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
10+
await FullZoom.enlarge();
11+
tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
12+
13+
tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
14+
tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);
15+
16+
is(
17+
tab2Zoom,
18+
tab1Zoom,
19+
"privacy.resistFingerprinting is false, site-specific zoom level should be enabled"
20+
);
21+
22+
await SpecialPowers.pushPrefEnv({
23+
set: [["privacy.resistFingerprinting", true]],
24+
});
25+
26+
tab3 = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
27+
tab3Zoom = ZoomManager.getZoomForBrowser(tab3.linkedBrowser);
28+
29+
isnot(
30+
tab3Zoom,
31+
tab1Zoom,
32+
"privacy.resistFingerprinting is true, site-specific zoom level should be disabled"
33+
);
34+
35+
await FullZoom.reset();
36+
37+
BrowserTestUtils.removeTab(tab1);
38+
BrowserTestUtils.removeTab(tab2);
39+
BrowserTestUtils.removeTab(tab3);
40+
41+
await SpecialPowers.popPrefEnv();
42+
});
43+
44+
add_task(async function exempt_domain() {
45+
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
46+
await FullZoom.enlarge();
47+
const netZoomOriginal = ZoomManager.getZoomForBrowser(tab.linkedBrowser);
48+
is(netZoomOriginal, 1.1, "Initial zoom is 110%");
49+
await BrowserTestUtils.removeTab(tab);
50+
51+
tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_ORG);
52+
await FullZoom.enlarge();
53+
const orgZoomOriginal = ZoomManager.getZoomForBrowser(tab.linkedBrowser);
54+
is(orgZoomOriginal, 1.1, "Initial zoom is 110%");
55+
await BrowserTestUtils.removeTab(tab);
56+
57+
await SpecialPowers.pushPrefEnv({
58+
set: [
59+
["privacy.resistFingerprinting.exemptedDomains", "example.net"],
60+
["privacy.resistFingerprinting", true],
61+
],
62+
});
63+
64+
tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_NET);
65+
const netZoom = ZoomManager.getZoomForBrowser(tab.linkedBrowser);
66+
is(netZoom, 1.1, "exempted example.net tab should have kept zoom level");
67+
await FullZoom.reset();
68+
await BrowserTestUtils.removeTab(tab);
69+
70+
tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, PATH_ORG);
71+
const orgZoom = ZoomManager.getZoomForBrowser(tab.linkedBrowser);
72+
is(orgZoom, 1.0, "example.org tab has its zoom reset to default 100%");
73+
await FullZoom.reset();
74+
await BrowserTestUtils.removeTab(tab);
75+
76+
await SpecialPowers.popPrefEnv();
77+
});

browser/components/resistfingerprinting/test/browser/browser_bug1975753_site_specific_zoom_level.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

browser/components/tabbrowser/content/browser-fullZoom.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var FullZoom = {
2727
// events before we're initialized.
2828
_initialLocations: new WeakMap(),
2929

30-
get siteSpecificPref() {
30+
get siteSpecific() {
3131
if (this._siteSpecificPref === undefined) {
3232
this._siteSpecificPref = Services.prefs.getBoolPref(
3333
"browser.zoom.siteSpecific"
@@ -236,7 +236,7 @@ var FullZoom = {
236236
// to the new location.
237237
this._ignorePendingZoomAccesses(browser);
238238

239-
if (!aURI || (aIsTabSwitch && !this.siteSpecificPref)) {
239+
if (!aURI || (aIsTabSwitch && !this._isSiteSpecific(browser))) {
240240
this._notifyOnLocationChange(browser);
241241
return;
242242
}
@@ -530,13 +530,13 @@ var FullZoom = {
530530
if (
531531
!aBrowser.mInitialized ||
532532
aBrowser.isSyntheticDocument ||
533-
(!this.siteSpecificPref && aBrowser.tabHasCustomZoom)
533+
(!this._isSiteSpecific(aBrowser) && aBrowser.tabHasCustomZoom)
534534
) {
535535
this._executeSoon(aCallback);
536536
return;
537537
}
538538

539-
if (aValue !== undefined && this.siteSpecificPref) {
539+
if (aValue !== undefined && this._isSiteSpecific(aBrowser)) {
540540
ZoomManager.setZoomForBrowser(aBrowser, this._ensureValid(aValue));
541541
this._ignorePendingZoomAccesses(aBrowser);
542542
this._executeSoon(aCallback);
@@ -563,11 +563,11 @@ var FullZoom = {
563563
* @param browser The zoom of this browser will be saved. Required.
564564
*/
565565
_applyZoomToPref: function FullZoom__applyZoomToPref(browser) {
566-
if (!this.siteSpecificPref || browser.isSyntheticDocument) {
566+
if (!this._isSiteSpecific(browser) || browser.isSyntheticDocument) {
567567
// If site-specific zoom is disabled, we have called this function
568568
// to adjust our tab's zoom level. It is now considered "custom"
569569
// and we mark that here.
570-
browser.tabHasCustomZoom = !this.siteSpecificPref;
570+
browser.tabHasCustomZoom = !this._isSiteSpecific(browser);
571571
return null;
572572
}
573573

@@ -697,6 +697,23 @@ var FullZoom = {
697697
return aValue;
698698
},
699699

700+
// Whether to remember the site specific zoom level for this browser.
701+
// This returns false when `browser.zoom.siteSpecific` is false or
702+
// the browser has content loaded that should resist fingerprinting.
703+
_isSiteSpecific(aBrowser) {
704+
if (!this.siteSpecific) {
705+
return false;
706+
}
707+
return (
708+
!aBrowser?.browsingContext?.topWindowContext.shouldResistFingerprinting ||
709+
!ChromeUtils.shouldResistFingerprinting(
710+
"SiteSpecificZoom",
711+
aBrowser?.browsingContext?.topWindowContext
712+
.overriddenFingerprintingSettings
713+
)
714+
);
715+
},
716+
700717
/**
701718
* Gets the load context from the given Browser.
702719
*

toolkit/components/cleardata/ClearDataService.sys.mjs

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -416,114 +416,32 @@ const CookieBannerExecutedRecordCleaner = {
416416

417417
// A cleaner for cleaning fingerprinting protection states.
418418
const FingerprintingProtectionStateCleaner = {
419-
async _maybeClearSiteSpecificZoom(
420-
deleteAll,
421-
aSchemelessSite,
422-
aOriginAttributes = {}
423-
) {
424-
if (
425-
!ChromeUtils.shouldResistFingerprinting("SiteSpecificZoom", null, true)
426-
) {
427-
return;
428-
}
429-
430-
const cps2 = Cc["@mozilla.org/content-pref/service;1"].getService(
431-
Ci.nsIContentPrefService2
432-
);
433-
const ZOOM_PREF_NAME = "browser.content.full-zoom";
434-
435-
await new Promise((aResolve, aReject) => {
436-
if (deleteAll) {
437-
cps2.removeByName(ZOOM_PREF_NAME, null, {
438-
handleCompletion: aReason => {
439-
if (aReason === cps2.COMPLETE_ERROR) {
440-
aReject();
441-
} else {
442-
aResolve();
443-
}
444-
},
445-
});
446-
} else {
447-
aOriginAttributes =
448-
ChromeUtils.fillNonDefaultOriginAttributes(aOriginAttributes);
449-
450-
let loadContext;
451-
if (
452-
aOriginAttributes.privateBrowsingId ==
453-
Services.scriptSecurityManager.DEFAULT_PRIVATE_BROWSING_ID
454-
) {
455-
loadContext = Cu.createLoadContext();
456-
} else {
457-
loadContext = Cu.createPrivateLoadContext();
458-
}
459-
460-
cps2.removeBySubdomainAndName(
461-
aSchemelessSite,
462-
ZOOM_PREF_NAME,
463-
loadContext,
464-
{
465-
handleCompletion: aReason => {
466-
if (aReason === cps2.COMPLETE_ERROR) {
467-
aReject();
468-
} else {
469-
aResolve();
470-
}
471-
},
472-
}
473-
);
474-
}
475-
});
476-
},
477-
478419
async deleteAll() {
479420
Services.rfp.cleanAllRandomKeys();
480-
481-
await this._maybeClearSiteSpecificZoom(true);
482421
},
483422

484423
async deleteByPrincipal(aPrincipal) {
485424
Services.rfp.cleanRandomKeyByPrincipal(aPrincipal);
486-
487-
await this._maybeClearSiteSpecificZoom(
488-
false,
489-
aPrincipal.host,
490-
aPrincipal.originAttributes
491-
);
492425
},
493426

494427
async deleteBySite(aSchemelessSite, aOriginAttributesPattern) {
495428
Services.rfp.cleanRandomKeyBySite(
496429
aSchemelessSite,
497430
aOriginAttributesPattern
498431
);
499-
500-
await this._maybeClearSiteSpecificZoom(
501-
false,
502-
aSchemelessSite,
503-
aOriginAttributesPattern
504-
);
505432
},
506433

507434
async deleteByHost(aHost, aOriginAttributesPattern) {
508435
Services.rfp.cleanRandomKeyByHost(
509436
aHost,
510437
JSON.stringify(aOriginAttributesPattern)
511438
);
512-
513-
await this._maybeClearSiteSpecificZoom(
514-
false,
515-
aHost,
516-
aOriginAttributesPattern
517-
);
518439
},
519440

520441
async deleteByOriginAttributes(aOriginAttributesString) {
521442
Services.rfp.cleanRandomKeyByOriginAttributesPattern(
522443
aOriginAttributesString
523444
);
524-
525-
// For deleteByOriginAttributes, we only receive userContextId which is not enough to target specific
526-
// site-specific zooms. So we don't clear site-specific zooms here.
527445
},
528446
};
529447

0 commit comments

Comments
 (0)