|
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 // The test data for our database, note that the ordering of the results that |
|
8 // will be returned by the query (the isInQuery: true objects) is IMPORTANT. |
|
9 // see compareArrayToResult in head_queries.js for more info. |
|
10 var testData = [ |
|
11 // Normal folder |
|
12 { isInQuery: true, isFolder: true, title: "Folder 1", |
|
13 parentFolder: PlacesUtils.toolbarFolderId }, |
|
14 |
|
15 // Read only folder |
|
16 { isInQuery: false, isFolder: true, title: "Folder 2 RO", |
|
17 parentFolder: PlacesUtils.toolbarFolderId, readOnly: true } |
|
18 ]; |
|
19 |
|
20 function run_test() |
|
21 { |
|
22 run_next_test(); |
|
23 } |
|
24 |
|
25 add_task(function test_excludeReadOnlyFolders() |
|
26 { |
|
27 yield task_populateDB(testData); |
|
28 |
|
29 var query = PlacesUtils.history.getNewQuery(); |
|
30 query.setFolders([PlacesUtils.toolbarFolderId], 1); |
|
31 |
|
32 // Options |
|
33 var options = PlacesUtils.history.getNewQueryOptions(); |
|
34 options.excludeQueries = true; |
|
35 options.excludeReadOnlyFolders = true; |
|
36 |
|
37 // Results |
|
38 var result = PlacesUtils.history.executeQuery(query, options); |
|
39 var root = result.root; |
|
40 root.containerOpen = true; |
|
41 |
|
42 displayResultSet(root); |
|
43 // The readonly folder should not be in our result set. |
|
44 do_check_eq(1, root.childCount); |
|
45 do_check_eq("Folder 1", root.getChild(0).title); |
|
46 |
|
47 root.containerOpen = false; |
|
48 }); |