| 
Commits:
20e6bcfa
 by Pier Angelo Vendrame   at 2023-11-14T22:14:32+00:00 
 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
7d7f8a1f
 by Pier Angelo Vendrame   at 2023-11-14T22:14:32+00:00 
 fixup! Firefox preference overrides.
Bug 41988: Do not expose page titles in winow title
 
4 changed files:
Changes:
browser/app/profile/001-base-profile.js
 
| ... | ... | @@ -86,6 +86,12 @@ pref("browser.sessionstore.resume_from_crash", false); |  
| 86 | 86 |  // Disable capturing thumbnails (tor-browser#41595)
 |  
| 87 | 87 |  // Also not needed in PBM at the moment.
 |  
| 88 | 88 |  pref("browser.pagethumbnails.capturing_disabled", true);
 |  
|  | 89 | +// tor-browser#41988: Remove page titles from window titles to prevent possible
 |  
|  | 90 | +// disk leaks, e.g., in system logs.
 |  
|  | 91 | +// For example, it happened that GNOME shell logged the window name that caused
 |  
|  | 92 | +// JS errors/unexpected conditions for unrelated issues.
 |  
|  | 93 | +pref("privacy.exposeContentTitleInWindow", false);
 |  
|  | 94 | +pref("privacy.exposeContentTitleInWindow.pbm", false);
 |  
| 89 | 95 |  
 |  
| 90 | 96 |  // Empty clipboard content from private windows on exit (tor-browser#42154)
 |  
| 91 | 97 |  pref("browser.privatebrowsing.preserveClipboard", false);
 |  browser/app/profile/firefox.js
 
 
| ... | ... | @@ -968,7 +968,7 @@ pref("privacy.panicButton.enabled",         true); |  
| 968 | 968 |  // Time until temporary permissions expire, in ms
 |  
| 969 | 969 |  pref("privacy.temporary_permission_expire_time_ms",  3600000);
 |  
| 970 | 970 |  
 |  
| 971 |  | -// Enables protection mechanism against password spoofing for cross domain auh requests
 |  
|  | 971 | +// Enables protection mechanism against password spoofing for cross domain auth requests
 |  
| 972 | 972 |  // See bug 791594
 |  
| 973 | 973 |  pref("privacy.authPromptSpoofingProtection",         true);
 |  
| 974 | 974 |  
 |  
| ... | ... | @@ -2104,6 +2104,12 @@ pref("privacy.webrtc.sharedTabWarning", false); |  
| 2104 | 2104 |  // before navigating to the actual meeting room page. Doesn't survive tab close.
 |  
| 2105 | 2105 |  pref("privacy.webrtc.deviceGracePeriodTimeoutMs", 3600000);
 |  
| 2106 | 2106 |  
 |  
|  | 2107 | +// Enable including the content in the window title.
 |  
|  | 2108 | +// PBM users might want to disable this to avoid a possible source of disk
 |  
|  | 2109 | +// leaks.
 |  
|  | 2110 | +pref("privacy.exposeContentTitleInWindow", true);
 |  
|  | 2111 | +pref("privacy.exposeContentTitleInWindow.pbm", true);
 |  
|  | 2112 | +
 |  
| 2107 | 2113 |  // Start the browser in e10s mode
 |  
| 2108 | 2114 |  pref("browser.tabs.remote.autostart", true);
 |  
| 2109 | 2115 |  pref("browser.tabs.remote.desktopbehavior", true);
 |  browser/base/content/tabbrowser.js
 
 
| ... | ... | @@ -102,6 +102,18 @@ |  
| 102 | 102 |            true
 |  
| 103 | 103 |          );
 |  
| 104 | 104 |        });
 |  
|  | 105 | +      XPCOMUtils.defineLazyPreferenceGetter(
 |  
|  | 106 | +        this,
 |  
|  | 107 | +        "_shouldExposeContentTitle",
 |  
|  | 108 | +        "privacy.exposeContentTitleInWindow",
 |  
|  | 109 | +        true
 |  
|  | 110 | +      );
 |  
|  | 111 | +      XPCOMUtils.defineLazyPreferenceGetter(
 |  
|  | 112 | +        this,
 |  
|  | 113 | +        "_shouldExposeContentTitlePbm",
 |  
|  | 114 | +        "privacy.exposeContentTitleInWindow.pbm",
 |  
|  | 115 | +        true
 |  
|  | 116 | +      );
 |  
| 105 | 117 |  
 |  
| 106 | 118 |        if (AppConstants.MOZ_CRASHREPORTER) {
 |  
| 107 | 119 |          ChromeUtils.defineModuleGetter(
 |  
| ... | ... | @@ -1072,6 +1084,19 @@ |  
| 1072 | 1084 |      getWindowTitleForBrowser(aBrowser) {
 |  
| 1073 | 1085 |        let docElement = document.documentElement;
 |  
| 1074 | 1086 |        let title = "";
 |  
|  | 1087 | +      let dataSuffix =
 |  
|  | 1088 | +        docElement.getAttribute("privatebrowsingmode") == "temporary"
 |  
|  | 1089 | +          ? "Private"
 |  
|  | 1090 | +          : "Default";
 |  
|  | 1091 | +      let defaultTitle = docElement.dataset["title" + dataSuffix];
 |  
|  | 1092 | +
 |  
|  | 1093 | +      if (
 |  
|  | 1094 | +        !this._shouldExposeContentTitle ||
 |  
|  | 1095 | +        (PrivateBrowsingUtils.isWindowPrivate(window) &&
 |  
|  | 1096 | +          !this._shouldExposeContentTitlePbm)
 |  
|  | 1097 | +      ) {
 |  
|  | 1098 | +        return defaultTitle;
 |  
|  | 1099 | +      }
 |  
| 1075 | 1100 |  
 |  
| 1076 | 1101 |        // If location bar is hidden and the URL type supports a host,
 |  
| 1077 | 1102 |        // add the scheme and host to the title to prevent spoofing.
 |  
| ... | ... | @@ -1109,10 +1134,6 @@ |  
| 1109 | 1134 |          title += tab.getAttribute("label").replace(/\0/g, "");
 |  
| 1110 | 1135 |        }
 |  
| 1111 | 1136 |  
 |  
| 1112 |  | -      let dataSuffix =
 |  
| 1113 |  | -        docElement.getAttribute("privatebrowsingmode") == "temporary"
 |  
| 1114 |  | -          ? "Private"
 |  
| 1115 |  | -          : "Default";
 |  
| 1116 | 1137 |        if (title) {
 |  
| 1117 | 1138 |          // We're using a function rather than just using `title` as the
 |  
| 1118 | 1139 |          // new substring to avoid `$$`, `$'` etc. having a special
 |  
| ... | ... | @@ -1125,7 +1146,7 @@ |  
| 1125 | 1146 |          );
 |  
| 1126 | 1147 |        }
 |  
| 1127 | 1148 |  
 |  
| 1128 |  | -      return docElement.dataset["title" + dataSuffix];
 |  
|  | 1149 | +      return defaultTitle;
 |  
| 1129 | 1150 |      },
 |  
| 1130 | 1151 |  
 |  
| 1131 | 1152 |      updateTitlebar() {
 |  browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
 
 
| ... | ... | @@ -107,4 +107,34 @@ add_task(async function test() { |  
| 107 | 107 |      true,
 |  
| 108 | 108 |      pb_about_pb_title
 |  
| 109 | 109 |    );
 |  
|  | 110 | +
 |  
|  | 111 | +  await SpecialPowers.pushPrefEnv({
 |  
|  | 112 | +    set: [["privacy.exposeContentTitleInWindow.pbm", false]],
 |  
|  | 113 | +  });
 |  
|  | 114 | +  await testTabTitle(await openWin(false), testPageURL, false, page_with_title);
 |  
|  | 115 | +  await testTabTitle(
 |  
|  | 116 | +    await openWin(true),
 |  
|  | 117 | +    testPageURL,
 |  
|  | 118 | +    true,
 |  
|  | 119 | +    pb_page_without_title
 |  
|  | 120 | +  );
 |  
|  | 121 | +  await SpecialPowers.pushPrefEnv({
 |  
|  | 122 | +    set: [
 |  
|  | 123 | +      ["privacy.exposeContentTitleInWindow", false],
 |  
|  | 124 | +      ["privacy.exposeContentTitleInWindow.pbm", true],
 |  
|  | 125 | +    ],
 |  
|  | 126 | +  });
 |  
|  | 127 | +  await testTabTitle(
 |  
|  | 128 | +    await openWin(false),
 |  
|  | 129 | +    testPageURL,
 |  
|  | 130 | +    false,
 |  
|  | 131 | +    page_without_title
 |  
|  | 132 | +  );
 |  
|  | 133 | +  // The generic preference set to false is intended to override the PBM one
 |  
|  | 134 | +  await testTabTitle(
 |  
|  | 135 | +    await openWin(true),
 |  
|  | 136 | +    testPageURL,
 |  
|  | 137 | +    true,
 |  
|  | 138 | +    pb_page_without_title
 |  
|  | 139 | +  );
 |  
| 110 | 140 |  }); |  
 |