Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 const Cc = Components.classes;
2 const Ci = Components.interfaces;
4 var addedTopic = "xpcom-category-entry-added";
5 var removedTopic = "xpcom-category-entry-removed";
6 var testCategory = "bug-test-category";
7 var testEntry = "@mozilla.org/bug-test-entry;1";
9 var testValue= "check validity";
10 var result = "";
11 var expected = "add remove add remove ";
12 var timer;
14 var observer = {
15 QueryInterface: function(iid) {
16 if (iid.equals(Ci.nsISupports) || iid.equals(Ci.nsIObserver))
17 return this;
19 throw Components.results.NS_ERROR_NO_INTERFACE;
20 },
22 observe: function(subject, topic, data) {
23 if (topic == "timer-callback") {
24 do_check_eq(result, expected);
26 var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
27 observerService.removeObserver(this, addedTopic);
28 observerService.removeObserver(this, removedTopic);
30 do_test_finished();
32 timer = null;
33 }
35 if (subject.QueryInterface(Ci.nsISupportsCString).data != testEntry || data != testCategory)
36 return;
38 if (topic == addedTopic)
39 result += "add ";
40 else if (topic == removedTopic)
41 result += "remove ";
42 }
43 };
45 function run_test() {
46 do_test_pending();
48 var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
49 observerService.addObserver(observer, addedTopic, false);
50 observerService.addObserver(observer, removedTopic, false);
52 var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
53 categoryManager.addCategoryEntry(testCategory, testEntry, testValue, false, true);
54 categoryManager.addCategoryEntry(testCategory, testEntry, testValue, false, true);
55 categoryManager.deleteCategoryEntry(testCategory, testEntry, false);
57 timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
58 timer.init(observer, 0, timer.TYPE_ONE_SHOT);
59 }