Bug 509733 - ES5: arguments.toString() === "[object Arguments]". r=brendan

This commit is contained in:
Jeff Walden 2010-07-13 16:39:03 -05:00
parent 61b0ed7260
commit e809f4b20f
2 changed files with 8 additions and 7 deletions

View File

@ -667,10 +667,11 @@ args_or_call_trace(JSTracer *trc, JSObject *obj)
#endif
/*
* The Arguments class is not initialized via JS_InitClass, and must not be,
* because its name is "Object". Per ECMA, that causes instances of it to
* delegate to the object named by Object.prototype. It also ensures that
* arguments.toString() returns "[object Object]".
* The Arguments class is not initialized via JS_InitClass, because arguments
* objects have the initial value of Object.prototype as their [[Prototype]].
* However, Object.prototype.toString.call(arguments) === "[object Arguments]"
* per ES5 (although not ES3), so its class name is "Arguments" rather than
* "Object".
*
* The JSClass functions below collaborate to lazily reflect and synchronize
* actual argument values, argument count, and callee function object stored
@ -678,7 +679,7 @@ args_or_call_trace(JSTracer *trc, JSObject *obj)
* arguments object.
*/
JSClass js_ArgumentsClass = {
js_Object_str,
"Arguments",
JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE |
JSCLASS_HAS_RESERVED_SLOTS(JSObject::ARGS_FIXED_RESERVED_SLOTS) |
JSCLASS_MARK_IS_TRACE | JSCLASS_HAS_CACHED_PROTO(JSProto_Object),

View File

@ -45,11 +45,11 @@ var expect;
printBugNumber(BUGNUMBER);
printStatus (summary);
expect = '[object Object]';
expect = '[object Arguments]';
actual = (function(){return (arguments + '');})();
reportCompare(expect, actual, summary);
// see bug 336100 comment 29
expect = typeof window == 'undefined' ? '' : '[object Object]';
expect = typeof window == 'undefined' ? '' : '[object Arguments]';
actual = (function(){with (this) return(arguments + '');})();
reportCompare(expect, actual, summary);