1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/unit/test_bookmark_catobs.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 1.9 + 1.10 +// Get services. 1.11 +let bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. 1.12 + getService(Ci.nsINavBookmarksService); 1.13 +let os = Cc["@mozilla.org/observer-service;1"]. 1.14 + getService(Ci.nsIObserverService); 1.15 + 1.16 +let gDummyCreated = false; 1.17 +let gDummyAdded = false; 1.18 + 1.19 +let observer = { 1.20 + observe: function(subject, topic, data) { 1.21 + if (topic == "dummy-observer-created") 1.22 + gDummyCreated = true; 1.23 + else if (topic == "dummy-observer-item-added") 1.24 + gDummyAdded = true; 1.25 + }, 1.26 + 1.27 + QueryInterface: XPCOMUtils.generateQI([ 1.28 + Ci.nsIObserver, 1.29 + Ci.nsISupportsWeakReference, 1.30 + ]) 1.31 +}; 1.32 + 1.33 +function verify() { 1.34 + do_check_true(gDummyCreated); 1.35 + do_check_true(gDummyAdded); 1.36 + do_test_finished(); 1.37 +} 1.38 + 1.39 +// main 1.40 +function run_test() { 1.41 + do_load_manifest("nsDummyObserver.manifest"); 1.42 + 1.43 + os.addObserver(observer, "dummy-observer-created", true); 1.44 + os.addObserver(observer, "dummy-observer-item-added", true); 1.45 + 1.46 + // Add a bookmark 1.47 + bs.insertBookmark(bs.unfiledBookmarksFolder, uri("http://typed.mozilla.org"), 1.48 + bs.DEFAULT_INDEX, "bookmark"); 1.49 + 1.50 + do_test_pending(); 1.51 + do_timeout(1000, verify); 1.52 +}