Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 9 +++++++-- dlls/jscript/tests/run.c | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index e64a520..cc46ee0 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1548,7 +1548,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc V_VT(pvarRes) = VT_EMPTY;
prop = get_prop(This, id); - if(!prop || prop->type == PROP_DELETED) { + if((!prop || prop->type == PROP_DELETED) && (id != DISPID_VALUE || wFlags != DISPATCH_PROPERTYGET)) { TRACE("invalid id\n"); return DISP_E_MEMBERNOTFOUND; } @@ -1580,7 +1580,12 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc case DISPATCH_PROPERTYGET: { jsval_t r;
- hres = prop_get(This, prop, &r); + hres = E_FAIL; + if(id == DISPID_VALUE) + hres = to_primitive(This->ctx, jsval_obj(This), &r, NO_HINT); + if(FAILED(hres)) + hres = prop_get(This, prop, &r); + if(SUCCEEDED(hres)) { hres = jsval_to_variant(r, pvarRes); jsval_release(r); diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c index ef0f39f..c71e550 100644 --- a/dlls/jscript/tests/run.c +++ b/dlls/jscript/tests/run.c @@ -2789,6 +2789,7 @@ static void test_retval(void)
static void test_default_value(void) { + IActiveScript *script; DISPPARAMS dp = {0}; IDispatch *disp; VARIANT v; @@ -2806,9 +2807,49 @@ static void test_default_value(void) { ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); } + VariantClear(&v); + IDispatch_Release(disp); + + hres = parse_script_expr(L"var arr = [5]; arr.toString = function() {return "foo";}; arr.valueOf = function() {return 42;}; arr", &v, &script); + ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + disp = V_DISPATCH(&v);
+ V_VT(&v) = VT_EMPTY; + hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL); + ok(hres == S_OK, "Invoke failed: %08x\n", hres); + ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v)); + ok(V_I4(&v) == 42, "V_I4(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + IDispatch_Release(disp); + close_script(script); + + hres = parse_script_expr(L"var arr = [5]; arr.toString = function() {return "foo";}; arr", &v, &script); + ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + disp = V_DISPATCH(&v); + + V_VT(&v) = VT_EMPTY; + hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL); + ok(hres == S_OK, "Invoke failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), L"foo"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + IDispatch_Release(disp); + close_script(script); + + hres = parse_script_expr(L"var arr = [5]; arr", &v, &script); + ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + disp = V_DISPATCH(&v); + + V_VT(&v) = VT_EMPTY; + hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL); + ok(hres == S_OK, "Invoke failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), L"5"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); IDispatch_Release(disp); + close_script(script); }
static void test_script_exprs(void)