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