From 3f6b2b72fc288099108fbe9aeedc5aa12bb8b7da Mon Sep 17 00:00:00 2001 From: Sammy Khamis Date: Thu, 27 Jan 2022 19:14:35 +0000 Subject: [PATCH] Bug 1643752 - Sort send tab targets by last used r=markh,vbudhram Differential Revision: https://phabricator.services.mozilla.com/D134722 --- browser/base/content/browser-sync.js | 2 +- browser/base/content/test/sync/browser_contextmenu_sendpage.js | 3 +++ browser/base/content/test/sync/browser_contextmenu_sendtab.js | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/browser/base/content/browser-sync.js b/browser/base/content/browser-sync.js index a6eb9063213c..70163297fe2a 100644 --- a/browser/base/content/browser-sync.js +++ b/browser/base/content/browser-sync.js @@ -419,7 +419,7 @@ var gSync = { targets.push(d); } } - return targets.sort((a, b) => a.name.localeCompare(b.name)); + return targets.sort((a, b) => b.lastAccessTime - a.lastAccessTime); }, _definePrefGetters() { diff --git a/browser/base/content/test/sync/browser_contextmenu_sendpage.js b/browser/base/content/test/sync/browser_contextmenu_sendpage.js index 2699efb30c9b..882b2a93eab9 100644 --- a/browser/base/content/test/sync/browser_contextmenu_sendpage.js +++ b/browser/base/content/test/sync/browser_contextmenu_sendpage.js @@ -10,16 +10,19 @@ const fxaDevices = [ id: 1, name: "Foo", availableCommands: { "https://identity.mozilla.com/cmd/open-uri": "baz" }, + lastAccessTime: Date.now(), }, { id: 2, name: "Bar", availableCommands: { "https://identity.mozilla.com/cmd/open-uri": "boo" }, + lastAccessTime: Date.now() + 60000, // add 30min }, { id: 3, name: "Baz", clientRecord: "bar", + lastAccessTime: Date.now() + 120000, // add 60min }, // Legacy send tab target (no availableCommands). { id: 4, name: "Homer" }, // Incompatible target. ]; diff --git a/browser/base/content/test/sync/browser_contextmenu_sendtab.js b/browser/base/content/test/sync/browser_contextmenu_sendtab.js index a9ae5733f581..cb7cb4c89433 100644 --- a/browser/base/content/test/sync/browser_contextmenu_sendtab.js +++ b/browser/base/content/test/sync/browser_contextmenu_sendtab.js @@ -15,16 +15,19 @@ const fxaDevices = [ id: 1, name: "Foo", availableCommands: { "https://identity.mozilla.com/cmd/open-uri": "baz" }, + lastAccessTime: Date.now(), }, { id: 2, name: "Bar", availableCommands: { "https://identity.mozilla.com/cmd/open-uri": "boo" }, + lastAccessTime: Date.now() + 60000, // add 30min }, { id: 3, name: "Baz", clientRecord: "bar", + lastAccessTime: Date.now() + 120000, // add 60min }, // Legacy send tab target (no availableCommands). { id: 4, name: "Homer" }, // Incompatible target. ];