Bug 1428760 - Tidy up browser_bookmarkProperties_*.js tests and stop using some obsolete APIs. r=mak

MozReview-Commit-ID: 40PbcRNNPH6

--HG--
extra : rebase_source : 06b888bd56bb2cbdbef871e7babd029dc61e4747
This commit is contained in:
Mark Banner 2018-01-08 13:42:53 +00:00
parent 74da912044
commit ab31f33d7d
5 changed files with 28 additions and 32 deletions

View File

@ -17,7 +17,7 @@ add_task(async function() {
await withSidebarTree("bookmarks", async function(tree) {
// Select the new bookmark in the sidebar.
tree.selectItems([newBookmark.guid]);
ok(tree.controller.isCommandEnabled("placesCmd_new:folder"),
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

View File

@ -18,14 +18,14 @@ add_task(async function() {
await withBookmarksDialog(true, AddKeywordForSearchField, async function(dialogWin) {
let acceptBtn = dialogWin.document.documentElement.getButton("accept");
ok(acceptBtn.disabled, "Accept button is disabled");
Assert.ok(acceptBtn.disabled, "Accept button is disabled");
let promiseKeywordNotification = PlacesTestUtils.waitForNotification(
"onItemChanged", (itemId, prop, isAnno, val) => prop == "keyword" && val == "kw");
fillBookmarkTextField("editBMPanel_keywordField", "kw", dialogWin);
ok(!acceptBtn.disabled, "Accept button is enabled");
Assert.ok(!acceptBtn.disabled, "Accept button is enabled");
// The dialog is instant apply.
await promiseKeywordNotification;
@ -37,18 +37,18 @@ add_task(async function() {
entry = await PlacesUtils.keywords.fetch("kw");
return !!entry;
}, "Unable to find the expected keyword");
is(entry.keyword, "kw", "keyword is correct");
is(entry.url.href, TEST_URL, "URL is correct");
is(entry.postData, "accenti%3D%E0%E8%EC%F2%F9&search%3D%25s", "POST data is correct");
Assert.equal(entry.keyword, "kw", "keyword is correct");
Assert.equal(entry.url.href, TEST_URL, "URL is correct");
Assert.equal(entry.postData, "accenti%3D%E0%E8%EC%F2%F9&search%3D%25s", "POST data is correct");
info("Check the charset has been saved");
let charset = await PlacesUtils.getCharsetForURI(NetUtil.newURI(TEST_URL));
is(charset, "windows-1252", "charset is correct");
Assert.equal(charset, "windows-1252", "charset is correct");
// Now check getShortcutOrURI.
let data = await getShortcutOrURIAndPostData("kw test");
is(getPostDataString(data.postData), "accenti=\u00E0\u00E8\u00EC\u00F2\u00F9&search=test", "getShortcutOrURI POST data is correct");
is(data.url, TEST_URL, "getShortcutOrURI URL is correct");
Assert.equal(getPostDataString(data.postData), "accenti=\u00E0\u00E8\u00EC\u00F2\u00F9&search=test", "getShortcutOrURI POST data is correct");
Assert.equal(data.url, TEST_URL, "getShortcutOrURI URL is correct");
}, closeHandler);
});
});

View File

@ -4,8 +4,7 @@ add_task(async function() {
info("Add a live bookmark editing its data");
await withSidebarTree("bookmarks", async function(tree) {
let itemId = PlacesUIUtils.leftPaneQueries.UnfiledBookmarks;
tree.selectItems([itemId]);
tree.selectItems([PlacesUtils.bookmarks.unfiledGuid]);
await withBookmarksDialog(
true,
@ -26,13 +25,13 @@ add_task(async function() {
index: PlacesUtils.bookmarks.DEFAULT_INDEX
});
is(bookmark.title, "modified", "folder name has been edited");
Assert.equal(bookmark.title, "modified", "folder name has been edited");
let livemark = await PlacesUtils.livemarks.getLivemark({
guid: bookmark.guid
});
is(livemark.feedURI.spec, "http://livemark.com/", "livemark has the correct url");
is(livemark.title, "modified", "livemark has the correct title");
Assert.equal(livemark.feedURI.spec, "http://livemark.com/", "livemark has the correct url");
Assert.equal(livemark.title, "modified", "livemark has the correct title");
}
);
});

View File

@ -22,7 +22,7 @@ add_task(async function() {
},
async dialog => {
let acceptBtn = dialog.document.documentElement.getButton("accept");
ok(!acceptBtn.disabled, "Accept button is enabled");
Assert.ok(!acceptBtn.disabled, "Accept button is enabled");
let namepicker = dialog.document.getElementById("editBMPanel_namePicker");
Assert.ok(!namepicker.readOnly, "Name field is writable");
@ -36,7 +36,7 @@ add_task(async function() {
},
dialog => {
let savedItemId = dialog.gEditItemOverlay.itemId;
ok(savedItemId > 0, "Found the itemId");
Assert.ok(savedItemId > 0, "Found the itemId");
return PlacesTestUtils.waitForNotification("onItemRemoved",
id => id === savedItemId);
}

View File

@ -4,10 +4,9 @@ add_task(async function() {
info("Bug 479348 - Properties on a root should be read-only.");
await withSidebarTree("bookmarks", async function(tree) {
let itemId = PlacesUIUtils.leftPaneQueries.UnfiledBookmarks;
tree.selectItems([itemId]);
ok(tree.controller.isCommandEnabled("placesCmd_show:info"),
"'placesCmd_show:info' on current selected node is enabled");
tree.selectItems([PlacesUtils.bookmarks.unfiledGuid]);
Assert.ok(tree.controller.isCommandEnabled("placesCmd_show:info"),
"'placesCmd_show:info' on current selected node is enabled");
await withBookmarksDialog(
true,
@ -16,26 +15,24 @@ add_task(async function() {
},
async function test(dialogWin) {
// Check that the dialog is read-only.
ok(dialogWin.gEditItemOverlay.readOnly, "Dialog is read-only");
Assert.ok(dialogWin.gEditItemOverlay.readOnly, "Dialog is read-only");
// Check that accept button is disabled
let acceptButton = dialogWin.document.documentElement.getButton("accept");
ok(acceptButton.disabled, "Accept button is disabled");
Assert.ok(acceptButton.disabled, "Accept button is disabled");
// Check that name picker is read only
let namepicker = dialogWin.document.getElementById("editBMPanel_namePicker");
ok(namepicker.readOnly, "Name field is read-only");
is(namepicker.value,
PlacesUtils.bookmarks.getItemTitle(PlacesUtils.unfiledBookmarksFolderId),
"Node title is correct");
Assert.ok(namepicker.readOnly, "Name field is read-only");
let bookmark = await PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(namepicker.value, bookmark.title, "Node title is correct");
// Blur the field and ensure root's name has not been changed.
namepicker.blur();
is(namepicker.value,
PlacesUtils.bookmarks.getItemTitle(PlacesUtils.unfiledBookmarksFolderId),
"Root title is correct");
bookmark = await PlacesUtils.bookmarks.fetch(PlacesUtils.bookmarks.unfiledGuid);
Assert.equal(namepicker.value, bookmark.title, "Root title is correct");
// Check the shortcut's title.
let bookmark = await PlacesUtils.bookmarks.fetch(tree.selectedNode.bookmarkGuid);
is(bookmark.title, "",
"Shortcut title is null");
info(tree.selectedNode.bookmarkGuid);
bookmark = await PlacesUtils.bookmarks.fetch(tree.selectedNode.bookmarkGuid);
Assert.equal(bookmark.title, "", "Shortcut title is null");
}
);
});