1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/unit/test_402799.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +// Get history services 1.11 +try { 1.12 + var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. 1.13 + getService(Ci.nsINavHistoryService); 1.14 + var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory); 1.15 +} catch(ex) { 1.16 + do_throw("Could not get history services\n"); 1.17 +} 1.18 + 1.19 +// Get bookmark service 1.20 +try { 1.21 + var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. 1.22 + getService(Ci.nsINavBookmarksService); 1.23 +} 1.24 +catch(ex) { 1.25 + do_throw("Could not get the nav-bookmarks-service\n"); 1.26 +} 1.27 + 1.28 +// Get tagging service 1.29 +try { 1.30 + var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"]. 1.31 + getService(Ci.nsITaggingService); 1.32 +} catch(ex) { 1.33 + do_throw("Could not get tagging service\n"); 1.34 +} 1.35 + 1.36 + 1.37 +// main 1.38 +function run_test() { 1.39 + var uri1 = uri("http://foo.bar/"); 1.40 + 1.41 + // create 2 bookmarks on the same uri 1.42 + var bookmark1id = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri1, 1.43 + bmsvc.DEFAULT_INDEX, "title 1"); 1.44 + var bookmark2id = bmsvc.insertBookmark(bmsvc.toolbarFolder, uri1, 1.45 + bmsvc.DEFAULT_INDEX, "title 2"); 1.46 + // add some tags 1.47 + tagssvc.tagURI(uri1, ["foo", "bar", "foobar", "foo bar"]); 1.48 + 1.49 + // check that a generic bookmark query returns only real bookmarks 1.50 + var options = histsvc.getNewQueryOptions(); 1.51 + options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; 1.52 + 1.53 + var query = histsvc.getNewQuery(); 1.54 + var result = histsvc.executeQuery(query, options); 1.55 + var root = result.root; 1.56 + 1.57 + root.containerOpen = true; 1.58 + var cc = root.childCount; 1.59 + do_check_eq(cc, 2); 1.60 + var node1 = root.getChild(0); 1.61 + do_check_eq(bmsvc.getFolderIdForItem(node1.itemId), bmsvc.bookmarksMenuFolder); 1.62 + var node2 = root.getChild(1); 1.63 + do_check_eq(bmsvc.getFolderIdForItem(node2.itemId), bmsvc.toolbarFolder); 1.64 + root.containerOpen = false; 1.65 +}