-- v2: jscript: Use the object containing the prop for builtin getters. jscript: Call the getter with the proper 'this' in invoke_prop_func.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 18 +++++++++--------- dlls/mshtml/tests/es5.js | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 2da2270fb0f..0dd575434c1 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -442,7 +442,7 @@ static HRESULT convert_params(script_ctx_t *ctx, const DISPPARAMS *dp, jsval_t * return S_OK; }
-static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r) +static HRESULT prop_get(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t *prop, jsval_t *r) { jsdisp_t *prop_obj = This; HRESULT hres; @@ -461,7 +461,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r) break; case PROP_ACCESSOR: if(prop->u.accessor.getter) { - hres = jsdisp_call_value(prop->u.accessor.getter, jsval_obj(This), + hres = jsdisp_call_value(prop->u.accessor.getter, jsval_disp(jsthis), DISPATCH_METHOD, 0, NULL, r); }else { *r = jsval_undefined(); @@ -579,7 +579,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t case PROP_IDX: { jsval_t val;
- hres = prop_get(This, prop, &val); + hres = prop_get(This, jsthis ? jsthis : (IDispatch *)&This->IDispatchEx_iface, prop, &val); if(FAILED(hres)) return hres;
@@ -1973,7 +1973,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc jsval_t r;
if(prop) - hres = prop_get(This, prop, &r); + hres = prop_get(This, to_disp(This), prop, &r); else { hres = to_primitive(This->ctx, jsval_obj(This), &r, NO_HINT); if(hres == JS_E_TO_PRIMITIVE) @@ -2305,7 +2305,7 @@ HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const built if(SUCCEEDED(hres) && prop && prop->type!=PROP_DELETED) { jsval_t val;
- hres = prop_get(constr, prop, &val); + hres = prop_get(constr, to_disp(constr), prop, &val); if(FAILED(hres)) { ERR("Could not get prototype\n"); return hres; @@ -2754,7 +2754,7 @@ HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val) return S_OK; }
- return prop_get(obj, prop, val); + return prop_get(obj, to_disp(obj), prop, val); }
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r) @@ -2774,7 +2774,7 @@ HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r) return DISP_E_UNKNOWNNAME; }
- return prop_get(obj, prop, r); + return prop_get(obj, to_disp(obj), prop, r); }
HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val) @@ -2785,7 +2785,7 @@ HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val) if(!prop) return DISP_E_MEMBERNOTFOUND;
- return prop_get(jsdisp, prop, val); + return prop_get(jsdisp, to_disp(jsdisp), prop, val); }
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val) @@ -2981,7 +2981,7 @@ HRESULT jsdisp_get_own_property(jsdisp_t *obj, const WCHAR *name, BOOL flags_onl desc->mask |= PROPF_WRITABLE; desc->explicit_value = TRUE; if(!flags_only) { - hres = prop_get(obj, prop, &desc->value); + hres = prop_get(obj, to_disp(obj), prop, &desc->value); if(FAILED(hres)) return hres; } diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index e86ab1dbe77..cef3c77c207 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -794,6 +794,7 @@ sync_test("defineProperty", function() { /* call prop with getter */ desc = { get: function() { + ok(this === obj, "this != obj"); return function(x) { ok(x === 100, "x = " + x); return 10; @@ -804,6 +805,10 @@ sync_test("defineProperty", function() { test_accessor_prop_desc(obj, "funcprop", desc); ok(obj.funcprop(100) === 10, "obj.funcprop() = " + obj.funcprop(100));
+ Object.defineProperty(child.prototype, "funcprop_prot", desc); + test_accessor_prop_desc(child.prototype, "funcprop_prot", desc); + ok(obj.funcprop_prot(100) === 10, "obj.funcprop_prot() = " + obj.funcprop_prot(100)); + expect_exception(function() { Object.defineProperty(null, "funcprop", desc); }, JS_E_OBJECT_EXPECTED);
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Since they act like values.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 2 +- dlls/mshtml/tests/es5.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 0dd575434c1..ef72860f627 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -454,7 +454,7 @@ static HRESULT prop_get(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t *prop,
switch(prop->type) { case PROP_BUILTIN: - hres = prop->u.p->getter(This->ctx, This, r); + hres = prop->u.p->getter(This->ctx, prop_obj, r); break; case PROP_JSVAL: hres = jsval_copy(prop->u.val, r); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index cef3c77c207..38a70740698 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -1720,6 +1720,9 @@ sync_test("builtin_context", function() { ok(obj === window, "obj = " + obj); obj = (function() { return this; }).call(42); ok(obj.valueOf() === 42, "obj = " + obj); + + obj = Object.create([100]); + ok(obj.length === 1, "obj.length = " + obj.length); });
sync_test("host this", function() {
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=135479
Your paranoid android.
=== w864 (64 bit report) ===
mshtml: script.c:1126: Test failed: L"/index.html?xhr.js: async_xhr.readyState = 1" script.c:1126: Test failed: L"/index.html?xhr.js: async_xhr.readyState = 1" script.c:1126: Test failed: L"/index.html?xhr.js: async_xhr2.readyState = 4" script.c:1126: Test failed: L"/index.html?xhr.js: async_xhr2.readyState = 4" script.c:1126: Test failed: L"/index.html?xhr.js: unexpected order: 0,1,2,3,sync_xhr(4),nested(4),4,async_xhr2(3),async_xhr2(4),async_xhr(3),async_xhr(4),sync_xhr_in_async,msg1,msg2,msg_sync,msg_nested,msg_async,timeout,timeout_sync,timeout_nested"
This merge request was approved by Jacek Caban.