Improve error reporting for proxy handlers and __iterator__ (568966, r=brendan).

This commit is contained in:
Andreas Gal
2010-05-29 19:04:01 -07:00
parent 03b1e5424e
commit f66960db71
7 changed files with 33 additions and 49 deletions

View File

@@ -363,10 +363,16 @@ GetCustomIterator(JSContext *cx, JSObject *obj, uintN flags, jsval *vp)
/* Otherwise call it and return that object. */
LeaveTrace(cx);
jsval arg = BOOLEAN_TO_JSVAL((flags & JSITER_FOREACH) == 0);
if (!js_InternalInvoke(cx, obj, *vp, JSINVOKE_ITERATOR, 1, &arg, vp))
if (!js_InternalCall(cx, obj, *vp, 1, &arg, vp))
return false;
if (JSVAL_IS_PRIMITIVE(*vp)) {
js_ReportValueError(cx, JSMSG_BAD_ITERATOR_RETURN, JSDVG_SEARCH_STACK, *vp, NULL);
/*
* We are always coming from js_ValueToIterator, and we are no longer on
* trace, so the object we are iterating over is on top of the stack (-1).
*/
js_ReportValueError2(cx, JSMSG_BAD_TRAP_RETURN_VALUE,
-1, OBJECT_TO_JSVAL(obj), NULL,
js_AtomToPrintableString(cx, atom));
return false;
}
return true;