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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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/. */
     7 function run_test() {
     8   run_next_test();
     9 }
    11 add_test(function test_resolveNullBookmarkTitles() {
    12   let uri1 = uri("http://foo.tld/");
    13   let uri2 = uri("https://bar.tld/");
    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);
    28     PlacesUtils.tagging.tagURI(uri1, ["tag 1"]);
    29     PlacesUtils.tagging.tagURI(uri2, ["tag 2"]);
    31     let options = PlacesUtils.history.getNewQueryOptions();
    32     options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
    33     options.resultType = options.RESULTS_AS_TAG_CONTENTS;
    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;
    47     run_next_test();
    48   });
    49 });

mercurial