|
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 function run_test() |
|
8 { |
|
9 run_next_test(); |
|
10 } |
|
11 |
|
12 add_task(function test_execute() |
|
13 { |
|
14 try { |
|
15 var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. |
|
16 getService(Ci.nsINavHistoryService); |
|
17 var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. |
|
18 getService(Ci.nsINavBookmarksService); |
|
19 } catch(ex) { |
|
20 do_throw("Unable to initialize Places services"); |
|
21 } |
|
22 |
|
23 // add a visit |
|
24 var testURI = uri("http://test"); |
|
25 yield promiseAddVisits(testURI); |
|
26 |
|
27 // query for the visit |
|
28 var options = histsvc.getNewQueryOptions(); |
|
29 options.maxResults = 1; |
|
30 options.resultType = options.RESULTS_AS_URI; |
|
31 var query = histsvc.getNewQuery(); |
|
32 query.uri = testURI; |
|
33 var result = histsvc.executeQuery(query, options); |
|
34 var root = result.root; |
|
35 |
|
36 // check hasChildren while the container is closed |
|
37 do_check_eq(root.hasChildren, true); |
|
38 |
|
39 // now check via the saved search path |
|
40 var queryURI = histsvc.queriesToQueryString([query], 1, options); |
|
41 bmsvc.insertBookmark(bmsvc.toolbarFolder, uri(queryURI), |
|
42 0 /* first item */, "test query"); |
|
43 |
|
44 // query for that query |
|
45 var options = histsvc.getNewQueryOptions(); |
|
46 var query = histsvc.getNewQuery(); |
|
47 query.setFolders([bmsvc.toolbarFolder], 1); |
|
48 var result = histsvc.executeQuery(query, options); |
|
49 var root = result.root; |
|
50 root.containerOpen = true; |
|
51 var queryNode = root.getChild(0); |
|
52 do_check_eq(queryNode.title, "test query"); |
|
53 queryNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); |
|
54 do_check_eq(queryNode.hasChildren, true); |
|
55 root.containerOpen = false; |
|
56 }); |