michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Get history services michael@0: try { michael@0: var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory); michael@0: } catch(ex) { michael@0: do_throw("Could not get history services\n"); michael@0: } michael@0: michael@0: // Get bookmark service michael@0: try { michael@0: var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. michael@0: getService(Ci.nsINavBookmarksService); michael@0: } michael@0: catch(ex) { michael@0: do_throw("Could not get the nav-bookmarks-service\n"); michael@0: } michael@0: michael@0: // Get tagging service michael@0: try { michael@0: var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"]. michael@0: getService(Ci.nsITaggingService); michael@0: } catch(ex) { michael@0: do_throw("Could not get tagging service\n"); michael@0: } michael@0: michael@0: michael@0: // main michael@0: function run_test() { michael@0: var uri1 = uri("http://foo.bar/"); michael@0: michael@0: // create 2 bookmarks on the same uri michael@0: var bookmark1id = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri1, michael@0: bmsvc.DEFAULT_INDEX, "title 1"); michael@0: var bookmark2id = bmsvc.insertBookmark(bmsvc.toolbarFolder, uri1, michael@0: bmsvc.DEFAULT_INDEX, "title 2"); michael@0: // add some tags michael@0: tagssvc.tagURI(uri1, ["foo", "bar", "foobar", "foo bar"]); michael@0: michael@0: // check that a generic bookmark query returns only real bookmarks michael@0: var options = histsvc.getNewQueryOptions(); michael@0: options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; michael@0: michael@0: var query = histsvc.getNewQuery(); michael@0: var result = histsvc.executeQuery(query, options); michael@0: var root = result.root; michael@0: michael@0: root.containerOpen = true; michael@0: var cc = root.childCount; michael@0: do_check_eq(cc, 2); michael@0: var node1 = root.getChild(0); michael@0: do_check_eq(bmsvc.getFolderIdForItem(node1.itemId), bmsvc.bookmarksMenuFolder); michael@0: var node2 = root.getChild(1); michael@0: do_check_eq(bmsvc.getFolderIdForItem(node2.itemId), bmsvc.toolbarFolder); michael@0: root.containerOpen = false; michael@0: }