Pier Angelo Vendrame pushed to branch tor-browser-115.9.0esr-13.5-1 at The Tor Project / Applications / Tor Browser
Commits: 41d01e49 by Pier Angelo Vendrame at 2024-03-27T10:04:05+01:00 fixup! Add TorStrings module for localization
Bug 42481: Modularize SecurityLevel.
- - - - - 494af376 by Pier Angelo Vendrame at 2024-03-27T10:07:34+01:00 fixup! Bug 40925: Implemented the Security Level component
Bug 42481: Modularize SecurityLevel.
- - - - -
6 changed files:
- browser/components/securitylevel/content/securityLevel.js - toolkit/components/search/SearchEngine.sys.mjs - toolkit/components/securitylevel/SecurityLevel.jsm → toolkit/components/securitylevel/SecurityLevel.sys.mjs - toolkit/components/securitylevel/components.conf - toolkit/components/securitylevel/moz.build - toolkit/modules/TorStrings.sys.mjs
Changes:
===================================== browser/components/securitylevel/content/securityLevel.js ===================================== @@ -2,11 +2,9 @@
/* global AppConstants, Services, openPreferences, XPCOMUtils */
-ChromeUtils.defineModuleGetter( - this, - "SecurityLevelPrefs", - "resource://gre/modules/SecurityLevel.jsm" -); +ChromeUtils.defineESModuleGetters(this, { + SecurityLevelPrefs: "resource://gre/modules/SecurityLevel.sys.mjs", +});
/* Security Level Button Code
===================================== toolkit/components/search/SearchEngine.sys.mjs ===================================== @@ -12,14 +12,9 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs", SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs", + SecurityLevelPrefs: "resource://gre/modules/SecurityLevel.sys.mjs", });
-ChromeUtils.defineModuleGetter( - lazy, - "SecurityLevelPrefs", - "resource://gre/modules/SecurityLevel.jsm" -); - const BinaryInputStream = Components.Constructor( "@mozilla.org/binaryinputstream;1", "nsIBinaryInputStream",
===================================== toolkit/components/securitylevel/SecurityLevel.jsm → toolkit/components/securitylevel/SecurityLevel.sys.mjs ===================================== @@ -1,17 +1,10 @@ -"use strict"; - -var EXPORTED_SYMBOLS = ["SecurityLevel", "SecurityLevelPrefs"]; - -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm"); +import { ConsoleAPI } from "resource://gre/modules/Console.sys.mjs";
const lazy = {};
-ChromeUtils.defineModuleGetter( - lazy, - "ExtensionParent", - "resource://gre/modules/ExtensionParent.jsm" -); +ChromeUtils.defineESModuleGetters(lazy, { + ExtensionParent: "resource://gre/modules/ExtensionParent.sys.mjs", +});
const logger = new ConsoleAPI({ maxLogLevel: "info", @@ -263,6 +256,7 @@ var initializeNoScriptControl = () => { // bind NoScript settings to the browser.security_level.security_slider // (see noscript-control.js). /* eslint-disable */ +// prettier-ignore const kSecuritySettings = { // Preference name : [0, 1-high 2-m 3-m 4-low] "javascript.options.ion" : [, false, false, false, true ], @@ -427,7 +421,7 @@ function migratePreferences() { }
// This class is used to initialize the security level stuff at the startup -class SecurityLevel { +export class SecurityLevel { QueryInterface = ChromeUtils.generateQI(["nsIObserver"]);
init() { @@ -448,7 +442,7 @@ class SecurityLevel {
Getters and Setters for relevant torbutton prefs */ -const SecurityLevelPrefs = { +export const SecurityLevelPrefs = { SecurityLevels: Object.freeze({ safest: 1, safer: 2,
===================================== toolkit/components/securitylevel/components.conf ===================================== @@ -4,7 +4,7 @@ Classes = [ "contract_ids": [ "@torproject.org/security-level;1", ], - "jsm": "resource://gre/modules/SecurityLevel.jsm", + "esModule": "resource://gre/modules/SecurityLevel.sys.mjs", "constructor": "SecurityLevel", } ]
===================================== toolkit/components/securitylevel/moz.build ===================================== @@ -1,5 +1,5 @@ EXTRA_JS_MODULES += [ - "SecurityLevel.jsm", + "SecurityLevel.sys.mjs", ]
XPCOM_MANIFESTS += [
===================================== toolkit/modules/TorStrings.sys.mjs ===================================== @@ -3,10 +3,7 @@ // 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/.
-const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const { AppConstants } = ChromeUtils.import( - "resource://gre/modules/AppConstants.jsm" -); +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
function getLocale() { const locale = Services.locale.appLocaleAsBCP47;
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/9e01b1a...