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.

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

mercurial