jscript: Use prototype for builtin Date properties.
This commit is contained in:
parent
5058c1d12d
commit
175c4ddad5
@ -2110,6 +2110,14 @@ static const builtin_info_t Date_info = {
|
|||||||
NULL
|
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)
|
static HRESULT create_date(script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE time, jsdisp_t **ret)
|
||||||
{
|
{
|
||||||
DateInstance *date;
|
DateInstance *date;
|
||||||
@ -2125,7 +2133,7 @@ static HRESULT create_date(script_ctx_t *ctx, jsdisp_t *object_prototype, DOUBLE
|
|||||||
if(object_prototype)
|
if(object_prototype)
|
||||||
hres = init_dispex(&date->dispex, ctx, &Date_info, object_prototype);
|
hres = init_dispex(&date->dispex, ctx, &Date_info, object_prototype);
|
||||||
else
|
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)) {
|
if(FAILED(hres)) {
|
||||||
heap_free(date);
|
heap_free(date);
|
||||||
return hres;
|
return hres;
|
||||||
|
@ -222,6 +222,11 @@ ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true");
|
|||||||
ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true");
|
ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true");
|
||||||
ok(Boolean.prototype.hasOwnProperty('toString'), "Boolean.prototype.hasOwnProperty('toString') is false");
|
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();
|
tmp = "" + new Object();
|
||||||
ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
|
ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
|
||||||
(tmp = new Array).f = Object.prototype.toString;
|
(tmp = new Array).f = Object.prototype.toString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user