Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | |
michael@0 | 8 | // Get history service |
michael@0 | 9 | try { |
michael@0 | 10 | var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService); |
michael@0 | 11 | } catch(ex) { |
michael@0 | 12 | do_throw("Could not get history service\n"); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | // main |
michael@0 | 16 | function run_test() { |
michael@0 | 17 | // XXX Full testing coverage for QueriesToQueryString and |
michael@0 | 18 | // QueryStringToQueries |
michael@0 | 19 | |
michael@0 | 20 | var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. |
michael@0 | 21 | getService(Ci.nsINavBookmarksService); |
michael@0 | 22 | const NHQO = Ci.nsINavHistoryQueryOptions; |
michael@0 | 23 | // Bug 376798 |
michael@0 | 24 | var query = histsvc.getNewQuery(); |
michael@0 | 25 | query.setFolders([bs.placesRoot], 1); |
michael@0 | 26 | do_check_eq(histsvc.queriesToQueryString([query], 1, histsvc.getNewQueryOptions()), |
michael@0 | 27 | "place:folder=PLACES_ROOT"); |
michael@0 | 28 | |
michael@0 | 29 | // Bug 378828 |
michael@0 | 30 | var options = histsvc.getNewQueryOptions(); |
michael@0 | 31 | options.sortingAnnotation = "test anno"; |
michael@0 | 32 | options.sortingMode = NHQO.SORT_BY_ANNOTATION_DESCENDING; |
michael@0 | 33 | var placeURI = |
michael@0 | 34 | "place:folder=PLACES_ROOT&sort=" + NHQO.SORT_BY_ANNOTATION_DESCENDING + |
michael@0 | 35 | "&sortingAnnotation=test%20anno"; |
michael@0 | 36 | do_check_eq(histsvc.queriesToQueryString([query], 1, options), |
michael@0 | 37 | placeURI); |
michael@0 | 38 | var options = {}; |
michael@0 | 39 | histsvc.queryStringToQueries(placeURI, { }, {}, options); |
michael@0 | 40 | do_check_eq(options.value.sortingAnnotation, "test anno"); |
michael@0 | 41 | do_check_eq(options.value.sortingMode, NHQO.SORT_BY_ANNOTATION_DESCENDING); |
michael@0 | 42 | } |