Bug 674255 - Add nsIObserverService to special powers, r=ted

This commit is contained in:
Ian Melven 2011-10-14 11:24:10 -07:00
Родитель effd32fe9e
Коммит 879d1f5caf
2 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -331,6 +331,24 @@ SpecialPowersAPI.prototype = {
this.wrappedJSObject.SpecialPowers._applyPrefs();
},
addObserver: function(obs, notification, weak) {
var obsvc = Cc['@mozilla.org/observer-service;1']
.getService(Ci.nsIObserverService);
obsvc.addObserver(obs, notification, weak);
},
removeObserver: function(obs, notification) {
var obsvc = Cc['@mozilla.org/observer-service;1']
.getService(Ci.nsIObserverService);
obsvc.removeObserver(obs, notification);
},
can_QI: function(obj) {
return obj.QueryInterface !== undefined;
},
do_QueryInterface: function(obj, iface) {
return obj.QueryInterface(Ci[iface]);
},
// Mimic the get*Pref API
getBoolPref: function(aPrefName) {
return (this._getPref(aPrefName, 'BOOL'));

Просмотреть файл

@ -81,6 +81,12 @@ function starttest(){
ok(xhr, "createSystemXHR should not return null");
is(xhr.readyState, XMLHttpRequest.UNSENT, "createSystemXHR should create an unsent XMLHttpRequest object");
// QueryInterface and getPrivilegedProps tests
is(SpecialPowers.can_QI(SpecialPowers), false);
ok(SpecialPowers.can_QI(window));
ok(SpecialPowers.do_QueryInterface(window, "nsIDOMWindow"));
is(SpecialPowers.getPrivilegedProps(SpecialPowers.do_QueryInterface(window, "nsIDOMWindow"), "document.nodeName"), "#document");
//try to run garbage collection
SpecialPowers.gc();