fune/browser/components/places/tests/browser/browser_bookmarkProperties_addFolderDefaultButton.js
Jonathan Sudiaman 1f02cc1ca2 Bug 1812083 - Enable delayed apply bookmarks in Firefox Nightly r=mak
As expected, the try job flagged a bunch of test failures when flipping the default `delayedApply` pref to `true`. Some of these failures are legitimate issues:

  - When creating a new folder in the tree under "Location", renaming the folder doesn't update its name in the Location field.
  - When right clicking a bookmark in the sidebar, and creating a new folder, the folder doesn't get placed before the bookmark, i.e. the insertion point is ignored.

And as you pointed out, tags were being wiped out on blur in the Star/Toolbar panels. These issues have been fixed. The rest of the failures have been fixed in one of these ways:

  - Update the test to pass regardless of `delayedApply` setting. This was the preferred method.
  - Force the test to use instant apply. This was only done for tests that have an existing delayed apply counterpart.
  - Force the entire test suite to use instant apply. This was only done for one file, namely `browser_bookmark_popup.js`. I'll file a bug to spin off a delayed apply version of this suite.

try job with `delayedApply` enabled: https://treeherder.mozilla.org/jobs?repo=try&revision=50e9cdb65feaec07c9519e928caf62042c3df9a4
try job with `delayedApply` disabled: https://treeherder.mozilla.org/jobs?repo=try&revision=1102b5076a79bf08a0e4b073fdf369af97a16ef7

Differential Revision: https://phabricator.services.mozilla.com/D168690
2023-02-16 17:31:49 +00:00

87 lines
2.9 KiB
JavaScript

"use strict";
async function add_folder_default_button(delayedApply) {
await SpecialPowers.pushPrefEnv({
set: [["browser.bookmarks.editDialog.delayedApply.enabled", delayedApply]],
});
info(
"Bug 475529 - Add is the default button for the new folder dialog + " +
"Bug 1206376 - Changing properties of a new bookmark while adding it " +
"acts on the last bookmark in the current container"
);
// Add a new bookmark at index 0 in the unfiled folder.
let insertionIndex = 0;
let newBookmark = await PlacesUtils.bookmarks.insert({
index: insertionIndex,
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/",
});
await withSidebarTree("bookmarks", async function(tree) {
// Select the new bookmark in the sidebar.
tree.selectItems([newBookmark.guid]);
Assert.ok(
tree.controller.isCommandEnabled("placesCmd_new:folder"),
"'placesCmd_new:folder' on current selected node is enabled"
);
// Create a new folder. Since the new bookmark is selected, and new items
// are inserted at the index of the currently selected item, the new folder
// will be inserted at index 0.
await withBookmarksDialog(
false,
function openDialog() {
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")
),
];
fillBookmarkTextField("editBMPanel_namePicker", "n", dialogWin, false);
// Confirm and close the dialog.
EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
await Promise.all(notifications);
let newFolder = await PlacesUtils.bookmarks.fetch({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
index: insertionIndex,
});
is(newFolder.title, "n", "folder name has been edited");
let bm = await PlacesUtils.bookmarks.fetch(newBookmark.guid);
Assert.equal(
bm.index,
insertionIndex + 1,
"Bookmark should have been shifted to the next index"
);
await PlacesUtils.bookmarks.remove(newFolder);
await PlacesUtils.bookmarks.remove(newBookmark);
}
);
});
}
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);
});