Bug 1250531 - Only show existing remote clients in the Synced Tabs UI. r=markh

MozReview-Commit-ID: LQw7TinhIfE

--HG--
extra : rebase_source : 6090764abd0aa3d7422677c04d8d8cf242cec793
This commit is contained in:
Kit Cambridge 2016-03-31 14:36:40 -07:00
Родитель 814c90a39d
Коммит d1de4b6824
3 изменённых файлов: 45 добавлений и 0 удалений

Просмотреть файл

@ -121,6 +121,9 @@ let SyncedTabsInternal = {
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);

Просмотреть файл

@ -140,6 +140,10 @@ ClientEngine.prototype = {
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;

Просмотреть файл

@ -39,6 +39,9 @@ let MockClientsEngine = {
}
return guid.endsWith("mobile");
},
remoteClientExists(id) {
return !id.startsWith("guid_stale");
},
}
// Configure Sync with our mock tabs engine and force it to become initialized.
@ -101,6 +104,41 @@ add_task(function* test_clientWithTabs() {
equal(clients[1].tabs.length, 0);
});
add_task(function* test_staleClientWithTabs() {
yield configureClients({
guid_desktop: {
clientName: "My Desktop",
tabs: [
{
urlHistory: ["http://foo.com/"],
icon: "http://foo.com/favicon",
}],
},
guid_mobile: {
clientName: "My Phone",
tabs: [],
},
guid_stale_mobile: {
clientName: "My Deleted Phone",
tabs: [],
},
guid_stale_desktop: {
clientName: "My Deleted Laptop",
tabs: [
{
urlHistory: ["https://bar.com/"],
icon: "https://bar.com/favicon",
}],
},
});
let clients = yield SyncedTabs.getTabClients();
clients.sort((a, b) => { return a.name.localeCompare(b.name);});
equal(clients.length, 2);
equal(clients[0].tabs.length, 1);
equal(clients[0].tabs[0].url, "http://foo.com/");
equal(clients[1].tabs.length, 0);
});
add_task(function* test_clientWithTabsIconsDisabled() {
Services.prefs.setBoolPref("services.sync.syncedTabs.showRemoteIcons", false);
yield configureClients({