Bug 1286627 - Check for undefined shell service before dereferencing it in the ShellService proxy. Linux builds that disable gio do not have the shell service defined and the proxy was throwing. r=Gijs a=ritu
authorJared Wein <jwein@mozilla.com>
Mon, 22 Aug 2016 20:34:49 -0400
changeset 349982 c66cc1b3d2273988fc49f14ca70464302248cb6a
parent 349981 02876d17a0b794ac7c2959a763a92960463d92b0
child 349983 21e634320cc7519d011ca8e28dbb8be116388897
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, ritu
bugs1286627
milestone50.0a2
Bug 1286627 - Check for undefined shell service before dereferencing it in the ShellService proxy. Linux builds that disable gio do not have the shell service defined and the proxy was throwing. r=Gijs a=ritu MozReview-Commit-ID: 1wWcEfWFP2c
browser/components/nsBrowserContentHandler.js
browser/components/shell/ShellService.jsm
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -710,22 +710,22 @@ nsDefaultCommandLineHandler.prototype = 
 
   /* nsICommandLineHandler */
   handle : function dch_handle(cmdLine) {
     // The -url flag is inserted by the operating system when the default
     // application handler is used. We check for default browser to remove
     // instances where users explicitly decide to "open with" the browser.
     // Note that users who launch firefox manually with the -url flag will
     // get erroneously counted.
-    if (cmdLine.findFlag("url", false) &&
-        ShellService.isDefaultBrowser(false, false)) {
-      try {
+    try {
+      if (cmdLine.findFlag("url", false) &&
+          ShellService.isDefaultBrowser(false, false)) {
         Services.telemetry.getHistogramById("FX_STARTUP_EXTERNAL_CONTENT_HANDLER").add();
-      } catch (e) {}
-    }
+      }
+    } catch (e) {}
 
     var urilist = [];
 
     if (AppConstants.platform == "win") {
       // If we don't have a profile selected yet (e.g. the Profile Manager is
       // displayed) we will crash if we open an url and then select a profile. To
       // prevent this handle all url command line flags and set the command line's
       // preventDefault to true to prevent the display of the ui. The initial
--- a/browser/components/shell/ShellService.jsm
+++ b/browser/components/shell/ShellService.jsm
@@ -96,12 +96,18 @@ let ShellServiceInternal = {
 XPCOMUtils.defineLazyServiceGetter(ShellServiceInternal, "shellService",
   "@mozilla.org/browser/shell-service;1", Ci.nsIShellService);
 
 /**
  * The external API exported by this module.
  */
 this.ShellService = new Proxy(ShellServiceInternal, {
   get(target, name) {
-    return name in target ? target[name] :
-                            target.shellService[name];
+    if (name in target) {
+      return target[name];
+    }
+    if (target.shellService) {
+      return target.shellService[name];
+    }
+    Services.console.logStringMessage(`${name} not found in ShellService: ${target.shellService}`);
+    return undefined;
   }
 });