1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/unit/test_placeURIs.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 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 + 1.11 +// Get history service 1.12 +try { 1.13 + var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService); 1.14 +} catch(ex) { 1.15 + do_throw("Could not get history service\n"); 1.16 +} 1.17 + 1.18 +// main 1.19 +function run_test() { 1.20 + // XXX Full testing coverage for QueriesToQueryString and 1.21 + // QueryStringToQueries 1.22 + 1.23 + var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. 1.24 + getService(Ci.nsINavBookmarksService); 1.25 + const NHQO = Ci.nsINavHistoryQueryOptions; 1.26 + // Bug 376798 1.27 + var query = histsvc.getNewQuery(); 1.28 + query.setFolders([bs.placesRoot], 1); 1.29 + do_check_eq(histsvc.queriesToQueryString([query], 1, histsvc.getNewQueryOptions()), 1.30 + "place:folder=PLACES_ROOT"); 1.31 + 1.32 + // Bug 378828 1.33 + var options = histsvc.getNewQueryOptions(); 1.34 + options.sortingAnnotation = "test anno"; 1.35 + options.sortingMode = NHQO.SORT_BY_ANNOTATION_DESCENDING; 1.36 + var placeURI = 1.37 + "place:folder=PLACES_ROOT&sort=" + NHQO.SORT_BY_ANNOTATION_DESCENDING + 1.38 + "&sortingAnnotation=test%20anno"; 1.39 + do_check_eq(histsvc.queriesToQueryString([query], 1, options), 1.40 + placeURI); 1.41 + var options = {}; 1.42 + histsvc.queryStringToQueries(placeURI, { }, {}, options); 1.43 + do_check_eq(options.value.sortingAnnotation, "test anno"); 1.44 + do_check_eq(options.value.sortingMode, NHQO.SORT_BY_ANNOTATION_DESCENDING); 1.45 +}