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
--- 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;
}
});