Address review comments from bhackett (bug 672829 comment 82).

This commit is contained in:
Jason Orendorff 2011-08-12 07:44:14 -05:00
parent 65e5022233
commit d36ff061fa
2 changed files with 20 additions and 2 deletions

View File

@ -0,0 +1,16 @@
// Basic preventExtensions test.
var g = newGlobal('new-compartment');
var obj = g.eval("({x: 1})");
assertEq(g.Object.isExtensible(obj), true);
var dbg = new Debugger;
var objw = dbg.addDebuggee(obj);
assertEq(objw.isExtensible(), true);
assertEq(objw.preventExtensions(), undefined);
assertEq(g.Object.isExtensible(obj), false);
assertEq(objw.isExtensible(), false);
// Calling preventExtensions again has no effect.
assertEq(objw.preventExtensions(), undefined);

View File

@ -3102,7 +3102,7 @@ UnwrapPropDesc(JSContext *cx, Debugger *dbg, JSObject *obj, PropDesc *desc)
/*
* Rewrap *idp and the fields of *desc for the current compartment. Also:
* defining a property on a proxy requiers the pd field to contain a descriptor
* defining a property on a proxy requires the pd field to contain a descriptor
* object, so reconstitute desc->pd if needed.
*/
static bool
@ -3232,8 +3232,10 @@ DebuggerObject_sealHelper(JSContext *cx, uintN argc, Value *vp, SealHelperOp op,
ok = obj->freeze(cx);
} else {
JS_ASSERT(op == PreventExtensions);
if (!obj->isExtensible())
if (!obj->isExtensible()) {
args.rval().setUndefined();
return true;
}
AutoIdVector props(cx);
ok = obj->preventExtensions(cx, &props);
}