1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/tests/unit/test_bug725015.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 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 file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const Cc = Components.classes; 1.9 +const Ci = Components.interfaces; 1.10 + 1.11 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.12 + 1.13 +const manifest = do_get_file('bug725015.manifest'); 1.14 +const contract = "@bug725015.test.contract"; 1.15 +const observerTopic = "xpcom-category-entry-added"; 1.16 +const category = "bug725015-test-category"; 1.17 +const entry = "bug725015-category-entry"; 1.18 +const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}"); 1.19 + 1.20 +function observe_category(subj, topic, data) { 1.21 + try { 1.22 + do_check_eq(topic, observerTopic); 1.23 + if (data != category) 1.24 + return; 1.25 + 1.26 + var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data; 1.27 + do_check_eq(thisentry, entry); 1.28 + 1.29 + do_check_eq(Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).getCategoryEntry(category, entry), contract); 1.30 + do_check_true(Cc[contract].equals(cid)); 1.31 + } 1.32 + catch (e) { 1.33 + do_throw(e); 1.34 + } 1.35 + do_test_finished(); 1.36 +} 1.37 + 1.38 +function run_test() { 1.39 + do_test_pending(); 1.40 + Services.obs.addObserver(observe_category, observerTopic, false); 1.41 + Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest); 1.42 +}