Bug 1257734: Support set/get for mocked object in content for mochitest, r=bholley
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -355,20 +355,23 @@ function wrapCallback(cb) {
return cb.apply(this, args);
}
}
function wrapCallbackObject(obj) {
obj = Cu.waiveXrays(obj);
var wrapper = {};
for (var i in obj) {
- if (typeof obj[i] == 'function')
- wrapper[i] = wrapCallback(obj[i]);
- else
- wrapper[i] = obj[i];
+ var property = Object.getOwnPropertyDescriptor(obj, i);
+ for (var key in property) {
+ if (typeof property[key] == 'function') {
+ property[key] = wrapCallback(property[key]);
+ }
+ }
+ Object.defineProperty(wrapper, i, property);
}
return wrapper;
}
function setWrapped(obj, prop, val) {
if (!isWrapper(obj))
throw "You only need to use this for SpecialPowers wrapped objects";
@@ -685,17 +688,17 @@ SpecialPowersAPI.prototype = {
}
return delayedCallback;
},
/* apply permissions to the system and when the test case is finished (SimpleTest.finish())
we will revert the permission back to the original.
inPermissions is an array of objects where each object has a type, action, context, ex:
- [{'type': 'SystemXHR', 'allow': 1, 'context': document},
+ [{'type': 'SystemXHR', 'allow': 1, 'context': document},
{'type': 'SystemXHR', 'allow': Ci.nsIPermissionManager.PROMPT_ACTION, 'context': document}]
Allow can be a boolean value of true/false or ALLOW_ACTION/DENY_ACTION/PROMPT_ACTION/UNKNOWN_ACTION
*/
pushPermissions: function(inPermissions, callback) {
inPermissions = Cu.waiveXrays(inPermissions);
var pendingPermissions = [];
var cleanupPermissions = [];