diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /services/sync/tests/unit/test_tab_provider.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'services/sync/tests/unit/test_tab_provider.js')
-rw-r--r-- | services/sync/tests/unit/test_tab_provider.js | 64 |
1 files changed, 64 insertions, 0 deletions
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..bbf68dea33 --- /dev/null +++ b/services/sync/tests/unit/test_tab_provider.js @@ -0,0 +1,64 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { TabProvider } = ChromeUtils.importESModule( + "resource://services-sync/engines/tabs.sys.mjs" +); + +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.getAllTabsWithEstimatedMax( + false, + Number.MAX_SAFE_INTEGER + ); + _("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.getAllTabsWithEstimatedMax( + true, + Number.MAX_SAFE_INTEGER + ); + _("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.getAllTabsWithEstimatedMax( + true, + Number.MAX_SAFE_INTEGER + ); + _("Ordered: " + JSON.stringify(tabs)); + equal(tabs[0].lastUsed > tabs[1].lastUsed, true); + + // reader mode URLs are provided. + provider.getWindowEnumerator = mockGetWindowEnumerator.bind(this, [ + "about:reader?url=http%3A%2F%2Ffoo.com%2F", + ]); + tabs = await provider.getAllTabsWithEstimatedMax( + true, + Number.MAX_SAFE_INTEGER + ); + equal(tabs[0].urlHistory[0], "http://foo.com/"); +}); |