Verified Commit 2650578c authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

Bug 1849186 - Add a preference not to expose the content title in the window...

Bug 1849186 - Add a preference not to expose the content title in the window title. r=Gijs,tabbrowser-reviewers,dao

Differential Revision: https://phabricator.services.mozilla.com/D190496
parent 40262776
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -968,7 +968,7 @@ pref("privacy.panicButton.enabled", true);
// Time until temporary permissions expire, in ms
pref("privacy.temporary_permission_expire_time_ms",  3600000);

// Enables protection mechanism against password spoofing for cross domain auh requests
// Enables protection mechanism against password spoofing for cross domain auth requests
// See bug 791594
pref("privacy.authPromptSpoofingProtection",         true);

@@ -2104,6 +2104,12 @@ pref("privacy.webrtc.sharedTabWarning", false);
// before navigating to the actual meeting room page. Doesn't survive tab close.
pref("privacy.webrtc.deviceGracePeriodTimeoutMs", 3600000);

// Enable including the content in the window title.
// PBM users might want to disable this to avoid a possible source of disk
// leaks.
pref("privacy.exposeContentTitleInWindow", true);
pref("privacy.exposeContentTitleInWindow.pbm", true);

// Start the browser in e10s mode
pref("browser.tabs.remote.autostart", true);
pref("browser.tabs.remote.desktopbehavior", true);
+26 −5
Original line number Diff line number Diff line
@@ -102,6 +102,18 @@
          true
        );
      });
      XPCOMUtils.defineLazyPreferenceGetter(
        this,
        "_shouldExposeContentTitle",
        "privacy.exposeContentTitleInWindow",
        true
      );
      XPCOMUtils.defineLazyPreferenceGetter(
        this,
        "_shouldExposeContentTitlePbm",
        "privacy.exposeContentTitleInWindow.pbm",
        true
      );

      if (AppConstants.MOZ_CRASHREPORTER) {
        ChromeUtils.defineModuleGetter(
@@ -1072,6 +1084,19 @@
    getWindowTitleForBrowser(aBrowser) {
      let docElement = document.documentElement;
      let title = "";
      let dataSuffix =
        docElement.getAttribute("privatebrowsingmode") == "temporary"
          ? "Private"
          : "Default";
      let defaultTitle = docElement.dataset["title" + dataSuffix];

      if (
        !this._shouldExposeContentTitle ||
        (PrivateBrowsingUtils.isWindowPrivate(window) &&
          !this._shouldExposeContentTitlePbm)
      ) {
        return defaultTitle;
      }

      // If location bar is hidden and the URL type supports a host,
      // add the scheme and host to the title to prevent spoofing.
@@ -1109,10 +1134,6 @@
        title += tab.getAttribute("label").replace(/\0/g, "");
      }

      let dataSuffix =
        docElement.getAttribute("privatebrowsingmode") == "temporary"
          ? "Private"
          : "Default";
      if (title) {
        // We're using a function rather than just using `title` as the
        // new substring to avoid `$$`, `$'` etc. having a special
@@ -1125,7 +1146,7 @@
        );
      }

      return docElement.dataset["title" + dataSuffix];
      return defaultTitle;
    },

    updateTitlebar() {
+30 −0
Original line number Diff line number Diff line
@@ -107,4 +107,34 @@ add_task(async function test() {
    true,
    pb_about_pb_title
  );

  await SpecialPowers.pushPrefEnv({
    set: [["privacy.exposeContentTitleInWindow.pbm", false]],
  });
  await testTabTitle(await openWin(false), testPageURL, false, page_with_title);
  await testTabTitle(
    await openWin(true),
    testPageURL,
    true,
    pb_page_without_title
  );
  await SpecialPowers.pushPrefEnv({
    set: [
      ["privacy.exposeContentTitleInWindow", false],
      ["privacy.exposeContentTitleInWindow.pbm", true],
    ],
  });
  await testTabTitle(
    await openWin(false),
    testPageURL,
    false,
    page_without_title
  );
  // The generic preference set to false is intended to override the PBM one
  await testTabTitle(
    await openWin(true),
    testPageURL,
    true,
    pb_page_without_title
  );
});