Address review comments from bhackett (bug 672829 comment 82).
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 12 Aug 2011 07:44:14 -0500
changeset 75253 8944653199f1060ac0c6f4b9aae16ed0168dc868
parent 75252 2e368c4a6b5c813c6bf71a4006589a4f3d46765b
child 75254 afe34d24652c568e612e81295354603eecc302c6
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs672829
milestone8.0a1
Address review comments from bhackett (bug 672829 comment 82).
js/src/jit-test/tests/debug/Object-preventExtensions-01.js
js/src/vm/Debugger.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Object-preventExtensions-01.js
@@ -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);
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -3097,17 +3097,17 @@ UnwrapPropDesc(JSContext *cx, Debugger *
                               desc->checkGetter(cx))) &&
            (!desc->hasSet || (dbg->unwrapDebuggeeValue(cx, &desc->set) &&
                               CheckArgCompartment(cx, obj, desc->set, "defineProperty", "set") &&
                               desc->checkSetter(cx)));
 }
 
 /*
  * 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
 WrapIdAndPropDesc(JSContext *cx, JSObject *obj, jsid *idp, PropDesc *desc)
 {
     JSCompartment *comp = cx->compartment;
     return comp->wrapId(cx, idp) &&
            comp->wrap(cx, &desc->value) &&
@@ -3227,18 +3227,20 @@ DebuggerObject_sealHelper(JSContext *cx,
     ErrorCopier ec(ac, dbg->toJSObject());
     bool ok;
     if (op == Seal) {
         ok = obj->seal(cx);
     } else if (op == Freeze) {
         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);
     }
     if (!ok)
         return false;
     args.rval().setUndefined();
     return true;
 }