|
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 run_next_test(); |
|
9 } |
|
10 |
|
11 add_test(function test_resolveNullBookmarkTitles() { |
|
12 let uri1 = uri("http://foo.tld/"); |
|
13 let uri2 = uri("https://bar.tld/"); |
|
14 |
|
15 promiseAddVisits([ |
|
16 { uri: uri1, title: "foo title" }, |
|
17 { uri: uri2, title: "bar title" } |
|
18 ]).then(function () { |
|
19 PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId, |
|
20 uri1, |
|
21 PlacesUtils.bookmarks.DEFAULT_INDEX, |
|
22 null); |
|
23 PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarksMenuFolderId, |
|
24 uri2, |
|
25 PlacesUtils.bookmarks.DEFAULT_INDEX, |
|
26 null); |
|
27 |
|
28 PlacesUtils.tagging.tagURI(uri1, ["tag 1"]); |
|
29 PlacesUtils.tagging.tagURI(uri2, ["tag 2"]); |
|
30 |
|
31 let options = PlacesUtils.history.getNewQueryOptions(); |
|
32 options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS; |
|
33 options.resultType = options.RESULTS_AS_TAG_CONTENTS; |
|
34 |
|
35 let query = PlacesUtils.history.getNewQuery(); |
|
36 // if we don't set a tag folder, RESULTS_AS_TAG_CONTENTS will return all |
|
37 // tagged URIs |
|
38 let root = PlacesUtils.history.executeQuery(query, options).root; |
|
39 root.containerOpen = true; |
|
40 do_check_eq(root.childCount, 2); |
|
41 // actually RESULTS_AS_TAG_CONTENTS return results ordered by place_id DESC |
|
42 // so they are reversed |
|
43 do_check_eq(root.getChild(0).title, "bar title"); |
|
44 do_check_eq(root.getChild(1).title, "foo title"); |
|
45 root.containerOpen = false; |
|
46 |
|
47 run_next_test(); |
|
48 }); |
|
49 }); |