Bug 574992 - Make Date.prototype.toGMTString a normal, non-enumerable, non-alias property; also fixes a failure (with Object.getOwnPropertyNames support) in the MS ES5 tests. r=brendan

This commit is contained in:
Jeff Walden
2010-06-26 14:08:58 -07:00
parent dc03824c5a
commit 73bdd65d1b
3 changed files with 28 additions and 8 deletions

View File

@@ -2322,20 +2322,32 @@ js_Date(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSObject *
js_InitDateClass(JSContext *cx, JSObject *obj)
{
JSObject *proto;
/* set static LocalTZA */
LocalTZA = -(PRMJ_LocalGMTDifference() * msPerSecond);
proto = js_InitClass(cx, obj, NULL, &js_DateClass, js_Date, MAXARGS,
NULL, date_methods, NULL, date_static_methods);
JSObject *proto = js_InitClass(cx, obj, NULL, &js_DateClass, js_Date, MAXARGS,
NULL, date_methods, NULL, date_static_methods);
if (!proto)
return NULL;
AutoObjectRooter tvr(cx, proto);
SetDateToNaN(cx, proto);
/* Alias toUTCString with toGMTString. (ECMA B.2.6) */
if (!JS_AliasProperty(cx, proto, "toUTCString", "toGMTString"))
/*
* ES5 B.2.6:
* The Function object that is the initial value of
* Date.prototype.toGMTString is the same Function
* object that is the initial value of
* Date.prototype.toUTCString.
*/
AutoValueRooter toUTCStringFun(cx);
jsid toUTCStringId = ATOM_TO_JSID(cx->runtime->atomState.toUTCStringAtom);
jsid toGMTStringId = ATOM_TO_JSID(cx->runtime->atomState.toGMTStringAtom);
if (!js_GetProperty(cx, proto, toUTCStringId, toUTCStringFun.addr()) ||
!js_DefineProperty(cx, proto, toGMTStringId, toUTCStringFun.value(),
JS_PropertyStub, JS_PropertyStub, 0)) {
return NULL;
}
return proto;
}