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: /** michael@0: * Obtains the id of the folder obtained from the query. michael@0: * michael@0: * @param aFolderID michael@0: * The id of the folder we want to generate a query for. michael@0: * @returns the string representation of the query for the given folder. michael@0: */ michael@0: function query_string(aFolderID) michael@0: { michael@0: var hs = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: michael@0: var query = hs.getNewQuery(); michael@0: query.setFolders([aFolderID], 1); michael@0: var options = hs.getNewQueryOptions(); michael@0: return hs.queriesToQueryString([query], 1, options); michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: var hs = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. michael@0: getService(Ci.nsINavBookmarksService); michael@0: michael@0: const QUERIES = [ michael@0: "folder=PLACES_ROOT" michael@0: , "folder=BOOKMARKS_MENU" michael@0: , "folder=TAGS" michael@0: , "folder=UNFILED_BOOKMARKS" michael@0: , "folder=TOOLBAR" michael@0: ]; michael@0: const FOLDER_IDS = [ michael@0: bs.placesRoot michael@0: , bs.bookmarksMenuFolder michael@0: , bs.tagsFolder michael@0: , bs.unfiledBookmarksFolder michael@0: , bs.toolbarFolder michael@0: ]; michael@0: michael@0: michael@0: for (var i = 0; i < QUERIES.length; i++) { michael@0: var result = query_string(FOLDER_IDS[i]); michael@0: dump("Looking for '" + QUERIES[i] + "' in '" + result + "'\n"); michael@0: do_check_neq(-1, result.indexOf(QUERIES[i])); michael@0: } michael@0: }