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:
Changes:
browser/components/securitylevel/content/securityLevel.js
... |
... |
@@ -2,11 +2,9 @@ |
2
|
2
|
|
3
|
3
|
/* global AppConstants, Services, openPreferences, XPCOMUtils */
|
4
|
4
|
|
5
|
|
-ChromeUtils.defineModuleGetter(
|
6
|
|
- this,
|
7
|
|
- "SecurityLevelPrefs",
|
8
|
|
- "resource://gre/modules/SecurityLevel.jsm"
|
9
|
|
-);
|
|
5
|
+ChromeUtils.defineESModuleGetters(this, {
|
|
6
|
+ SecurityLevelPrefs: "resource://gre/modules/SecurityLevel.sys.mjs",
|
|
7
|
+});
|
10
|
8
|
|
11
|
9
|
/*
|
12
|
10
|
Security Level Button Code
|
toolkit/components/search/SearchEngine.sys.mjs
... |
... |
@@ -12,14 +12,9 @@ const lazy = {}; |
12
|
12
|
ChromeUtils.defineESModuleGetters(lazy, {
|
13
|
13
|
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
|
14
|
14
|
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
|
|
15
|
+ SecurityLevelPrefs: "resource://gre/modules/SecurityLevel.sys.mjs",
|
15
|
16
|
});
|
16
|
17
|
|
17
|
|
-ChromeUtils.defineModuleGetter(
|
18
|
|
- lazy,
|
19
|
|
- "SecurityLevelPrefs",
|
20
|
|
- "resource://gre/modules/SecurityLevel.jsm"
|
21
|
|
-);
|
22
|
|
-
|
23
|
18
|
const BinaryInputStream = Components.Constructor(
|
24
|
19
|
"@mozilla.org/binaryinputstream;1",
|
25
|
20
|
"nsIBinaryInputStream",
|
toolkit/components/securitylevel/SecurityLevel.jsm
→
toolkit/components/securitylevel/SecurityLevel.sys.mjs
1
|
|
-"use strict";
|
2
|
|
-
|
3
|
|
-var EXPORTED_SYMBOLS = ["SecurityLevel", "SecurityLevelPrefs"];
|
4
|
|
-
|
5
|
|
-const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
6
|
|
-const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
|
|
1
|
+import { ConsoleAPI } from "resource://gre/modules/Console.sys.mjs";
|
7
|
2
|
|
8
|
3
|
const lazy = {};
|
9
|
4
|
|
10
|
|
-ChromeUtils.defineModuleGetter(
|
11
|
|
- lazy,
|
12
|
|
- "ExtensionParent",
|
13
|
|
- "resource://gre/modules/ExtensionParent.jsm"
|
14
|
|
-);
|
|
5
|
+ChromeUtils.defineESModuleGetters(lazy, {
|
|
6
|
+ ExtensionParent: "resource://gre/modules/ExtensionParent.sys.mjs",
|
|
7
|
+});
|
15
|
8
|
|
16
|
9
|
const logger = new ConsoleAPI({
|
17
|
10
|
maxLogLevel: "info",
|
... |
... |
@@ -263,6 +256,7 @@ var initializeNoScriptControl = () => { |
263
|
256
|
// bind NoScript settings to the browser.security_level.security_slider
|
264
|
257
|
// (see noscript-control.js).
|
265
|
258
|
/* eslint-disable */
|
|
259
|
+// prettier-ignore
|
266
|
260
|
const kSecuritySettings = {
|
267
|
261
|
// Preference name : [0, 1-high 2-m 3-m 4-low]
|
268
|
262
|
"_javascript_.options.ion" : [, false, false, false, true ],
|
... |
... |
@@ -427,7 +421,7 @@ function migratePreferences() { |
427
|
421
|
}
|
428
|
422
|
|
429
|
423
|
// This class is used to initialize the security level stuff at the startup
|
430
|
|
-class SecurityLevel {
|
|
424
|
+export class SecurityLevel {
|
431
|
425
|
QueryInterface = ChromeUtils.generateQI(["nsIObserver"]);
|
432
|
426
|
|
433
|
427
|
init() {
|
... |
... |
@@ -448,7 +442,7 @@ class SecurityLevel { |
448
|
442
|
|
449
|
443
|
Getters and Setters for relevant torbutton prefs
|
450
|
444
|
*/
|
451
|
|
-const SecurityLevelPrefs = {
|
|
445
|
+export const SecurityLevelPrefs = {
|
452
|
446
|
SecurityLevels: Object.freeze({
|
453
|
447
|
safest: 1,
|
454
|
448
|
safer: 2,
|
toolkit/components/securitylevel/components.conf
... |
... |
@@ -4,7 +4,7 @@ Classes = [ |
4
|
4
|
"contract_ids": [
|
5
|
5
|
"@torproject.org/security-level;1",
|
6
|
6
|
],
|
7
|
|
- "jsm": "resource://gre/modules/SecurityLevel.jsm",
|
|
7
|
+ "esModule": "resource://gre/modules/SecurityLevel.sys.mjs",
|
8
|
8
|
"constructor": "SecurityLevel",
|
9
|
9
|
}
|
10
|
10
|
] |
toolkit/components/securitylevel/moz.build
1
|
1
|
EXTRA_JS_MODULES += [
|
2
|
|
- "SecurityLevel.jsm",
|
|
2
|
+ "SecurityLevel.sys.mjs",
|
3
|
3
|
]
|
4
|
4
|
|
5
|
5
|
XPCOM_MANIFESTS += [
|
toolkit/modules/TorStrings.sys.mjs
... |
... |
@@ -3,10 +3,7 @@ |
3
|
3
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
4
|
4
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
5
|
5
|
|
6
|
|
-const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
7
|
|
-const { AppConstants } = ChromeUtils.import(
|
8
|
|
- "resource://gre/modules/AppConstants.jsm"
|
9
|
|
-);
|
|
6
|
+import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
10
|
7
|
|
11
|
8
|
function getLocale() {
|
12
|
9
|
const locale = Services.locale.appLocaleAsBCP47;
|
|