brizental pushed to branch tor-browser-153.4.0esr-16.0-1 at The Tor Project / Applications / Tor Browser Commits: c60bca12 by Beatriz Rizental at 2026-10-05T17:23:00-03:00 fixup! BB 41695: Warn on window maximization without letterboxing in RFPHelper module Keep the original window sizes in a module-level WeakMap keyed by window, instead of in a _rfpOriginalSize expando on the chrome window. Browser chrome tests fail when a test leaves unexpected properties on the window. - - - - - 45f07062 by Beatriz Rizental at 2026-10-05T17:23:01-03:00 fixup! BB 42443: Shrink window to match letterboxing size when the emtpy area is clicked. Make shrinkToLetterbox an RFPHelper method that takes the window, instead of attaching it to every chrome window. Browser chrome tests fail when a test leaves unexpected properties on the window. - - - - - 304ac9a4 by Beatriz Rizental at 2026-10-05T17:23:02-03:00 fixup! BB 41919: Letterboxing, add temporarily visible web content-size indicator on window resizing. Keep the letterboxing status timeouts in a module-level WeakMap keyed by window, instead of in a _letterboxingStatusTimeout expando on the chrome window. Browser chrome tests fail when a test leaves unexpected properties on the window. - - - - - 1 changed file: - toolkit/components/resistfingerprinting/RFPHelper.sys.mjs Changes: ===================================== toolkit/components/resistfingerprinting/RFPHelper.sys.mjs ===================================== @@ -10,6 +10,9 @@ const kPrefResistFingerprinting = "privacy.resistFingerprinting"; const kPrefSpoofEnglish = "privacy.spoof_english"; const kTopicHttpOnModifyRequest = "http-on-modify-request"; +// The original (rounded) size of each window, recorded when it was ready. +const originalWindowSizes = new WeakMap(); + const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing"; const kPrefLetterboxingDimensions = "privacy.resistFingerprinting.letterboxing.dimensions"; @@ -29,6 +32,9 @@ const kPrefVerticalTabs = "sidebar.verticalTabs"; const kPrefResizeWarnings = "privacy.resistFingerprinting.resizeWarnings"; +// Timeouts that hide the letterboxing size status, keyed by window. +const letterboxingStatusTimeouts = new WeakMap(); + const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { @@ -113,9 +119,9 @@ async function windowResizeHandler(aEvent) { // reset notification timer to work-around resize race conditions windowResizeHandler.timestamp = Date.now(); // restore the original (rounded) size we had stored on window startup - let { _rfpOriginalSize } = window; + let originalSize = originalWindowSizes.get(window); window.setTimeout(() => { - window.resizeTo(_rfpOriginalSize.width, _rfpOriginalSize.height); + window.resizeTo(originalSize.width, originalSize.height); }, 0); }, }, @@ -567,16 +573,17 @@ class _RFPHelper { ]) ); + const originalSize = originalWindowSizes.get(win); const isInitialSize = - win._rfpOriginalSize && - win.outerWidth === win._rfpOriginalSize.width && - win.outerHeight === win._rfpOriginalSize.height; + originalSize && + win.outerWidth === originalSize.width && + win.outerHeight === originalSize.height; // We may need to shrink this window to rounded size if the browser container // area is taller than the original, meaning extra chrome (like the optional // "Only Show on New Tab" bookmarks toobar) was present and now gone. const needToShrink = - isInitialSize && containerHeight > win._rfpOriginalSize.containerHeight; + isInitialSize && containerHeight > originalSize.containerHeight; log( `${logPrefix} contentWidth=${contentWidth} contentHeight=${contentHeight} parentWidth=${parentWidth} parentHeight=${parentHeight} containerWidth=${containerWidth} containerHeight=${containerHeight}${ @@ -664,7 +671,7 @@ class _RFPHelper { lazy.logConsole.error(e); } } - if (needToShrink && win.shrinkToLetterbox()) { + if (needToShrink && RFPHelper.shrinkToLetterbox(win)) { win.addEventListener( "resize", () => { @@ -739,8 +746,11 @@ class _RFPHelper { browserParent.classList.add(clazz); } updateStatus(lastRoundedSize); - win.clearTimeout(win._letterboxingStatusTimeout); - win._letterboxingStatusTimeout = win.setTimeout(updateStatus, 1000); + win.clearTimeout(letterboxingStatusTimeouts.get(win)); + letterboxingStatusTimeouts.set( + win, + win.setTimeout(updateStatus, 1000) + ); } else { updateStatus(""); } @@ -808,7 +818,7 @@ class _RFPHelper { // maximized. aWindow.setTimeout(() => { tabBrowser.tabbox.classList.add("letterboxing-ready"); - if (!aWindow._rfpOriginalSize) { + if (!originalWindowSizes.has(aWindow)) { this._recordWindowSize(aWindow); } }); @@ -816,26 +826,26 @@ class _RFPHelper { _recordWindowSize(aWindow) { aWindow.promiseDocumentFlushed(() => { - aWindow._rfpOriginalSize = { + const size = { width: aWindow.outerWidth, height: aWindow.outerHeight, containerHeight: aWindow.gBrowser.getBrowserContainer()?.clientHeight, }; - log("Recording original window size", aWindow._rfpOriginalSize); + originalWindowSizes.set(aWindow, size); + log("Recording original window size", size); }); } - // We will attach this method to each browser window. When called - // it will instantly resize the window to exactly fit the selected - // (possibly letterboxed) browser. + // Instantly resize the window to exactly fit the selected (possibly + // letterboxed) browser. // Returns true if a window resize will occur, false otherwise. - shrinkToLetterbox() { - let { selectedBrowser } = this.gBrowser; + shrinkToLetterbox(aWindow) { + let { selectedBrowser } = aWindow.gBrowser; let stack = selectedBrowser.closest(".browserStack"); const outer = stack.getBoundingClientRect(); const inner = selectedBrowser.getBoundingClientRect(); if (inner.width !== outer.witdh || inner.height !== outer.height) { - this.resizeBy(inner.width - outer.width, inner.height - outer.height); + aWindow.resizeBy(inner.width - outer.width, inner.height - outer.height); return true; } return false; @@ -843,14 +853,13 @@ class _RFPHelper { _onWindowDoubleClick(e) { if (e.target.classList.contains("browserStack")) { - e.currentTarget.shrinkToLetterbox(); + RFPHelper.shrinkToLetterbox(e.currentTarget); } } _attachWindow(aWindow) { this._fixRounding(aWindow); aWindow.addEventListener("sizemodechange", windowResizeHandler); - aWindow.shrinkToLetterbox = this.shrinkToLetterbox; aWindow.addEventListener("dblclick", this._onWindowDoubleClick); aWindow.gBrowser.addTabsProgressListener(this); aWindow.addEventListener("TabOpen", this); @@ -1203,7 +1212,6 @@ class _RFPHelper { this._resetContentSize(browser); } aWindow.removeEventListener("dblclick", this._onWindowDoubleClick); - delete aWindow.shrinkToLetterbox; aWindow.removeEventListener("sizemodechange", windowResizeHandler); aWindow.removeEventListener("nativethemechange", this); View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4341214... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4341214... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help