toolkit/components/places/tests/unit/test_402799.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 // Get history services
     8 try {
     9   var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
    10                 getService(Ci.nsINavHistoryService);
    11   var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
    12 } catch(ex) {
    13   do_throw("Could not get history services\n");
    14 }
    16 // Get bookmark service
    17 try {
    18   var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    19               getService(Ci.nsINavBookmarksService);
    20 }
    21 catch(ex) {
    22   do_throw("Could not get the nav-bookmarks-service\n");
    23 }
    25 // Get tagging service
    26 try {
    27   var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
    28                 getService(Ci.nsITaggingService);
    29 } catch(ex) {
    30   do_throw("Could not get tagging service\n");
    31 }
    34 // main
    35 function run_test() {
    36   var uri1 = uri("http://foo.bar/");
    38   // create 2 bookmarks on the same uri
    39   var bookmark1id = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri1,
    40                                          bmsvc.DEFAULT_INDEX, "title 1");
    41   var bookmark2id = bmsvc.insertBookmark(bmsvc.toolbarFolder, uri1,
    42                                          bmsvc.DEFAULT_INDEX, "title 2");
    43   // add some tags
    44   tagssvc.tagURI(uri1, ["foo", "bar", "foobar", "foo bar"]);
    46   // check that a generic bookmark query returns only real bookmarks
    47   var options = histsvc.getNewQueryOptions();
    48   options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
    50   var query = histsvc.getNewQuery();
    51   var result = histsvc.executeQuery(query, options);
    52   var root = result.root;
    54   root.containerOpen = true;
    55   var cc = root.childCount;
    56   do_check_eq(cc, 2);
    57   var node1 = root.getChild(0);
    58   do_check_eq(bmsvc.getFolderIdForItem(node1.itemId), bmsvc.bookmarksMenuFolder);
    59   var node2 = root.getChild(1);
    60   do_check_eq(bmsvc.getFolderIdForItem(node2.itemId), bmsvc.toolbarFolder);
    61   root.containerOpen = false;
    62 }

mercurial