testcase for bug #369887. r=dietrich
authorsspitzer@mozilla.org
Fri, 23 Mar 2007 01:06:01 -0700
changeset 31 ff90b3756379c9dc2a7a7ab79a86fb3e8d441c10
parent 30 531a9e17e9928b292a9f2048cc30b38d1cc7b37d
child 32 a3a81775ad8909c3af7352a4e2e8b3a30265345f
push idunknown
push userunknown
push dateunknown
reviewersdietrich
bugs369887
milestone1.9a3pre
testcase for bug #369887. r=dietrich
toolkit/components/places/tests/bookmarks/test_bookmarks.js
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks.js
@@ -412,16 +412,53 @@ function run_test() {
   var oldToolbarFolder = bmsvc.toolbarFolder;
   var newToolbarFolderId = bmsvc.createFolder(testRoot, "new toolbar folder", -1);
   bmsvc.toolbarFolder = newToolbarFolderId;
   do_check_eq(bmsvc.toolbarFolder, newToolbarFolderId);
   do_check_eq(observer._itemChangedId, newToolbarFolderId);
   do_check_eq(observer._itemChanged.spec, bmsvc.getFolderURI(newToolbarFolderId).spec);
   do_check_eq(observer._itemChangedProperty, "became_toolbar_folder");
   do_check_eq(observer._itemChangedValue, "");
+
+  // insert a bookmark with title ZZZXXXYYY and then search for it.
+  // this test confirms that we can find bookmarks that we haven't visited
+  // (which are "hidden") and that we can find by title.
+  // see bug #369887 for more details
+  var newId13 = bmsvc.insertItem(testRoot, uri("http://foobarcheese.com/"), bmsvc.DEFAULT_INDEX);
+  do_check_eq(observer._itemAddedId, newId13);
+  do_check_eq(observer._itemAdded.spec, "http://foobarcheese.com/");
+  do_check_eq(observer._itemAddedFolder, testRoot);
+  do_check_eq(observer._itemAddedIndex, 12);
+
+  // set bookmark title
+  bmsvc.setItemTitle(newId13, "ZZZXXXYYY");
+  do_check_eq(observer._itemChangedId, newId13);
+  do_check_eq(observer._itemChanged.spec, "http://foobarcheese.com/");
+  do_check_eq(observer._itemChangedProperty, "title");
+  do_check_eq(observer._itemChangedValue, "ZZZXXXYYY");
+
+  // test search on bookmark title ZZZXXXYYY
+  try {
+    var options = histsvc.getNewQueryOptions();
+    options.excludeQueries = 1;
+    var query = histsvc.getNewQuery();
+    query.onlyBookmarked = true;
+    query.searchTerms = "ZZZXXXYYY";
+    var result = histsvc.executeQuery(query, options);
+    var rootNode = result.root;
+    rootNode.containerOpen = true;
+    var cc = rootNode.childCount;
+    do_check_eq(cc, 1);
+    var node = rootNode.getChild(0);
+    do_check_eq(node.title, "ZZZXXXYYY");
+    testRoot.containerOpen = false;
+  }
+  catch(ex) {
+    do_throw("bookmarks query: " + ex);
+  }
 }
 
 // XXXDietrich - get this section up to date
 
 ///  EXPECTED TABLE RESULTS
 ///  moz_bookmarks:
 ///  item_child    folder_child    parent    position
 ///  ----------    ------------    ------    --------