summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/pageActions/browser_PageActions_bookmark.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/base/content/test/pageActions/browser_PageActions_bookmark.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.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/base/content/test/pageActions/browser_PageActions_bookmark.js')
-rw-r--r--browser/base/content/test/pageActions/browser_PageActions_bookmark.js130
1 files changed, 130 insertions, 0 deletions
diff --git a/browser/base/content/test/pageActions/browser_PageActions_bookmark.js b/browser/base/content/test/pageActions/browser_PageActions_bookmark.js
new file mode 100644
index 0000000000..a77095f2cd
--- /dev/null
+++ b/browser/base/content/test/pageActions/browser_PageActions_bookmark.js
@@ -0,0 +1,130 @@
+"use strict";
+
+add_task(async function starButtonCtrlClick() {
+ // Open a unique page.
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ let url = "http://example.com/browser_page_action_star_button";
+ await BrowserTestUtils.withNewTab(url, async () => {
+ StarUI._createPanelIfNeeded();
+ // The button ignores activation while the bookmarked status is being
+ // updated. So, wait for it to finish updating.
+ await TestUtils.waitForCondition(
+ () => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING
+ );
+
+ const popup = document.getElementById("editBookmarkPanel");
+ const starButtonBox = document.getElementById("star-button-box");
+
+ let shownPromise = promisePanelShown(popup);
+ EventUtils.synthesizeMouseAtCenter(starButtonBox, { ctrlKey: true });
+ await shownPromise;
+ ok(true, "Panel shown after button pressed");
+
+ let hiddenPromise = promisePanelHidden(popup);
+ document.getElementById("editBookmarkPanelRemoveButton").click();
+ await hiddenPromise;
+ });
+});
+
+add_task(async function bookmark() {
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ const url = "http://example.com/browser_page_action_menu";
+
+ const win = await BrowserTestUtils.openNewBrowserWindow();
+ registerCleanupFunction(async () => {
+ await BrowserTestUtils.closeWindow(win);
+ });
+
+ await BrowserTestUtils.withNewTab(
+ { gBrowser: win.gBrowser, url },
+ async () => {
+ // The bookmark button should not be starred.
+ const bookmarkButton =
+ win.BrowserPageActions.urlbarButtonNodeForActionID("bookmark");
+ Assert.ok(!bookmarkButton.hasAttribute("starred"));
+
+ info("Click the button.");
+ // The button ignores activation while the bookmarked status is being
+ // updated. So, wait for it to finish updating.
+ await TestUtils.waitForCondition(
+ () => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING
+ );
+ const starUIPanel = win.StarUI.panel;
+ let panelShown = BrowserTestUtils.waitForPopupEvent(starUIPanel, "shown");
+ EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
+ await panelShown;
+ is(
+ await PlacesUtils.bookmarks.fetch({ url }),
+ null,
+ "Bookmark has not been created before save."
+ );
+
+ // The bookmark button should now be starred.
+ Assert.equal(bookmarkButton.firstChild.getAttribute("starred"), "true");
+
+ info("Save the bookmark.");
+ const onItemAddedPromise = PlacesTestUtils.waitForNotification(
+ "bookmark-added",
+ events => events.some(event => event.url == url)
+ );
+ starUIPanel.hidePopup();
+ await onItemAddedPromise;
+
+ info("Click it again.");
+ // The button ignores activation while the bookmarked status is being
+ // updated. So, wait for it to finish updating.
+ await TestUtils.waitForCondition(
+ () => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING
+ );
+ panelShown = BrowserTestUtils.waitForPopupEvent(starUIPanel, "shown");
+ EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
+ await panelShown;
+
+ info("Remove the bookmark.");
+ const onItemRemovedPromise = PlacesTestUtils.waitForNotification(
+ "bookmark-removed",
+ events => events.some(event => event.url == url)
+ );
+ win.StarUI._element("editBookmarkPanelRemoveButton").click();
+ await onItemRemovedPromise;
+ }
+ );
+});
+
+add_task(async function bookmarkNoEditDialog() {
+ const url =
+ // eslint-disable-next-line @microsoft/sdl/no-insecure-url
+ "http://example.com/browser_page_action_menu_no_edit_dialog";
+
+ await SpecialPowers.pushPrefEnv({
+ set: [["browser.bookmarks.editDialog.showForNewBookmarks", false]],
+ });
+ const win = await BrowserTestUtils.openNewBrowserWindow();
+ registerCleanupFunction(async () => {
+ await BrowserTestUtils.closeWindow(win);
+ await PlacesUtils.bookmarks.eraseEverything();
+ });
+
+ await BrowserTestUtils.withNewTab(
+ { gBrowser: win.gBrowser, url },
+ async () => {
+ info("Click the button.");
+ // The button ignores activation while the bookmarked status is being
+ // updated. So, wait for it to finish updating.
+ await TestUtils.waitForCondition(
+ () => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING
+ );
+ const bookmarkButton = win.document.getElementById(
+ BrowserPageActions.urlbarButtonNodeIDForActionID("bookmark")
+ );
+
+ // The bookmark should be saved immediately after clicking the star.
+ const onItemAddedPromise = PlacesTestUtils.waitForNotification(
+ "bookmark-added",
+ events => events.some(event => event.url == url)
+ );
+ EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
+ await onItemAddedPromise;
+ }
+ );
+});