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 draft
authorJared Wein <jwein@mozilla.com>
Mon, 22 Aug 2016 20:34:49 -0400
changeset 404151 d6ec88985795d1a355ced9178e400ab8377d09b7
parent 404150 ecfadaf5a5ddfdc0fc4658198d0f7875ed40562c
child 404152 a902accffa60b40143831e108ef00dafd0e28670
push id27132
push userjwein@mozilla.com
push dateTue, 23 Aug 2016 00:39:37 +0000
reviewersgijs
bugs1286627
milestone51.0a1
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 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;
   }
 });