toolkit/components/places/tests/unit/test_PlacesUtils_lazyobservers.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function run_test() {
     5   do_test_pending();
     7   const TEST_URI = NetUtil.newURI("http://moz.org/")
     8   let observer = {
     9     QueryInterface: XPCOMUtils.generateQI([
    10       Ci.nsINavBookmarkObserver,
    11     ]),
    13     onBeginUpdateBatch: function () {},
    14     onEndUpdateBatch: function () {},
    15     onItemAdded: function (aItemId, aParentId, aIndex, aItemType, aURI) {
    16       do_check_true(aURI.equals(TEST_URI));
    17       PlacesUtils.removeLazyBookmarkObserver(this);
    18       do_test_finished();
    19     },
    20     onItemRemoved: function () {},
    21     onItemChanged: function () {},
    22     onItemVisited: function () {},
    23     onItemMoved: function () {},
    24   };
    26   // Check registration and removal with uninitialized bookmarks service.
    27   PlacesUtils.addLazyBookmarkObserver(observer);
    28   PlacesUtils.removeLazyBookmarkObserver(observer);
    30   // Add a proper lazy observer we will test.
    31   PlacesUtils.addLazyBookmarkObserver(observer);
    33   // Check that we don't leak when adding and removing an observer while the
    34   // bookmarks service is instantiated but no change happened (bug 721319).
    35   PlacesUtils.bookmarks;
    36   PlacesUtils.addLazyBookmarkObserver(observer);
    37   PlacesUtils.removeLazyBookmarkObserver(observer);
    38   try {
    39     PlacesUtils.bookmarks.removeObserver(observer);
    40     do_throw("Trying to remove a nonexisting observer should throw!");
    41   } catch (ex) {}
    43   PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
    44                                        TEST_URI,
    45                                        PlacesUtils.bookmarks.DEFAULT_INDEX,
    46                                        "Bookmark title");
    47 }

mercurial