зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
9d829630dc
Коммит
5c9d6dd494
|
@ -156,9 +156,11 @@ const char *const js_common_atom_names[] = {
|
||||||
js_source_str, /* sourceAtom */
|
js_source_str, /* sourceAtom */
|
||||||
js_stack_str, /* stackAtom */
|
js_stack_str, /* stackAtom */
|
||||||
js_sticky_str, /* stickyAtom */
|
js_sticky_str, /* stickyAtom */
|
||||||
|
js_toGMTString_str, /* toGMTStringAtom */
|
||||||
js_toLocaleString_str, /* toLocaleStringAtom */
|
js_toLocaleString_str, /* toLocaleStringAtom */
|
||||||
js_toSource_str, /* toSourceAtom */
|
js_toSource_str, /* toSourceAtom */
|
||||||
js_toString_str, /* toStringAtom */
|
js_toString_str, /* toStringAtom */
|
||||||
|
js_toUTCString_str, /* toUTCStringAtom */
|
||||||
js_valueOf_str, /* valueOfAtom */
|
js_valueOf_str, /* valueOfAtom */
|
||||||
js_toJSON_str, /* toJSONAtom */
|
js_toJSON_str, /* toJSONAtom */
|
||||||
"(void 0)", /* void0Atom */
|
"(void 0)", /* void0Atom */
|
||||||
|
@ -250,9 +252,11 @@ const char js_set_str[] = "set";
|
||||||
const char js_source_str[] = "source";
|
const char js_source_str[] = "source";
|
||||||
const char js_stack_str[] = "stack";
|
const char js_stack_str[] = "stack";
|
||||||
const char js_sticky_str[] = "sticky";
|
const char js_sticky_str[] = "sticky";
|
||||||
|
const char js_toGMTString_str[] = "toGMTString";
|
||||||
|
const char js_toLocaleString_str[] = "toLocaleString";
|
||||||
const char js_toSource_str[] = "toSource";
|
const char js_toSource_str[] = "toSource";
|
||||||
const char js_toString_str[] = "toString";
|
const char js_toString_str[] = "toString";
|
||||||
const char js_toLocaleString_str[] = "toLocaleString";
|
const char js_toUTCString_str[] = "toUTCString";
|
||||||
const char js_undefined_str[] = "undefined";
|
const char js_undefined_str[] = "undefined";
|
||||||
const char js_valueOf_str[] = "valueOf";
|
const char js_valueOf_str[] = "valueOf";
|
||||||
const char js_toJSON_str[] = "toJSON";
|
const char js_toJSON_str[] = "toJSON";
|
||||||
|
|
|
@ -268,9 +268,11 @@ struct JSAtomState {
|
||||||
JSAtom *sourceAtom;
|
JSAtom *sourceAtom;
|
||||||
JSAtom *stackAtom;
|
JSAtom *stackAtom;
|
||||||
JSAtom *stickyAtom;
|
JSAtom *stickyAtom;
|
||||||
|
JSAtom *toGMTStringAtom;
|
||||||
JSAtom *toLocaleStringAtom;
|
JSAtom *toLocaleStringAtom;
|
||||||
JSAtom *toSourceAtom;
|
JSAtom *toSourceAtom;
|
||||||
JSAtom *toStringAtom;
|
JSAtom *toStringAtom;
|
||||||
|
JSAtom *toUTCStringAtom;
|
||||||
JSAtom *valueOfAtom;
|
JSAtom *valueOfAtom;
|
||||||
JSAtom *toJSONAtom;
|
JSAtom *toJSONAtom;
|
||||||
JSAtom *void0Atom;
|
JSAtom *void0Atom;
|
||||||
|
@ -428,9 +430,11 @@ extern const char js_stago_str[];
|
||||||
extern const char js_star_str[];
|
extern const char js_star_str[];
|
||||||
extern const char js_starQualifier_str[];
|
extern const char js_starQualifier_str[];
|
||||||
extern const char js_tagc_str[];
|
extern const char js_tagc_str[];
|
||||||
|
extern const char js_toGMTString_str[];
|
||||||
|
extern const char js_toLocaleString_str[];
|
||||||
extern const char js_toSource_str[];
|
extern const char js_toSource_str[];
|
||||||
extern const char js_toString_str[];
|
extern const char js_toString_str[];
|
||||||
extern const char js_toLocaleString_str[];
|
extern const char js_toUTCString_str[];
|
||||||
extern const char js_undefined_str[];
|
extern const char js_undefined_str[];
|
||||||
extern const char js_valueOf_str[];
|
extern const char js_valueOf_str[];
|
||||||
extern const char js_toJSON_str[];
|
extern const char js_toJSON_str[];
|
||||||
|
|
|
@ -2322,20 +2322,32 @@ js_Date(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||||
JSObject *
|
JSObject *
|
||||||
js_InitDateClass(JSContext *cx, JSObject *obj)
|
js_InitDateClass(JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
JSObject *proto;
|
|
||||||
|
|
||||||
/* set static LocalTZA */
|
/* set static LocalTZA */
|
||||||
LocalTZA = -(PRMJ_LocalGMTDifference() * msPerSecond);
|
LocalTZA = -(PRMJ_LocalGMTDifference() * msPerSecond);
|
||||||
proto = js_InitClass(cx, obj, NULL, &js_DateClass, js_Date, MAXARGS,
|
JSObject *proto = js_InitClass(cx, obj, NULL, &js_DateClass, js_Date, MAXARGS,
|
||||||
NULL, date_methods, NULL, date_static_methods);
|
NULL, date_methods, NULL, date_static_methods);
|
||||||
if (!proto)
|
if (!proto)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
AutoObjectRooter tvr(cx, proto);
|
||||||
|
|
||||||
SetDateToNaN(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 NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче