test_bug725015.js 1.3 KB

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