toolkit/components/places/tests/unit/test_resolveNullBookmarkTitles.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 });

mercurial