Bug 1378833 - use Environment service instead of sdk/system/environment in WebIDE;r=ochameau draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 24 Jul 2017 23:11:17 +0200
changeset 615216 5f4096492595f682dacad69d7c4da3368ebd878c
parent 615213 c5f3042087d4f52f57dfa8ac8962025134bdbc99
child 639104 8bb71f67f2408965b481357b271a97265d0e661a
push id70271
push userjdescottes@mozilla.com
push dateTue, 25 Jul 2017 16:19:22 +0000
reviewersochameau
bugs1378833
milestone56.0a1
Bug 1378833 - use Environment service instead of sdk/system/environment in WebIDE;r=ochameau MozReview-Commit-ID: 9Uc9HYImK6G
devtools/client/webide/modules/simulator-process.js
--- 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),