Commit 6d445e50 authored by Yuheng Huang's avatar Yuheng Huang Committed by Josip Sokcevic

Sort tabs by most recent active time

This CL needs to be checked in before the related CL to prevent a revert
due to src-internal build test breakage.

Related CL: https://chromium-review.googlesource.com/c/chromium/src/+/2382655
Bug: 1099917
Change-Id: Id79e1fa21be1bf0bdea52aa902f6685d8c985a4a
Reviewed-on: https://chrome-internal-review.googlesource.com/c/chrome/browser/resources/tab_search/+/3261333Reviewed-by: default avatarRoman Arora <romanarora@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819593}
parent 389959c6
......@@ -288,6 +288,9 @@ export class TabSearchAppElement extends PolymerElement {
})
.flat() :
windowTabs.map(window => window.tabs).flat();
this.filteredOpenTabs_.sort((a, b) => (b.lastActiveTimeTicks && a.lastActiveTimeTicks) ?
b.lastActiveTimeTicks.internalValue - a.lastActiveTimeTicks.internalValue :
0);
}
}
......
......@@ -267,6 +267,7 @@ suite('TabSearchAppTest', () => {
favIconUrl: '',
title: 'Example',
url: 'https://example.com',
lastActiveTimeTicks: { internalValue: 1 },
});
testProxy.getCallbackRouterRemote().tabUpdated(updatedTab);
await flushTasks();
......@@ -387,4 +388,35 @@ suite('TabSearchAppTest', () => {
feedbackButton.click();
await testProxy.whenCalled('showFeedbackPage');
});
test('Sort by most recent active tabs', async () => {
const tabs = [
{
index: 0,
tabId: 1,
favIconUrl: '',
title: 'Google',
url: 'https://www.google.com',
lastActiveTimeTicks: { internalValue: 2 },
},
{
index: 1,
tabId: 2,
favIconUrl: '',
title: 'Bing',
url: 'https://www.bing.com',
lastActiveTimeTicks: { internalValue: 4 },
},
{
index: 2,
tabId: 3,
favIconUrl: '',
title: 'Yahoo',
url: 'https://www.yahoo.com',
lastActiveTimeTicks: { internalValue: 3 },
}];
await setupTest({windows: [{active: true, tabs}]});
verifyTabIds(queryRows(), [2, 3, 1]);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment