Fix Frame.arguments bug noticed by luke in bug 672829 comment 69.

This commit is contained in:
Jason Orendorff 2011-08-11 15:50:04 -05:00
parent f3fcd7625a
commit 02efc70ce2
2 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,23 @@
// When argument[x] is assigned, where x > callee.length, frame.arguments reflects the change.
var g = newGlobal('new-compartment');
g.eval("function f(a, b) {\n" +
" for (var i = 0; i < arguments.length; i++)\n" +
" arguments[i] = i;\n" +
" debugger;\n" +
"}\n");
var dbg = Debugger(g);
var hits = 0;
dbg.onDebuggerStatement = function (frame) {
var argc = frame.eval("arguments.length").return;
var args = frame.arguments;
assertEq(args.length, argc);
for (var i = 0; i < argc; i++)
assertEq(args[i], i);
hits++;
}
g.f(9);
g.f(9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9);
assertEq(hits, 2);

View File

@ -2506,7 +2506,7 @@ DebuggerArguments_getArg(JSContext *cx, uintN argc, Value *vp)
*/
JS_ASSERT(i >= 0);
if (uintN(i) < fp->numActualArgs())
*vp = fp->actualArgs()[i];
*vp = fp->canonicalActualArg(i);
else
vp->setUndefined();
return Debugger::fromChildJSObject(thisobj)->wrapDebuggeeValue(cx, vp);