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: * 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. * object, so reconstitute desc->pd if needed.
*/ */
static bool static bool
@ -3232,8 +3232,10 @@ DebuggerObject_sealHelper(JSContext *cx, uintN argc, Value *vp, SealHelperOp op,
ok = obj->freeze(cx); ok = obj->freeze(cx);
} else { } else {
JS_ASSERT(op == PreventExtensions); JS_ASSERT(op == PreventExtensions);
if (!obj->isExtensible()) if (!obj->isExtensible()) {
args.rval().setUndefined();
return true; return true;
}
AutoIdVector props(cx); AutoIdVector props(cx);
ok = obj->preventExtensions(cx, &props); ok = obj->preventExtensions(cx, &props);
} }