diff --git a/testing/mochitest/tests/SimpleTest/specialpowersAPI.js b/testing/mochitest/tests/SimpleTest/specialpowersAPI.js index 419d8a9302c0..b662ed8c5b46 100644 --- a/testing/mochitest/tests/SimpleTest/specialpowersAPI.js +++ b/testing/mochitest/tests/SimpleTest/specialpowersAPI.js @@ -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')); diff --git a/testing/mochitest/tests/test_SpecialPowersExtension.html b/testing/mochitest/tests/test_SpecialPowersExtension.html index ea7d80527ca1..c00c5095d1e6 100644 --- a/testing/mochitest/tests/test_SpecialPowersExtension.html +++ b/testing/mochitest/tests/test_SpecialPowersExtension.html @@ -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();