Bug 1196288 - Fix various exceptions in gcli on b2g. r=jwalker
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 08 Sep 2015 09:48:38 -0700
changeset 293941 4cb79a78ecf5854b05717e8a871a55b043b1cc4a
parent 293940 5f5ffdb6dba376015615bac236f5cba08f544edf
child 293942 e95bfd7d9d36420790c0290fadf06f84b5cf069d
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalker
bugs1196288
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1196288 - Fix various exceptions in gcli on b2g. r=jwalker
toolkit/devtools/gcli/commands/calllog.js
toolkit/devtools/gcli/commands/paintflashing.js
toolkit/devtools/gcli/commands/rulers.js
toolkit/devtools/gcli/source/lib/gcli/util/filesystem.js
--- a/toolkit/devtools/gcli/commands/calllog.js
+++ b/toolkit/devtools/gcli/commands/calllog.js
@@ -4,16 +4,18 @@
 
 "use strict";
 
 const { Cc, Ci, Cu } = require("chrome");
 const {TargetFactory} = require("devtools/framework/target");
 const l10n = require("gcli/l10n");
 const gcli = require("gcli/index");
 
+loader.lazyRequireGetter(this, "TargetFactory", "devtools/framework/target", true);
+
 loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
 
 loader.lazyGetter(this, "Debugger", () => {
   let global = Cu.getGlobalForObject({});
   let JsDebugger = Cu.import("resource://gre/modules/jsdebugger.jsm", {});
   JsDebugger.addDebuggerToGlobal(global);
   return global.Debugger;
 });
--- a/toolkit/devtools/gcli/commands/paintflashing.js
+++ b/toolkit/devtools/gcli/commands/paintflashing.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 { Ci } = require("chrome");
-const { getOuterId } = require("sdk/window/utils");
-const { getBrowserForTab } = require("sdk/tabs/utils");
+loader.lazyRequireGetter(this, "getOuterId", "sdk/window/utils", true);
+loader.lazyRequireGetter(this, "getBrowserForTab", "sdk/tabs/utils", true);
 
 let telemetry;
 try {
   const Telemetry = require("devtools/shared/telemetry");
   telemetry = new Telemetry();
 } catch(e) {
   // DevTools Telemetry module only available in Firefox
 }
--- a/toolkit/devtools/gcli/commands/rulers.js
+++ b/toolkit/devtools/gcli/commands/rulers.js
@@ -2,18 +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 EventEmitter = require("devtools/toolkit/event-emitter");
 const eventEmitter = new EventEmitter();
 const events = require("sdk/event/core");
-const { getOuterId } = require("sdk/window/utils");
-const { getBrowserForTab } = require("sdk/tabs/utils");
+loader.lazyRequireGetter(this, "getOuterId", "sdk/window/utils", true);
+loader.lazyRequireGetter(this, "getBrowserForTab", "sdk/tabs/utils", true);
 
 const l10n = require("gcli/l10n");
 require("devtools/server/actors/inspector");
 const { RulersHighlighter, HighlighterEnvironment } =
   require("devtools/server/actors/highlighter");
 
 const highlighters = new WeakMap();
 const visibleHighlighters = new Set();
--- a/toolkit/devtools/gcli/source/lib/gcli/util/filesystem.js
+++ b/toolkit/devtools/gcli/source/lib/gcli/util/filesystem.js
@@ -27,19 +27,24 @@ var OS = Cu.import('resource://gre/modul
  * really universal in scope) but also kind of do (because they're not specific
  * to GCLI
  */
 
 exports.join = OS.Path.join;
 exports.sep = OS.Path.sep;
 exports.dirname = OS.Path.dirname;
 
-var dirService = Cc['@mozilla.org/file/directory_service;1']
-                           .getService(Ci.nsIProperties);
-exports.home = dirService.get('Home', Ci.nsIFile).path;
+// On B2G, there is no home folder
+var home = null;
+try {
+  var dirService = Cc['@mozilla.org/file/directory_service;1']
+                     .getService(Ci.nsIProperties);
+  home = dirService.get('Home', Ci.nsIFile).path;
+} catch(e) {}
+exports.home = home;
 
 if ('winGetDrive' in OS.Path) {
   exports.sep = '\\';
 }
 else {
   exports.sep = '/';
 }