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: // Get history service michael@0: try { michael@0: var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService); michael@0: } catch(ex) { michael@0: do_throw("Could not get history service\n"); michael@0: } michael@0: michael@0: // main michael@0: function run_test() { michael@0: // XXX Full testing coverage for QueriesToQueryString and michael@0: // QueryStringToQueries michael@0: michael@0: var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. michael@0: getService(Ci.nsINavBookmarksService); michael@0: const NHQO = Ci.nsINavHistoryQueryOptions; michael@0: // Bug 376798 michael@0: var query = histsvc.getNewQuery(); michael@0: query.setFolders([bs.placesRoot], 1); michael@0: do_check_eq(histsvc.queriesToQueryString([query], 1, histsvc.getNewQueryOptions()), michael@0: "place:folder=PLACES_ROOT"); michael@0: michael@0: // Bug 378828 michael@0: var options = histsvc.getNewQueryOptions(); michael@0: options.sortingAnnotation = "test anno"; michael@0: options.sortingMode = NHQO.SORT_BY_ANNOTATION_DESCENDING; michael@0: var placeURI = michael@0: "place:folder=PLACES_ROOT&sort=" + NHQO.SORT_BY_ANNOTATION_DESCENDING + michael@0: "&sortingAnnotation=test%20anno"; michael@0: do_check_eq(histsvc.queriesToQueryString([query], 1, options), michael@0: placeURI); michael@0: var options = {}; michael@0: histsvc.queryStringToQueries(placeURI, { }, {}, options); michael@0: do_check_eq(options.value.sortingAnnotation, "test anno"); michael@0: do_check_eq(options.value.sortingMode, NHQO.SORT_BY_ANNOTATION_DESCENDING); michael@0: }