Bug 641531 - Close Places containers after use (mechanical changes)
authorMarco Bonardo <mbonardo@mozilla.com>
Sat, 23 Apr 2011 02:09:13 +0200
changeset 68472 80793bce352afe20c7efec3002eb0d13712e2cc3
parent 68471 7bc382705bc7479c30fe9462d72bee1a5a48bb33
child 68473 5794bcf0f85edeaa6e9d33e5a4cb7cf046d81c30
push id19654
push usermak77@bonardo.net
push dateSat, 23 Apr 2011 10:52:50 +0000
treeherdermozilla-central@5794bcf0f85e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs641531
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 641531 - Close Places containers after use (mechanical changes) rs=me
browser/components/places/tests/browser/browser_423515.js
browser/components/places/tests/browser/browser_425884.js
docshell/test/browser/browser_bug503832.js
toolkit/components/places/tests/bookmarks/test_395101.js
toolkit/components/places/tests/bookmarks/test_423515_forceCopyShortcuts.js
toolkit/components/places/tests/bookmarks/test_savedsearches.js
toolkit/components/places/tests/chrome/test_329534.xul
toolkit/components/places/tests/queries/head_queries.js
toolkit/components/places/tests/queries/test_excludeReadOnlyFolders.js
toolkit/components/places/tests/queries/test_results-as-visit.js
toolkit/components/places/tests/queries/test_searchterms-domain.js
toolkit/components/places/tests/queries/test_searchterms-uri.js
toolkit/components/places/tests/unit/test_331487.js
toolkit/components/places/tests/unit/test_415460.js
toolkit/components/places/tests/unit/test_415757.js
toolkit/components/places/tests/unit/test_419731.js
toolkit/components/places/tests/unit/test_429505_remove_shortcuts.js
toolkit/components/places/tests/unit/test_433317_query_title_update.js
toolkit/components/places/tests/unit/test_433525_hasChildren_crash.js
toolkit/components/places/tests/unit/test_browserhistory.js
toolkit/components/places/tests/unit/test_dynamic_containers.js
toolkit/components/places/tests/unit/test_exclude_livemarks.js
toolkit/components/places/tests/unit/test_history.js
toolkit/components/places/tests/unit/test_history_import.js
toolkit/components/places/tests/unit/test_multi_word_tags.js
toolkit/components/places/tests/unit/test_resolveNullBookmarkTitles.js
toolkit/components/places/tests/unit/test_result_sort.js
--- a/browser/components/places/tests/browser/browser_423515.js
+++ b/browser/components/places/tests/browser/browser_423515.js
@@ -232,19 +232,21 @@ function test() {
       readOnlyFolder.QueryInterface(Ci.nsINavHistoryContainerResultNode);
       readOnlyFolder.containerOpen = true;
       var childFolder = readOnlyFolder.getChild(0);
 
       is(PlacesControllerDragHelper.canMoveContainer(childFolder.itemId),
          false, "cannot move a child of a read-only folder");
       is(PlacesControllerDragHelper.canMoveNode(childFolder),
          false, "cannot move a child node of a read-only folder node");
+      readOnlyFolder.containerOpen = false;
     }
   });
 
   tests.forEach(function(aTest) {
     PlacesUtils.bookmarks.removeFolderChildren(rootId);
     aTest.populate();
     aTest.validate();
   });
 
+  rootNode.containerOpen = false;
   PlacesUtils.bookmarks.removeItem(rootId);
 }
--- a/browser/components/places/tests/browser/browser_425884.js
+++ b/browser/components/places/tests/browser/browser_425884.js
@@ -73,16 +73,18 @@ function test() {
   validate(folderANode);
   is(testRootNode.childCount, 1, "create test folder");
 
   // copy it, using the front-end helper functions
   var serializedNode = PlacesUtils.wrapNode(folderANode, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER);
   var rawNode = PlacesUtils.unwrapNodes(serializedNode, PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER).shift();
   // confirm serialization
   ok(rawNode.type, "confirm json node");
+  folderANode.containerOpen = false;
+
   var transaction = PlacesUIUtils.makeTransaction(rawNode,
                                                   PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER,
                                                   testRootId,
                                                   -1,
                                                   true);
   ok(transaction, "create transaction");
   PlacesUIUtils.ptm.doTransaction(transaction);
   // confirm copy
--- a/docshell/test/browser/browser_bug503832.js
+++ b/docshell/test/browser/browser_bug503832.js
@@ -62,17 +62,19 @@ function test() {
         query.uri = aURI;
 
         var result = historyService.executeQuery(query, options);
         result.root.containerOpen = true;
 
         if (!result.root.childCount) {
             return null;
         }
-        return result.root.getChild(0);
+        var node = result.root.getChild(0);
+        result.root.containerOpen = false;
+        return node;
     }
 
 
     function onPageLoad() {
         gBrowser.selectedBrowser.removeEventListener(
             "DOMContentLoaded", onPageLoad, true);
 
         // Now that the page is loaded, click on fragment link
--- a/toolkit/components/places/tests/bookmarks/test_395101.js
+++ b/toolkit/components/places/tests/bookmarks/test_395101.js
@@ -84,32 +84,36 @@ function run_test() {
   query.setFolders([folder], 1);
 
   var result = histsvc.executeQuery(query, options);
   var rootNode = result.root;
   rootNode.containerOpen = true;
 
   do_check_eq(rootNode.childCount, 1);
   do_check_eq(rootNode.getChild(0).itemId, b1);
+  rootNode.containerOpen = false;
 
   // partial matches are okay
   query.searchTerms = "wal";
   var result = histsvc.executeQuery(query, options);
   var rootNode = result.root;
   rootNode.containerOpen = true;
   do_check_eq(rootNode.childCount, 1);
+  rootNode.containerOpen = false;
 
   // case insensitive search term
   query.searchTerms = "WALRUS";
   var result = histsvc.executeQuery(query, options);
   var rootNode = result.root;
   rootNode.containerOpen = true;
   do_check_eq(rootNode.childCount, 1);
   do_check_eq(rootNode.getChild(0).itemId, b1);
+  rootNode.containerOpen = false;
 
   // case insensitive tag
   query.searchTerms = "baboon";
   var result = histsvc.executeQuery(query, options);
   var rootNode = result.root;
   rootNode.containerOpen = true;
   do_check_eq(rootNode.childCount, 1);
   do_check_eq(rootNode.getChild(0).itemId, b1);
+  rootNode.containerOpen = false;
 }
--- a/toolkit/components/places/tests/bookmarks/test_423515_forceCopyShortcuts.js
+++ b/toolkit/components/places/tests/bookmarks/test_423515_forceCopyShortcuts.js
@@ -131,15 +131,19 @@ function run_test() {
   // check folder node (no longer shortcut)
   var queryNode = root.getChild(root.childCount-2);
   do_check_eq(queryNode.type, queryNode.RESULT_TYPE_FOLDER);
   queryNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
   queryNode.containerOpen = true;
   do_check_eq(queryNode.childCount, 1);
   var child = queryNode.getChild(0);
   do_check_true(bookmarkURI.equals(uri(child.uri)));
+  queryNode.containerOpen = false;
 
   var queryNode2 = root.getChild(root.childCount-1);
   do_check_eq(queryNode2.type, queryNode2.RESULT_TYPE_QUERY);
   queryNode2.QueryInterface(Ci.nsINavHistoryContainerResultNode);
   queryNode2.containerOpen = true;
   do_check_eq(queryNode2.childCount, 0);
+  queryNode.containerOpen = false;
+
+  root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/bookmarks/test_savedsearches.js
+++ b/toolkit/components/places/tests/bookmarks/test_savedsearches.js
@@ -105,16 +105,17 @@ function run_test() {
     for (var i = 0; i < cc; i++) {
       var node = rootNode.getChild(i);
       // test that queries have valid itemId
       do_check_true(node.itemId > 0);
       // test that the container is closed
       node.QueryInterface(Ci.nsINavHistoryContainerResultNode);
       do_check_eq(node.containerOpen, false);
     }
+    rootNode.containerOpen = false;
   }
   catch(ex) {
     do_throw("expandQueries=0 query error: " + ex);
   }
 
   // bookmark saved search
   // query for the test root, expandQueries=1
   // the query should show up as a query container, with 1 child
@@ -157,16 +158,17 @@ function run_test() {
       // test live-update of query results - add a folder that matches the query
       bmsvc.createFolder(root, searchTerm + "zaa", bmsvc.DEFAULT_INDEX);
       do_check_eq(node.childCount, 1);
       // test live-update of query results - add a query that matches the query
       bmsvc.insertBookmark(root, uri("place:terms=foo&excludeQueries=1&expandQueries=1&queryType=1"),
                            bmsvc.DEFAULT_INDEX, searchTerm + "blah");
       do_check_eq(node.childCount, 1);
     }
+    rootNode.containerOpen = false;
   }
   catch(ex) {
     do_throw("expandQueries=1 bookmarks query: " + ex);
   }
 
   // delete the bookmark search
   bmsvc.removeItem(searchId);
 
@@ -217,16 +219,17 @@ function run_test() {
 
       // test live-update of query results - add a history visit that matches the query
       bhist.addPageWithDetails(uri("http://foo.com"), searchTerm + "blah", Date.now() * 1000);
       do_check_eq(node.childCount, 2);
 
       // test live-update of query results - delete a history visit that matches the query
       bhist.removePage(uri("http://foo.com"));
       do_check_eq(node.childCount, 1);
+      node.containerOpen = false;
     }
 
     // test live-update of moved queries
     var tmpFolderId = bmsvc.createFolder(testRoot, "foo", bmsvc.DEFAULT_INDEX); 
     bmsvc.moveItem(searchId, tmpFolderId, bmsvc.DEFAULT_INDEX);
     var tmpFolderNode = rootNode.getChild(0);
     do_check_eq(tmpFolderNode.itemId, tmpFolderId);
     tmpFolderNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
@@ -238,13 +241,16 @@ function run_test() {
     do_check_eq(tmpFolderNode.title, "foo");
 
     // test live-update of deleted queries
     bmsvc.removeItem(searchId);
     try {
       var tmpFolderNode = root.getChild(1);
       do_throw("query was not removed");
     } catch(ex) {}
+
+    tmpFolderNode.containerOpen = false;
+    rootNode.containerOpen = false;
   }
   catch(ex) {
     do_throw("expandQueries=1 bookmarks query: " + ex);
   }
 }
--- a/toolkit/components/places/tests/chrome/test_329534.xul
+++ b/toolkit/components/places/tests/chrome/test_329534.xul
@@ -116,26 +116,28 @@ function runTest1( folderId ) {
     var result = histsvc.executeQuery(query, options);
     var rootNode = result.root;
     rootNode.containerOpen = true;
     var cc = rootNode.childCount;
     ok( cc == 1, "first livemark is empty" );
     var node = rootNode.getChild( 0 );
     ok( node.uri == firstURL,
         "first livemark item is invalid value "+node.uri);
+    rootNode.containerOpen = false;
 
     /* second folder has no item */
     options = histsvc.getNewQueryOptions();
     query = histsvc.getNewQuery();
     query.setFolders([secondFolderId], 1);
     result = histsvc.executeQuery(query, options);
     rootNode = result.root;
     rootNode.containerOpen = true;
     cc = rootNode.childCount;
     ok( cc == 0, "second livemark is not empty" );
+    rootNode.containerOpen = false;
   }
 }
 
 // Second
 function runTest2( folderId ) {
   if ( folderId == secondFolderId ) {
     status++;
     var secondLoadTime = Date.now();
@@ -147,16 +149,17 @@ function runTest2( folderId ) {
     var result = histsvc.executeQuery(query, options);
     var rootNode = result.root;
     rootNode.containerOpen = true;
     var cc = rootNode.childCount;
     ok( cc == 1, "second livemark is empty" );
     var node = rootNode.getChild( 0 );
     ok( node.uri == secondURL,
         "second livemark item is invalid value "+node.uri);
+    rootNode.containerOpen = false;
 
     /* Check passed 2sec.
        We should check for 3s but are relaxing request to accomplish possible
        VM timing bugs.
        For the same reason if time elapsed is 0 we have catched an interval
        where VM has not updated timers, we will still consider the test valid
        to avoid random test failures.
     */
--- a/toolkit/components/places/tests/queries/head_queries.js
+++ b/toolkit/components/places/tests/queries/head_queries.js
@@ -384,49 +384,55 @@ function compareArrayToResult(aArray, aR
  * to see if it is in the result set.
  * Returns: True if item is in query set, and false if item is not in query set
  *          If input is an array, returns True if FIRST object in array is in
  *          query set.  To compare entire array, use the function above.
  */
 function isInResult(aQueryData, aRoot) {
   var rv = false;
   var uri;
-  if (!aRoot.containerOpen)
+  var wasOpen = aRoot.containerOpen;
+  if (!wasOpen)
     aRoot.containerOpen = true;
 
   // If we have an array, pluck out the first item. If an object, pluc out the
   // URI, we just compare URI's here.
   if ("uri" in aQueryData) {
     uri = aQueryData.uri;
   } else {
     uri = aQueryData[0].uri;
   }
 
   for (var i=0; i < aRoot.childCount; i++) {
     if (uri == aRoot.getChild(i).uri) {
       rv = true;
       break;
     }
   }
+  if (!wasOpen)
+    aRoot.containerOpen = false;
   return rv;
 }
 
 
 /**
  * A nice helper function for debugging things. It LOGs the contents of a
  * result set.
  */
 function displayResultSet(aRoot) {
 
-  if (!aRoot.containerOpen)
+  var wasOpen = aRoot.containerOpen;
+  if (!wasOpen)
     aRoot.containerOpen = true;
 
   if (!aRoot.hasChildren) {
     // Something wrong? Empty result set?
     LOG("Result Set Empty");
     return;
   }
 
   for (var i=0; i < aRoot.childCount; ++i) {
     LOG("Result Set URI: " + aRoot.getChild(i).uri + "   Title: " +
         aRoot.getChild(i).title + "   Visit Time: " + aRoot.getChild(i).time);
   }
+  if (!wasOpen)
+    aRoot.containerOpen = false;
 }
--- a/toolkit/components/places/tests/queries/test_excludeReadOnlyFolders.js
+++ b/toolkit/components/places/tests/queries/test_excludeReadOnlyFolders.js
@@ -60,15 +60,17 @@ function run_test() {
   // Options
   var options = PlacesUtils.history.getNewQueryOptions();
   options.excludeQueries = true;
   options.excludeReadOnlyFolders = true;
 
   // Results
   var result = PlacesUtils.history.executeQuery(query, options);
   var root = result.root;
+  root.containerOpen = true;
+
   displayResultSet(root);
   // The readonly folder should not be in our result set.
   do_check_eq(1, root.childCount);
   do_check_eq("Folder 1", root.getChild(0).title);
 
   root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/queries/test_results-as-visit.js
+++ b/toolkit/components/places/tests/queries/test_results-as-visit.js
@@ -134,9 +134,11 @@ function createTestData() {
    // And now, delete one
    LOG("Delete item outside of batch");
    var change4 = [{ isVisit: true,
                     lastVisit: now++,
                     uri: "http://moilla.com/",
                     title: "mo,z" }];
    populateDB(change4);
    do_check_false(isInResult(change4, root));
+
+   root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/queries/test_searchterms-domain.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-domain.js
@@ -146,9 +146,11 @@ function run_test() {
   do_check_false(isInResult({uri: "ftp://foo.com/ftp"}, root));
 
   // And now, delete one
   LOG("Delete item outside of batch");
   var change4 = [{isDetails: true, uri: "https://foo.com/",
                   title: "mo,z"}];
   populateDB(change4);
   do_check_false(isInResult(change4, root));
+
+  root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/queries/test_searchterms-uri.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-uri.js
@@ -143,9 +143,11 @@
    do_check_false(isInResult({uri: "http://foo.com/redirect"}, root));
 
    // And now, delete one
    LOG("Delete item outside of batch");
    var change4 = [{isDetails: true, uri: "http://foo.com/",
                    title: "mo,z"}];
    populateDB(change4);
    do_check_false(isInResult(change4, root));
+
+   root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_331487.js
+++ b/toolkit/components/places/tests/unit/test_331487.js
@@ -97,29 +97,34 @@ function run_test() {
 
   // check the contents of the subfolder's subfolder
   var sf2Node = sf1Node.getChild(1);
   sf2Node = sf2Node.QueryInterface(Ci.nsINavHistoryContainerResultNode);
   sf2Node.containerOpen = true;
   do_check_eq(sf2Node.childCount, 1);
   do_check_eq(sf2Node.getChild(0).itemId, b3);
 
+  sf2Node.containerOpen = false;
+  sf1Node.containerOpen = false;
+  root.containerOpen = false;
+
   // bookmark query that should result in a flat list
   // because we specified max results
   var options = histsvc.getNewQueryOptions();
   options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
   options.maxResults = 10;
   var query = histsvc.getNewQuery();
   query.setFolders([folder], 1);
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 3);
   do_check_eq(root.getChild(0).itemId, b1);
   do_check_eq(root.getChild(1).itemId, b2);
   do_check_eq(root.getChild(2).itemId, b3);
+  root.containerOpen = false;
 
   // XXX TODO
   // test that if we have: more than one query, 
   // multiple folders, a begin time, an end time, a domain, a uri
   // or a search term, that we get the (correct) flat list results
   // (like we do when specified maxResults)
 }
--- a/toolkit/components/places/tests/unit/test_415460.js
+++ b/toolkit/components/places/tests/unit/test_415460.js
@@ -52,17 +52,19 @@ function search_has_result(aTerms)
   var options = hs.getNewQueryOptions();
   options.maxResults = 1;
   options.resultType = options.RESULTS_AS_URI;
   var query = hs.getNewQuery();
   query.searchTerms = aTerms;
   var result = hs.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
-  return (root.childCount == 1);
+  var cc = root.childCount;
+  root.containerOpen = false;
+  return (cc == 1);
 }
 
 function run_test()
 {
   const SEARCH_TERM = "ユニコード";
   const TEST_URL = "http://example.com/" + SEARCH_TERM + "/";
   var ios = Cc["@mozilla.org/network/io-service;1"].
             getService(Ci.nsIIOService);
--- a/toolkit/components/places/tests/unit/test_415757.js
+++ b/toolkit/components/places/tests/unit/test_415757.js
@@ -71,17 +71,19 @@ function uri_in_db(aURI) {
   var options = histsvc.getNewQueryOptions();
   options.maxResults = 1;
   options.resultType = options.RESULTS_AS_URI
   var query = histsvc.getNewQuery();
   query.uri = aURI;
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
-  return (root.childCount == 1);
+  var cc = root.childCount;
+  root.containerOpen = false;
+  return (cc == 1);
 }
 
 const TOTAL_SITES = 20;
 
 // main
 function run_test() {
 
   // add pages to global history
--- a/toolkit/components/places/tests/unit/test_419731.js
+++ b/toolkit/components/places/tests/unit/test_419731.js
@@ -114,16 +114,17 @@ function run_test() {
                    .QueryInterface(Ci.nsINavHistoryContainerResultNode);
   do_check_eq(theTag.title, "bar");
 
   // Check that tag container contains new title
   theTag.containerOpen = true;
   do_check_eq(theTag.childCount, 1);
   var node = theTag.getChild(0);
   do_check_eq(node.title, "new title 1");
+  theTag.containerOpen = false;
   root.containerOpen = false;
 
   // Change bookmark 2 title.
   bmsvc.setItemTitle(bookmark2id, "new title 2");
 
   // Workaround VM timers issues.
   var bookmark1LastMod = bmsvc.getItemLastModified(bookmark1id);
   bmsvc.setItemLastModified(bookmark2id, bookmark1LastMod + 1);
--- a/toolkit/components/places/tests/unit/test_429505_remove_shortcuts.js
+++ b/toolkit/components/places/tests/unit/test_429505_remove_shortcuts.js
@@ -58,9 +58,11 @@ function run_test() {
     
     var root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId, false, true).root;
 
     var oldCount = root.childCount;
 
     PlacesUtils.bookmarks.removeItem(queryId);
 
     do_check_eq(root.childCount, oldCount-1);
+
+    root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_433317_query_title_update.js
+++ b/toolkit/components/places/tests/unit/test_433317_query_title_update.js
@@ -60,9 +60,11 @@ function run_test() {
   var queryNode = root.getChild(0);
   do_check_eq(queryNode.title, "test query");
 
   // change the title
   bmsvc.setItemTitle(queryId, "foo");
 
   // confirm the node was updated
   do_check_eq(queryNode.title, "foo");
+
+  root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_433525_hasChildren_crash.js
+++ b/toolkit/components/places/tests/unit/test_433525_hasChildren_crash.js
@@ -75,9 +75,10 @@ function run_test() {
   query.setFolders([bmsvc.toolbarFolder], 1);
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
   var queryNode = root.getChild(0);
   do_check_eq(queryNode.title, "test query");
   queryNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
   do_check_eq(queryNode.hasChildren, true);
+  root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_browserhistory.js
+++ b/toolkit/components/places/tests/unit/test_browserhistory.js
@@ -82,17 +82,19 @@ function uri_in_db(aURI) {
   var options = histsvc.getNewQueryOptions();
   options.maxResults = 1;
   options.resultType = options.RESULTS_AS_URI;
   var query = histsvc.getNewQuery();
   query.uri = aURI;
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
-  return (root.childCount == 1);
+  var cc = root.childCount;
+  root.containerOpen = false;
+  return (cc == 1);
 }
 
 // main
 function run_test() {
   var testURI = uri("http://mozilla.com");
 
   /**
    * addPageWithDetails
--- a/toolkit/components/places/tests/unit/test_dynamic_containers.js
+++ b/toolkit/components/places/tests/unit/test_dynamic_containers.js
@@ -84,16 +84,19 @@ function run_test() {
   do_check_eq(folder.itemId, exposedFolder);
   folder.containerOpen = true;
   do_check_eq(folder.childCount, 1);
 
   // check live update of a folder exposed within a remote container
   bmsvc.insertBookmark(exposedFolder, uri("http://uri2.tld"), bmsvc.DEFAULT_INDEX, "");
   do_check_eq(folder.childCount, 2);
 
+  folder.containerOpen = false;
+  rootNode.containerOpen = false;
+
   // Bug 457681
   // Make the dynamic container read-only and check that it appear in the result
   bmsvc.setFolderReadonly(remoteContainer, true);
   options = histsvc.getNewQueryOptions();
   query = histsvc.getNewQuery();
   query.setFolders([testRoot], 1);
   result = histsvc.executeQuery(query, options);
   rootNode = result.root;
--- a/toolkit/components/places/tests/unit/test_exclude_livemarks.js
+++ b/toolkit/components/places/tests/unit/test_exclude_livemarks.js
@@ -90,23 +90,25 @@ function run_test() {
   var rootNode = result.root;
   rootNode.containerOpen = true;
   var cc = rootNode.childCount;
   do_check_eq(cc, 2);
   var node = rootNode.getChild(0);
   do_check_eq(node.itemId, livemarkItem);
   node = rootNode.getChild(1);
   do_check_eq(node.itemId, nonLivemarkItem);
+  rootNode.containerOpen = false;
 
   // exclude livemark items, search for "item", should get one result
   options = histsvc.getNewQueryOptions();
   options.excludeItemIfParentHasAnnotation = "livemark/feedURI";
   options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
   query = histsvc.getNewQuery();
   query.searchTerms = "item";
   result = histsvc.executeQuery(query, options);
   rootNode = result.root;
   rootNode.containerOpen = true;
   cc = rootNode.childCount;
   do_check_eq(cc, 1);
   var node = rootNode.getChild(0);
   do_check_eq(node.itemId, nonLivemarkItem);
+  rootNode.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_history.js
+++ b/toolkit/components/places/tests/unit/test_history.js
@@ -77,17 +77,19 @@ function uri_in_db(aURI) {
   var options = histsvc.getNewQueryOptions();
   options.maxResults = 1;
   options.resultType = options.RESULTS_AS_URI
   var query = histsvc.getNewQuery();
   query.uri = aURI;
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
-  return (root.childCount == 1);
+  var cc = root.childCount;
+  root.containerOpen = false;
+  return (cc == 1);
 }
 
 // main
 function run_test() {
   // we have a new profile, so we should have imported bookmarks
   do_check_eq(histsvc.databaseStatus, histsvc.DATABASE_STATUS_CREATE);
 
   // add a visit
@@ -125,69 +127,80 @@ function run_test() {
   options.maxResults = 5;
   options.resultType = options.RESULTS_AS_URI;
 
   // test minVisits
   query.minVisits = 0;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 2);
+  result.root.containerOpen = false;
   query.minVisits = 1;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 2);
+  result.root.containerOpen = false;
   query.minVisits = 2;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 1);
   query.minVisits = 3;
+  result.root.containerOpen = false;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 0);
+  result.root.containerOpen = false;
 
   // test maxVisits
   query.minVisits = -1;
   query.maxVisits = -1;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 2);
+  result.root.containerOpen = false;
   query.maxVisits = 0;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 0);
+  result.root.containerOpen = false;
   query.maxVisits = 1;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 1);
+  result.root.containerOpen = false;
   query.maxVisits = 2;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 2);
+  result.root.containerOpen = false;
   query.maxVisits = 3;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 2);
+  result.root.containerOpen = false;
   
   // test annotation-based queries
   var annos = Cc["@mozilla.org/browser/annotation-service;1"].
               getService(Ci.nsIAnnotationService);
   annos.setPageAnnotation(uri("http://mozilla.com/"), "testAnno", 0, 0,
                           Ci.nsIAnnotationService.EXPIRE_NEVER);
   query.annotation = "testAnno";
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 1);
   do_check_eq(result.root.getChild(0).uri, "http://mozilla.com/");
+  result.root.containerOpen = false;
 
   // test annotationIsNot
   query.annotationIsNot = true;
   result = histsvc.executeQuery(query, options);
   result.root.containerOpen = true;
   do_check_eq(result.root.childCount, 1);
   do_check_eq(result.root.getChild(0).uri, "http://google.com/");
+  result.root.containerOpen = false;
 
   // By default history is enabled.
   do_check_true(!histsvc.historyDisabled);
 
   // test getPageTitle
   var title = histsvc.getPageTitle(uri("http://mozilla.com"));
   do_check_eq(title, null);
 
@@ -213,16 +226,17 @@ function run_test() {
   var options = histsvc.getNewQueryOptions();
   //options.resultType = options.RESULTS_AS_VISIT;
   var query = histsvc.getNewQuery();
   query.searchTerms = "moz";
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
   do_check_true(root.childCount > 0);
+  root.containerOpen = false;
 
   // bug 400544 - testing that a referrer that is not in the DB gets added
   var referrerURI = uri("http://yahoo.com");
   do_check_false(uri_in_db(referrerURI));
   add_visit(uri("http://mozilla.com"), referrerURI);
   do_check_true(uri_in_db(referrerURI));
 
   // test to ensure history.dat gets deleted if all history is being cleared
--- a/toolkit/components/places/tests/unit/test_history_import.js
+++ b/toolkit/components/places/tests/unit/test_history_import.js
@@ -51,17 +51,19 @@ function uri_in_db(aURI) {
   var options = hs.getNewQueryOptions();
   options.maxResults = 1;
   options.resultType = options.RESULTS_AS_URI
   var query = hs.getNewQuery();
   query.uri = aURI;
   var result = hs.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
-  return (root.childCount == 1);
+  var cc = root.childCount;
+  root.containerOpen = false;
+  return (cc == 1);
 }
 
 // main
 function run_test() {
   // test import history
   var file = do_get_file("history_import_test.dat");
   gh.importHistory(file);
   var uri1 = uri("http://www.mozilla.org/");
--- a/toolkit/components/places/tests/unit/test_multi_word_tags.js
+++ b/toolkit/components/places/tests/unit/test_multi_word_tags.js
@@ -94,81 +94,91 @@ function run_test() {
   query.searchTerms = "foo";
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 3);
   do_check_eq(root.getChild(0).uri, "http://site.tld/1");
   do_check_eq(root.getChild(1).uri, "http://site.tld/4");
   do_check_eq(root.getChild(2).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "bar";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 4);
   do_check_eq(root.getChild(0).uri, "http://site.tld/2");
   do_check_eq(root.getChild(1).uri, "http://site.tld/4");
   do_check_eq(root.getChild(2).uri, "http://site.tld/5");
   do_check_eq(root.getChild(3).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "cheese";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 3);
   do_check_eq(root.getChild(0).uri, "http://site.tld/3");
   do_check_eq(root.getChild(1).uri, "http://site.tld/5");
   do_check_eq(root.getChild(2).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "foo bar";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 2);
   do_check_eq(root.getChild(0).uri, "http://site.tld/4");
   do_check_eq(root.getChild(1).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "bar foo";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 2);
   do_check_eq(root.getChild(0).uri, "http://site.tld/4");
   do_check_eq(root.getChild(1).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "bar cheese";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 2);
   do_check_eq(root.getChild(0).uri, "http://site.tld/5");
   do_check_eq(root.getChild(1).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "cheese bar";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 2);
   do_check_eq(root.getChild(0).uri, "http://site.tld/5");
   do_check_eq(root.getChild(1).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "foo bar cheese";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 1);
   do_check_eq(root.getChild(0).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "cheese foo bar";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 1);
   do_check_eq(root.getChild(0).uri, "http://site.tld/6");
+  root.containerOpen = false;
 
   query.searchTerms = "cheese bar foo";
   result = histsvc.executeQuery(query, options);
   root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 1);
   do_check_eq(root.getChild(0).uri, "http://site.tld/6");
+  root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_resolveNullBookmarkTitles.js
+++ b/toolkit/components/places/tests/unit/test_resolveNullBookmarkTitles.js
@@ -88,9 +88,10 @@ function run_test() {
   var result = histsvc.executeQuery(query, options);
   var root = result.root;
   root.containerOpen = true;
   do_check_eq(root.childCount, 2);
   // actually RESULTS_AS_TAG_CONTENTS return results ordered by place_id DESC
   // so they are reversed
   do_check_eq(root.getChild(0).title, "bar title");
   do_check_eq(root.getChild(1).title, "foo title");
+  root.containerOpen = false;
 }
--- a/toolkit/components/places/tests/unit/test_result_sort.js
+++ b/toolkit/components/places/tests/unit/test_result_sort.js
@@ -154,11 +154,12 @@ function run_test() {
   // Add a visit, then check frecency ordering.
   add_visit(NetUtil.newURI("http://foo.tld/b"));
   waitForAsyncUpdates(function () {
     result.sortingMode = NHQO.SORT_BY_FRECENCY_DESCENDING;
     checkOrder(id2, id3, id1);
     result.sortingMode = NHQO.SORT_BY_FRECENCY_ASCENDING;
     checkOrder(id1, id3, id2);
 
+    root.containerOpen = false;
     do_test_finished();
   });
 }