# HG changeset patch # User Mark Banner # Date 1515418973 0 # Node ID dd18db6ffcb0f66a0366fb28f716a39c69ed9bb1 # Parent a66b031b9f6bb1b259be74ea80802229a6d7a187 Bug 1428760 - Tidy up browser_bookmarkProperties_*.js tests and stop using some obsolete APIs. r=mak MozReview-Commit-ID: 40PbcRNNPH6 diff --git a/browser/components/places/tests/browser/browser_bookmarkProperties_addFolderDefaultButton.js b/browser/components/places/tests/browser/browser_bookmarkProperties_addFolderDefaultButton.js --- a/browser/components/places/tests/browser/browser_bookmarkProperties_addFolderDefaultButton.js +++ b/browser/components/places/tests/browser/browser_bookmarkProperties_addFolderDefaultButton.js @@ -12,17 +12,17 @@ add_task(async function() { 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]); - 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 // are inserted at the index of the currently selected item, the new folder // will be inserted at index 0. await withBookmarksDialog( false, function openDialog() { diff --git a/browser/components/places/tests/browser/browser_bookmarkProperties_addKeywordForThisSearch.js b/browser/components/places/tests/browser/browser_bookmarkProperties_addKeywordForThisSearch.js --- a/browser/components/places/tests/browser/browser_bookmarkProperties_addKeywordForThisSearch.js +++ b/browser/components/places/tests/browser/browser_bookmarkProperties_addKeywordForThisSearch.js @@ -13,47 +13,47 @@ add_task(async function() { gBrowser, url: TEST_URL, }, async function(browser) { // We must wait for the context menu code to build metadata. await openContextMenuForContentSelector(browser, '#form1 > input[name="search"]'); 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; // After the notification, the keywords cache will update asynchronously. info("Check the keyword entry has been created"); let entry; await waitForCondition(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); }); }); add_task(async function reopen_same_field() { await PlacesUtils.keywords.insert({ url: TEST_URL, keyword: "kw", diff --git a/browser/components/places/tests/browser/browser_bookmarkProperties_addLivemark.js b/browser/components/places/tests/browser/browser_bookmarkProperties_addLivemark.js --- a/browser/components/places/tests/browser/browser_bookmarkProperties_addLivemark.js +++ b/browser/components/places/tests/browser/browser_bookmarkProperties_addLivemark.js @@ -1,16 +1,15 @@ "use strict"; 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, function openDialog() { PlacesCommandHook.addLiveBookmark("http://livemark.com/", "livemark", "description"); }, async function test(dialogWin) { @@ -21,19 +20,19 @@ add_task(async function() { await promiseTitleChangeNotification; let bookmark = await PlacesUtils.bookmarks.fetch({ parentGuid: PlacesUtils.bookmarks.toolbarGuid, 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"); } ); }); }); diff --git a/browser/components/places/tests/browser/browser_bookmarkProperties_bookmarkAllTabs.js b/browser/components/places/tests/browser/browser_bookmarkProperties_bookmarkAllTabs.js --- a/browser/components/places/tests/browser/browser_bookmarkProperties_bookmarkAllTabs.js +++ b/browser/components/places/tests/browser/browser_bookmarkProperties_bookmarkAllTabs.js @@ -17,28 +17,28 @@ add_task(async function() { }); await withBookmarksDialog(true, function open() { document.getElementById("Browser:BookmarkAllTabs").doCommand(); }, 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"); let folderName = dialog.document.getElementById("stringBundle").getString("bookmarkAllTabsDefault"); Assert.equal(namepicker.value, folderName, "Name field is correct."); let promiseTitleChange = PlacesTestUtils.waitForNotification( "onItemChanged", (id, prop, isAnno, val) => prop == "title" && val == "folder"); fillBookmarkTextField("editBMPanel_namePicker", "folder", dialog); await promiseTitleChange; }, 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); } ); }); diff --git a/browser/components/places/tests/browser/browser_bookmarkProperties_readOnlyRoot.js b/browser/components/places/tests/browser/browser_bookmarkProperties_readOnlyRoot.js --- a/browser/components/places/tests/browser/browser_bookmarkProperties_readOnlyRoot.js +++ b/browser/components/places/tests/browser/browser_bookmarkProperties_readOnlyRoot.js @@ -1,42 +1,39 @@ "use strict"; 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, function openDialog() { tree.controller.doCommand("placesCmd_show:info"); }, 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"); } ); }); });