Bug 1378833 - use Environment service instead of sdk/system/environment in WebIDE;r=ochameau
MozReview-Commit-ID: 9Uc9HYImK6G
--- a/devtools/client/webide/modules/simulator-process.js
+++ b/devtools/client/webide/modules/simulator-process.js
@@ -2,17 +2,18 @@
* 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/.
*/
"use strict";
const { Cc, Ci, Cu } = require("chrome");
-const Environment = require("sdk/system/environment").env;
+const Environment = Cc["@mozilla.org/process/environment;1"]
+ .getService(Ci.nsIEnvironment);
const EventEmitter = require("devtools/shared/event-emitter");
const Subprocess = require("sdk/system/child_process/subprocess");
const Services = require("Services");
loader.lazyGetter(this, "OS", () => {
const Runtime = require("sdk/system/runtime");
switch (Runtime.OS) {
case "Darwin":
@@ -72,21 +73,21 @@ SimulatorProcess.prototype = {
this.once("exit", () => {
this.off("stdout", logHandler);
this.off("stderr", logHandler);
});
let environment;
if (OS.indexOf("linux") > -1) {
environment = ["TMPDIR=" + Services.dirsvc.get("TmpD", Ci.nsIFile).path];
- ["DISPLAY", "XAUTHORITY"].forEach(key => {
- if (key in Environment) {
- environment.push(key + "=" + Environment[key]);
- }
- });
+ ["DISPLAY", "XAUTHORITY"]
+ .filter(key => Environment.exists(key))
+ .forEach(key => {
+ environment.push(key + "=" + Environment.get(key));
+ });
}
// Spawn a B2G instance.
this.process = Subprocess.call({
command: b2g,
arguments: this.args,
environment: environment,
stdout: data => this.emit("stdout", data),