toolkit/components/places/tests/bookmarks/test_changeBookmarkURI.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 var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
michael@0 9 getService(Ci.nsINavBookmarksService);
michael@0 10
michael@0 11 /**
michael@0 12 * Ensures that the Places APIs recognize that aBookmarkedUri is bookmarked
michael@0 13 * via aBookmarkId and that aUnbookmarkedUri is not bookmarked at all.
michael@0 14 *
michael@0 15 * @param aBookmarkId
michael@0 16 * an item ID whose corresponding URI is aBookmarkedUri
michael@0 17 * @param aBookmarkedUri
michael@0 18 * a bookmarked URI that has a corresponding item ID aBookmarkId
michael@0 19 * @param aUnbookmarkedUri
michael@0 20 * a URI that is not currently bookmarked at all
michael@0 21 */
michael@0 22 function checkUris(aBookmarkId, aBookmarkedUri, aUnbookmarkedUri)
michael@0 23 {
michael@0 24 // Ensure that aBookmarkedUri equals some URI that is bookmarked
michael@0 25 var uri = bmsvc.getBookmarkedURIFor(aBookmarkedUri);
michael@0 26 do_check_neq(uri, null);
michael@0 27 do_check_true(uri.equals(aBookmarkedUri));
michael@0 28
michael@0 29 // Ensure that aBookmarkedUri is considered bookmarked
michael@0 30 do_check_true(bmsvc.isBookmarked(aBookmarkedUri));
michael@0 31
michael@0 32 // Ensure that the URI corresponding to aBookmarkId equals aBookmarkedUri
michael@0 33 do_check_true(bmsvc.getBookmarkURI(aBookmarkId).equals(aBookmarkedUri));
michael@0 34
michael@0 35 // Ensure that aUnbookmarkedUri does not equal any URI that is bookmarked
michael@0 36 uri = bmsvc.getBookmarkedURIFor(aUnbookmarkedUri);
michael@0 37 do_check_eq(uri, null);
michael@0 38
michael@0 39 // Ensure that aUnbookmarkedUri is not considered bookmarked
michael@0 40 do_check_false(bmsvc.isBookmarked(aUnbookmarkedUri));
michael@0 41 }
michael@0 42
michael@0 43 // main
michael@0 44 function run_test() {
michael@0 45 // Create a folder
michael@0 46 var folderId = bmsvc.createFolder(bmsvc.toolbarFolder,
michael@0 47 "test",
michael@0 48 bmsvc.DEFAULT_INDEX);
michael@0 49
michael@0 50 // Create 2 URIs
michael@0 51 var uri1 = uri("http://www.dogs.com");
michael@0 52 var uri2 = uri("http://www.cats.com");
michael@0 53
michael@0 54 // Bookmark the first one
michael@0 55 var bookmarkId = bmsvc.insertBookmark(folderId,
michael@0 56 uri1,
michael@0 57 bmsvc.DEFAULT_INDEX,
michael@0 58 "Dogs");
michael@0 59
michael@0 60 // uri1 is bookmarked via bookmarkId, uri2 is not
michael@0 61 checkUris(bookmarkId, uri1, uri2);
michael@0 62
michael@0 63 // Change the URI of the bookmark to uri2
michael@0 64 bmsvc.changeBookmarkURI(bookmarkId, uri2);
michael@0 65
michael@0 66 // uri2 is now bookmarked via bookmarkId, uri1 is not
michael@0 67 checkUris(bookmarkId, uri2, uri1);
michael@0 68 }

mercurial