Bug 1250531 - Only show existing remote clients in the Synced Tabs UI. r?markh draft
authorKit Cambridge <kcambridge@mozilla.com>
Fri, 18 Mar 2016 17:34:34 -0700
changeset 342363 909e25d537e6998884aa9b66f940a87094ab7a92
parent 342362 9d4cc2d0f5f6105d7236e5b5a8e5bfa1650a6ecc
child 516578 557d2e77a4e2c5408c7e390549c660b9d030d251
push id13413
push userkcambridge@mozilla.com
push dateSat, 19 Mar 2016 00:35:11 +0000
reviewersmarkh
bugs1250531
milestone48.0a1
Bug 1250531 - Only show existing remote clients in the Synced Tabs UI. r?markh MozReview-Commit-ID: LQw7TinhIfE
services/sync/modules/SyncedTabs.jsm
services/sync/modules/engines/clients.js
services/sync/tests/unit/test_syncedtabs.js
--- a/services/sync/modules/SyncedTabs.jsm
+++ b/services/sync/modules/SyncedTabs.jsm
@@ -116,16 +116,19 @@ let SyncedTabsInternal = {
 
     let engine = Weave.Service.engineManager.get("tabs");
 
     let seenURLs = new Set();
     let parentIndex = 0;
     let ntabs = 0;
 
     for (let [guid, client] in Iterator(engine.getAllClients())) {
+      if (!Weave.Service.clientsEngine.remoteClientExists(client.id)) {
+        continue;
+      }
       let clientRepr = yield this._makeClient(client);
       log.debug("Processing client", clientRepr);
 
       for (let tab of client.tabs) {
         let url = tab.urlHistory[0];
         log.debug("remote tab", url);
         // Note there are some issues with tracking "seen" tabs, including:
         // * We really can't return the entire urlHistory record as we are
--- a/services/sync/modules/engines/clients.js
+++ b/services/sync/modules/engines/clients.js
@@ -141,16 +141,20 @@ ClientEngine.prototype = {
 
   get localType() {
     return Utils.getDeviceType();
   },
   set localType(value) {
     Svc.Prefs.set("client.type", value);
   },
 
+  remoteClientExists(id) {
+    return !!this._store._remoteClients[id];
+  },
+
   isMobile: function isMobile(id) {
     if (this._store._remoteClients[id])
       return this._store._remoteClients[id].type == DEVICE_TYPE_MOBILE;
     return false;
   },
 
   _wipeCachedClients() {
     for (let id in this._store.getAllIDs()) {
--- a/services/sync/tests/unit/test_syncedtabs.js
+++ b/services/sync/tests/unit/test_syncedtabs.js
@@ -34,16 +34,19 @@ MockTabsEngine.prototype = {
 // A clients engine that doesn't need to be a constructor.
 let MockClientsEngine = {
   isMobile(guid) {
     if (!guid.endsWith("desktop") && !guid.endsWith("mobile")) {
       throw new Error("this module expected guids to end with 'desktop' or 'mobile'");
     }
     return guid.endsWith("mobile");
   },
+  remoteClientExists(id) {
+    return true;
+  },
 }
 
 // Configure Sync with our mock tabs engine and force it to become initialized.
 Services.prefs.setCharPref("services.sync.username", "someone@somewhere.com");
 
 Weave.Service.engineManager.unregister("tabs");
 Weave.Service.engineManager.register(MockTabsEngine);
 Weave.Service.clientsEngine = MockClientsEngine;