Bug 1441969 - Switch browser_library_commands to use Assert.* rather than the simple methods. r?mak draft
authorMark Banner <standard8@mozilla.com>
Tue, 27 Feb 2018 21:24:41 +0000
changeset 761142 83a683e81ffcb654d425c037436cc5eab4e15f25
parent 760935 ee326c976eebdca48128054022c443d3993e12b0
push id100884
push userbmo:standard8@mozilla.com
push dateWed, 28 Feb 2018 19:32:21 +0000
reviewersmak
bugs1441969
milestone60.0a1
Bug 1441969 - Switch browser_library_commands to use Assert.* rather than the simple methods. r?mak MozReview-Commit-ID: Ggd4Kzmnglx
browser/components/places/tests/browser/browser_library_commands.js
--- a/browser/components/places/tests/browser/browser_library_commands.js
+++ b/browser/components/places/tests/browser/browser_library_commands.js
@@ -20,121 +20,121 @@ add_task(async function test_date_contai
   info("Ensure date containers under History cannot be cut but can be deleted");
 
   await PlacesTestUtils.addVisits(TEST_URI);
 
   // Select and open the left pane "History" query.
   let PO = library.PlacesOrganizer;
 
   PO.selectLeftPaneBuiltIn("History");
-  isnot(PO._places.selectedNode, null, "We correctly selected History");
+  Assert.notEqual(PO._places.selectedNode, null, "We correctly selected History");
 
   // Check that both delete and cut commands are disabled, cause this is
   // a child of the left pane folder.
-  ok(PO._places.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is disabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is disabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is disabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is disabled");
   let historyNode = PlacesUtils.asContainer(PO._places.selectedNode);
   historyNode.containerOpen = true;
 
   // Check that we have a child container. It is "Today" container.
-  is(historyNode.childCount, 1, "History node has one child");
+  Assert.equal(historyNode.childCount, 1, "History node has one child");
   let todayNode = historyNode.getChild(0);
   let todayNodeExpectedTitle = PlacesUtils.getString("finduri-AgeInDays-is-0");
-  is(todayNode.title, todayNodeExpectedTitle,
-     "History child is the expected container");
+  Assert.equal(todayNode.title, todayNodeExpectedTitle,
+    "History child is the expected container");
 
   // Select "Today" container.
   PO._places.selectNode(todayNode);
-  is(PO._places.selectedNode, todayNode,
-     "We correctly selected Today container");
+  Assert.equal(PO._places.selectedNode, todayNode,
+    "We correctly selected Today container");
   // Check that delete command is enabled but cut command is disabled, cause
   // this is an history item.
-  ok(PO._places.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is disabled");
-  ok(PO._places.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is enabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is disabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is enabled");
 
   // Execute the delete command and check visit has been removed.
   let promiseURIRemoved = PlacesTestUtils.waitForNotification(
     "onDeleteURI", v => TEST_URI.equals(v), "history");
   PO._places.controller.doCommand("cmd_delete");
   await promiseURIRemoved;
 
   // Test live update of "History" query.
-  is(historyNode.childCount, 0, "History node has no more children");
+  Assert.equal(historyNode.childCount, 0, "History node has no more children");
 
   historyNode.containerOpen = false;
 
-  ok(!(await PlacesUtils.history.hasVisits(TEST_URI)), "Visit has been removed");
+  Assert.ok(!(await PlacesUtils.history.hasVisits(TEST_URI)), "Visit has been removed");
 
   library.close();
 });
 
 add_task(async function test_query_on_toolbar() {
   let library = await promiseLibrary();
   info("Ensure queries can be cut or deleted");
 
   // Select and open the left pane "Bookmarks Toolbar" folder.
   let PO = library.PlacesOrganizer;
 
   PO.selectLeftPaneBuiltIn("BookmarksToolbar");
-  isnot(PO._places.selectedNode, null, "We have a valid selection");
-  is(PlacesUtils.getConcreteItemId(PO._places.selectedNode),
-     PlacesUtils.toolbarFolderId,
-     "We have correctly selected bookmarks toolbar node.");
+  Assert.notEqual(PO._places.selectedNode, null, "We have a valid selection");
+  Assert.equal(PlacesUtils.getConcreteItemId(PO._places.selectedNode),
+    PlacesUtils.toolbarFolderId,
+    "We have correctly selected bookmarks toolbar node.");
 
   // Check that both cut and delete commands are disabled, cause this is a child
   // of the All Bookmarks special query.
-  ok(PO._places.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is disabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is disabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is disabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is disabled");
 
   let toolbarNode = PlacesUtils.asContainer(PO._places.selectedNode);
   toolbarNode.containerOpen = true;
 
   // Add an History query to the toolbar.
   let query = await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
                                                    url: "place:sort=4",
                                                    title: "special_query",
                                                    parentGuid: PlacesUtils.bookmarks.toolbarGuid,
                                                    index: 0 });
 
   // Get first child and check it is the just inserted query.
-  ok(toolbarNode.childCount > 0, "Toolbar node has children");
+  Assert.ok(toolbarNode.childCount > 0, "Toolbar node has children");
   let queryNode = toolbarNode.getChild(0);
-  is(queryNode.title, "special_query", "Query node is correctly selected");
+  Assert.equal(queryNode.title, "special_query", "Query node is correctly selected");
 
   // Select query node.
   PO._places.selectNode(queryNode);
-  is(PO._places.selectedNode, queryNode, "We correctly selected query node");
+  Assert.equal(PO._places.selectedNode, queryNode, "We correctly selected query node");
 
   // Check that both cut and delete commands are enabled.
-  ok(PO._places.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(PO._places.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is enabled");
-  ok(PO._places.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is enabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is enabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is enabled");
 
   // Execute the delete command and check bookmark has been removed.
   let promiseItemRemoved = PlacesTestUtils.waitForNotification(
     "onItemRemoved", (...args) => query.guid == args[5]);
   PO._places.controller.doCommand("cmd_delete");
   await promiseItemRemoved;
 
-  is((await PlacesUtils.bookmarks.fetch(query.guid)), null,
+  Assert.equal((await PlacesUtils.bookmarks.fetch(query.guid)), null,
      "Query node bookmark has been correctly removed");
 
   toolbarNode.containerOpen = false;
 
   library.close();
 });
 
 add_task(async function test_search_contents() {
@@ -146,35 +146,35 @@ add_task(async function test_search_cont
 
   let library = await promiseLibrary();
   info("Ensure query contents can be cut or deleted");
 
   // Select and open the left pane "Bookmarks Toolbar" folder.
   let PO = library.PlacesOrganizer;
 
   PO.selectLeftPaneBuiltIn("BookmarksToolbar");
-  isnot(PO._places.selectedNode, null, "We have a valid selection");
-  is(PlacesUtils.getConcreteItemId(PO._places.selectedNode),
-     PlacesUtils.toolbarFolderId,
-     "We have correctly selected bookmarks toolbar node.");
+  Assert.notEqual(PO._places.selectedNode, null, "We have a valid selection");
+  Assert.equal(PlacesUtils.getConcreteItemId(PO._places.selectedNode),
+    PlacesUtils.toolbarFolderId,
+    "We have correctly selected bookmarks toolbar node.");
 
   let searchBox = library.document.getElementById("searchFilter");
   searchBox.value = "example";
   library.PlacesSearchBox.search(searchBox.value);
 
   let bookmarkNode = library.ContentTree.view.selectedNode;
-  is(bookmarkNode.uri, "http://example.com/", "Found the expected bookmark");
+  Assert.equal(bookmarkNode.uri, "http://example.com/", "Found the expected bookmark");
 
   // Check that both cut and delete commands are enabled.
-  ok(library.ContentTree.view.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(library.ContentTree.view.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is enabled");
-  ok(library.ContentTree.view.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is enabled");
+  Assert.ok(library.ContentTree.view.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(library.ContentTree.view.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is enabled");
+  Assert.ok(library.ContentTree.view.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is enabled");
 
   library.close();
 });
 
 add_task(async function test_tags() {
   await PlacesUtils.bookmarks.insert({ type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
                                        url: "http://example.com/",
                                        title: "example page",
@@ -185,51 +185,51 @@ add_task(async function test_tags() {
   let library = await promiseLibrary();
   info("Ensure query contents can be cut or deleted");
 
   // Select and open the left pane "Bookmarks Toolbar" folder.
   let PO = library.PlacesOrganizer;
 
   PO.selectLeftPaneBuiltIn("Tags");
   let tagsNode = PO._places.selectedNode;
-  isnot(tagsNode, null, "We have a valid selection");
+  Assert.notEqual(tagsNode, null, "We have a valid selection");
   let tagsTitle = PlacesUtils.getString("TagsFolderTitle");
-  is(tagsNode.title, tagsTitle,
-     "Tags has been properly selected");
+  Assert.equal(tagsNode.title, tagsTitle,
+    "Tags has been properly selected");
 
   // Check that both cut and delete commands are disabled.
-  ok(PO._places.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is disabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is disabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is disabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is disabled");
 
   // Now select the tag.
   PlacesUtils.asContainer(tagsNode).containerOpen = true;
   let tag = tagsNode.getChild(0);
   PO._places.selectNode(tag);
-  is(PO._places.selectedNode.title, "test",
-     "The created tag has been properly selected");
+  Assert.equal(PO._places.selectedNode.title, "test",
+    "The created tag has been properly selected");
 
   // Check that cut is disabled but delete is enabled.
-  ok(PO._places.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is disabled");
-  ok(PO._places.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is enabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is disabled");
+  Assert.ok(PO._places.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is enabled");
 
   let bookmarkNode = library.ContentTree.view.selectedNode;
-  is(bookmarkNode.uri, "http://example.com/", "Found the expected bookmark");
+  Assert.equal(bookmarkNode.uri, "http://example.com/", "Found the expected bookmark");
 
   // Check that both cut and delete commands are enabled.
-  ok(library.ContentTree.view.controller.isCommandEnabled("cmd_copy"),
-     "Copy command is enabled");
-  ok(!library.ContentTree.view.controller.isCommandEnabled("cmd_cut"),
-     "Cut command is disabled");
-  ok(library.ContentTree.view.controller.isCommandEnabled("cmd_delete"),
-     "Delete command is enabled");
+  Assert.ok(library.ContentTree.view.controller.isCommandEnabled("cmd_copy"),
+    "Copy command is enabled");
+  Assert.ok(!library.ContentTree.view.controller.isCommandEnabled("cmd_cut"),
+    "Cut command is disabled");
+  Assert.ok(library.ContentTree.view.controller.isCommandEnabled("cmd_delete"),
+    "Delete command is enabled");
 
   tagsNode.containerOpen = false;
 
   library.close();
 });