forked from mirrors/gecko-dev
Backed out changeset 8107b1fc07e0 (bug 1812083) for causing failures at browser_bookmarks_change_url.js. CLOSED TREE
This commit is contained in:
parent
b778f2672a
commit
7d923b6c43
18 changed files with 410 additions and 1533 deletions
|
|
@ -1269,11 +1269,7 @@ pref("browser.bookmarks.editDialog.maxRecentFolders", 7);
|
|||
|
||||
// By default the Edit Bookmark dialog is instant-apply. This feature pref will allow to
|
||||
// just save on Accept, once the project is complete.
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("browser.bookmarks.editDialog.delayedApply.enabled", true);
|
||||
#else
|
||||
pref("browser.bookmarks.editDialog.delayedApply.enabled", false);
|
||||
#endif
|
||||
pref("browser.bookmarks.editDialog.delayedApply.enabled", false);
|
||||
|
||||
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
||||
// This controls the strength of the Windows content process sandbox for
|
||||
|
|
|
|||
|
|
@ -204,11 +204,11 @@ var StarUI = {
|
|||
return;
|
||||
}
|
||||
|
||||
await this._storeRecentlyUsedFolder(selectedFolderGuid, didChangeFolder);
|
||||
await bookmarkState.save();
|
||||
if (this._isNewBookmark) {
|
||||
this.showConfirmation();
|
||||
}
|
||||
await this._storeRecentlyUsedFolder(selectedFolderGuid, didChangeFolder);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,107 +30,86 @@ add_task(async function bookmark() {
|
|||
// Open a unique page.
|
||||
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
|
||||
let url = "http://example.com/browser_page_action_menu";
|
||||
await BrowserTestUtils.withNewTab(url, async () => {
|
||||
// The bookmark button should read "Bookmark this page ([shortcut])" and not
|
||||
// be starred.
|
||||
let bookmarkButton = BrowserPageActions.urlbarButtonNodeForActionID(
|
||||
"bookmark"
|
||||
);
|
||||
let tooltipText = bookmarkButton.getAttribute("tooltiptext");
|
||||
Assert.ok(
|
||||
tooltipText.startsWith("Bookmark this page"),
|
||||
`Expecting the tooltip text to be updated. Tooltip text: ${tooltipText}`
|
||||
);
|
||||
Assert.ok(!bookmarkButton.hasAttribute("starred"));
|
||||
|
||||
// Open a new window with delayed apply mode disabled. In the new window,
|
||||
// opening the star panel should instantly create a new bookmark.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", false]],
|
||||
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
|
||||
);
|
||||
let onItemAddedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-added",
|
||||
events => events.some(event => event.url == url)
|
||||
);
|
||||
let promise = BrowserTestUtils.waitForPopupEvent(StarUI.panel, "shown");
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkButton, {});
|
||||
await promise;
|
||||
await onItemAddedPromise;
|
||||
|
||||
Assert.equal(
|
||||
BookmarkingUI.starBox.getAttribute("open"),
|
||||
"true",
|
||||
"Star has open attribute"
|
||||
);
|
||||
// The bookmark button should now read "Edit this bookmark ([shortcut])" and
|
||||
// be starred.
|
||||
tooltipText = bookmarkButton.getAttribute("tooltiptext");
|
||||
Assert.ok(
|
||||
tooltipText.startsWith("Edit this bookmark"),
|
||||
`Expecting the tooltip text to be updated. Tooltip text: ${tooltipText}`
|
||||
);
|
||||
Assert.equal(bookmarkButton.firstChild.getAttribute("starred"), "true");
|
||||
|
||||
StarUI.panel.hidePopup();
|
||||
Assert.ok(
|
||||
!BookmarkingUI.starBox.hasAttribute("open"),
|
||||
"Star no longer has open attribute"
|
||||
);
|
||||
|
||||
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
|
||||
);
|
||||
promise = BrowserTestUtils.waitForPopupEvent(StarUI.panel, "shown");
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkButton, {});
|
||||
await promise;
|
||||
|
||||
let onItemRemovedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-removed",
|
||||
events => events.some(event => event.url == url)
|
||||
);
|
||||
// Click the remove-bookmark button in the panel.
|
||||
StarUI._element("editBookmarkPanelRemoveButton").click();
|
||||
// Wait for the bookmark to be removed before continuing.
|
||||
await onItemRemovedPromise;
|
||||
|
||||
// Check there's no contextual menu on the button.
|
||||
let contextMenuPromise = promisePopupNotShown("pageActionContextMenu");
|
||||
// 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
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkButton, {
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
});
|
||||
await contextMenuPromise;
|
||||
});
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
registerCleanupFunction(async () => {
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser: win.gBrowser, url },
|
||||
async () => {
|
||||
// The bookmark button should read "Bookmark this page ([shortcut])" and not
|
||||
// be starred.
|
||||
let bookmarkButton = win.BrowserPageActions.urlbarButtonNodeForActionID(
|
||||
"bookmark"
|
||||
);
|
||||
let tooltipText = bookmarkButton.getAttribute("tooltiptext");
|
||||
Assert.ok(
|
||||
tooltipText.startsWith("Bookmark this page"),
|
||||
`Expecting the tooltip text to be updated. Tooltip text: ${tooltipText}`
|
||||
);
|
||||
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(
|
||||
() => win.BookmarkingUI.status != win.BookmarkingUI.STATUS_UPDATING
|
||||
);
|
||||
let onItemAddedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-added",
|
||||
events => events.some(event => event.url == url)
|
||||
);
|
||||
let promise = BrowserTestUtils.waitForPopupEvent(
|
||||
win.StarUI.panel,
|
||||
"shown"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
|
||||
await promise;
|
||||
await onItemAddedPromise;
|
||||
|
||||
Assert.equal(
|
||||
win.BookmarkingUI.starBox.getAttribute("open"),
|
||||
"true",
|
||||
"Star has open attribute"
|
||||
);
|
||||
// The bookmark button should now read "Edit this bookmark ([shortcut])" and
|
||||
// be starred.
|
||||
tooltipText = bookmarkButton.getAttribute("tooltiptext");
|
||||
Assert.ok(
|
||||
tooltipText.startsWith("Edit this bookmark"),
|
||||
`Expecting the tooltip text to be updated. Tooltip text: ${tooltipText}`
|
||||
);
|
||||
Assert.equal(bookmarkButton.firstChild.getAttribute("starred"), "true");
|
||||
|
||||
win.StarUI.panel.hidePopup();
|
||||
Assert.ok(
|
||||
!win.BookmarkingUI.starBox.hasAttribute("open"),
|
||||
"Star no longer has open attribute"
|
||||
);
|
||||
|
||||
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(
|
||||
() => win.BookmarkingUI.status != win.BookmarkingUI.STATUS_UPDATING
|
||||
);
|
||||
promise = BrowserTestUtils.waitForPopupEvent(win.StarUI.panel, "shown");
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
|
||||
await promise;
|
||||
|
||||
let onItemRemovedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-removed",
|
||||
events => events.some(event => event.url == url)
|
||||
);
|
||||
// Click the remove-bookmark button in the panel.
|
||||
win.StarUI._element("editBookmarkPanelRemoveButton").click();
|
||||
// Wait for the bookmark to be removed before continuing.
|
||||
await onItemRemovedPromise;
|
||||
|
||||
// Check there's no contextual menu on the button.
|
||||
let contextMenuPromise = promisePopupNotShown("pageActionContextMenu");
|
||||
// The button ignores activation while the bookmarked status is being
|
||||
// updated. So, wait for it to finish updating.
|
||||
await TestUtils.waitForCondition(
|
||||
() => win.BookmarkingUI.status != win.BookmarkingUI.STATUS_UPDATING
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkButton,
|
||||
{
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
},
|
||||
win
|
||||
);
|
||||
await contextMenuPromise;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function bookmarkDelayedApply() {
|
||||
|
|
|
|||
|
|
@ -282,8 +282,6 @@ class BookmarkState {
|
|||
* If changes to bookmark fields should be saved immediately after calling
|
||||
* its respective "changed" method, rather than waiting for save() to be
|
||||
* called.
|
||||
* @param {number} [options.index]
|
||||
* The insertion point index of the bookmark.
|
||||
*/
|
||||
constructor({
|
||||
info,
|
||||
|
|
@ -292,7 +290,6 @@ class BookmarkState {
|
|||
isFolder = false,
|
||||
children = [],
|
||||
autosave = false,
|
||||
index,
|
||||
}) {
|
||||
this._guid = info.itemGuid;
|
||||
this._postData = info.postData;
|
||||
|
|
@ -312,7 +309,6 @@ class BookmarkState {
|
|||
.filter(tag => !!tag.length),
|
||||
keyword,
|
||||
parentGuid: info.parentGuid,
|
||||
index,
|
||||
};
|
||||
|
||||
// Edited bookmark
|
||||
|
|
@ -395,7 +391,6 @@ class BookmarkState {
|
|||
tags: this._newState.tags,
|
||||
title: this._newState.title ?? this._originalState.title,
|
||||
url: this._newState.uri ?? this._originalState.uri,
|
||||
index: this._originalState.index,
|
||||
}).transact();
|
||||
if (this._newState.keyword) {
|
||||
await lazy.PlacesTransactions.EditKeyword({
|
||||
|
|
@ -421,7 +416,6 @@ class BookmarkState {
|
|||
url: item.uri,
|
||||
title: item.title,
|
||||
})),
|
||||
index: this._originalState.index,
|
||||
}).transact();
|
||||
return this._guid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -508,7 +508,6 @@ var BookmarkPropertiesPanel = {
|
|||
? undefined
|
||||
: await PlacesUtils.promiseItemId(parentGuid);
|
||||
return Object.freeze({
|
||||
index,
|
||||
itemId,
|
||||
bookmarkGuid: itemGuid,
|
||||
title: this._title,
|
||||
|
|
|
|||
|
|
@ -378,17 +378,6 @@ var gEditItemOverlay = {
|
|||
);
|
||||
}
|
||||
|
||||
// Observe changes.
|
||||
if (!this._observersAdded) {
|
||||
this.handlePlacesEvents = this.handlePlacesEvents.bind(this);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-title-changed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
window.addEventListener("unload", this);
|
||||
this._observersAdded = true;
|
||||
}
|
||||
|
||||
let focusElement = () => {
|
||||
// The focusedElement possible values are:
|
||||
// * preferred: focus the field that the user touched first the last
|
||||
|
|
@ -423,7 +412,7 @@ var gEditItemOverlay = {
|
|||
await this._tagsUpdatePromise;
|
||||
}
|
||||
|
||||
this._bookmarkState = this.makeNewStateObject({ index: aInfo.node?.index });
|
||||
this._bookmarkState = this.makeNewStateObject();
|
||||
if (isBookmark || bulkTagging) {
|
||||
await this._initAllTags();
|
||||
await this._rebuildTagsSelectorList();
|
||||
|
|
@ -595,15 +584,6 @@ var gEditItemOverlay = {
|
|||
}
|
||||
}
|
||||
|
||||
if (this._observersAdded) {
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-title-changed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
window.removeEventListener("unload", this);
|
||||
this._observersAdded = false;
|
||||
}
|
||||
|
||||
if (this._folderMenuListListenerAdded) {
|
||||
this._folderMenuList.removeEventListener("select", this);
|
||||
this._folderMenuListListenerAdded = false;
|
||||
|
|
@ -624,7 +604,7 @@ var gEditItemOverlay = {
|
|||
);
|
||||
},
|
||||
|
||||
makeNewStateObject(extraOptions) {
|
||||
makeNewStateObject() {
|
||||
if (
|
||||
this._paneInfo.isItem ||
|
||||
this._paneInfo.isTag ||
|
||||
|
|
@ -633,11 +613,7 @@ var gEditItemOverlay = {
|
|||
const isLibraryWindow =
|
||||
document.documentElement.getAttribute("windowtype") ===
|
||||
"Places:Organizer";
|
||||
const options = {
|
||||
autosave: isLibraryWindow,
|
||||
info: this._paneInfo,
|
||||
...extraOptions,
|
||||
};
|
||||
const options = { autosave: isLibraryWindow, info: this._paneInfo };
|
||||
|
||||
if (this._paneInfo.isBookmark) {
|
||||
options.tags = this._element("tagsField").value;
|
||||
|
|
@ -681,24 +657,16 @@ var gEditItemOverlay = {
|
|||
async _updateTags() {
|
||||
this._tagsUpdatePromise = (async () => {
|
||||
const inputTags = this._getTagsArrayFromTagsInputField();
|
||||
const isLibraryWindow =
|
||||
document.documentElement.getAttribute("windowtype") ===
|
||||
"Places:Organizer";
|
||||
await this._bookmarkState._tagsChanged(inputTags);
|
||||
delete this._paneInfo._cachedCommonTags;
|
||||
|
||||
if (isLibraryWindow) {
|
||||
// Ensure the tagsField is in sync, clean it up from empty tags
|
||||
delete this._paneInfo._cachedCommonTags;
|
||||
const currentTags = this._paneInfo.bulkTagging
|
||||
? this._getCommonTags()
|
||||
: PlacesUtils.tagging.getTagsForURI(this._paneInfo.uri);
|
||||
this._initTextField(this._tagsField, currentTags.join(", "), false);
|
||||
await this._initAllTags();
|
||||
} else {
|
||||
// Autosave is disabled. Update _allTags in memory so that the selector
|
||||
// list shows any new tags that haven't been saved yet.
|
||||
inputTags.forEach(tag => this._allTags?.set(tag.toLowerCase(), tag));
|
||||
}
|
||||
// Ensure the tagsField is in sync, clean it up from empty tags
|
||||
const currentTags = this._paneInfo.bulkTagging
|
||||
? this._getCommonTags()
|
||||
: PlacesUtils.tagging.getTagsForURI(this._paneInfo.uri);
|
||||
this._initTextField(this._tagsField, currentTags.join(", "), false);
|
||||
|
||||
await this._initAllTags();
|
||||
await this._rebuildTagsSelectorList();
|
||||
})().catch(console.error);
|
||||
await this._tagsUpdatePromise;
|
||||
|
|
@ -1104,19 +1072,6 @@ var gEditItemOverlay = {
|
|||
}
|
||||
},
|
||||
|
||||
async handlePlacesEvents(events) {
|
||||
for (const event of events) {
|
||||
switch (event.type) {
|
||||
case "bookmark-title-changed":
|
||||
if (this._paneInfo.isItem || this._paneInfo.isTag) {
|
||||
// This also updates titles of folders in the folder menu list.
|
||||
this._onItemTitleChange(event.id, event.title, event.guid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggleItemCheckbox(item) {
|
||||
// Update the tags field when items are checked/unchecked in the listbox
|
||||
let tags = this._getTagsArrayFromTagsInputField();
|
||||
|
|
@ -1153,30 +1108,6 @@ var gEditItemOverlay = {
|
|||
this._initTextField(this._tagsField, tags.join(", "));
|
||||
},
|
||||
|
||||
_onItemTitleChange(aItemId, aNewTitle, aGuid) {
|
||||
if (this._paneInfo.visibleRows.has("folderRow")) {
|
||||
// If the title of a folder which is listed within the folders
|
||||
// menulist has been changed, we need to update the label of its
|
||||
// representing element.
|
||||
let menupopup = this._folderMenuList.menupopup;
|
||||
for (let menuitem of menupopup.children) {
|
||||
if ("folderGuid" in menuitem && menuitem.folderGuid == aGuid) {
|
||||
menuitem.label = aNewTitle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We need to also update title of recent folders.
|
||||
if (this._recentFolders) {
|
||||
for (let folder of this._recentFolders) {
|
||||
if (folder.folderGuid == aGuid) {
|
||||
folder.title = aNewTitle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flag which signals to consumers that this script is loaded, thus delayed
|
||||
* apply logic should be used.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ support-files =
|
|||
[browser_addBookmarkForFrame.js]
|
||||
skip-if = (verify && debug)
|
||||
[browser_autoshow_bookmarks_toolbar.js]
|
||||
[browser_autoshow_bookmarks_toolbar_delayed_apply.js]
|
||||
[browser_bookmark_add_tags.js]
|
||||
https_first_disabled = true
|
||||
skip-if =
|
||||
|
|
@ -27,12 +26,6 @@ skip-if = os == 'linux' # times out on linux, Bug 1739081
|
|||
[browser_bookmark_folder_moveability.js]
|
||||
[browser_bookmark_menu_ctrl_click.js]
|
||||
[browser_bookmark_popup.js]
|
||||
skip-if =
|
||||
os == "linux" && asan # Bug 1712814
|
||||
os == "linux" && tsan # Bug 1712814
|
||||
os == "linux" && debug # mouseover not reliable on linux debug builds
|
||||
verify && (os == 'win') # mouseover not reliable on linux debug builds
|
||||
[browser_bookmark_popup_delayed_apply.js]
|
||||
skip-if =
|
||||
os == "linux" && asan # Bug 1712814
|
||||
os == "linux" && tsan # Bug 1712814
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ add_setup(async function() {
|
|||
Services.prefs.clearUserPref(LOCATION_PREF);
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
|
||||
// Panel must be instant apply for tests to pass.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", false]],
|
||||
});
|
||||
win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
let oldTimeout = win.StarUI._autoCloseTimeout;
|
||||
|
|
|
|||
|
|
@ -1,169 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const LOCATION_PREF = "browser.bookmarks.defaultLocation";
|
||||
const TOOLBAR_VISIBILITY_PREF = "browser.toolbars.bookmarks.visibility";
|
||||
let bookmarkPanel;
|
||||
let win;
|
||||
|
||||
add_setup(async function() {
|
||||
Services.prefs.clearUserPref(LOCATION_PREF);
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
|
||||
// Panel must be delayed apply for tests to pass.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", true]],
|
||||
});
|
||||
win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
let oldTimeout = win.StarUI._autoCloseTimeout;
|
||||
// Make the timeout something big, so it doesn't interact badly with tests.
|
||||
win.StarUI._autoCloseTimeout = 6000000;
|
||||
|
||||
win.StarUI._createPanelIfNeeded();
|
||||
bookmarkPanel = win.document.getElementById("editBookmarkPanel");
|
||||
bookmarkPanel.setAttribute("animate", false);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
bookmarkPanel = null;
|
||||
win.StarUI._autoCloseTimeout = oldTimeout;
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
win = null;
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
Services.prefs.clearUserPref(LOCATION_PREF);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Helper to check we've shown the toolbar
|
||||
*
|
||||
* @param {object} options
|
||||
* Options for the test
|
||||
* @param {boolean} options.showToolbar
|
||||
* If the toolbar should be shown or not
|
||||
* @param {string} options.expectedFolder
|
||||
* The expected folder to be shown
|
||||
* @param {string} options.reason
|
||||
* The reason the toolbar should be shown
|
||||
*/
|
||||
async function checkResponse({ showToolbar, expectedFolder, reason }) {
|
||||
// Check folder.
|
||||
let menuList = win.document.getElementById("editBMPanel_folderMenuList");
|
||||
|
||||
Assert.equal(
|
||||
menuList.label,
|
||||
PlacesUtils.getString(expectedFolder),
|
||||
`Should have ${expectedFolder} selected ${reason}.`
|
||||
);
|
||||
|
||||
// Check toolbar:
|
||||
let toolbar = win.document.getElementById("PersonalToolbar");
|
||||
Assert.equal(
|
||||
!toolbar.collapsed,
|
||||
showToolbar,
|
||||
`Toolbar should be ${showToolbar ? "visible" : "hidden"} ${reason}.`
|
||||
);
|
||||
|
||||
// Confirm and close the dialog.
|
||||
let hiddenPromise = promisePopupHidden(
|
||||
win.document.getElementById("editBookmarkPanel")
|
||||
);
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
await hiddenPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that if we create a bookmark on the toolbar, we show the
|
||||
* toolbar:
|
||||
*/
|
||||
add_task(async function test_new_on_toolbar() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser: win.gBrowser, url: "https://example.com/1" },
|
||||
async browser => {
|
||||
let toolbar = win.document.getElementById("PersonalToolbar");
|
||||
Assert.equal(
|
||||
toolbar.collapsed,
|
||||
true,
|
||||
"Bookmarks toolbar should start out collapsed."
|
||||
);
|
||||
let shownPromise = promisePopupShown(
|
||||
win.document.getElementById("editBookmarkPanel")
|
||||
);
|
||||
win.document.getElementById("Browser:AddBookmarkAs").doCommand();
|
||||
await shownPromise;
|
||||
await TestUtils.waitForCondition(
|
||||
() => !toolbar.collapsed,
|
||||
"Toolbar should be shown."
|
||||
);
|
||||
let expectedFolder = "BookmarksToolbarFolderTitle";
|
||||
let reason = "when creating a bookmark there";
|
||||
await checkResponse({ showToolbar: true, expectedFolder, reason });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that if we create a bookmark on the toolbar, we do not
|
||||
* show the toolbar if toolbar should never be shown:
|
||||
*/
|
||||
add_task(async function test_new_on_toolbar_never_show_toolbar() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[TOOLBAR_VISIBILITY_PREF, "never"]],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser: win.gBrowser, url: "https://example.com/1" },
|
||||
async browser => {
|
||||
let toolbar = win.document.getElementById("PersonalToolbar");
|
||||
Assert.equal(
|
||||
toolbar.collapsed,
|
||||
true,
|
||||
"Bookmarks toolbar should start out collapsed."
|
||||
);
|
||||
let shownPromise = promisePopupShown(
|
||||
win.document.getElementById("editBookmarkPanel")
|
||||
);
|
||||
win.document.getElementById("Browser:AddBookmarkAs").doCommand();
|
||||
await shownPromise;
|
||||
let expectedFolder = "BookmarksToolbarFolderTitle";
|
||||
let reason = "when the visibility pref is 'never'";
|
||||
await checkResponse({ showToolbar: false, expectedFolder, reason });
|
||||
}
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that if we edit an existing bookmark, we don't show the toolbar.
|
||||
*/
|
||||
add_task(async function test_existing_on_toolbar() {
|
||||
// Create the bookmark first:
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
title: "Test for editing",
|
||||
url: "https://example.com/editing-test",
|
||||
});
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser: win.gBrowser, url: "https://example.com/editing-test" },
|
||||
async browser => {
|
||||
await TestUtils.waitForCondition(
|
||||
() => win.BookmarkingUI.status == BookmarkingUI.STATUS_STARRED,
|
||||
"Page should be starred."
|
||||
);
|
||||
|
||||
let toolbar = win.document.getElementById("PersonalToolbar");
|
||||
Assert.equal(
|
||||
toolbar.collapsed,
|
||||
true,
|
||||
"Bookmarks toolbar should start out collapsed."
|
||||
);
|
||||
await clickBookmarkStar(win);
|
||||
let expectedFolder = "BookmarksToolbarFolderTitle";
|
||||
let reason = "when editing a bookmark there";
|
||||
await checkResponse({ showToolbar: false, expectedFolder, reason });
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
async function add_folder_default_button(delayedApply) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", delayedApply]],
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
info(
|
||||
"Bug 475529 - Add is the default button for the new folder dialog + " +
|
||||
"Bug 1206376 - Changing properties of a new bookmark while adding it " +
|
||||
|
|
@ -37,25 +33,16 @@ async function add_folder_default_button(delayedApply) {
|
|||
tree.controller.doCommand("placesCmd_new:folder");
|
||||
},
|
||||
async function test(dialogWin) {
|
||||
const notifications = delayedApply
|
||||
? [
|
||||
PlacesTestUtils.waitForNotification("bookmark-added", events =>
|
||||
events.some(e => e.title === "n")
|
||||
),
|
||||
PlacesTestUtils.waitForNotification("bookmark-moved", null),
|
||||
]
|
||||
: [
|
||||
PlacesTestUtils.waitForNotification(
|
||||
"bookmark-title-changed",
|
||||
events => events.some(e => e.title === "n")
|
||||
),
|
||||
];
|
||||
let promiseTitleChangeNotification = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-title-changed",
|
||||
events => events.some(e => e.title === "n")
|
||||
);
|
||||
|
||||
fillBookmarkTextField("editBMPanel_namePicker", "n", dialogWin, false);
|
||||
|
||||
// Confirm and close the dialog.
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
|
||||
await Promise.all(notifications);
|
||||
await promiseTitleChangeNotification;
|
||||
|
||||
let newFolder = await PlacesUtils.bookmarks.fetch({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
|
|
@ -76,12 +63,4 @@ async function add_folder_default_button(delayedApply) {
|
|||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function add_folder_default_button_instant_apply() {
|
||||
await add_folder_default_button(false);
|
||||
});
|
||||
|
||||
add_task(async function add_folder_default_button_delayed_apply() {
|
||||
await add_folder_default_button(true);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@
|
|||
const TEST_URL =
|
||||
"http://mochi.test:8888/browser/browser/components/places/tests/browser/keyword_form.html";
|
||||
|
||||
function closeHandler(dialogWin, delayedApply) {
|
||||
if (delayedApply) {
|
||||
// We are in delayed apply mode, thus cancelling dialog will not produce a
|
||||
// bookmark-removed notification.
|
||||
return PlacesUtils.bookmarks.eraseEverything();
|
||||
}
|
||||
function closeHandler(dialogWin) {
|
||||
let savedItemId = dialogWin.gEditItemOverlay.itemId;
|
||||
return PlacesTestUtils.waitForNotification("bookmark-removed", events =>
|
||||
events.some(event => event.id === savedItemId)
|
||||
|
|
@ -17,10 +12,7 @@ function closeHandler(dialogWin, delayedApply) {
|
|||
|
||||
let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
|
||||
|
||||
async function add_keyword(delayedApply) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", delayedApply]],
|
||||
});
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{
|
||||
gBrowser,
|
||||
|
|
@ -34,7 +26,7 @@ async function add_keyword(delayedApply) {
|
|||
);
|
||||
|
||||
await withBookmarksDialog(
|
||||
!delayedApply,
|
||||
true,
|
||||
function() {
|
||||
AddKeywordForSearchField();
|
||||
contentAreaContextMenu.hidePopup();
|
||||
|
|
@ -54,9 +46,7 @@ async function add_keyword(delayedApply) {
|
|||
|
||||
Assert.ok(!acceptBtn.disabled, "Accept button is enabled");
|
||||
|
||||
if (delayedApply) {
|
||||
acceptBtn.click();
|
||||
}
|
||||
// The dialog is instant apply.
|
||||
await promiseKeywordNotification;
|
||||
|
||||
// After the notification, the keywords cache will update asynchronously.
|
||||
|
|
@ -73,7 +63,9 @@ async function add_keyword(delayedApply) {
|
|||
"accenti%3D%E0%E8%EC%F2%F9&search%3D%25s",
|
||||
"POST data is correct"
|
||||
);
|
||||
let bm = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
let savedItemId = dialogWin.gEditItemOverlay.itemId;
|
||||
let savedItemGuid = await PlacesUtils.promiseItemGuid(savedItemId);
|
||||
let bm = await PlacesUtils.bookmarks.fetch(savedItemGuid);
|
||||
Assert.equal(
|
||||
bm.parentGuid,
|
||||
await PlacesUIUtils.defaultParentGuid,
|
||||
|
|
@ -99,24 +91,13 @@ async function add_keyword(delayedApply) {
|
|||
);
|
||||
Assert.equal(data.url, TEST_URL, "getShortcutOrURI URL is correct");
|
||||
},
|
||||
dialogWin => closeHandler(dialogWin, delayedApply)
|
||||
closeHandler
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function add_keyword_instant_apply() {
|
||||
await add_keyword(false);
|
||||
});
|
||||
|
||||
add_task(async function add_keyword_delayed_apply() {
|
||||
await add_keyword(true);
|
||||
});
|
||||
|
||||
async function reopen_same_field(delayedApply) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", delayedApply]],
|
||||
});
|
||||
add_task(async function reopen_same_field() {
|
||||
await PlacesUtils.keywords.insert({
|
||||
url: TEST_URL,
|
||||
keyword: "kw",
|
||||
|
|
@ -155,24 +136,13 @@ async function reopen_same_field(delayedApply) {
|
|||
.getButton("accept");
|
||||
ok(!acceptBtn.disabled, "Accept button is enabled");
|
||||
},
|
||||
dialogWin => closeHandler(dialogWin, delayedApply)
|
||||
closeHandler
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function reopen_same_field_instant_apply() {
|
||||
await reopen_same_field(false);
|
||||
});
|
||||
|
||||
add_task(async function reopen_same_field_delayed_apply() {
|
||||
await reopen_same_field(true);
|
||||
});
|
||||
|
||||
async function open_other_field(delayedApply) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", delayedApply]],
|
||||
});
|
||||
add_task(async function open_other_field() {
|
||||
await PlacesUtils.keywords.insert({
|
||||
url: TEST_URL,
|
||||
keyword: "kw2",
|
||||
|
|
@ -212,18 +182,10 @@ async function open_other_field(delayedApply) {
|
|||
);
|
||||
is(elt.value, "");
|
||||
},
|
||||
dialogWin => closeHandler(dialogWin, delayedApply)
|
||||
closeHandler
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function open_other_field_instant_apply() {
|
||||
await open_other_field(false);
|
||||
});
|
||||
|
||||
add_task(async function open_other_field_delayed_apply() {
|
||||
await open_other_field(true);
|
||||
});
|
||||
|
||||
function getPostDataString(stream) {
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@ add_setup(async function() {
|
|||
});
|
||||
|
||||
add_task(async function test_newFolder() {
|
||||
let newBookmarkObserver = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-added",
|
||||
events => events.some(({ url }) => url === TEST_URL)
|
||||
);
|
||||
await clickBookmarkStar();
|
||||
|
||||
// Open folder selector.
|
||||
|
|
@ -98,8 +94,6 @@ add_task(async function test_newFolder() {
|
|||
"Should have the new folder title"
|
||||
);
|
||||
|
||||
await hideBookmarksPanel();
|
||||
await newBookmarkObserver;
|
||||
let bookmark = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
|
||||
Assert.equal(
|
||||
|
|
@ -107,4 +101,6 @@ add_task(async function test_newFolder() {
|
|||
newFolderGuid,
|
||||
"The bookmark should be parented by the new folder"
|
||||
);
|
||||
|
||||
await hideBookmarksPanel();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@
|
|||
/**
|
||||
* Tests that multiple tags can be added to a bookmark using the star-shaped button, the library and the sidebar.
|
||||
*/
|
||||
let bookmarkPanel;
|
||||
let bookmarkStar;
|
||||
|
||||
StarUI._createPanelIfNeeded();
|
||||
const bookmarkPanel = document.getElementById("editBookmarkPanel");
|
||||
const bookmarkStar = BookmarkingUI.star;
|
||||
|
||||
async function clickBookmarkStar() {
|
||||
let shownPromise = promisePopupShown(bookmarkPanel);
|
||||
|
|
@ -22,39 +24,35 @@ async function hideBookmarksPanel(callback) {
|
|||
await hiddenPromise;
|
||||
}
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
add_setup(function() {
|
||||
let oldTimeout = StarUI._autoCloseTimeout;
|
||||
|
||||
bookmarkPanel.setAttribute("animate", false);
|
||||
|
||||
StarUI._autoCloseTimeout = 1000;
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
StarUI._autoCloseTimeout = oldTimeout;
|
||||
bookmarkPanel.removeAttribute("animate");
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_add_bookmark_tags_from_bookmarkProperties() {
|
||||
const TEST_URL = "about:robots";
|
||||
|
||||
// Open a new window with delayed apply disabled.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", false]],
|
||||
});
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser: win.gBrowser,
|
||||
gBrowser,
|
||||
opening: TEST_URL,
|
||||
waitForStateStop: true,
|
||||
});
|
||||
|
||||
win.StarUI._createPanelIfNeeded();
|
||||
win.StarUI._autoCloseTimeout = 1000;
|
||||
bookmarkPanel = win.document.getElementById("editBookmarkPanel");
|
||||
bookmarkPanel.setAttribute("animate", false);
|
||||
bookmarkStar = win.BookmarkingUI.star;
|
||||
|
||||
// Cleanup.
|
||||
registerCleanupFunction(async function() {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
let bookmarkPanelTitle = win.document.getElementById(
|
||||
"editBookmarkPanelTitle"
|
||||
);
|
||||
let bookmarkPanelTitle = document.getElementById("editBookmarkPanelTitle");
|
||||
|
||||
// The bookmarks panel is expected to auto-close after this step.
|
||||
await hideBookmarksPanel(async () => {
|
||||
|
|
@ -83,7 +81,7 @@ add_task(async function test_add_bookmark_tags_from_bookmarkProperties() {
|
|||
"bookmark-added",
|
||||
events => events.some(({ url }) => !url || url == TEST_URL)
|
||||
);
|
||||
await fillBookmarkTextField("editBMPanel_tagsField", "tag1", win);
|
||||
await fillBookmarkTextField("editBMPanel_tagsField", "tag1", window);
|
||||
await promiseNotification;
|
||||
let bookmarks = [];
|
||||
await PlacesUtils.bookmarks.fetch({ url: TEST_URL }, bm =>
|
||||
|
|
@ -98,7 +96,7 @@ add_task(async function test_add_bookmark_tags_from_bookmarkProperties() {
|
|||
PlacesUtils.tagging.getTagsForURI(Services.io.newURI(TEST_URL)),
|
||||
["tag1"]
|
||||
);
|
||||
let doneButton = win.document.getElementById("editBookmarkPanelDoneButton");
|
||||
let doneButton = document.getElementById("editBookmarkPanelDoneButton");
|
||||
await hideBookmarksPanel(() => doneButton.click());
|
||||
|
||||
// Click the bookmark star again, add more tags.
|
||||
|
|
@ -106,7 +104,11 @@ add_task(async function test_add_bookmark_tags_from_bookmarkProperties() {
|
|||
promiseNotification = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-tags-changed"
|
||||
);
|
||||
await fillBookmarkTextField("editBMPanel_tagsField", "tag1, tag2, tag3", win);
|
||||
await fillBookmarkTextField(
|
||||
"editBMPanel_tagsField",
|
||||
"tag1, tag2, tag3",
|
||||
window
|
||||
);
|
||||
await promiseNotification;
|
||||
await hideBookmarksPanel(() => doneButton.click());
|
||||
|
||||
|
|
|
|||
|
|
@ -8,34 +8,24 @@
|
|||
/**
|
||||
* Test opening and closing the bookmarks panel.
|
||||
*/
|
||||
let win;
|
||||
let bookmarkPanel;
|
||||
let bookmarkStar;
|
||||
let bookmarkPanelTitle;
|
||||
let bookmarkRemoveButton;
|
||||
|
||||
StarUI._createPanelIfNeeded();
|
||||
let bookmarkPanel = document.getElementById("editBookmarkPanel");
|
||||
let bookmarkStar = BookmarkingUI.star;
|
||||
let bookmarkPanelTitle = document.getElementById("editBookmarkPanelTitle");
|
||||
let bookmarkRemoveButton = document.getElementById(
|
||||
"editBookmarkPanelRemoveButton"
|
||||
);
|
||||
let editBookmarkPanelRemoveButtonRect;
|
||||
|
||||
const TEST_URL = "data:text/html,<html><body></body></html>";
|
||||
|
||||
StarUI._closePanelQuickForTesting = true;
|
||||
|
||||
add_setup(async function() {
|
||||
// Panel must be instant apply for tests to pass.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", false]],
|
||||
});
|
||||
win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
win.StarUI._createPanelIfNeeded();
|
||||
win.StarUI._closePanelQuickForTesting = true;
|
||||
bookmarkPanel = win.document.getElementById("editBookmarkPanel");
|
||||
bookmarkPanel.setAttribute("animate", false);
|
||||
bookmarkStar = win.BookmarkingUI.star;
|
||||
bookmarkPanelTitle = win.document.getElementById("editBookmarkPanelTitle");
|
||||
bookmarkRemoveButton = win.document.getElementById(
|
||||
"editBookmarkPanelRemoveButton"
|
||||
);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
registerCleanupFunction(() => {
|
||||
bookmarkPanel.removeAttribute("animate");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -44,12 +34,8 @@ function mouseout() {
|
|||
bookmarkPanel,
|
||||
"mouseout"
|
||||
);
|
||||
EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, { type: "mouseout" }, win);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
gURLBar.textbox,
|
||||
{ type: "mousemove" },
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, { type: "mouseout" });
|
||||
EventUtils.synthesizeMouseAtCenter(gURLBar.textbox, { type: "mousemove" });
|
||||
info("Waiting for mouseout event");
|
||||
return mouseOutPromise;
|
||||
}
|
||||
|
|
@ -62,115 +48,114 @@ async function test_bookmarks_popup({
|
|||
popupHideFn,
|
||||
isBookmarkRemoved,
|
||||
}) {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser: win.gBrowser, url: TEST_URL },
|
||||
async function(browser) {
|
||||
try {
|
||||
if (!isNewBookmark) {
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: await PlacesUIUtils.defaultParentGuid,
|
||||
url: TEST_URL,
|
||||
title: "Home Page",
|
||||
});
|
||||
}
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url: TEST_URL }, async function(
|
||||
browser
|
||||
) {
|
||||
try {
|
||||
if (!isNewBookmark) {
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: await PlacesUIUtils.defaultParentGuid,
|
||||
url: TEST_URL,
|
||||
title: "Home Page",
|
||||
});
|
||||
}
|
||||
|
||||
info(`BookmarkingUI.status is ${win.BookmarkingUI.status}`);
|
||||
await TestUtils.waitForCondition(
|
||||
() => win.BookmarkingUI.status != win.BookmarkingUI.STATUS_UPDATING,
|
||||
"BookmarkingUI should not be updating"
|
||||
);
|
||||
info(`BookmarkingUI.status is ${BookmarkingUI.status}`);
|
||||
await TestUtils.waitForCondition(
|
||||
() => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING,
|
||||
"BookmarkingUI should not be updating"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
bookmarkStar.hasAttribute("starred"),
|
||||
!isNewBookmark,
|
||||
"Page should only be starred prior to popupshown if editing bookmark"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"closed",
|
||||
"Panel should be 'closed' to start test"
|
||||
);
|
||||
let shownPromise = promisePopupShown(bookmarkPanel);
|
||||
await popupShowFn(browser);
|
||||
await shownPromise;
|
||||
Assert.equal(
|
||||
bookmarkStar.hasAttribute("starred"),
|
||||
!isNewBookmark,
|
||||
"Page should only be starred prior to popupshown if editing bookmark"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"closed",
|
||||
"Panel should be 'closed' to start test"
|
||||
);
|
||||
let shownPromise = promisePopupShown(bookmarkPanel);
|
||||
await popupShowFn(browser);
|
||||
await shownPromise;
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should be 'open' after shownPromise is resolved"
|
||||
);
|
||||
|
||||
editBookmarkPanelRemoveButtonRect = bookmarkRemoveButton.getBoundingClientRect();
|
||||
|
||||
if (popupEditFn) {
|
||||
await popupEditFn();
|
||||
}
|
||||
let bookmarks = [];
|
||||
await PlacesUtils.bookmarks.fetch({ url: TEST_URL }, bm =>
|
||||
bookmarks.push(bm)
|
||||
);
|
||||
Assert.equal(bookmarks.length, 1, "Only one bookmark should exist");
|
||||
Assert.equal(
|
||||
bookmarkStar.getAttribute("starred"),
|
||||
"true",
|
||||
"Page is starred"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkPanelTitle.dataset.l10nId,
|
||||
isNewBookmark ? "bookmarks-add-bookmark" : "bookmarks-edit-bookmark",
|
||||
"title should match isEditingBookmark state"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkRemoveButton.dataset.l10nId,
|
||||
isNewBookmark ? "bookmark-panel-cancel" : "bookmark-panel-remove",
|
||||
"remove/cancel button label should match isEditingBookmark state"
|
||||
);
|
||||
|
||||
if (!shouldAutoClose) {
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should be 'open' after shownPromise is resolved"
|
||||
"Panel should still be 'open' for non-autoclose"
|
||||
);
|
||||
}
|
||||
|
||||
editBookmarkPanelRemoveButtonRect = bookmarkRemoveButton.getBoundingClientRect();
|
||||
let defaultLocation = await PlacesUIUtils.defaultParentGuid;
|
||||
let bookmarkRemovedPromise = Promise.resolve();
|
||||
if (isBookmarkRemoved) {
|
||||
bookmarkRemovedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-removed",
|
||||
events =>
|
||||
events.some(
|
||||
event =>
|
||||
event.parentGuid == defaultLocation && TEST_URL == event.url
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (popupEditFn) {
|
||||
await popupEditFn();
|
||||
}
|
||||
let bookmarks = [];
|
||||
await PlacesUtils.bookmarks.fetch({ url: TEST_URL }, bm =>
|
||||
bookmarks.push(bm)
|
||||
);
|
||||
Assert.equal(bookmarks.length, 1, "Only one bookmark should exist");
|
||||
Assert.equal(
|
||||
bookmarkStar.getAttribute("starred"),
|
||||
"true",
|
||||
"Page is starred"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkPanelTitle.dataset.l10nId,
|
||||
isNewBookmark ? "bookmarks-add-bookmark" : "bookmarks-edit-bookmark",
|
||||
"title should match isEditingBookmark state"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkRemoveButton.dataset.l10nId,
|
||||
isNewBookmark ? "bookmark-panel-cancel" : "bookmark-panel-remove",
|
||||
"remove/cancel button label should match isEditingBookmark state"
|
||||
);
|
||||
let hiddenPromise = promisePopupHidden(bookmarkPanel);
|
||||
if (popupHideFn) {
|
||||
await popupHideFn();
|
||||
}
|
||||
await Promise.all([hiddenPromise, bookmarkRemovedPromise]);
|
||||
|
||||
if (!shouldAutoClose) {
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should still be 'open' for non-autoclose"
|
||||
);
|
||||
}
|
||||
|
||||
let defaultLocation = await PlacesUIUtils.defaultParentGuid;
|
||||
let bookmarkRemovedPromise = Promise.resolve();
|
||||
if (isBookmarkRemoved) {
|
||||
bookmarkRemovedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-removed",
|
||||
events =>
|
||||
events.some(
|
||||
event =>
|
||||
event.parentGuid == defaultLocation && TEST_URL == event.url
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
let hiddenPromise = promisePopupHidden(bookmarkPanel);
|
||||
if (popupHideFn) {
|
||||
await popupHideFn();
|
||||
}
|
||||
await Promise.all([hiddenPromise, bookmarkRemovedPromise]);
|
||||
|
||||
Assert.equal(
|
||||
bookmarkStar.hasAttribute("starred"),
|
||||
!isBookmarkRemoved,
|
||||
"Page is starred after closing"
|
||||
);
|
||||
} finally {
|
||||
let bookmark = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
Assert.equal(
|
||||
!!bookmark,
|
||||
!isBookmarkRemoved,
|
||||
"bookmark should not be present if a panel action should've removed it"
|
||||
);
|
||||
if (bookmark) {
|
||||
await PlacesUtils.bookmarks.remove(bookmark);
|
||||
}
|
||||
Assert.equal(
|
||||
bookmarkStar.hasAttribute("starred"),
|
||||
!isBookmarkRemoved,
|
||||
"Page is starred after closing"
|
||||
);
|
||||
} finally {
|
||||
let bookmark = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
Assert.equal(
|
||||
!!bookmark,
|
||||
!isBookmarkRemoved,
|
||||
"bookmark should not be present if a panel action should've removed it"
|
||||
);
|
||||
if (bookmark) {
|
||||
await PlacesUtils.bookmarks.remove(bookmark);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function panel_shown_for_new_bookmarks_and_autocloses() {
|
||||
|
|
@ -194,7 +179,7 @@ add_task(
|
|||
10,
|
||||
10,
|
||||
{ clickCount: 2 },
|
||||
win
|
||||
window
|
||||
);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
|
|
@ -231,7 +216,7 @@ add_task(
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, window);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
isBookmarkRemoved: false,
|
||||
|
|
@ -250,11 +235,7 @@ add_task(async function panel_shown_for_new_bookmarks_mousemove_mouseout() {
|
|||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{ type: "mousemove" },
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkPanel, { type: "mousemove" });
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
|
@ -283,7 +264,7 @@ add_task(async function panel_shown_for_new_bookmark_close_with_ESC() {
|
|||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }, window);
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -297,7 +278,7 @@ add_task(async function panel_shown_for_editing_no_autoclose_close_with_ESC() {
|
|||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }, window);
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
|
|
@ -310,7 +291,7 @@ add_task(async function panel_shown_for_new_bookmark_keypress_no_autoclose() {
|
|||
bookmarkStar.click();
|
||||
},
|
||||
popupEditFn() {
|
||||
EventUtils.sendChar("VK_TAB", win);
|
||||
EventUtils.sendChar("VK_TAB", window);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
|
|
@ -327,7 +308,7 @@ add_task(async function bookmark_with_invalid_default_folder() {
|
|||
isNewBookmark: true,
|
||||
shouldAutoClose: true,
|
||||
async popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, window);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
@ -344,17 +325,14 @@ add_task(
|
|||
bookmarkPanel,
|
||||
"compositionstart"
|
||||
);
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, win);
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, window);
|
||||
info("Waiting for compositionstart event");
|
||||
await compositionStartPromise;
|
||||
info("Got compositionstart event");
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeComposition(
|
||||
{ type: "compositioncommitasis" },
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeComposition({ type: "compositioncommitasis" });
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
|
|
@ -374,13 +352,9 @@ add_task(
|
|||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{
|
||||
type: "mousemove",
|
||||
},
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {
|
||||
type: "mousemove",
|
||||
});
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
|
@ -389,7 +363,7 @@ add_task(
|
|||
bookmarkPanel,
|
||||
"compositionstart"
|
||||
);
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, win);
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, window);
|
||||
info("Waiting for compositionstart event");
|
||||
await compositionStartPromise;
|
||||
info("Got compositionstart event");
|
||||
|
|
@ -399,10 +373,7 @@ add_task(
|
|||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeComposition(
|
||||
{ type: "compositioncommitasis" },
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeComposition({ type: "compositioncommitasis" });
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
|
|
@ -422,24 +393,17 @@ add_task(
|
|||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{
|
||||
type: "mousemove",
|
||||
},
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkPanel, {
|
||||
type: "mousemove",
|
||||
});
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
||||
EventUtils.synthesizeComposition(
|
||||
{
|
||||
type: "compositioncommit",
|
||||
data: "committed text",
|
||||
},
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeComposition({
|
||||
type: "compositioncommit",
|
||||
data: "committed text",
|
||||
});
|
||||
},
|
||||
popupHideFn() {
|
||||
bookmarkPanel.hidePopup();
|
||||
|
|
@ -454,7 +418,7 @@ add_task(async function contextmenu_new_bookmark_keypress_no_autoclose() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
async popupShowFn(browser) {
|
||||
let contextMenu = win.document.getElementById("contentAreaContextMenu");
|
||||
let contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
let awaitPopupShown = BrowserTestUtils.waitForEvent(
|
||||
contextMenu,
|
||||
"popupshown"
|
||||
|
|
@ -472,13 +436,11 @@ add_task(async function contextmenu_new_bookmark_keypress_no_autoclose() {
|
|||
browser
|
||||
);
|
||||
await awaitPopupShown;
|
||||
contextMenu.activateItem(
|
||||
win.document.getElementById("context-bookmarkpage")
|
||||
);
|
||||
contextMenu.activateItem(document.getElementById("context-bookmarkpage"));
|
||||
await awaitPopupHidden;
|
||||
},
|
||||
popupEditFn() {
|
||||
EventUtils.sendChar("VK_TAB", win);
|
||||
EventUtils.sendChar("VK_TAB", window);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
|
|
@ -492,11 +454,11 @@ add_task(async function bookmarks_menu_new_bookmark_remove_bookmark() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn(browser) {
|
||||
win.document.getElementById("menu_bookmarkThisPage").doCommand();
|
||||
document.getElementById("menu_bookmarkThisPage").doCommand();
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -506,11 +468,11 @@ add_task(async function ctrl_d_edit_bookmark_remove_bookmark() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: false,
|
||||
popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, window);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -526,17 +488,17 @@ add_task(async function enter_on_remove_bookmark_should_remove_bookmark() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, window);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
while (
|
||||
!win.document.activeElement ||
|
||||
win.document.activeElement.id != "editBookmarkPanelRemoveButton"
|
||||
!document.activeElement ||
|
||||
document.activeElement.id != "editBookmarkPanelRemoveButton"
|
||||
) {
|
||||
EventUtils.sendChar("VK_TAB", win);
|
||||
EventUtils.sendChar("VK_TAB", window);
|
||||
}
|
||||
EventUtils.sendChar("VK_RETURN", win);
|
||||
EventUtils.sendChar("VK_RETURN", window);
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -553,15 +515,15 @@ add_task(async function mouse_hovering_panel_should_prevent_autoclose() {
|
|||
async popupShowFn() {
|
||||
await EventUtils.promiseNativeMouseEvent({
|
||||
type: "mousemove",
|
||||
target: win.document.documentElement,
|
||||
target: document.documentElement,
|
||||
offsetX: editBookmarkPanelRemoveButtonRect.left,
|
||||
offsetY: editBookmarkPanelRemoveButtonRect.top,
|
||||
});
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, window);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -571,18 +533,14 @@ add_task(async function ctrl_d_new_bookmark_mousedown_mouseout_no_autoclose() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, window);
|
||||
},
|
||||
async popupEditFn() {
|
||||
let mouseMovePromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{ type: "mousemove" },
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkPanel, { type: "mousemove" });
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
|
@ -594,20 +552,16 @@ add_task(async function ctrl_d_new_bookmark_mousedown_mouseout_no_autoclose() {
|
|||
"Panel should still be open on mousemove"
|
||||
);
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanelTitle,
|
||||
{
|
||||
button: 1,
|
||||
type: "mousedown",
|
||||
},
|
||||
win
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(bookmarkPanelTitle, {
|
||||
button: 1,
|
||||
type: "mousedown",
|
||||
});
|
||||
|
||||
await mouseout();
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -617,31 +571,31 @@ add_task(async function enter_during_autocomplete_should_prevent_autoclose() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
async popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, window);
|
||||
},
|
||||
async popupEditFn() {
|
||||
let tagsField = win.document.getElementById("editBMPanel_tagsField");
|
||||
let tagsField = document.getElementById("editBMPanel_tagsField");
|
||||
tagsField.value = "";
|
||||
tagsField.focus();
|
||||
|
||||
// Register a tag into the DB.
|
||||
EventUtils.sendString("Abc", win);
|
||||
EventUtils.sendString("Abc", window);
|
||||
tagsField.blur();
|
||||
|
||||
// Start autocomplete with the registered tag.
|
||||
tagsField.value = "";
|
||||
let popup = win.document.getElementById("editBMPanel_tagsAutocomplete");
|
||||
let popup = document.getElementById("editBMPanel_tagsAutocomplete");
|
||||
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
tagsField.focus();
|
||||
EventUtils.sendString("a", win);
|
||||
EventUtils.sendString("a", window);
|
||||
await promiseShown;
|
||||
ok(promiseShown, "autocomplete shown");
|
||||
|
||||
// Select first candidate.
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
|
||||
|
||||
// Type Enter key to choose the item.
|
||||
EventUtils.synthesizeKey("KEY_Enter", {}, win);
|
||||
EventUtils.synthesizeKey("KEY_Enter", {}, window);
|
||||
|
||||
Assert.equal(
|
||||
tagsField.value,
|
||||
|
|
@ -651,7 +605,7 @@ add_task(async function enter_during_autocomplete_should_prevent_autoclose() {
|
|||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, win);
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, window);
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
@ -661,31 +615,31 @@ add_task(async function escape_during_autocomplete_should_prevent_autoclose() {
|
|||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
async popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, win);
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, window);
|
||||
},
|
||||
async popupEditFn() {
|
||||
let tagsField = win.document.getElementById("editBMPanel_tagsField");
|
||||
let tagsField = document.getElementById("editBMPanel_tagsField");
|
||||
tagsField.value = "";
|
||||
tagsField.focus();
|
||||
|
||||
// Register a tag into the DB.
|
||||
EventUtils.sendString("Abc", win);
|
||||
EventUtils.sendString("Abc", window);
|
||||
tagsField.blur();
|
||||
|
||||
// Start autocomplete with the registered tag.
|
||||
tagsField.value = "";
|
||||
let popup = win.document.getElementById("editBMPanel_tagsAutocomplete");
|
||||
let popup = document.getElementById("editBMPanel_tagsAutocomplete");
|
||||
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
tagsField.focus();
|
||||
EventUtils.sendString("a", win);
|
||||
EventUtils.sendString("a", window);
|
||||
await promiseShown;
|
||||
ok(promiseShown, "autocomplete shown");
|
||||
|
||||
// Select first candidate.
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", {}, window);
|
||||
|
||||
// Type Escape key to close autocomplete.
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, win);
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, window);
|
||||
|
||||
// The text reverts to what was typed.
|
||||
// Note, it's important that this is different from the previously
|
||||
|
|
@ -698,7 +652,7 @@ add_task(async function escape_during_autocomplete_should_prevent_autoclose() {
|
|||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, win);
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, window);
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,712 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test opening and closing the bookmarks panel.
|
||||
*/
|
||||
let win;
|
||||
let bookmarkPanel;
|
||||
let bookmarkStar;
|
||||
let bookmarkPanelTitle;
|
||||
let bookmarkRemoveButton;
|
||||
let editBookmarkPanelRemoveButtonRect;
|
||||
|
||||
const TEST_URL = "data:text/html,<html><body></body></html>";
|
||||
|
||||
add_setup(async function() {
|
||||
// Panel must be delayed apply for tests to pass.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.bookmarks.editDialog.delayedApply.enabled", true]],
|
||||
});
|
||||
win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
win.StarUI._createPanelIfNeeded();
|
||||
win.StarUI._closePanelQuickForTesting = true;
|
||||
bookmarkPanel = win.document.getElementById("editBookmarkPanel");
|
||||
bookmarkPanel.setAttribute("animate", false);
|
||||
bookmarkStar = win.BookmarkingUI.star;
|
||||
bookmarkPanelTitle = win.document.getElementById("editBookmarkPanelTitle");
|
||||
bookmarkRemoveButton = win.document.getElementById(
|
||||
"editBookmarkPanelRemoveButton"
|
||||
);
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
});
|
||||
|
||||
function mouseout() {
|
||||
let mouseOutPromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"mouseout"
|
||||
);
|
||||
EventUtils.synthesizeMouse(bookmarkPanel, 0, 0, { type: "mouseout" }, win);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
gURLBar.textbox,
|
||||
{ type: "mousemove" },
|
||||
win
|
||||
);
|
||||
info("Waiting for mouseout event");
|
||||
return mouseOutPromise;
|
||||
}
|
||||
|
||||
async function test_bookmarks_popup({
|
||||
isNewBookmark,
|
||||
popupShowFn,
|
||||
popupEditFn,
|
||||
shouldAutoClose,
|
||||
popupHideFn,
|
||||
isBookmarkRemoved,
|
||||
}) {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser: win.gBrowser, url: TEST_URL },
|
||||
async function(browser) {
|
||||
try {
|
||||
if (!isNewBookmark) {
|
||||
await PlacesUtils.bookmarks.insert({
|
||||
parentGuid: await PlacesUIUtils.defaultParentGuid,
|
||||
url: TEST_URL,
|
||||
title: "Home Page",
|
||||
});
|
||||
}
|
||||
|
||||
info(`BookmarkingUI.status is ${win.BookmarkingUI.status}`);
|
||||
await TestUtils.waitForCondition(
|
||||
() => win.BookmarkingUI.status != win.BookmarkingUI.STATUS_UPDATING,
|
||||
"BookmarkingUI should not be updating"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
bookmarkStar.hasAttribute("starred"),
|
||||
!isNewBookmark,
|
||||
"Page should only be starred prior to popupshown if editing bookmark"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"closed",
|
||||
"Panel should be 'closed' to start test"
|
||||
);
|
||||
let shownPromise = promisePopupShown(bookmarkPanel);
|
||||
await popupShowFn(browser);
|
||||
await shownPromise;
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should be 'open' after shownPromise is resolved"
|
||||
);
|
||||
|
||||
editBookmarkPanelRemoveButtonRect = bookmarkRemoveButton.getBoundingClientRect();
|
||||
|
||||
if (popupEditFn) {
|
||||
await popupEditFn();
|
||||
}
|
||||
Assert.equal(
|
||||
bookmarkStar.getAttribute("starred"),
|
||||
"true",
|
||||
"Page is starred"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkPanelTitle.dataset.l10nId,
|
||||
isNewBookmark ? "bookmarks-add-bookmark" : "bookmarks-edit-bookmark",
|
||||
"title should match isEditingBookmark state"
|
||||
);
|
||||
Assert.equal(
|
||||
bookmarkRemoveButton.dataset.l10nId,
|
||||
isNewBookmark ? "bookmark-panel-cancel" : "bookmark-panel-remove",
|
||||
"remove/cancel button label should match isEditingBookmark state"
|
||||
);
|
||||
|
||||
if (!shouldAutoClose) {
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
Assert.equal(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should still be 'open' for non-autoclose"
|
||||
);
|
||||
}
|
||||
|
||||
let defaultLocation = await PlacesUIUtils.defaultParentGuid;
|
||||
const promises = [];
|
||||
if (isNewBookmark && !isBookmarkRemoved) {
|
||||
// Expect new bookmark to be created.
|
||||
promises.push(
|
||||
PlacesTestUtils.waitForNotification("bookmark-added", events =>
|
||||
events.some(
|
||||
({ parentGuid, url }) =>
|
||||
parentGuid == defaultLocation && TEST_URL == url
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (!isNewBookmark && isBookmarkRemoved) {
|
||||
// Expect existing bookmark to be removed.
|
||||
promises.push(
|
||||
PlacesTestUtils.waitForNotification("bookmark-removed", events =>
|
||||
events.some(
|
||||
({ parentGuid, url }) =>
|
||||
parentGuid == defaultLocation && TEST_URL == url
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
promises.push(promisePopupHidden(bookmarkPanel));
|
||||
if (popupHideFn) {
|
||||
await popupHideFn();
|
||||
}
|
||||
await Promise.all(promises);
|
||||
|
||||
Assert.equal(
|
||||
bookmarkStar.hasAttribute("starred"),
|
||||
!isBookmarkRemoved,
|
||||
"Page is starred after closing"
|
||||
);
|
||||
|
||||
// Count number of bookmarks.
|
||||
let count = 0;
|
||||
await PlacesUtils.bookmarks.fetch({ url: TEST_URL }, () => count++);
|
||||
const message = isBookmarkRemoved
|
||||
? "No bookmark should exist"
|
||||
: "Only one bookmark should exist";
|
||||
Assert.equal(count, isBookmarkRemoved ^ 1, message);
|
||||
} finally {
|
||||
let bookmark = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
Assert.equal(
|
||||
!!bookmark,
|
||||
!isBookmarkRemoved,
|
||||
"bookmark should not be present if a panel action should've removed it"
|
||||
);
|
||||
if (bookmark) {
|
||||
await PlacesUtils.bookmarks.remove(bookmark);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function panel_shown_for_new_bookmarks_and_autocloses() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(
|
||||
async function panel_shown_once_for_doubleclick_on_new_bookmark_star_and_autocloses() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
EventUtils.synthesizeMouse(
|
||||
bookmarkStar,
|
||||
10,
|
||||
10,
|
||||
{ clickCount: 2 },
|
||||
win
|
||||
);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function panel_shown_once_for_slow_doubleclick_on_new_bookmark_star_and_autocloses() {
|
||||
todo(
|
||||
false,
|
||||
"bug 1250267, may need to add some tracking state to " +
|
||||
"browser-places.js for this."
|
||||
);
|
||||
|
||||
/*
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
*popupShowFn() {
|
||||
EventUtils.synthesizeMouse(bookmarkStar, 10, 10, window);
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
EventUtils.synthesizeMouse(bookmarkStar, 10, 10, window);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
*/
|
||||
}
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function panel_shown_for_keyboardshortcut_on_new_bookmark_star_and_autocloses() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function panel_shown_for_new_bookmarks_mousemove_mouseout() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
async popupEditFn() {
|
||||
let mouseMovePromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{ type: "mousemove" },
|
||||
win
|
||||
);
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
is(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should still be open on mousemove"
|
||||
);
|
||||
},
|
||||
async popupHideFn() {
|
||||
await mouseout();
|
||||
info("Got mouseout event, should autoclose now");
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function panel_shown_for_new_bookmark_close_with_ESC() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }, win);
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function panel_shown_for_editing_no_autoclose_close_with_ESC() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: false,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", { accelKey: true }, win);
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function panel_shown_for_new_bookmark_keypress_no_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
popupEditFn() {
|
||||
EventUtils.sendChar("VK_TAB", win);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function bookmark_with_invalid_default_folder() {
|
||||
await createAndRemoveDefaultFolder();
|
||||
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
shouldAutoClose: true,
|
||||
async popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, win);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
add_task(
|
||||
async function panel_shown_for_new_bookmark_compositionstart_no_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
async popupEditFn() {
|
||||
let compositionStartPromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"compositionstart"
|
||||
);
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, win);
|
||||
info("Waiting for compositionstart event");
|
||||
await compositionStartPromise;
|
||||
info("Got compositionstart event");
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeComposition(
|
||||
{ type: "compositioncommitasis" },
|
||||
win
|
||||
);
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function panel_shown_for_new_bookmark_compositionstart_mouseout_no_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
async popupEditFn() {
|
||||
let mouseMovePromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{
|
||||
type: "mousemove",
|
||||
},
|
||||
win
|
||||
);
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
||||
let compositionStartPromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"compositionstart"
|
||||
);
|
||||
EventUtils.synthesizeComposition({ type: "compositionstart" }, win);
|
||||
info("Waiting for compositionstart event");
|
||||
await compositionStartPromise;
|
||||
info("Got compositionstart event");
|
||||
|
||||
await mouseout();
|
||||
info("Got mouseout event, but shouldn't run autoclose");
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeComposition(
|
||||
{ type: "compositioncommitasis" },
|
||||
win
|
||||
);
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
add_task(
|
||||
async function panel_shown_for_new_bookmark_compositionend_no_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn() {
|
||||
bookmarkStar.click();
|
||||
},
|
||||
async popupEditFn() {
|
||||
let mouseMovePromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{
|
||||
type: "mousemove",
|
||||
},
|
||||
win
|
||||
);
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
||||
EventUtils.synthesizeComposition(
|
||||
{
|
||||
type: "compositioncommit",
|
||||
data: "committed text",
|
||||
},
|
||||
win
|
||||
);
|
||||
},
|
||||
popupHideFn() {
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
add_task(async function contextmenu_new_bookmark_keypress_no_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
async popupShowFn(browser) {
|
||||
let contextMenu = win.document.getElementById("contentAreaContextMenu");
|
||||
let awaitPopupShown = BrowserTestUtils.waitForEvent(
|
||||
contextMenu,
|
||||
"popupshown"
|
||||
);
|
||||
let awaitPopupHidden = BrowserTestUtils.waitForEvent(
|
||||
contextMenu,
|
||||
"popuphidden"
|
||||
);
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter(
|
||||
"body",
|
||||
{
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
},
|
||||
browser
|
||||
);
|
||||
await awaitPopupShown;
|
||||
contextMenu.activateItem(
|
||||
win.document.getElementById("context-bookmarkpage")
|
||||
);
|
||||
await awaitPopupHidden;
|
||||
},
|
||||
popupEditFn() {
|
||||
EventUtils.sendChar("VK_TAB", win);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
bookmarkPanel.hidePopup();
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function bookmarks_menu_new_bookmark_remove_bookmark() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn(browser) {
|
||||
win.document.getElementById("menu_bookmarkThisPage").doCommand();
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function ctrl_d_edit_bookmark_remove_bookmark() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: false,
|
||||
popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function enter_on_remove_bookmark_should_remove_bookmark() {
|
||||
if (AppConstants.platform == "macosx") {
|
||||
// "Full Keyboard Access" is disabled by default, and thus doesn't allow
|
||||
// keyboard navigation to the "Remove Bookmarks" button by default.
|
||||
return;
|
||||
}
|
||||
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
},
|
||||
shouldAutoClose: true,
|
||||
popupHideFn() {
|
||||
while (
|
||||
!win.document.activeElement ||
|
||||
win.document.activeElement.id != "editBookmarkPanelRemoveButton"
|
||||
) {
|
||||
EventUtils.sendChar("VK_TAB", win);
|
||||
}
|
||||
EventUtils.sendChar("VK_RETURN", win);
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function mouse_hovering_panel_should_prevent_autoclose() {
|
||||
if (AppConstants.platform != "win") {
|
||||
// This test requires synthesizing native mouse movement which is
|
||||
// best supported on Windows.
|
||||
return;
|
||||
}
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
async popupShowFn() {
|
||||
await EventUtils.promiseNativeMouseEvent({
|
||||
type: "mousemove",
|
||||
target: win.document.documentElement,
|
||||
offsetX: editBookmarkPanelRemoveButtonRect.left,
|
||||
offsetY: editBookmarkPanelRemoveButtonRect.top,
|
||||
});
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function ctrl_d_new_bookmark_mousedown_mouseout_no_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: true,
|
||||
popupShowFn(browser) {
|
||||
EventUtils.synthesizeKey("D", { accelKey: true }, win);
|
||||
},
|
||||
async popupEditFn() {
|
||||
let mouseMovePromise = BrowserTestUtils.waitForEvent(
|
||||
bookmarkPanel,
|
||||
"mousemove"
|
||||
);
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanel,
|
||||
{ type: "mousemove" },
|
||||
win
|
||||
);
|
||||
info("Waiting for mousemove event");
|
||||
await mouseMovePromise;
|
||||
info("Got mousemove event");
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 400));
|
||||
is(
|
||||
bookmarkPanel.state,
|
||||
"open",
|
||||
"Panel should still be open on mousemove"
|
||||
);
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
bookmarkPanelTitle,
|
||||
{
|
||||
button: 1,
|
||||
type: "mousedown",
|
||||
},
|
||||
win
|
||||
);
|
||||
|
||||
await mouseout();
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
win.document.getElementById("editBookmarkPanelRemoveButton").click();
|
||||
},
|
||||
isBookmarkRemoved: true,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function enter_during_autocomplete_should_prevent_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: false,
|
||||
async popupShowFn(browser) {
|
||||
PlacesUtils.tagging.tagURI(makeURI(TEST_URL), ["Abc"]);
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, win);
|
||||
},
|
||||
async popupEditFn() {
|
||||
// Start autocomplete with the registered tag.
|
||||
let tagsField = win.document.getElementById("editBMPanel_tagsField");
|
||||
tagsField.value = "";
|
||||
let popup = win.document.getElementById("editBMPanel_tagsAutocomplete");
|
||||
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
tagsField.focus();
|
||||
EventUtils.sendString("a", win);
|
||||
await promiseShown;
|
||||
ok(promiseShown, "autocomplete shown");
|
||||
|
||||
// Select first candidate.
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
|
||||
|
||||
// Type Enter key to choose the item.
|
||||
EventUtils.synthesizeKey("KEY_Enter", {}, win);
|
||||
|
||||
Assert.equal(
|
||||
tagsField.value,
|
||||
"Abc",
|
||||
"Autocomplete should've inserted the selected item"
|
||||
);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, win);
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function escape_during_autocomplete_should_prevent_autoclose() {
|
||||
await test_bookmarks_popup({
|
||||
isNewBookmark: false,
|
||||
async popupShowFn(browser) {
|
||||
PlacesUtils.tagging.tagURI(makeURI(TEST_URL), ["Abc"]);
|
||||
EventUtils.synthesizeKey("d", { accelKey: true }, win);
|
||||
},
|
||||
async popupEditFn() {
|
||||
// Start autocomplete with the registered tag.
|
||||
let tagsField = win.document.getElementById("editBMPanel_tagsField");
|
||||
tagsField.value = "";
|
||||
let popup = win.document.getElementById("editBMPanel_tagsAutocomplete");
|
||||
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
tagsField.focus();
|
||||
EventUtils.sendString("a", win);
|
||||
await promiseShown;
|
||||
ok(promiseShown, "autocomplete shown");
|
||||
|
||||
// Select first candidate.
|
||||
EventUtils.synthesizeKey("KEY_ArrowDown", {}, win);
|
||||
|
||||
// Type Escape key to close autocomplete.
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, win);
|
||||
|
||||
// The text reverts to what was typed.
|
||||
// Note, it's important that this is different from the previously
|
||||
// inserted tag, since it will test an untag/tag undo condition.
|
||||
Assert.equal(
|
||||
tagsField.value,
|
||||
"a",
|
||||
"Autocomplete should revert to what was typed"
|
||||
);
|
||||
},
|
||||
shouldAutoClose: false,
|
||||
popupHideFn() {
|
||||
EventUtils.synthesizeKey("KEY_Escape", {}, win);
|
||||
},
|
||||
isBookmarkRemoved: false,
|
||||
});
|
||||
});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
delete StarUI._closePanelQuickForTesting;
|
||||
});
|
||||
|
|
@ -27,10 +27,6 @@ add_task(async function test_add_bookmark_from_private_window() {
|
|||
win.StarUI._createPanelIfNeeded();
|
||||
let bookmarkPanel = win.document.getElementById("editBookmarkPanel");
|
||||
let shownPromise = promisePopupShown(bookmarkPanel);
|
||||
let bookmarkAddedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-added",
|
||||
events => events.some(({ url }) => url === TEST_URL)
|
||||
);
|
||||
let bookmarkStar = win.BookmarkingUI.star;
|
||||
bookmarkStar.click();
|
||||
await shownPromise;
|
||||
|
|
@ -47,7 +43,6 @@ add_task(async function test_add_bookmark_from_private_window() {
|
|||
let doneButton = win.document.getElementById("editBookmarkPanelDoneButton");
|
||||
doneButton.click();
|
||||
await hiddenPromise;
|
||||
await bookmarkAddedPromise;
|
||||
|
||||
let bm = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
Assert.equal(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ add_task(async function test_remove_tags_from_BookmarkStar() {
|
|||
url: TEST_URL,
|
||||
title: TEST_URL,
|
||||
});
|
||||
PlacesUtils.tagging.tagURI(TEST_URI, ["tag1", "tag2", "tag3", "tag4"]);
|
||||
PlacesUtils.tagging.tagURI(TEST_URI, ["tag1, tag2, tag3, tag4"]);
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
|
|
|
|||
|
|
@ -303,137 +303,119 @@ gTests.push({
|
|||
// ------------------------------------------------------------------------------
|
||||
// Bug 491269 - Test that editing folder name in bookmarks properties dialog does not accept the dialog
|
||||
|
||||
for (const delayedApply of [false, true]) {
|
||||
const prefDesc = delayedApply ? "Delayed Apply" : "Instant Apply";
|
||||
gTests.push({
|
||||
desc: `Bug 491269 (${prefDesc}) - Test that editing folder name in bookmarks properties dialog does not accept the dialog`,
|
||||
sidebar: SIDEBAR_HISTORY_ID,
|
||||
dialogUrl: DIALOG_URL,
|
||||
action: ACTION_ADD,
|
||||
historyView: SIDEBAR_HISTORY_BYLASTVISITED_VIEW,
|
||||
window: null,
|
||||
gTests.push({
|
||||
desc:
|
||||
" Bug 491269 - Test that editing folder name in bookmarks properties dialog does not accept the dialog",
|
||||
sidebar: SIDEBAR_HISTORY_ID,
|
||||
dialogUrl: DIALOG_URL,
|
||||
action: ACTION_ADD,
|
||||
historyView: SIDEBAR_HISTORY_BYLASTVISITED_VIEW,
|
||||
window: null,
|
||||
|
||||
async setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.bookmarks.editDialog.delayedApply.enabled", delayedApply],
|
||||
],
|
||||
});
|
||||
async setup() {
|
||||
// Add a visit.
|
||||
await PlacesTestUtils.addVisits(TEST_URL);
|
||||
|
||||
// Add a visit.
|
||||
await PlacesTestUtils.addVisits(TEST_URL);
|
||||
if (!delayedApply) {
|
||||
this._addObserver = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-added",
|
||||
null
|
||||
);
|
||||
}
|
||||
},
|
||||
this._addObserver = PlacesTestUtils.waitForNotification("bookmark-added");
|
||||
},
|
||||
|
||||
selectNode(tree) {
|
||||
var visitNode = tree.view.nodeForTreeIndex(0);
|
||||
tree.selectNode(visitNode);
|
||||
Assert.equal(
|
||||
tree.selectedNode.uri,
|
||||
TEST_URL,
|
||||
"The correct visit has been selected"
|
||||
);
|
||||
Assert.equal(
|
||||
tree.selectedNode.itemId,
|
||||
-1,
|
||||
"The selected node is not bookmarked"
|
||||
);
|
||||
},
|
||||
selectNode(tree) {
|
||||
var visitNode = tree.view.nodeForTreeIndex(0);
|
||||
tree.selectNode(visitNode);
|
||||
Assert.equal(
|
||||
tree.selectedNode.uri,
|
||||
TEST_URL,
|
||||
"The correct visit has been selected"
|
||||
);
|
||||
Assert.equal(
|
||||
tree.selectedNode.itemId,
|
||||
-1,
|
||||
"The selected node is not bookmarked"
|
||||
);
|
||||
},
|
||||
|
||||
async run() {
|
||||
// Open folder selector.
|
||||
var foldersExpander = this.window.document.getElementById(
|
||||
"editBMPanel_foldersExpander"
|
||||
);
|
||||
var folderTree = this.window.gEditItemOverlay._folderTree;
|
||||
var self = this;
|
||||
async run() {
|
||||
// Open folder selector.
|
||||
var foldersExpander = this.window.document.getElementById(
|
||||
"editBMPanel_foldersExpander"
|
||||
);
|
||||
var folderTree = this.window.gEditItemOverlay._folderTree;
|
||||
var self = this;
|
||||
|
||||
let unloadPromise = new Promise(resolve => {
|
||||
this.window.addEventListener(
|
||||
"unload",
|
||||
event => {
|
||||
Assert.ok(
|
||||
self._cleanShutdown,
|
||||
"Dialog window should not be closed by pressing ESC in folder name textbox"
|
||||
);
|
||||
executeSoon(() => {
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
{ capture: true, once: true }
|
||||
);
|
||||
});
|
||||
|
||||
folderTree.addEventListener("DOMAttrModified", function onDOMAttrModified(
|
||||
event
|
||||
) {
|
||||
if (event.attrName != "place") {
|
||||
return;
|
||||
}
|
||||
folderTree.removeEventListener("DOMAttrModified", onDOMAttrModified);
|
||||
executeSoon(async function() {
|
||||
if (!delayedApply) {
|
||||
await self._addObserver;
|
||||
let bookmark = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
self._bookmarkGuid = bookmark.guid;
|
||||
}
|
||||
|
||||
// Create a new folder.
|
||||
var newFolderButton = self.window.document.getElementById(
|
||||
"editBMPanel_newFolderButton"
|
||||
);
|
||||
newFolderButton.doCommand();
|
||||
|
||||
// Wait for the folder to be created and for editing to start.
|
||||
await TestUtils.waitForCondition(
|
||||
() => folderTree.hasAttribute("editing"),
|
||||
"We are editing new folder name in folder tree"
|
||||
);
|
||||
|
||||
// Press Escape to discard editing new folder name.
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, self.window);
|
||||
let unloadPromise = new Promise(resolve => {
|
||||
this.window.addEventListener(
|
||||
"unload",
|
||||
event => {
|
||||
Assert.ok(
|
||||
!folderTree.hasAttribute("editing"),
|
||||
"We have finished editing folder name in folder tree"
|
||||
self._cleanShutdown,
|
||||
"Dialog window should not be closed by pressing ESC in folder name textbox"
|
||||
);
|
||||
executeSoon(() => {
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
{ capture: true, once: true }
|
||||
);
|
||||
});
|
||||
|
||||
self._cleanShutdown = true;
|
||||
if (!delayedApply) {
|
||||
self._removeObserver = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-removed",
|
||||
events => events.some(eve => eve.guid == self._bookmarkGuid)
|
||||
);
|
||||
}
|
||||
|
||||
self.window.document
|
||||
.getElementById("bookmarkpropertiesdialog")
|
||||
.cancelDialog();
|
||||
});
|
||||
});
|
||||
foldersExpander.doCommand();
|
||||
await unloadPromise;
|
||||
},
|
||||
|
||||
finish() {
|
||||
SidebarUI.hide();
|
||||
},
|
||||
|
||||
async cleanup() {
|
||||
if (!delayedApply) {
|
||||
await this._removeObserver;
|
||||
delete this._removeObserver;
|
||||
folderTree.addEventListener("DOMAttrModified", function onDOMAttrModified(
|
||||
event
|
||||
) {
|
||||
if (event.attrName != "place") {
|
||||
return;
|
||||
}
|
||||
await PlacesTestUtils.promiseAsyncUpdates();
|
||||
folderTree.removeEventListener("DOMAttrModified", onDOMAttrModified);
|
||||
executeSoon(async function() {
|
||||
await self._addObserver;
|
||||
let bookmark = await PlacesUtils.bookmarks.fetch({ url: TEST_URL });
|
||||
self._bookmarkGuid = bookmark.guid;
|
||||
|
||||
await PlacesUtils.history.clear();
|
||||
},
|
||||
});
|
||||
}
|
||||
// Create a new folder.
|
||||
var newFolderButton = self.window.document.getElementById(
|
||||
"editBMPanel_newFolderButton"
|
||||
);
|
||||
newFolderButton.doCommand();
|
||||
|
||||
// Wait for the folder to be created and for editing to start.
|
||||
await TestUtils.waitForCondition(
|
||||
() => folderTree.hasAttribute("editing"),
|
||||
"We are editing new folder name in folder tree"
|
||||
);
|
||||
|
||||
// Press Escape to discard editing new folder name.
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, self.window);
|
||||
Assert.ok(
|
||||
!folderTree.hasAttribute("editing"),
|
||||
"We have finished editing folder name in folder tree"
|
||||
);
|
||||
|
||||
self._cleanShutdown = true;
|
||||
self._removeObserver = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-removed",
|
||||
events => events.some(eve => eve.guid == self._bookmarkGuid)
|
||||
);
|
||||
|
||||
self.window.document
|
||||
.getElementById("bookmarkpropertiesdialog")
|
||||
.cancelDialog();
|
||||
});
|
||||
});
|
||||
foldersExpander.doCommand();
|
||||
await unloadPromise;
|
||||
},
|
||||
|
||||
finish() {
|
||||
SidebarUI.hide();
|
||||
},
|
||||
|
||||
async cleanup() {
|
||||
await this._removeObserver;
|
||||
delete this._removeObserver;
|
||||
await PlacesTestUtils.promiseAsyncUpdates();
|
||||
|
||||
await PlacesUtils.history.clear();
|
||||
},
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue