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.

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

mercurial