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