Bug 1022002 - make cloneInto create functions that clone their arguments, r=bholley

This commit is contained in:
Gijs Kruitbosch 2014-06-09 19:09:51 +01:00
parent f7c610d4d2
commit 9255c62f6f
2 changed files with 8 additions and 2 deletions

View File

@ -3531,7 +3531,7 @@ CloneIntoReadStructuredClone(JSContext *cx,
if (!JS_WrapObject(cx, &obj))
return nullptr;
if (!xpc::NewFunctionForwarder(cx, obj, false, &functionValue))
if (!xpc::NewFunctionForwarder(cx, obj, true, &functionValue))
return nullptr;
return &functionValue.toObject();

View File

@ -161,8 +161,14 @@
'CloneInto should only work on less privileged target scopes.');
}
var test = { a: function() { return 42; } }
var test = { a: function() { return 42; } };
cloneAndTestWithFunctions(test);
// Check that we're cloning input to functions:
test = { a: function(obj) { return obj; } };
var clonedTest = Cu.cloneInto(test, sandbox, {cloneFunctions: true});
var testInput = {};
isnot(clonedTest.a(testInput), testInput, "Objects should not be identical");
]]>
</script>
</window>