toolkit/components/places/tests/unit/test_bookmark_catobs.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
     7 // Get services.
     8 let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
     9          getService(Ci.nsINavBookmarksService);
    10 let os = Cc["@mozilla.org/observer-service;1"].
    11          getService(Ci.nsIObserverService);
    13 let gDummyCreated = false;
    14 let gDummyAdded = false;
    16 let observer = {
    17   observe: function(subject, topic, data) {
    18     if (topic == "dummy-observer-created")
    19       gDummyCreated = true;
    20     else if (topic == "dummy-observer-item-added")
    21       gDummyAdded = true;
    22   },
    24   QueryInterface: XPCOMUtils.generateQI([
    25     Ci.nsIObserver,
    26     Ci.nsISupportsWeakReference,
    27   ])
    28 };
    30 function verify() {
    31   do_check_true(gDummyCreated);
    32   do_check_true(gDummyAdded);
    33   do_test_finished();
    34 }
    36 // main
    37 function run_test() {
    38   do_load_manifest("nsDummyObserver.manifest");
    40   os.addObserver(observer, "dummy-observer-created", true);
    41   os.addObserver(observer, "dummy-observer-item-added", true);
    43   // Add a bookmark
    44   bs.insertBookmark(bs.unfiledBookmarksFolder, uri("http://typed.mozilla.org"),
    45                     bs.DEFAULT_INDEX, "bookmark");
    47   do_test_pending();
    48   do_timeout(1000, verify);
    49 }

mercurial