jscript: Correctly handle forin statement on pure IDispatch object.

This commit is contained in:
Jacek Caban 2011-06-21 17:45:50 +02:00 committed by Alexandre Julliard
parent 3d56d674aa
commit 42c2bd7bd9
3 changed files with 51 additions and 2 deletions

View File

@ -884,8 +884,9 @@ HRESULT forin_statement_eval(script_ctx_t *ctx, statement_t *_stat, return_type_
hres = IDispatch_QueryInterface(V_DISPATCH(&val), &IID_IDispatchEx, (void**)&in_obj);
IDispatch_Release(V_DISPATCH(&val));
if(FAILED(hres)) {
FIXME("Object doesn't support IDispatchEx\n");
return E_NOTIMPL;
TRACE("Object doesn't support IDispatchEx\n");
V_VT(ret) = VT_EMPTY;
return S_OK;
}
V_VT(&retv) = VT_EMPTY;

View File

@ -205,6 +205,9 @@ for(var iter in null)
for(var iter in false)
ok(false, "unexpected forin call, test = " + iter);
for(var iter in pureDisp)
ok(false, "unexpected forin call in pureDisp object");
tmp = 0;
if(true)
tmp = 1;

View File

@ -90,6 +90,7 @@ DEFINE_EXPECT(invoke_func);
#define DISPID_GLOBAL_PROPGETFUNC 0x100d
#define DISPID_GLOBAL_OBJECT_FLAG 0x100e
#define DISPID_GLOBAL_ISWIN64 0x100f
#define DISPID_GLOBAL_PUREDISP 0x1010
#define DISPID_TESTOBJ_PROP 0x2000
#define DISPID_TESTOBJ_ONLYDISPID 0x2001
@ -324,6 +325,29 @@ static IDispatchExVtbl testObjVtbl = {
static IDispatchEx testObj = { &testObjVtbl };
static HRESULT WINAPI pureDisp_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch)) {
*ppv = iface;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
static IDispatchExVtbl pureDispVtbl = {
pureDisp_QueryInterface,
DispatchEx_AddRef,
DispatchEx_Release,
DispatchEx_GetTypeInfoCount,
DispatchEx_GetTypeInfo,
DispatchEx_GetIDsOfNames,
DispatchEx_Invoke
};
static IDispatchEx pureDisp = { &pureDispVtbl };
static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
{
if(!strcmp_wa(bstrName, "ok")) {
@ -417,6 +441,12 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
return S_OK;
}
if(!strcmp_wa(bstrName, "pureDisp")) {
test_grfdex(grfdex, fdexNameCaseSensitive);
*pid = DISPID_GLOBAL_PUREDISP;
return S_OK;
}
if(strict_dispid_check)
ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
return DISP_E_UNKNOWNNAME;
@ -566,6 +596,21 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
V_DISPATCH(pvarRes) = (IDispatch*)&testObj;
return S_OK;
case DISPID_GLOBAL_PUREDISP:
ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
ok(pdp != NULL, "pdp == NULL\n");
ok(!pdp->rgvarg, "rgvarg != NULL\n");
ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
ok(pvarRes != NULL, "pvarRes == NULL\n");
ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
ok(pei != NULL, "pei == NULL\n");
V_VT(pvarRes) = VT_DISPATCH;
V_DISPATCH(pvarRes) = (IDispatch*)&pureDisp;
return S_OK;
case DISPID_GLOBAL_NULL_BSTR:
if(pvarRes) {
V_VT(pvarRes) = VT_BSTR;