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 file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: const manifest = do_get_file('bug725015.manifest'); michael@0: const contract = "@bug725015.test.contract"; michael@0: const observerTopic = "xpcom-category-entry-added"; michael@0: const category = "bug725015-test-category"; michael@0: const entry = "bug725015-category-entry"; michael@0: const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}"); michael@0: michael@0: function observe_category(subj, topic, data) { michael@0: try { michael@0: do_check_eq(topic, observerTopic); michael@0: if (data != category) michael@0: return; michael@0: michael@0: var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data; michael@0: do_check_eq(thisentry, entry); michael@0: michael@0: do_check_eq(Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).getCategoryEntry(category, entry), contract); michael@0: do_check_true(Cc[contract].equals(cid)); michael@0: } michael@0: catch (e) { michael@0: do_throw(e); michael@0: } michael@0: do_test_finished(); michael@0: } michael@0: michael@0: function run_test() { michael@0: do_test_pending(); michael@0: Services.obs.addObserver(observe_category, observerTopic, false); michael@0: Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest); michael@0: }