mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 15:26:07 +00:00
Bug 1541508 - Use Services.env in remote/ r=whimboo,webdriver-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D160144
This commit is contained in:
parent
e48f6a32ef
commit
3618828859
@ -24,13 +24,6 @@ XPCOMUtils.defineLazyGetter(lazy, "logger", () =>
|
||||
|
||||
XPCOMUtils.defineLazyGetter(lazy, "textEncoder", () => new TextEncoder());
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
lazy,
|
||||
"env",
|
||||
"@mozilla.org/process/environment;1",
|
||||
"nsIEnvironment"
|
||||
);
|
||||
|
||||
const NOTIFY_LISTENING = "marionette-listening";
|
||||
|
||||
// Complements -marionette flag for starting the Marionette server.
|
||||
@ -72,7 +65,7 @@ class MarionetteParentProcess {
|
||||
this.helpInfo = " --marionette Enable remote control server.\n";
|
||||
|
||||
// Initially set the enabled state based on the environment variable.
|
||||
this.enabled = lazy.env.exists(ENV_ENABLED);
|
||||
this.enabled = Services.env.exists(ENV_ENABLED);
|
||||
|
||||
Services.ppmm.addMessageListener("Marionette:IsRunning", this);
|
||||
|
||||
@ -238,7 +231,7 @@ class MarionetteParentProcess {
|
||||
return;
|
||||
}
|
||||
|
||||
lazy.env.set(ENV_ENABLED, "1");
|
||||
Services.env.set(ENV_ENABLED, "1");
|
||||
Services.obs.notifyObservers(this, NOTIFY_LISTENING, true);
|
||||
lazy.logger.debug("Marionette is listening");
|
||||
|
||||
|
@ -2,17 +2,6 @@
|
||||
* 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/. */
|
||||
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
lazy,
|
||||
"env",
|
||||
"@mozilla.org/process/environment;1",
|
||||
"nsIEnvironment"
|
||||
);
|
||||
|
||||
const { PREF_BOOL, PREF_INT, PREF_INVALID, PREF_STRING } = Ci.nsIPrefBranch;
|
||||
|
||||
export class Branch {
|
||||
@ -169,13 +158,13 @@ export class EnvironmentPrefs {
|
||||
* @return {Iterable.<string, (string|boolean|number)>
|
||||
*/
|
||||
static *from(key) {
|
||||
if (!lazy.env.exists(key)) {
|
||||
if (!Services.env.exists(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let prefs;
|
||||
try {
|
||||
prefs = JSON.parse(lazy.env.get(key));
|
||||
prefs = JSON.parse(Services.env.get(key));
|
||||
} catch (e) {
|
||||
throw new TypeError(`Unable to parse prefs from ${key}`, e);
|
||||
}
|
||||
|
@ -4,17 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
this,
|
||||
"env",
|
||||
"@mozilla.org/process/environment;1",
|
||||
"nsIEnvironment"
|
||||
);
|
||||
|
||||
const {
|
||||
Branch,
|
||||
EnvironmentPrefs,
|
||||
@ -94,14 +83,14 @@ add_test(function test_EnvironmentPrefs_from() {
|
||||
"test.int": 888,
|
||||
"test.string": "bar",
|
||||
};
|
||||
env.set("FOO", JSON.stringify(prefsTable));
|
||||
Services.env.set("FOO", JSON.stringify(prefsTable));
|
||||
|
||||
try {
|
||||
for (let [key, value] of EnvironmentPrefs.from("FOO")) {
|
||||
equal(prefsTable[key], value);
|
||||
}
|
||||
} finally {
|
||||
env.set("FOO", null);
|
||||
Services.env.set("FOO", null);
|
||||
}
|
||||
|
||||
run_next_test();
|
||||
|
Loading…
x
Reference in New Issue
Block a user