[tbb-commits] [torbutton] branch maint-11.5 updated: Bug 41460: Migrate preferences to the name we will user for 12.0.
gitolite role
git at cupani.torproject.org
Fri Nov 18 11:50:36 UTC 2022
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch maint-11.5
in repository torbutton.
The following commit(s) were added to refs/heads/maint-11.5 by this push:
new 86cdbafd Bug 41460: Migrate preferences to the name we will user for 12.0.
86cdbafd is described below
commit 86cdbafdffdb5e8552f664b33e7668a8492fa2df
Author: Pier Angelo Vendrame <pierov at torproject.org>
AuthorDate: Thu Nov 17 17:51:58 2022 +0100
Bug 41460: Migrate preferences to the name we will user for 12.0.
We are forcing users to pass by 11.5.8, so, instead of adding migration
code in 12.0 and keep it for a long time, we just add it to 11.5.
---
chrome/content/preferences-mobile.js | 10 ++++-----
chrome/content/torbutton.js | 8 +++----
components/startup-observer.js | 41 ++++++++++++++++++++++++++++++++++++
modules/noscript-control.js | 10 ++++-----
modules/security-prefs.js | 18 ++++++++--------
5 files changed, 64 insertions(+), 23 deletions(-)
diff --git a/chrome/content/preferences-mobile.js b/chrome/content/preferences-mobile.js
index fa79dce8..4b357e72 100644
--- a/chrome/content/preferences-mobile.js
+++ b/chrome/content/preferences-mobile.js
@@ -39,19 +39,19 @@ function torbutton_set_slider(sliderValue) {
torbutton_save_security_settings();
}
-// Read prefs 'extensions.torbutton.security_slider' and
-// 'extensions.torbutton.security_custom', and initialize the UI.
+// Read prefs 'browser.security_level.security_slider' and
+// 'browser.security_level.security_custom', and initialize the UI.
function torbutton_init_security_ui() {
torbutton_set_slider(prefSettingToSliderPosition(
- getIntPref("extensions.torbutton.security_slider")));
+ getIntPref("browser.security_level.security_slider")));
torbutton_set_learn_more_links();
}
// Write the two prefs from the current settings.
function torbutton_save_security_settings() {
- setIntPref("extensions.torbutton.security_slider",
+ setIntPref("browser.security_level.security_slider",
sliderPositionToPrefSetting(state.slider));
- setBoolPref("extensions.torbutton.security_custom", state.custom);
+ setBoolPref("browser.security_level.security_custom", state.custom);
}
// We follow the way we treat the links to the Tor Browser User Manual on the
diff --git a/chrome/content/torbutton.js b/chrome/content/torbutton.js
index 2f6ff1ee..d2c2d2b7 100644
--- a/chrome/content/torbutton.js
+++ b/chrome/content/torbutton.js
@@ -393,7 +393,7 @@ torbutton_new_identity = async function() {
newIdentityInProgress = true;
- let shouldConfirm = m_tb_prefs.getBoolPref("extensions.torbutton.confirm_newnym");
+ let shouldConfirm = m_tb_prefs.getBoolPref("browser.new_identity.confirm_newnym");
if (shouldConfirm) {
let prompts = Services.prompt;
@@ -408,7 +408,7 @@ torbutton_new_identity = async function() {
let confirmed = (prompts.confirmEx(null, "", message, flags, null, null, null,
askAgainText, askAgain) == 0);
- m_tb_prefs.setBoolPref("extensions.torbutton.confirm_newnym", !askAgain.value);
+ m_tb_prefs.setBoolPref("browser.new_identity.confirm_newnym", !askAgain.value);
if (confirmed) {
await torbutton_do_new_identity();
@@ -507,7 +507,7 @@ async function torbutton_do_new_identity() {
torbutton_log(3, "New Identity: Clearing HTTP Auth");
- if (m_tb_prefs.getBoolPref("extensions.torbutton.clear_http_auth")) {
+ if (m_tb_prefs.getBoolPref("browser.new_identity.clear_http_auth")) {
var auth = Cc["@mozilla.org/network/http-auth-manager;1"].
getService(Ci.nsIHttpAuthManager);
auth.clearAll();
@@ -979,7 +979,7 @@ function torbutton_update_fingerprinting_prefs() {
// This function closes all XUL browser windows except this one. For this
// window, it closes all existing tabs and creates one about:blank tab.
function torbutton_close_tabs_on_new_identity() {
- if (!m_tb_prefs.getBoolPref("extensions.torbutton.close_newnym")) {
+ if (!m_tb_prefs.getBoolPref("browser.new_identity.close_newnym")) {
torbutton_log(3, "Not closing tabs");
return;
}
diff --git a/components/startup-observer.js b/components/startup-observer.js
index f9697987..bf89b9b9 100644
--- a/components/startup-observer.js
+++ b/components/startup-observer.js
@@ -193,6 +193,8 @@ StartupObserver.prototype = {
// but only for hackish reasons.
this._prefs.setBoolPref("extensions.torbutton.startup", true);
+ this.updatePreferences();
+
// We need to listen for NoScript before it starts.
NoScriptControl.initialize();
@@ -205,6 +207,45 @@ StartupObserver.prototype = {
Services.prefs.savePrefFile(null);
},
+ updatePreferences: function() {
+ // tor-browser#41460: Prepare 11.5.8 for 12.0
+ const kUpdatePrefName = "extensions.torbutton.pref_fixup_for_12";
+ if(Services.prefs.getBoolPref(kUpdatePrefName, false)) {
+ return;
+ }
+ const migrate = (oldName, newName, getter, setter) => {
+ oldName = `extensions.torbutton.${oldName}`;
+ newName = `browser.${newName}`;
+ if (Services.prefs.prefHasUserValue(oldName)) {
+ setter(newName, getter(oldName));
+ Services.prefs.clearUserPref(oldName);
+ }
+ };
+ const prefs = {
+ close_newnym: "new_identity.close_newnym",
+ clear_http_auth: "new_identity.clear_http_auth",
+ confirm_newnym: "new_identity.confirm_newnym",
+ security_custom: "security_level.security_custom",
+ noscript_persist: "security_level.noscript_persist",
+ noscript_inited: "security_level.noscript_inited",
+ }
+ for (const [oldName, newName] of Object.entries(prefs)) {
+ migrate(
+ oldName,
+ newName,
+ Services.prefs.getBoolPref.bind(Services.prefs),
+ Services.prefs.setBoolPref.bind(Services.prefs)
+ );
+ }
+ migrate(
+ "security_slider",
+ "security_level.security_slider",
+ Services.prefs.getIntPref.bind(Services.prefs),
+ Services.prefs.setIntPref.bind(Services.prefs)
+ );
+ Services.prefs.setBoolPref(kUpdatePrefName, true);
+ },
+
QueryInterface: ChromeUtils.generateQI([Ci.nsIClassInfo]),
// method of nsIClassInfo
diff --git a/modules/noscript-control.js b/modules/noscript-control.js
index ea735377..397153fb 100644
--- a/modules/noscript-control.js
+++ b/modules/noscript-control.js
@@ -174,7 +174,7 @@ var initialize = () => {
sendNoScriptSettings(noscriptSettings(safetyLevel));
// __securitySliderToSafetyLevel(sliderState)__.
- // Converts the "extensions.torbutton.security_slider" pref value
+ // Converts the "browser.security_level.security_slider" pref value
// to a "safety level" value: 0 = Standard, 1 = Safer, 2 = Safest
let securitySliderToSafetyLevel = sliderState =>
[undefined, 2, 1, 1, 0][sliderState];
@@ -184,18 +184,18 @@ var initialize = () => {
let messageListener = a => {
try {
log(3, `Message received from NoScript: ${JSON.stringify([a])}`);
- let noscriptPersist = Services.prefs.getBoolPref("extensions.torbutton.noscript_persist", false);
- let noscriptInited = Services.prefs.getBoolPref("extensions.torbutton.noscript_inited", false);
+ let noscriptPersist = Services.prefs.getBoolPref("browser.security_level.noscript_persist", false);
+ let noscriptInited = Services.prefs.getBoolPref("browser.security_level.noscript_inited", false);
// Set the noscript safety level once if we have never run noscript
// before, or if we are not allowing noscript per-site settings to be
// persisted between browser sessions. Otherwise make sure that the
// security slider position, if changed, will rewrite the noscript
// settings.
- bindPref("extensions.torbutton.security_slider",
+ bindPref("browser.security_level.security_slider",
sliderState => setNoScriptSafetyLevel(securitySliderToSafetyLevel(sliderState)),
!noscriptPersist || !noscriptInited);
if (!noscriptInited) {
- Services.prefs.setBoolPref("extensions.torbutton.noscript_inited", true);
+ Services.prefs.setBoolPref("browser.security_level.noscript_inited", true);
}
} catch (e) {
log(5, e.message);
diff --git a/modules/security-prefs.js b/modules/security-prefs.js
index c41458fa..c3ff682e 100644
--- a/modules/security-prefs.js
+++ b/modules/security-prefs.js
@@ -16,7 +16,7 @@ let log = (level, msg) => logger.log(level, msg);
// A table of all prefs bound to the security slider, and the value
// for each security setting. Note that 2-m and 3-m are identical,
// corresponding to the old 2-medium-high setting. We also separately
-// bind NoScript settings to the extensions.torbutton.security_slider
+// bind NoScript settings to the browser.security_level.security_slider
// (see noscript-control.js).
const kSecuritySettings = {
// Preference name : [0, 1-high 2-m 3-m 4-low]
@@ -33,9 +33,9 @@ const kSecuritySettings = {
};
// The Security Settings prefs in question.
-const kSliderPref = "extensions.torbutton.security_slider";
-const kCustomPref = "extensions.torbutton.security_custom";
-const kSliderMigration = "extensions.torbutton.security_slider_migration";
+const kSliderPref = "browser.security_level.security_slider";
+const kCustomPref = "browser.security_level.security_custom";
+const kSliderMigration = "browser.security_level.security_slider_migration";
// ### Prefs
@@ -92,8 +92,8 @@ var watch_security_prefs = function (onSettingChanged) {
var initialized = false;
// __initialize()__.
-// Defines the behavior of "extensions.torbutton.security_custom",
-// "extensions.torbutton.security_slider", and the security-sensitive
+// Defines the behavior of "browser.security_level.security_custom",
+// "browser.security_level.security_slider", and the security-sensitive
// prefs declared in kSecuritySettings.
var initialize = function () {
// Only run once.
@@ -126,9 +126,9 @@ var initialize = function () {
}
});
// Migrate from old medium-low (3) to new medium (2).
- if (getBoolPref("extensions.torbutton.security_custom") === false &&
- getIntPref("extensions.torbutton.security_slider") === 3) {
- setIntPref("extensions.torbutton.security_slider", 2);
+ if (getBoolPref("browser.security_level.security_custom") === false &&
+ getIntPref("browser.security_level.security_slider") === 3) {
+ setIntPref("browser.security_level.security_slider", 2);
write_setting_to_prefs(2);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list