jscript: Use prototype for builtin Date properties.

This commit is contained in:
Jacek Caban 2012-07-24 13:17:06 +02:00 committed by Alexandre Julliard
parent 5058c1d12d
commit 175c4ddad5
2 changed files with 14 additions and 1 deletions

View File

@ -2110,6 +2110,14 @@ static const builtin_info_t Date_info = {
NULL
};
static const builtin_info_t DateInst_info = {
JSCLASS_DATE,
{NULL, Date_value, 0},
0, NULL,
NULL,
NULL
};
static HRESULT create_date(script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE time, jsdisp_t **ret)
{
DateInstance *date;
@ -2125,7 +2133,7 @@ static HRESULT create_date(script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE
if(object_prototype)
hres = init_dispex(&date->dispex, ctx, &Date_info, object_prototype);
else
hres = init_dispex_from_constr(&date->dispex, ctx, &Date_info, ctx->date_constr);
hres = init_dispex_from_constr(&date->dispex, ctx, &DateInst_info, ctx->date_constr);
if(FAILED(hres)) {
heap_free(date);
return hres;

View File

@ -222,6 +222,11 @@ ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true");
ok(Boolean.prototype.hasOwnProperty('toString'), "Boolean.prototype.hasOwnProperty('toString') is false");
obj = new Date();
ok(!obj.hasOwnProperty('getTime'), "obj.hasOwnProperty('getTime') is true");
ok(!Date.hasOwnProperty('getTime'), "Date.hasOwnProperty('getTime') is true");
ok(Date.prototype.hasOwnProperty('getTime'), "Date.prototype.hasOwnProperty('getTime') is false");
tmp = "" + new Object();
ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
(tmp = new Array).f = Object.prototype.toString;