Bug 951632 - Fix shell metadata hook to skip functions from other compartments. r=luke

--HG--
extra : rebase_source : c1b5d5fdde8748890cc6179d7d0676c809c4939b
This commit is contained in:
Jan de Mooij 2014-01-09 11:07:59 +01:00
parent e49d78a446
commit 4e89986f1d
2 changed files with 10 additions and 1 deletions

View File

@ -1009,7 +1009,7 @@ ShellObjectMetadataCallback(JSContext *cx, JSObject **pmetadata)
int stackIndex = 0;
for (NonBuiltinScriptFrameIter iter(cx); !iter.done(); ++iter) {
if (iter.isFunctionFrame()) {
if (iter.isFunctionFrame() && iter.compartment() == cx->compartment()) {
if (!JS_DefinePropertyById(cx, stack, INT_TO_JSID(stackIndex), ObjectValue(*iter.callee()),
JS_PropertyStub, JS_StrictPropertyStub, 0))
{

View File

@ -0,0 +1,9 @@
setObjectMetadataCallback(true);
var g = newGlobal()
g.eval("function f(a) { return h(); }");
g.h = function () {
return [1, 2, 3];
};
var o = getObjectMetadata(g.f(5));
assertEq(o.stack.length, 1);
assertEq(o.stack[0], g.h);