From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- services/sync/tests/unit/test_tab_provider.js | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 services/sync/tests/unit/test_tab_provider.js (limited to 'services/sync/tests/unit/test_tab_provider.js') diff --git a/services/sync/tests/unit/test_tab_provider.js b/services/sync/tests/unit/test_tab_provider.js new file mode 100644 index 0000000000..861a729cf3 --- /dev/null +++ b/services/sync/tests/unit/test_tab_provider.js @@ -0,0 +1,45 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { TabProvider } = ChromeUtils.import( + "resource://services-sync/engines/tabs.js" +); + +add_task(async function test_getAllTabs() { + let provider = TabProvider; + provider.shouldSkipWindow = mockShouldSkipWindow; + + let tabs; + + provider.getWindowEnumerator = mockGetWindowEnumerator.bind(this, [ + "http://bar.com", + ]); + + _("Get all tabs."); + tabs = await provider.getAllTabs(); + _("Tabs: " + JSON.stringify(tabs)); + equal(tabs.length, 1); + equal(tabs[0].title, "title"); + equal(tabs[0].urlHistory.length, 1); + equal(tabs[0].urlHistory[0], "http://bar.com/"); + equal(tabs[0].icon, ""); + equal(tabs[0].lastUsed, 2); // windowenumerator returns in ms but the getAllTabs() returns in seconds + + _("Get all tabs, and check that filtering works."); + provider.getWindowEnumerator = mockGetWindowEnumerator.bind(this, [ + "http://foo.com", + "about:foo", + ]); + tabs = await provider.getAllTabs(true); + _("Filtered: " + JSON.stringify(tabs)); + equal(tabs.length, 1); + + _("Get all tabs, and check that they are properly sorted"); + provider.getWindowEnumerator = mockGetWindowEnumerator.bind(this, [ + "http://foo.com", + "http://bar.com", + ]); + tabs = await provider.getAllTabs(true); + _("Ordered: " + JSON.stringify(tabs)); + equal(tabs[0].lastUsed > tabs[1].lastUsed, true); +}); -- cgit v1.2.3