jscript: Support getting value of accessor property.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-05-15 13:26:25 +02:00 committed by Alexandre Julliard
parent d8aa26f660
commit fd91fe52b7
2 changed files with 24 additions and 6 deletions

View File

@ -434,8 +434,14 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r)
{
jsdisp_t *prop_obj = This;
HRESULT hres;
while(prop->type == PROP_PROTREF) {
prop_obj = prop_obj->prototype;
prop = prop_obj->props + prop->u.ref;
}
switch(prop->type) {
case PROP_BUILTIN:
if(prop->u.p->getter) {
@ -456,18 +462,20 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r)
*r = jsval_obj(obj);
}
break;
case PROP_PROTREF:
hres = prop_get(This->prototype, This->prototype->props + prop->u.ref, r);
break;
case PROP_JSVAL:
hres = jsval_copy(prop->u.val, r);
break;
case PROP_ACCESSOR:
FIXME("not supported on accessor property\n");
hres = E_NOTIMPL;
if(prop->u.accessor.getter) {
hres = jsdisp_call_value(prop->u.accessor.getter, to_disp(This),
DISPATCH_METHOD, 0, NULL, r);
}else {
*r = jsval_undefined();
hres = S_OK;
}
break;
case PROP_IDX:
hres = This->builtin_info->idx_get(This, prop->u.idx, r);
hres = prop_obj->builtin_info->idx_get(prop_obj, prop->u.idx, r);
break;
default:
ERR("type %d\n", prop->type);

View File

@ -257,6 +257,8 @@ function test_defineProperty() {
Object.defineProperty(obj, "getsetprop", desc);
test_accessor_prop_desc(obj, "getsetprop", desc);
ok(obj.getsetprop === 1, "getsetprop = " + obj.getsetprop);
Object.defineProperty(obj, "notConf", {writable: true, enumerable: true, configurable: false, value: 1});
test_own_data_prop_desc(obj, "notConf", true, true, false);
@ -379,9 +381,11 @@ function test_defineProperty() {
function child() {}
desc = {
get: function() {
ok(this === obj, "this != obj");
return getsetprop_value;
},
set: function(v) {
ok(this === obj, "this != obj");
getsetprop_value = v;
},
configurable: true
@ -389,11 +393,17 @@ function test_defineProperty() {
Object.defineProperty(child.prototype, "parent_accessor", desc);
obj = new child();
getsetprop_value = 6;
ok(obj.parent_accessor === 6, "parent_accessor = " + obj.parent_accessor);
ok(Object.getOwnPropertyDescriptor(obj, "parent_accessor") === undefined,
"getOwnPropertyDescriptor(parent_accessor) did not return undefined");
test_accessor_prop_desc(child.prototype, "parent_accessor", desc);
desc.get = undefined;
Object.defineProperty(child.prototype, "parent_accessor", desc);
ok(obj.parent_accessor === undefined, "parent_accessor = " + obj.parent_accessor);
next_test();
}