Verified Commit 20ddbc37 authored by ma1's avatar ma1
Browse files

BB 32308: Use direct browser sizing for letterboxing.

Bug 30556: align letterboxing with 200x100 new win width stepping
parent 73dbf51c
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing";

const lazy = {};

XPCOMUtils.defineLazyPreferenceGetter(
  lazy,
  "isLetterboxingEnabled",
  kPrefLetterboxing,
  false
);

export class RFPHelperChild extends JSWindowActorChild {
  handleEvent(event) {
    if (lazy.isLetterboxingEnabled && event.type == "resize") {
      this.sendAsyncMessage("Letterboxing:ContentSizeUpdated");
    }
  }
}
+0 −33
Original line number Diff line number Diff line
1; /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
  RFPHelper: "resource://gre/modules/RFPHelper.sys.mjs",
});

const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing";

XPCOMUtils.defineLazyPreferenceGetter(
  lazy,
  "isLetterboxingEnabled",
  kPrefLetterboxing,
  false
);

export class RFPHelperParent extends JSWindowActorParent {
  receiveMessage(aMessage) {
    if (
      lazy.isLetterboxingEnabled &&
      aMessage.name == "Letterboxing:ContentSizeUpdated"
    ) {
      let browser = this.browsingContext.top.embedderElement;
      let window = browser.ownerGlobal;
      lazy.RFPHelper.contentSizeUpdated(window);
    }
  }
}
+0 −2
Original line number Diff line number Diff line
@@ -75,8 +75,6 @@ FINAL_TARGET_FILES.actors += [
    "PromptParent.sys.mjs",
    "RefreshBlockerChild.sys.mjs",
    "RefreshBlockerParent.sys.mjs",
    "RFPHelperChild.sys.mjs",
    "RFPHelperParent.sys.mjs",
    "ScreenshotsComponentChild.sys.mjs",
    "SearchSERPTelemetryChild.sys.mjs",
    "SearchSERPTelemetryParent.sys.mjs",
+4 −0
Original line number Diff line number Diff line
@@ -446,6 +446,10 @@ pref("security.remote_settings.intermediates.enabled", false);
pref("dom.use_components_shim", false);
// Enable letterboxing
pref("privacy.resistFingerprinting.letterboxing", true);
// tor-browser#41917: Center letterboxed area vertically
pref("privacy.resistFingerprinting.letterboxing.vcenter", true);
// tor-browser#41917: Letterboxing gradient background
pref("privacy.resistFingerprinting.letterboxing.gradient", true);
// tor-browser#43402: Avoid a resize from the skeleton to the newwin size.
// Should be fixed in ESR-140 with Bug 1448423.
pref("browser.startup.blankWindow", false);
+6 −6
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ function checkForDefaultSetting(
  aRealHeight
) {
  // We can get the rounded size by subtracting twice the margin.
  let targetWidth = aRealWidth - 2 * RFPHelper.steppedRange(aRealWidth, true);
  let targetHeight = aRealHeight - 2 * RFPHelper.steppedRange(aRealHeight);
  let targetWidth = aRealWidth - 2 * RFPHelper.steppedSize(aRealWidth, true);
  let targetHeight = aRealHeight - 2 * RFPHelper.steppedSize(aRealHeight);

  // This platform-specific code is explained in the large comment below.
  if (getPlatform() != "linux") {
@@ -82,7 +82,7 @@ async function test_dynamical_window_rounding(aWindow, aCheckFunc) {
  // We need to wait for the updating the margins for the newly opened tab, or
  // it will affect the following tests.
  let promiseForTheFirstRounding = TestUtils.topicObserved(
    "test:letterboxing:update-margin-finish"
    "test:letterboxing:update-size-finish"
  );

  info("Open a content tab for testing.");
@@ -108,7 +108,7 @@ async function test_dynamical_window_rounding(aWindow, aCheckFunc) {
    let caseString = "Case " + width + "x" + height + ": ";
    // Create a promise for waiting for the margin update.
    let promiseRounding = TestUtils.topicObserved(
      "test:letterboxing:update-margin-finish"
      "test:letterboxing:update-size-finish"
    );

    let { containerWidth, containerHeight } = getContainerSize(tab);
@@ -316,7 +316,7 @@ async function test_findbar(aWindow) {
  );

  let promiseRounding = TestUtils.topicObserved(
    "test:letterboxing:update-margin-finish"
    "test:letterboxing:update-size-finish"
  );

  let findBarOpenPromise = BrowserTestUtils.waitForEvent(
@@ -330,7 +330,7 @@ async function test_findbar(aWindow) {
  ok(true, "Margin updated when findbar opened");

  promiseRounding = TestUtils.topicObserved(
    "test:letterboxing:update-margin-finish"
    "test:letterboxing:update-size-finish"
  );

  let findBarClosePromise = BrowserTestUtils.waitForEvent(
Loading