summaryrefslogtreecommitdiffstats
path: root/browser/components/sessionstore/test/browser_label_and_icon.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /browser/components/sessionstore/test/browser_label_and_icon.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/sessionstore/test/browser_label_and_icon.js')
-rw-r--r--browser/components/sessionstore/test/browser_label_and_icon.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/browser/components/sessionstore/test/browser_label_and_icon.js b/browser/components/sessionstore/test/browser_label_and_icon.js
new file mode 100644
index 0000000000..9b254c5e77
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_label_and_icon.js
@@ -0,0 +1,53 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Ensure that a pending tab has label and icon correctly set.
+ */
+add_task(async function test_label_and_icon() {
+ // Make sure that tabs are restored on demand as otherwise the tab will start
+ // loading immediately and we can't check its icon and label.
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.sessionstore.restore_on_demand", true]],
+ });
+
+ // Create a new tab.
+ let tab = BrowserTestUtils.addTab(gBrowser, "about:robots");
+ let browser = tab.linkedBrowser;
+ await promiseBrowserLoaded(browser);
+ // Because there is debounce logic in ContentLinkHandler.jsm to reduce the
+ // favicon loads, we have to wait some time before checking that icon was
+ // stored properly.
+ await BrowserTestUtils.waitForCondition(
+ () => {
+ return gBrowser.getIcon(tab) != null;
+ },
+ "wait for favicon load to finish",
+ 100,
+ 5
+ );
+
+ // Retrieve the tab state.
+ await TabStateFlusher.flush(browser);
+ let state = ss.getTabState(tab);
+ BrowserTestUtils.removeTab(tab);
+ browser = null;
+
+ // Open a new tab to restore into.
+ tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
+ ss.setTabState(tab, state);
+ await promiseTabRestoring(tab);
+
+ // Check that label and icon are set for the restoring tab.
+ is(
+ gBrowser.getIcon(tab),
+ "chrome://browser/content/robot.ico",
+ "icon is set"
+ );
+ is(tab.label, "Gort! Klaatu barada nikto!", "label is set");
+
+ // Cleanup.
+ BrowserTestUtils.removeTab(tab);
+});