Bug 1103640 - Allow DeviceActor to work when no browser windows. r=jryans
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 24 Nov 2014 12:33:04 +1100
changeset 217109 2faabeaf92c8d7a2dd2180d04ded1a12349d2506
parent 217108 b9f99bf668a96916fddaaf950f98ca71896b5cb3
child 217110 4991397b35e92067aad4f4e64fc9b95a0650b982
push id52224
push usercbook@mozilla.com
push dateMon, 24 Nov 2014 13:16:24 +0000
treeherdermozilla-inbound@bf9071999612 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1103640
milestone36.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 1103640 - Allow DeviceActor to work when no browser windows. r=jryans
toolkit/devtools/server/actors/device.js
--- a/toolkit/devtools/server/actors/device.js
+++ b/toolkit/devtools/server/actors/device.js
@@ -64,43 +64,45 @@ let DeviceActor = exports.DeviceActor = 
   },
 
   getDescription: method(function() {
     // Most of this code is inspired from Nightly Tester Tools:
     // https://wiki.mozilla.org/Auto-tools/Projects/NightlyTesterTools
 
     let appInfo = Services.appinfo;
     let win = Services.wm.getMostRecentWindow(DebuggerServer.chromeWindowType);
-    let utils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
 
     desc = {
       appid: appInfo.ID,
       apptype: APP_MAP[appInfo.ID],
       vendor: appInfo.vendor,
       name: appInfo.name,
       version: appInfo.version,
       appbuildid: appInfo.appBuildID,
       platformbuildid: appInfo.platformBuildID,
       platformversion: appInfo.platformVersion,
       geckobuildid: appInfo.platformBuildID,
       geckoversion: appInfo.platformVersion,
       changeset: this._getAppIniString("App", "SourceStamp"),
-      useragent: win.navigator.userAgent,
       locale: Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry).getSelectedLocale("global"),
       os: null,
       hardware: "unknown",
       processor: appInfo.XPCOMABI.split("-")[0],
       compiler: appInfo.XPCOMABI.split("-")[1],
-      dpi: utils.displayDPI,
       brandName: null,
       channel: null,
       profile: null,
-      width: win.screen.width,
-      height: win.screen.height
     };
+    if (win) {
+      let utils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+      desc.dpi: utils.displayDPI;
+      desc.useragent = win.navigator.userAgent;
+      desc.width = win.screen.width;
+      desc.height = win.screen.height;
+    }
 
     // Profile
     let profd = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
     let profservice = Cc["@mozilla.org/toolkit/profile-service;1"].getService(Ci.nsIToolkitProfileService);
     var profiles = profservice.profiles;
     while (profiles.hasMoreElements()) {
       let profile = profiles.getNext().QueryInterface(Ci.nsIToolkitProfile);
       if (profile.rootDir.path == profd.path) {