toolkit/components/places/tests/bookmarks/test_395101.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 bookmark service
michael@0 8 try {
michael@0 9 var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
michael@0 10 } catch(ex) {
michael@0 11 do_throw("Could not get nav-bookmarks-service\n");
michael@0 12 }
michael@0 13
michael@0 14 // Get history service
michael@0 15 try {
michael@0 16 var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
michael@0 17 } catch(ex) {
michael@0 18 do_throw("Could not get history service\n");
michael@0 19 }
michael@0 20
michael@0 21 // Get tagging service
michael@0 22 try {
michael@0 23 var tagssvc = Cc["@mozilla.org/browser/tagging-service;1"].
michael@0 24 getService(Ci.nsITaggingService);
michael@0 25 } catch(ex) {
michael@0 26 do_throw("Could not get tagging service\n");
michael@0 27 }
michael@0 28
michael@0 29 // get bookmarks root id
michael@0 30 var root = bmsvc.bookmarksMenuFolder;
michael@0 31
michael@0 32 // main
michael@0 33 function run_test() {
michael@0 34 // test searching for tagged bookmarks
michael@0 35
michael@0 36 // test folder
michael@0 37 var folder = bmsvc.createFolder(root, "bug 395101 test", bmsvc.DEFAULT_INDEX);
michael@0 38
michael@0 39 // create a bookmark
michael@0 40 var testURI = uri("http://a1.com");
michael@0 41 var b1 = bmsvc.insertBookmark(folder, testURI,
michael@0 42 bmsvc.DEFAULT_INDEX, "1 title");
michael@0 43
michael@0 44 // tag the bookmarked URI
michael@0 45 tagssvc.tagURI(testURI, ["elephant", "walrus", "giraffe", "turkey", "hiPPo", "BABOON", "alf"]);
michael@0 46
michael@0 47 // search for the bookmark, using a tag
michael@0 48 var query = histsvc.getNewQuery();
michael@0 49 query.searchTerms = "elephant";
michael@0 50 var options = histsvc.getNewQueryOptions();
michael@0 51 options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
michael@0 52 query.setFolders([folder], 1);
michael@0 53
michael@0 54 var result = histsvc.executeQuery(query, options);
michael@0 55 var rootNode = result.root;
michael@0 56 rootNode.containerOpen = true;
michael@0 57
michael@0 58 do_check_eq(rootNode.childCount, 1);
michael@0 59 do_check_eq(rootNode.getChild(0).itemId, b1);
michael@0 60 rootNode.containerOpen = false;
michael@0 61
michael@0 62 // partial matches are okay
michael@0 63 query.searchTerms = "wal";
michael@0 64 var result = histsvc.executeQuery(query, options);
michael@0 65 var rootNode = result.root;
michael@0 66 rootNode.containerOpen = true;
michael@0 67 do_check_eq(rootNode.childCount, 1);
michael@0 68 rootNode.containerOpen = false;
michael@0 69
michael@0 70 // case insensitive search term
michael@0 71 query.searchTerms = "WALRUS";
michael@0 72 var result = histsvc.executeQuery(query, options);
michael@0 73 var rootNode = result.root;
michael@0 74 rootNode.containerOpen = true;
michael@0 75 do_check_eq(rootNode.childCount, 1);
michael@0 76 do_check_eq(rootNode.getChild(0).itemId, b1);
michael@0 77 rootNode.containerOpen = false;
michael@0 78
michael@0 79 // case insensitive tag
michael@0 80 query.searchTerms = "baboon";
michael@0 81 var result = histsvc.executeQuery(query, options);
michael@0 82 var rootNode = result.root;
michael@0 83 rootNode.containerOpen = true;
michael@0 84 do_check_eq(rootNode.childCount, 1);
michael@0 85 do_check_eq(rootNode.getChild(0).itemId, b1);
michael@0 86 rootNode.containerOpen = false;
michael@0 87 }

mercurial