Commit 11f41aa0 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Treat VT_UNKNOWN VARIANTs supporting IDispatch interface as VT_DISPATCH.

parent 61448249
......@@ -315,6 +315,18 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
case VT_INT:
*r = jsval_number(V_INT(var));
return S_OK;
case VT_UNKNOWN:
if(V_UNKNOWN(var)) {
IDispatch *disp;
HRESULT hres;
hres = IUnknown_QueryInterface(V_UNKNOWN(var), &IID_IDispatch, (void**)&disp);
if(SUCCEEDED(hres)) {
*r = jsval_disp(disp);
return S_OK;
}
}
/* fall through */
default:
return jsval_variant(r, var);
}
......
......@@ -125,6 +125,7 @@ DEFINE_EXPECT(DeleteMemberByDispID);
#define DISPID_GLOBAL_GETSHORT 0x1014
#define DISPID_GLOBAL_TESTARGTYPES 0x1015
#define DISPID_GLOBAL_INTPROP 0x1016
#define DISPID_GLOBAL_DISPUNK 0x1017
#define DISPID_GLOBAL_TESTPROPDELETE 0x2000
......@@ -592,6 +593,11 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
return S_OK;
}
if(!strcmp_wa(bstrName, "dispUnk")) {
*pid = DISPID_GLOBAL_DISPUNK;
return S_OK;
}
if(strict_dispid_check && strcmp_wa(bstrName, "t"))
ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
return DISP_E_UNKNOWNNAME;
......@@ -987,8 +993,13 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
V_INT(pvarRes) = 22;
return S_OK;
case DISPID_GLOBAL_DISPUNK:
V_VT(pvarRes) = VT_UNKNOWN;
V_UNKNOWN(pvarRes) = (IUnknown*)&testObj;
return S_OK;
case DISPID_GLOBAL_TESTARGTYPES: {
VARIANT args[2];
VARIANT args[3];
DISPPARAMS dp = {args, NULL, sizeof(args)/sizeof(*args), 0};
HRESULT hres;
......@@ -996,7 +1007,7 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
ok(pdp != NULL, "pdp == NULL\n");
ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
ok(pdp->cArgs == 5, "cArgs = %d\n", pdp->cArgs);
ok(pdp->cArgs == 6, "cArgs = %d\n", pdp->cArgs);
ok(!pvarRes, "pvarRes != NULL\n");
ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
......@@ -1011,12 +1022,17 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
ok(V_VT(pdp->rgvarg+4) == VT_I4, "V_VT(pdp->rgvarg+4) = %d\n", V_VT(pdp->rgvarg+4));
ok(V_I4(pdp->rgvarg+4) == 22, "V_I4(pdp->rgvarg+4) = %d\n", V_I4(pdp->rgvarg+4));
ok(V_VT(pdp->rgvarg+5) == VT_DISPATCH, "V_VT(pdp->rgvarg+5) = %d\n", V_VT(pdp->rgvarg+5));
ok(V_DISPATCH(pdp->rgvarg+5) == (IDispatch*)&testObj, "V_DISPATCH(pdp->rgvarg+5) != testObj\n");
ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
V_VT(args) = VT_I2;
V_I2(args) = 2;
V_VT(args+1) = VT_INT;
V_INT(args+1) = 22;
V_VT(args+2) = VT_UNKNOWN;
V_UNKNOWN(args+2) = (IUnknown*)&testObj;
hres = IDispatch_Invoke(V_DISPATCH(pdp->rgvarg), DISPID_VALUE, &IID_NULL, 0, DISPATCH_METHOD, &dp, NULL, NULL, NULL);
ok(hres == S_OK, "Invoke failed: %08x\n", hres);
......@@ -1839,9 +1855,10 @@ static BOOL run_tests(void)
CHECK_CALLED(global_propargput_i);
SET_EXPECT(global_testargtypes_i);
parse_script_a("testArgTypes(intProp(), intProp, getShort(), shortProp, function(i,s) {"
parse_script_a("testArgTypes(dispUnk, intProp(), intProp, getShort(), shortProp, function(d,i,s) {"
" ok(getVT(i) === 'VT_I4', 'getVT(i) = ' + getVT(i));"
" ok(getVT(s) === 'VT_I4', 'getVT(s) = ' + getVT(s));"
" ok(getVT(d) === 'VT_DISPATCH', 'getVT(d) = ' + getVT(d));"
"});");
CHECK_CALLED(global_testargtypes_i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment