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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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