diff --git a/src/zen/tests/pinned/browser.toml b/src/zen/tests/pinned/browser.toml new file mode 100644 index 000000000..331475f1a --- /dev/null +++ b/src/zen/tests/pinned/browser.toml @@ -0,0 +1,8 @@ +["browser_pinned_changed.js"] +["browser_pinned_created.js"] +["browser_pinned_edit_label.js"] +["browser_pinned_removed.js"] +["browser_pinned_reorder_changed_label.js"] +["browser_pinned_reordered.js"] + +["browser_issue_7654.js"] \ No newline at end of file diff --git a/src/zen/tests/pinned/browser_issue_7654.js b/src/zen/tests/pinned/browser_issue_7654.js new file mode 100644 index 000000000..10c51beec --- /dev/null +++ b/src/zen/tests/pinned/browser_issue_7654.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + https://creativecommons.org/publicdomain/zero/1.0/ */ + +'use strict'; + +ChromeUtils.defineESModuleGetters(this, { + UrlbarTestUtils: 'resource://testing-common/UrlbarTestUtils.sys.mjs', +}); + +add_task(async function test_Create_Pinned() { + let resolvePromise; + const promise = new Promise((resolve) => { + resolvePromise = resolve; + }); + + const customLabel = 'ZEN ROCKS'; + + await BrowserTestUtils.withNewTab({ gBrowser, url: 'https://example.com/1' }, async (browser) => { + const tab = gBrowser.getTabForBrowser(browser); + tab.addEventListener( + 'ZenPinnedTabCreated', + async function () { + const pinTabID = tab.getAttribute('zen-pin-id'); + ok(pinTabID, 'The tab should have a zen-pin-id attribute after being pinned'); + + await gZenPinnedTabManager.updatePinTitle(tab, customLabel, true); + + const pinnedTabs = await ZenPinnedTabsStorage.getPins(); + const pinObject = pinnedTabs.find((pin) => pin.uuid === pinTabID); + Assert.equal(pinObject.title, customLabel, 'The pin object should have the correct title'); + + await BrowserTestUtils.openNewForegroundTab(window.gBrowser, 'https://example.com/2', true); + + await UrlbarTestUtils.promiseAutocompleteResultPopup({ + window, + value: customLabel, + waitForFocus: SimpleTest.waitForFocus, + }); + + const total = UrlbarTestUtils.getResultCount(window); + info(`Found ${total} matches`); + + const result = await UrlbarTestUtils.getDetailsOfResultAt(window, 0); + + const url = result?.url; + Assert.equal( + url, + 'https://example.com/1', + `Should have the found result '${url}' in the expected list of entries` + ); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); + resolvePromise(); + }, + { once: true } + ); + gBrowser.pinTab(tab); + await promise; + }); +});