Skip to content

Commit

Permalink
Bug 1747689: Changed browser_bookmarkProperties_bookmarkAllTabs.js to…
Browse files Browse the repository at this point in the history
… pass with editBookmark.js. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D139100
  • Loading branch information
janekotovich committed Mar 1, 2022
1 parent e7f1fca commit ea1cbc5
Showing 1 changed file with 155 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,61 +13,159 @@ add_task(async function() {
}
});

await withBookmarksDialog(
true,
function open() {
document.getElementById("Browser:BookmarkAllTabs").doCommand();
},
async dialog => {
let acceptBtn = dialog.document
.getElementById("bookmarkpropertiesdialog")
.getButton("accept");
Assert.ok(!acceptBtn.disabled, "Accept button is enabled");

let namepicker = dialog.document.getElementById("editBMPanel_namePicker");
Assert.ok(!namepicker.readOnly, "Name field is writable");
let folderName = dialog.document
.getElementById("stringBundle")
.getString("bookmarkAllTabsDefault");
Assert.equal(namepicker.value, folderName, "Name field is correct.");

let promiseTitleChange = PlacesTestUtils.waitForNotification(
"bookmark-title-changed",
events => events.some(e => e.title === "folder"),
"places"
);

fillBookmarkTextField("editBMPanel_namePicker", "folder", dialog);
await promiseTitleChange;

let folderPicker = dialog.document.getElementById(
"editBMPanel_folderMenuList"
);

let defaultParentGuid = await PlacesUIUtils.defaultParentGuid;
// Check the initial state of the folder picker.
await TestUtils.waitForCondition(
() => folderPicker.getAttribute("selectedGuid") == defaultParentGuid,
"The folder is the expected one."
);

let savedItemId = dialog.gEditItemOverlay.itemId;
let savedItemGuid = await PlacesUtils.promiseItemGuid(savedItemId);
let entry = await PlacesUtils.bookmarks.fetch(savedItemGuid);
Assert.equal(
entry.parentGuid,
defaultParentGuid,
"Should have created the keyword in the right folder."
);
},
dialog => {
let savedItemId = dialog.gEditItemOverlay.itemId;
Assert.greater(savedItemId, 0, "Found the itemId");
return PlacesTestUtils.waitForNotification(
"bookmark-removed",
events => events.some(event => event.id === savedItemId),
"places"
);
}
);
add_task(async function test_bookmarkAllTabs_instantEditBookmark() {
await SpecialPowers.pushPrefEnv({
set: [["browser.bookmarks.editDialog.delayedApply.enabled", false]],
});
await withBookmarksDialog(
true,
function open() {
document.getElementById("Browser:BookmarkAllTabs").doCommand();
},
async dialog => {
let acceptBtn = dialog.document
.getElementById("bookmarkpropertiesdialog")
.getButton("accept");
Assert.ok(
!acceptBtn.disabled,
"InstantEditBookmark: Accept button is enabled"
);

let namepicker = dialog.document.getElementById(
"editBMPanel_namePicker"
);
Assert.ok(
!namepicker.readOnly,
"InstantEditBookmark: Name field is writable"
);
let folderName = dialog.document
.getElementById("stringBundle")
.getString("bookmarkAllTabsDefault");
Assert.equal(
namepicker.value,
folderName,
"InstantEditBookmark: Name field is correct."
);

let promiseTitleChange = PlacesTestUtils.waitForNotification(
"bookmark-title-changed",
events => events.some(e => e.title === "folder"),
"places"
);

fillBookmarkTextField("editBMPanel_namePicker", "folder", dialog);
await promiseTitleChange;

let folderPicker = dialog.document.getElementById(
"editBMPanel_folderMenuList"
);

let defaultParentGuid = await PlacesUIUtils.defaultParentGuid;
// Check the initial state of the folder picker.
await TestUtils.waitForCondition(
() => folderPicker.getAttribute("selectedGuid") == defaultParentGuid,
"InstantEditBookmark: The folder is the expected one."
);

let savedItemId = dialog.gEditItemOverlay.itemId;
let savedItemGuid = await PlacesUtils.promiseItemGuid(savedItemId);
let entry = await PlacesUtils.bookmarks.fetch(savedItemGuid);
Assert.equal(
entry.parentGuid,
defaultParentGuid,
"InstantEditBookmark: Should have created the keyword in the right folder."
);
},
dialog => {
let savedItemId = dialog.gEditItemOverlay.itemId;
Assert.greater(savedItemId, 0, "Found the itemId");
return PlacesTestUtils.waitForNotification(
"bookmark-removed",
events => events.some(event => event.id === savedItemId),
"places"
);
}
);
});

add_task(async function test_bookmarkAllTabs_eitBookmark() {
await SpecialPowers.pushPrefEnv({
set: [["browser.bookmarks.editDialog.delayedApply.enabled", true]],
});
await withBookmarksDialog(
false,
function open() {
document.getElementById("Browser:BookmarkAllTabs").doCommand();
},
async dialog => {
let acceptBtn = dialog.document
.getElementById("bookmarkpropertiesdialog")
.getButton("accept");
Assert.ok(
!acceptBtn.disabled,
"EditBookmark: Accept button is enabled"
);

let namepicker = dialog.document.getElementById(
"editBMPanel_namePicker"
);
Assert.ok(!namepicker.readOnly, "EditBookmark: Name field is writable");
let folderName = dialog.document
.getElementById("stringBundle")
.getString("bookmarkAllTabsDefault");
Assert.equal(
namepicker.value,
folderName,
"EditBookmark: Name field is correct."
);

fillBookmarkTextField("editBMPanel_namePicker", "folder", dialog);

let folderPicker = dialog.document.getElementById(
"editBMPanel_folderMenuList"
);

let defaultParentGuid = await PlacesUIUtils.defaultParentGuid;
// Check the initial state of the folder picker.
await TestUtils.waitForCondition(
() => folderPicker.getAttribute("selectedGuid") == defaultParentGuid,
"EditBookmark: The folder is the expected one."
);

let savedItemId = dialog.gEditItemOverlay.itemId;
let savedItemGuid = await PlacesUtils.promiseItemGuid(savedItemId);
let entry = await PlacesUtils.bookmarks.fetch(savedItemGuid);
Assert.equal(
entry.parentGuid,
defaultParentGuid,
"EditBookmark: Should have created the keyword in the right folder."
);

EventUtils.synthesizeKey("VK_RETURN", {}, dialog);
}
);

let bookmark1 = await PlacesUtils.bookmarks.fetch({ url: "about:mozilla" });
let bookmark2 = await PlacesUtils.bookmarks.fetch({ url: "about:robots" });
let defaultParentGuid = await PlacesUIUtils.defaultParentGuid;

Assert.equal(
bookmark1.parentGuid,
bookmark2.parentGuid,
"EditBookmark: Both bookmarks created in same folder"
);
let folder = await PlacesUtils.bookmarks.fetch(bookmark1.parentGuid);
Assert.equal(
folder.parentGuid,
defaultParentGuid,
"EditBookmark: ParentGuid of bokmarks is default one as expected (toolbar)"
);
Assert.equal(
folder.title,
"folder",
"EditBookmark: folder title is expected one"
);

await PlacesUtils.bookmarks.eraseEverything();
});
});

0 comments on commit ea1cbc5

Please sign in to comment.