backout bug 468836, checked in on persistent orange.
authorRobert Sayre <sayrer@gmail.com>
Thu, 11 Dec 2008 02:44:01 -0800
changeset 22599 885d919d18ee91a7a73a4e4b8b33ba1e58db81fa
parent 22583 523bdc0860027778ed120a6c12e0aed6a06eff2c
child 22600 eb568873736e7634fa3a88e1a65244a33566b969
push idunknown
push userunknown
push dateunknown
bugs468836
milestone1.9.2a1pre
backout bug 468836, checked in on persistent orange.
toolkit/components/places/src/nsTaggingService.js
toolkit/components/places/tests/unit/test_tagging.js
--- a/toolkit/components/places/src/nsTaggingService.js
+++ b/toolkit/components/places/src/nsTaggingService.js
@@ -294,18 +294,19 @@ TaggingService.prototype = {
     return tags;
   },
 
   __tagFolders: null, 
   get _tagFolders() {
     if (!this.__tagFolders) {
       this.__tagFolders = [];
       var options = this._history.getNewQueryOptions();
+      options.resultType = Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_QUERY;
+      options.expandQueries = 0;
       var query = this._history.getNewQuery();
-      query.setFolders([this._bms.tagsFolder], 1);
       var tagsResult = this._history.executeQuery(query, options);
       var root = tagsResult.root;
       root.containerOpen = true;
       var cc = root.childCount;
       for (var i=0; i < cc; i++) {
         var child = root.getChild(i);
         this.__tagFolders[child.itemId] = child.title;
       }
--- a/toolkit/components/places/tests/unit/test_tagging.js
+++ b/toolkit/components/places/tests/unit/test_tagging.js
@@ -51,20 +51,18 @@ try {
               getService(Ci.nsINavBookmarksService);
 }
 catch(ex) {
   do_throw("Could not get the nav-bookmarks-service\n");
 }
 
 // Get tagging service
 try {
-  // Notice we use createInstance because later we will have to terminate the
-  // service and restart it.
   var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
-                createInstance().QueryInterface(Ci.nsITaggingService);
+                getService(Ci.nsITaggingService);
 } catch(ex) {
   do_throw("Could not get tagging service\n");
 }
 
 // main
 function run_test() {
   var options = histsvc.getNewQueryOptions();
   var query = histsvc.getNewQuery();
@@ -128,22 +126,25 @@ function run_test() {
 
   // test untagging
   tagssvc.untagURI(uri1, ["tag 1"]);
   do_check_eq(tag1node.childCount, 1);
 
   // removing the last uri from a tag should remove the tag-container
   tagssvc.untagURI(uri2, ["tag 1"]);
   do_check_eq(tagRoot.childCount, 1);
-
-  // cleanup
-  tag1node.containerOpen = false;
-
+  
   // get array of tag folder ids => title
   // for testing tagging with mixed folder ids and tags
+  var options = histsvc.getNewQueryOptions();
+  var query = histsvc.getNewQuery();
+  query.setFolders([bmsvc.tagsFolder], 1);
+  var result = histsvc.executeQuery(query, options);
+  var tagRoot = result.root;
+  tagRoot.containerOpen = true;
   var tagFolders = [];
   var child = tagRoot.getChild(0);
   var tagId = child.itemId;
   var tagTitle = child.title;
 
   // test mixed id/name tagging
   // as well as non-id numeric tags
   var uri3 = uri("http://testuri/3");
@@ -152,26 +153,9 @@ function run_test() {
   do_check_true(tags.indexOf(tagTitle) != -1);
   do_check_true(tags.indexOf("tag 3") != -1);
   do_check_true(tags.indexOf("456") != -1);
 
   // test mixed id/name tagging
   tagssvc.untagURI(uri3, [tagId, "tag 3", "456"]);
   tags = tagssvc.getTagsForURI(uri3, {});
   do_check_eq(tags.length, 0);
-
-  // Terminate tagging service, fire up a new instance and check that existing
-  // tags are there.  This will ensure that any internal caching system is
-  // correctly filled at startup and we are not losing previously existing tags.
-  var uri4 = uri("http://testuri/4");
-  tagssvc.tagURI(uri4, [tagId, "tag 3", "456"]);
-  tagssvc = null;
-  tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
-            getService(Ci.nsITaggingService);
-  var uri4Tags = tagssvc.getTagsForURI(uri4, {});
-  do_check_eq(uri4Tags.length, 3);
-  do_check_true(uri4Tags.indexOf(tagTitle) != -1);
-  do_check_true(uri4Tags.indexOf("tag 3") != -1);
-  do_check_true(uri4Tags.indexOf("456") != -1);
-
-  // cleanup
-  tagRoot.containerOpen = false;
 }