From a42574040a543950f94d95a911f083df70cdfa14 Mon Sep 17 00:00:00 2001
From: Richard Pospesel <richard@torproject.org>
Date: Tue, 19 Jun 2018 11:45:29 -0700
Subject: [PATCH] Bug 26039: <profiledir>/preferences/extension-overrides.js
 will not be loaded in ESR 60

The infrastructure for loading extension-overrides.js no longer
exists in ESR60, so these prefs had to be moved.

Unfortunately, we can't just dump the contents of extension-overrides.js
into 000-tor-browser.js.  The settings are actually partially built in
tor-browser-build to conditionally include various bridge strings as well
as localization settings.  So, we piggy back off this existing build
process and just append the contents of the partially generated
extension-overrids.js to 000-tor-browser.js.
---
 .../extension-overrides.js                    |  0
 .../preferences/extension-overrides.js        | 63 -------------------
 .../preferences/extension-overrides.js        | 63 -------------------
 projects/tor-browser/build                    | 17 ++---
 4 files changed, 9 insertions(+), 134 deletions(-)
 rename projects/tor-browser/Bundle-Data/{linux/Data/Browser/profile.default/preferences => PTConfigs}/extension-overrides.js (100%)
 delete mode 100644 projects/tor-browser/Bundle-Data/mac/TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
 delete mode 100644 projects/tor-browser/Bundle-Data/windows/Data/Browser/profile.default/preferences/extension-overrides.js

diff --git a/projects/tor-browser/Bundle-Data/linux/Data/Browser/profile.default/preferences/extension-overrides.js b/projects/tor-browser/Bundle-Data/PTConfigs/extension-overrides.js
similarity index 100%
rename from projects/tor-browser/Bundle-Data/linux/Data/Browser/profile.default/preferences/extension-overrides.js
rename to projects/tor-browser/Bundle-Data/PTConfigs/extension-overrides.js
diff --git a/projects/tor-browser/Bundle-Data/mac/TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js b/projects/tor-browser/Bundle-Data/mac/TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
deleted file mode 100644
index c81a7bf..0000000
--- a/projects/tor-browser/Bundle-Data/mac/TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
+++ /dev/null
@@ -1,63 +0,0 @@
-# Overrides for Extension Preferences
-# Tor Browser Bundle
-# Do not edit this file.
-
-# HTTPS Everywhere Preferences:
-pref("extensions.https_everywhere._observatory.popup_shown", true);
-pref("extensions.https_everywhere.toolbar_hint_shown", true);
-
-# NoScript Preferences:
-pref("capability.policy.maonoscript.javascript.enabled", "allAccess");
-pref("capability.policy.maonoscript.sites", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache");
-pref("noscript.default", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache");
-pref("noscript.mandatory", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache");
-pref("noscript.ABE.enabled", false);
-pref("noscript.ABE.notify", false);
-pref("noscript.ABE.wanIpAsLocal", false);
-pref("noscript.confirmUnblock", false);
-pref("noscript.contentBlocker", true);
-pref("noscript.firstRunRedirection", false);
-pref("noscript.global", true);
-pref("noscript.gtemp", "");
-pref("noscript.opacizeObject", 3);
-pref("noscript.forbidWebGL", true);
-pref("noscript.forbidFonts", false);
-pref("noscript.options.tabSelectedIndexes", "5,0,0");
-pref("noscript.policynames", "");
-pref("noscript.secureCookies", true);
-pref("noscript.showAllowPage", false);
-pref("noscript.showBaseDomain", false);
-pref("noscript.showDistrust", false);
-pref("noscript.showRecentlyBlocked", false);
-pref("noscript.showTemp", false);
-pref("noscript.showTempToPerm", false);
-pref("noscript.showUntrusted", false);
-pref("noscript.STS.enabled", false);
-pref("noscript.subscription.lastCheck", -142148139);
-pref("noscript.temp", "");
-pref("noscript.untrusted", "");
-pref("noscript.forbidMedia", false);
-pref("noscript.allowWhitelistUpdates", false);
-pref("noscript.fixLinks", false);
-// Now handled by plugins.click_to_play
-pref("noscript.forbidFlash", false);
-pref("noscript.forbidSilverlight", false);
-pref("noscript.forbidJava", false);
-pref("noscript.forbidPlugins", false);
-// Usability tweaks
-pref("noscript.showPermanent", false);
-pref("noscript.showTempAllowPage", true);
-pref("noscript.showRevokeTemp", true);
-pref("noscript.notify", false);
-pref("noscript.autoReload", true);
-pref("noscript.autoReload.allTabs", false);
-pref("noscript.cascadePermissions", true);
-pref("noscript.restrictSubdocScripting", true);
-pref("noscript.showVolatilePrivatePermissionsToggle", false);
-pref("noscript.volatilePrivatePermissions", true);
-pref("noscript.clearClick", 0);
-
-# PDF.js
-// needs to be a user_pref because pdf.js blows away non-user prefs with its own
-// defaults each time
-user_pref("pdfjs.disableRange", true);
diff --git a/projects/tor-browser/Bundle-Data/windows/Data/Browser/profile.default/preferences/extension-overrides.js b/projects/tor-browser/Bundle-Data/windows/Data/Browser/profile.default/preferences/extension-overrides.js
deleted file mode 100644
index c81a7bf..0000000
--- a/projects/tor-browser/Bundle-Data/windows/Data/Browser/profile.default/preferences/extension-overrides.js
+++ /dev/null
@@ -1,63 +0,0 @@
-# Overrides for Extension Preferences
-# Tor Browser Bundle
-# Do not edit this file.
-
-# HTTPS Everywhere Preferences:
-pref("extensions.https_everywhere._observatory.popup_shown", true);
-pref("extensions.https_everywhere.toolbar_hint_shown", true);
-
-# NoScript Preferences:
-pref("capability.policy.maonoscript.javascript.enabled", "allAccess");
-pref("capability.policy.maonoscript.sites", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache");
-pref("noscript.default", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache");
-pref("noscript.mandatory", "[System+Principal] about: about:tbupdate about:tor chrome: resource: blob: mediasource: moz-extension: moz-safe-about: about:neterror about:certerror about:feeds about:tabcrashed about:cache");
-pref("noscript.ABE.enabled", false);
-pref("noscript.ABE.notify", false);
-pref("noscript.ABE.wanIpAsLocal", false);
-pref("noscript.confirmUnblock", false);
-pref("noscript.contentBlocker", true);
-pref("noscript.firstRunRedirection", false);
-pref("noscript.global", true);
-pref("noscript.gtemp", "");
-pref("noscript.opacizeObject", 3);
-pref("noscript.forbidWebGL", true);
-pref("noscript.forbidFonts", false);
-pref("noscript.options.tabSelectedIndexes", "5,0,0");
-pref("noscript.policynames", "");
-pref("noscript.secureCookies", true);
-pref("noscript.showAllowPage", false);
-pref("noscript.showBaseDomain", false);
-pref("noscript.showDistrust", false);
-pref("noscript.showRecentlyBlocked", false);
-pref("noscript.showTemp", false);
-pref("noscript.showTempToPerm", false);
-pref("noscript.showUntrusted", false);
-pref("noscript.STS.enabled", false);
-pref("noscript.subscription.lastCheck", -142148139);
-pref("noscript.temp", "");
-pref("noscript.untrusted", "");
-pref("noscript.forbidMedia", false);
-pref("noscript.allowWhitelistUpdates", false);
-pref("noscript.fixLinks", false);
-// Now handled by plugins.click_to_play
-pref("noscript.forbidFlash", false);
-pref("noscript.forbidSilverlight", false);
-pref("noscript.forbidJava", false);
-pref("noscript.forbidPlugins", false);
-// Usability tweaks
-pref("noscript.showPermanent", false);
-pref("noscript.showTempAllowPage", true);
-pref("noscript.showRevokeTemp", true);
-pref("noscript.notify", false);
-pref("noscript.autoReload", true);
-pref("noscript.autoReload.allTabs", false);
-pref("noscript.cascadePermissions", true);
-pref("noscript.restrictSubdocScripting", true);
-pref("noscript.showVolatilePrivatePermissionsToggle", false);
-pref("noscript.volatilePrivatePermissions", true);
-pref("noscript.clearClick", 0);
-
-# PDF.js
-// needs to be a user_pref because pdf.js blows away non-user prefs with its own
-// defaults each time
-user_pref("pdfjs.disableRange", true);
diff --git a/projects/tor-browser/build b/projects/tor-browser/build
index 52678ed..fb3d05e 100644
--- a/projects/tor-browser/build
+++ b/projects/tor-browser/build
@@ -12,6 +12,7 @@ mkdir -p $OUTDIR
 # directory named tor-browser (instead of tor-browser_en-US). Therefore we
 # stage everything under tor-browser-stage to avoid a conflict.
 TB_STAGE_DIR=$distdir/tor-browser-stage
+EXTOVERRIDESPATH=$rootdir/Bundle-Data/PTConfigs/extension-overrides.js
 
 [% IF c("var/osx") %]
   TBDIR="$TB_STAGE_DIR/Tor Browser.app"
@@ -20,7 +21,6 @@ TB_STAGE_DIR=$distdir/tor-browser-stage
   EXTSPATH=Contents/Resources/distribution/extensions
   TORBINPATH=Contents/MacOS/Tor
   TORCONFIGPATH=Contents/Resources/TorBrowser/Tor
-  EXTOVERRIDESPATH=Contents/Resources/distribution/preferences//extension-overrides.js
   MEEKPROFILEPATH=Contents/Resources/TorBrowser/Tor/PluggableTransports/template-profile.meek-http-helper
 
   tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/libdmg') %]
@@ -31,7 +31,6 @@ TB_STAGE_DIR=$distdir/tor-browser-stage
   DOCSPATH=TorBrowser/Docs
   EXTSPATH=TorBrowser/Data/Browser/profile.default/extensions
   TORCONFIGPATH=TorBrowser/Data/Tor
-  EXTOVERRIDESPATH=TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
   MEEKPROFILEPATH=TorBrowser/Data/Browser/profile.meek-http-helper
 
   mkdir -p "$TBDIR/TorBrowser/Data/Browser/Caches"
@@ -126,9 +125,9 @@ cat Bundle-Data/PTConfigs/[% bundledata_osname %]/torrc-defaults-appendix >> "$T
 [% IF c("var/linux") -%]
   [% IF ! c("var/snowflake") %]
     grep -v 'default_bridge\.snowflake' Bundle-Data/PTConfigs/bridge_prefs.js \
-       >> "$TBDIR/$EXTOVERRIDESPATH"
+       >> "$EXTOVERRIDESPATH"
   [% ELSE %]
-    cat Bundle-Data/PTConfigs/bridge_prefs.js >> "$TBDIR/$EXTOVERRIDESPATH"
+    cat Bundle-Data/PTConfigs/bridge_prefs.js >> "$EXTOVERRIDESPATH"
   [% END %]
 [% END -%]
 [% IF c("var/windows") -%]
@@ -136,13 +135,13 @@ cat Bundle-Data/PTConfigs/[% bundledata_osname %]/torrc-defaults-appendix >> "$T
   # We don't have fte available on Windows x86_64 yet
   grep -v 'default_bridge\.snowflake' Bundle-Data/PTConfigs/bridge_prefs.js \
   [% IF c("var/windows-x86_64") %]| grep -v 'default_bridge\.fte' [% END %] \
-      >> "$TBDIR/$EXTOVERRIDESPATH"
+      >> "$EXTOVERRIDESPATH"
 [% END -%]
 [% IF c("var/osx") -%]
   # FTE is temporarily removed due to bug 18495.
   grep -Ev 'default_bridge\.fte' Bundle-Data/PTConfigs/bridge_prefs.js \
   [% IF ! c("var/snowflake") %]| grep -v 'default_bridge\.snowflake' [% END %] \
-      >> "$TBDIR/$EXTOVERRIDESPATH"
+      >> "$EXTOVERRIDESPATH"
 [% END -%]
 cat Bundle-Data/PTConfigs/meek-http-helper-user.js >> "$TBDIR/$MEEKPROFILEPATH/user.js"
 
@@ -156,8 +155,8 @@ cat Bundle-Data/PTConfigs/meek-http-helper-user.js >> "$TBDIR/$MEEKPROFILEPATH/u
 [% END %]
 
 [% IF ! c("var/multi_lingual") %]
-  echo 'pref("extensions.torlauncher.prompt_for_locale", false);' >> "$TBDIR/$EXTOVERRIDESPATH"
-  echo 'pref("intl.locale.matchOS", false);' >> "$TBDIR/$EXTOVERRIDESPATH"
+  echo 'pref("extensions.torlauncher.prompt_for_locale", false);' >> "$EXTOVERRIDESPATH"
+  echo 'pref("intl.locale.matchOS", false);' >> "$EXTOVERRIDESPATH"
 [% END %]
 
 [% IF c("var/linux") %]
@@ -184,6 +183,8 @@ unzip omni.ja chrome/en-US/locale/browser/searchplugins* || [ $? -lt 3 ]
 mv chrome/en-US/locale/browser/searchplugins $rootdir
 rm -rf chrome/en-US
 unzip omni.ja defaults/preferences/000-tor-browser.js || [ $? -lt 3 ]
+# Append our built extension-overrides.js to 000-tor-browser.js
+cat "$EXTOVERRIDESPATH" >> defaults/preferences/000-tor-browser.js
 cp defaults/preferences/000-tor-browser.js $rootdir
 [% IF c("var/osx") %]
   # Embed our default bookmarks within the en-US locale.
-- 
2.17.0

