Bug 1428389 - handle case gracefully where weaveXPCService is not available. r=kitcambridge
authorJorg K <jorgk@jorgk.com>
Fri, 05 Jan 2018 14:04:00 +0200
changeset 449892 537f1536010aa800e0e2b7082bc43cc9878d890e
parent 449891 ceb61da04fd81da9f9f835479e90359ccc50ebf7
child 449893 60d0c815b98047ab945bf8b7d2c235bc260ba8ac
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge
bugs1428389
milestone59.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 1428389 - handle case gracefully where weaveXPCService is not available. r=kitcambridge
toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -12,19 +12,24 @@
 this.EXPORTED_SYMBOLS = ["PlacesRemoteTabsAutocompleteProvider"];
 
 const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "weaveXPCService", function() {
-  return Cc["@mozilla.org/weave/service;1"]
-           .getService(Ci.nsISupports)
-           .wrappedJSObject;
+  try {
+    return Cc["@mozilla.org/weave/service;1"]
+             .getService(Ci.nsISupports)
+             .wrappedJSObject;
+  } catch (ex) {
+    // The app didn't build Sync.
+  }
+  return null;
 });
 
 XPCOMUtils.defineLazyGetter(this, "Weave", () => {
   try {
     let {Weave} = Cu.import("resource://services-sync/main.js", {});
     return Weave;
   } catch (ex) {
     // The app didn't build Sync.
@@ -111,17 +116,17 @@ Services.obs.addObserver(observe, "weave
 Services.prefs.addObserver(PREF_SHOW_REMOTE_ICONS, observe);
 observe(null, "nsPref:changed", PREF_SHOW_REMOTE_ICONS);
 
 // This public object is a static singleton.
 this.PlacesRemoteTabsAutocompleteProvider = {
   // a promise that resolves with an array of matching remote tabs.
   getMatches(searchString) {
     // If Sync isn't configured we bail early.
-    if (!weaveXPCService.ready || !weaveXPCService.enabled) {
+    if (!weaveXPCService || !weaveXPCService.ready || !weaveXPCService.enabled) {
       return Promise.resolve([]);
     }
 
     let re = new RegExp(escapeRegExp(searchString), "i");
     let matches = [];
     let { tabs, clients } = ensureItems();
     for (let [url, { clientId, tab }] of tabs) {
       let title = tab.title;