Bug 646129 - [[DefaultValue]] on Date objects is wrong when called with no hint. r=luke

This commit is contained in:
Jeff Walden
2011-04-01 15:24:21 -07:00
parent 340cd95750
commit ae1c0cce06
25 changed files with 340 additions and 328 deletions

View File

@@ -487,6 +487,15 @@ msFromTime(jsdouble t)
* end of ECMA 'support' functions
*/
static JSBool
date_convert(JSContext *cx, JSObject *obj, JSType hint, Value *vp)
{
JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
JS_ASSERT(obj->isDate());
return DefaultValue(cx, obj, (hint == JSTYPE_VOID) ? JSTYPE_STRING : hint, vp);
}
/*
* Other Support routines and definitions
*/
@@ -501,7 +510,7 @@ Class js_DateClass = {
StrictPropertyStub, /* setProperty */
EnumerateStub,
ResolveStub,
ConvertStub
date_convert
};
/* for use by date_parse */
@@ -2083,8 +2092,8 @@ date_toJSON(JSContext *cx, uintN argc, Value *vp)
return false;
/* Step 2. */
Value &tv = vp[0];
if (!DefaultValue(cx, obj, JSTYPE_NUMBER, &tv))
Value tv = ObjectValue(*obj);
if (!ToPrimitive(cx, JSTYPE_NUMBER, &tv))
return false;
/* Step 3. */