|
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 file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 const Cc = Components.classes; |
|
6 const Ci = Components.interfaces; |
|
7 |
|
8 Components.utils.import("resource://gre/modules/Services.jsm"); |
|
9 |
|
10 const manifest = do_get_file('bug725015.manifest'); |
|
11 const contract = "@bug725015.test.contract"; |
|
12 const observerTopic = "xpcom-category-entry-added"; |
|
13 const category = "bug725015-test-category"; |
|
14 const entry = "bug725015-category-entry"; |
|
15 const cid = Components.ID("{05070380-6e6e-42ba-aaa5-3289fc55ca5a}"); |
|
16 |
|
17 function observe_category(subj, topic, data) { |
|
18 try { |
|
19 do_check_eq(topic, observerTopic); |
|
20 if (data != category) |
|
21 return; |
|
22 |
|
23 var thisentry = subj.QueryInterface(Ci.nsISupportsCString).data; |
|
24 do_check_eq(thisentry, entry); |
|
25 |
|
26 do_check_eq(Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager).getCategoryEntry(category, entry), contract); |
|
27 do_check_true(Cc[contract].equals(cid)); |
|
28 } |
|
29 catch (e) { |
|
30 do_throw(e); |
|
31 } |
|
32 do_test_finished(); |
|
33 } |
|
34 |
|
35 function run_test() { |
|
36 do_test_pending(); |
|
37 Services.obs.addObserver(observe_category, observerTopic, false); |
|
38 Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest); |
|
39 } |