Jacek Caban : jscript: Support getting value of accessor property.
Alexandre Julliard
julliard at winehq.org
Tue May 15 16:25:22 CDT 2018
Module: wine
Branch: master
Commit: fd91fe52b779f91f8e62ebdacc2e52ac358929f5
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fd91fe52b779f91f8e62ebdacc2e52ac358929f5
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue May 15 13:26:25 2018 +0200
jscript: Support getting value of accessor property.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/dispex.c | 20 ++++++++++++++------
dlls/mshtml/tests/es5.js | 10 ++++++++++
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index a1298eb..2557471 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -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);
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js
index df5b7c7..4e7b83b 100644
--- a/dlls/mshtml/tests/es5.js
+++ b/dlls/mshtml/tests/es5.js
@@ -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();
}
More information about the wine-cvs
mailing list