From d36ff061fae00f79f8cd7e124a8ebe25d4937f95 Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Fri, 12 Aug 2011 07:44:14 -0500 Subject: [PATCH] Address review comments from bhackett (bug 672829 comment 82). --- .../tests/debug/Object-preventExtensions-01.js | 16 ++++++++++++++++ js/src/vm/Debugger.cpp | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 js/src/jit-test/tests/debug/Object-preventExtensions-01.js diff --git a/js/src/jit-test/tests/debug/Object-preventExtensions-01.js b/js/src/jit-test/tests/debug/Object-preventExtensions-01.js new file mode 100644 index 00000000000..6a2cfc882f8 --- /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); diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index cf94a1eb7c4..0d71c3f5a04 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -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); }