michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: // Get services. michael@0: let os = Cc["@mozilla.org/observer-service;1"]. michael@0: getService(Ci.nsIObserverService); michael@0: michael@0: let gDummyCreated = false; michael@0: let gDummyVisited = false; michael@0: michael@0: let observer = { michael@0: observe: function(subject, topic, data) { michael@0: if (topic == "dummy-observer-created") michael@0: gDummyCreated = true; michael@0: else if (topic == "dummy-observer-visited") michael@0: gDummyVisited = true; michael@0: }, michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([ michael@0: Ci.nsIObserver, michael@0: Ci.nsISupportsWeakReference, michael@0: ]) michael@0: }; michael@0: michael@0: function verify() { michael@0: do_check_true(gDummyCreated); michael@0: do_check_true(gDummyVisited); michael@0: do_test_finished(); michael@0: } michael@0: michael@0: // main michael@0: function run_test() { michael@0: do_load_manifest("nsDummyObserver.manifest"); michael@0: michael@0: os.addObserver(observer, "dummy-observer-created", true); michael@0: os.addObserver(observer, "dummy-observer-visited", true); michael@0: michael@0: do_test_pending(); michael@0: michael@0: // Add a visit michael@0: promiseAddVisits(uri("http://typed.mozilla.org")).then( michael@0: function () do_timeout(1000, verify)); michael@0: }