diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/base/content/test/general/browser_bug432599.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/general/browser_bug432599.js')
-rw-r--r-- | browser/base/content/test/general/browser_bug432599.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_bug432599.js b/browser/base/content/test/general/browser_bug432599.js new file mode 100644 index 0000000000..512b184a67 --- /dev/null +++ b/browser/base/content/test/general/browser_bug432599.js @@ -0,0 +1,104 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function invokeUsingCtrlD(phase) { + switch (phase) { + case 1: + EventUtils.synthesizeKey("d", { accelKey: true }); + break; + case 2: + case 4: + EventUtils.synthesizeKey("KEY_Escape"); + break; + case 3: + EventUtils.synthesizeKey("d", { accelKey: true }); + EventUtils.synthesizeKey("d", { accelKey: true }); + break; + } +} + +function invokeUsingStarButton(phase) { + switch (phase) { + case 1: + EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, {}); + break; + case 2: + case 4: + EventUtils.synthesizeKey("KEY_Escape"); + break; + case 3: + EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, { clickCount: 2 }); + break; + } +} + +add_task(async function() { + const TEST_URL = "data:text/plain,Content"; + + let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); + registerCleanupFunction(async () => { + await BrowserTestUtils.removeTab(tab); + await PlacesUtils.bookmarks.eraseEverything(); + }); + + // Changing the location causes the star to asynchronously update, thus wait + // for it to be in a stable state before proceeding. + await TestUtils.waitForCondition( + () => BookmarkingUI.status == BookmarkingUI.STATUS_UNSTARRED + ); + + await PlacesUtils.bookmarks.insert({ + parentGuid: PlacesUtils.bookmarks.unfiledGuid, + url: TEST_URL, + title: "Bug 432599 Test", + }); + Assert.equal( + BookmarkingUI.status, + BookmarkingUI.STATUS_STARRED, + "The star state should be starred" + ); + + for (let invoker of [invokeUsingStarButton, invokeUsingCtrlD]) { + for (let phase = 1; phase < 5; ++phase) { + let promise = checkBookmarksPanel(phase); + invoker(phase); + await promise; + Assert.equal( + BookmarkingUI.status, + BookmarkingUI.STATUS_STARRED, + "The star state shouldn't change" + ); + } + } +}); + +var initialValue; +var initialRemoveHidden; +function checkBookmarksPanel(phase) { + StarUI._createPanelIfNeeded(); + let popupElement = document.getElementById("editBookmarkPanel"); + let titleElement = document.getElementById("editBookmarkPanelTitle"); + let removeElement = document.getElementById("editBookmarkPanelRemoveButton"); + switch (phase) { + case 1: + case 3: + return promisePopupShown(popupElement); + case 2: + initialValue = titleElement.value; + initialRemoveHidden = removeElement.hidden; + return promisePopupHidden(popupElement); + case 4: + Assert.equal( + titleElement.value, + initialValue, + "The bookmark panel's title should be the same" + ); + Assert.equal( + removeElement.hidden, + initialRemoveHidden, + "The bookmark panel's visibility should not change" + ); + return promisePopupHidden(popupElement); + } + return Promise.reject(new Error("Unknown phase")); +} |