mirror of
https://github.com/zen-browser/desktop.git
synced 2026-02-05 19:37:22 +00:00
test: Added tests for https://github.com/zen-browser/desktop/pull/8221, b=(no-bug), c=tests
This commit is contained in:
8
src/zen/tests/pinned/browser.toml
Normal file
8
src/zen/tests/pinned/browser.toml
Normal file
@@ -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"]
|
||||
60
src/zen/tests/pinned/browser_issue_7654.js
Normal file
60
src/zen/tests/pinned/browser_issue_7654.js
Normal file
@@ -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;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user