mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 05:57:27 +00:00
jscript/tests: Add initial tests for the script TypeInfo.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2e3ebd64e7
commit
cf7a432df5
|
@ -33,6 +33,8 @@
|
|||
#define IActiveScriptParse_Release IActiveScriptParse64_Release
|
||||
#define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
|
||||
#define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
|
||||
#define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_64_Release
|
||||
#define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_64_ParseProcedureText
|
||||
|
||||
#else
|
||||
|
||||
|
@ -40,10 +42,13 @@
|
|||
#define IActiveScriptParse_Release IActiveScriptParse32_Release
|
||||
#define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
|
||||
#define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
|
||||
#define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_32_Release
|
||||
#define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_32_ParseProcedureText
|
||||
|
||||
#endif
|
||||
|
||||
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
||||
DEFINE_GUID(IID_IScriptTypeInfo, 0xc59c6b12, 0xf6c1, 0x11cf, 0x88,0x35, 0x00,0xa0,0xc9,0x11,0xe8,0xb2);
|
||||
|
||||
static const CLSID CLSID_JScript =
|
||||
{0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
|
||||
|
@ -274,6 +279,20 @@ static IDispatchEx *get_script_dispatch(IActiveScript *script)
|
|||
return dispex;
|
||||
}
|
||||
|
||||
static void parse_script(IActiveScriptParse *parser, const WCHAR *src)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
SET_EXPECT(OnEnterScript);
|
||||
SET_EXPECT(OnLeaveScript);
|
||||
|
||||
hres = IActiveScriptParse_ParseScriptText(parser, src, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
|
||||
ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
|
||||
|
||||
CHECK_CALLED(OnEnterScript);
|
||||
CHECK_CALLED(OnLeaveScript);
|
||||
}
|
||||
|
||||
#define get_disp_id(a,b,c,d) _get_disp_id(__LINE__,a,b,c,d)
|
||||
static void _get_disp_id(unsigned line, IDispatchEx *dispex, const WCHAR *name, HRESULT exhr, DISPID *id)
|
||||
{
|
||||
|
@ -907,6 +926,347 @@ static void test_code_persistence(void)
|
|||
CHECK_CALLED(OnStateChange_CLOSED);
|
||||
}
|
||||
|
||||
static void test_typeinfo(const WCHAR *parse_func_name)
|
||||
{
|
||||
static struct
|
||||
{
|
||||
const WCHAR *name;
|
||||
UINT num_args;
|
||||
} func[] =
|
||||
{
|
||||
{ L"emptyfn", 0 },
|
||||
{ L"voidfn", 0 },
|
||||
{ L"math", 2 },
|
||||
{ L"foobar", 1 },
|
||||
{ L"C", 0 },
|
||||
{ L"funcvar", 2 },
|
||||
{ L"f1", 1 },
|
||||
{ L"f2", 1 }
|
||||
};
|
||||
static struct
|
||||
{
|
||||
const WCHAR *name;
|
||||
} var[] =
|
||||
{
|
||||
{ L"global_var" },
|
||||
{ L"uninit" },
|
||||
{ L"obj" }
|
||||
};
|
||||
const WCHAR *source = L""
|
||||
"var global_var = 42;\n"
|
||||
|
||||
"function emptyfn() { }\n"
|
||||
"function voidfn() { return void(0); }\n"
|
||||
"function math(x, y) { return x - y; }\n"
|
||||
"function foobar(x) { return \"foobar\"; }\n"
|
||||
|
||||
"function C() {\n"
|
||||
" this.x;\n"
|
||||
" this.strret = function() { return \"ret\"; }\n"
|
||||
"}\n"
|
||||
|
||||
"var uninit;\n"
|
||||
"var obj = new C();\n"
|
||||
|
||||
"var funcvar = function(x, y) { return x * y; };\n"
|
||||
"var native_func = decodeURI;\n"
|
||||
|
||||
"(function() {\n"
|
||||
" f1 = function infuncexpr(x) { return 1; }\n"
|
||||
" f2 = function infuncexpr(x) { return 2; }\n"
|
||||
"})();\n";
|
||||
UINT expected_funcs_cnt = parse_func_name ? 0 : ARRAY_SIZE(func);
|
||||
UINT expected_vars_cnt = parse_func_name ? 0 : ARRAY_SIZE(var);
|
||||
|
||||
ITypeInfo *typeinfo, *typeinfo2;
|
||||
ITypeComp *typecomp, *typecomp2;
|
||||
IActiveScriptParse *parser;
|
||||
IActiveScript *script;
|
||||
FUNCDESC *funcdesc;
|
||||
VARDESC *vardesc;
|
||||
IDispatchEx *disp;
|
||||
DESCKIND desckind;
|
||||
BINDPTR bindptr;
|
||||
MEMBERID memid;
|
||||
TYPEATTR *attr;
|
||||
UINT index;
|
||||
HRESULT hr;
|
||||
WCHAR str[64], *names = str;
|
||||
int i;
|
||||
|
||||
if (parse_func_name)
|
||||
trace("Testing TypeInfo for function %s...\n", wine_dbgstr_w(parse_func_name));
|
||||
else
|
||||
trace("Testing TypeInfo for script dispatch...\n");
|
||||
|
||||
script = create_jscript();
|
||||
|
||||
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
|
||||
ok(hr == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hr);
|
||||
|
||||
SET_EXPECT(GetLCID);
|
||||
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
|
||||
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
|
||||
CHECK_CALLED(GetLCID);
|
||||
|
||||
SET_EXPECT(OnStateChange_INITIALIZED);
|
||||
hr = IActiveScriptParse_InitNew(parser);
|
||||
ok(hr == S_OK, "InitNew failed: %08x\n", hr);
|
||||
CHECK_CALLED(OnStateChange_INITIALIZED);
|
||||
|
||||
SET_EXPECT(OnStateChange_CONNECTED);
|
||||
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
|
||||
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
|
||||
CHECK_CALLED(OnStateChange_CONNECTED);
|
||||
|
||||
if (parse_func_name)
|
||||
{
|
||||
IActiveScriptParseProcedure2 *parse_proc;
|
||||
IDispatch *proc_disp;
|
||||
|
||||
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
|
||||
ok(hr == S_OK, "Could not get IActiveScriptParse: %08x\n", hr);
|
||||
|
||||
hr = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, source, NULL, parse_func_name,
|
||||
NULL, NULL, NULL, 0, 0, SCRIPTPROC_IMPLICIT_THIS | SCRIPTPROC_IMPLICIT_PARENTS, &proc_disp);
|
||||
ok(hr == S_OK, "ParseProcedureText failed: %08x\n", hr);
|
||||
IActiveScriptParseProcedure2_Release(parse_proc);
|
||||
|
||||
hr = IDispatch_QueryInterface(proc_disp, &IID_IDispatchEx, (void**)&disp);
|
||||
ok(hr == S_OK, "Could not get IDispatchEx: %08x\n", hr);
|
||||
IDispatch_Release(proc_disp);
|
||||
}
|
||||
else
|
||||
{
|
||||
parse_script(parser, source);
|
||||
disp = get_script_dispatch(script);
|
||||
}
|
||||
|
||||
hr = IDispatchEx_QueryInterface(disp, &IID_ITypeInfo, (void**)&typeinfo);
|
||||
ok(hr == E_NOINTERFACE, "QueryInterface(IID_ITypeInfo) returned: %08x\n", hr);
|
||||
hr = IDispatchEx_GetTypeInfo(disp, 1, LOCALE_USER_DEFAULT, &typeinfo);
|
||||
ok(hr == DISP_E_BADINDEX, "GetTypeInfo returned: %08x\n", hr);
|
||||
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo);
|
||||
ok(hr == S_OK, "GetTypeInfo failed: %08x\n", hr);
|
||||
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo2);
|
||||
ok(hr == S_OK, "GetTypeInfo failed: %08x\n", hr);
|
||||
ok(typeinfo != typeinfo2, "TypeInfo was not supposed to be shared.\n");
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
|
||||
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
||||
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
||||
ok(IsEqualGUID(&attr->guid, &IID_IScriptTypeInfo), "Unexpected GUID %s\n", wine_dbgstr_guid(&attr->guid));
|
||||
ok(attr->lcid == LOCALE_USER_DEFAULT, "Unexpected LCID %u\n", attr->lcid);
|
||||
ok(attr->memidConstructor == MEMBERID_NIL, "Unexpected constructor memid %u\n", attr->memidConstructor);
|
||||
ok(attr->memidDestructor == MEMBERID_NIL, "Unexpected destructor memid %u\n", attr->memidDestructor);
|
||||
ok(attr->cbSizeInstance == 4, "Unexpected cbSizeInstance %u\n", attr->cbSizeInstance);
|
||||
ok(attr->typekind == TKIND_DISPATCH, "Unexpected typekind %u\n", attr->typekind);
|
||||
ok(attr->cFuncs == expected_funcs_cnt, "Unexpected cFuncs %u\n", attr->cFuncs);
|
||||
ok(attr->cVars == expected_vars_cnt, "Unexpected cVars %u\n", attr->cVars);
|
||||
ok(attr->cImplTypes == 1, "Unexpected cImplTypes %u\n", attr->cImplTypes);
|
||||
ok(attr->cbSizeVft == sizeof(IDispatchVtbl), "Unexpected cbSizeVft %u\n", attr->cbSizeVft);
|
||||
ok(attr->cbAlignment == 4, "Unexpected cbAlignment %u\n", attr->cbAlignment);
|
||||
ok(attr->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "Unexpected wTypeFlags 0x%x\n", attr->wTypeFlags);
|
||||
ok(attr->tdescAlias.vt == VT_EMPTY, "Unexpected tdescAlias.vt %d\n", attr->tdescAlias.vt);
|
||||
ok(attr->idldescType.wIDLFlags == IDLFLAG_NONE, "Unexpected idldescType.wIDLFlags 0x%x\n", attr->idldescType.wIDLFlags);
|
||||
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
||||
|
||||
/* GetIDsOfNames looks into the inherited types as well */
|
||||
wcscpy(str, L"queryinterface");
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, NULL, 1, &memid);
|
||||
ok(hr == E_INVALIDARG, "GetIDsOfNames returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetIDsOfNames returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 0, &memid);
|
||||
ok(hr == E_INVALIDARG, "GetIDsOfNames returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
||||
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
||||
ok(!lstrcmpW(str, L"queryinterface"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
||||
if (expected_funcs_cnt)
|
||||
{
|
||||
wcscpy(str, L"Math");
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
||||
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
||||
ok(!lstrcmpW(str, L"Math"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
||||
}
|
||||
|
||||
/* Check variable descriptions */
|
||||
hr = ITypeInfo_GetVarDesc(typeinfo, 0, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetVarDesc returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetVarDesc(typeinfo, 1337, &vardesc);
|
||||
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetVarDesc returned: %08x\n", hr);
|
||||
for (i = 0; i < expected_vars_cnt; i++)
|
||||
{
|
||||
hr = ITypeInfo_GetVarDesc(typeinfo, i, &vardesc);
|
||||
ok(hr == S_OK, "GetVarDesc(%u) failed: %08x\n", i, hr);
|
||||
ok(vardesc->memid <= 0xFFFF, "[%u] Unexpected memid 0x%x\n", i, vardesc->memid);
|
||||
ok(vardesc->lpstrSchema == NULL, "[%u] Unexpected lpstrSchema %p\n", i, vardesc->lpstrSchema);
|
||||
ok(vardesc->oInst == 0, "[%u] Unexpected oInst %u\n", i, vardesc->oInst);
|
||||
ok(vardesc->varkind == VAR_DISPATCH, "[%u] Unexpected varkind %d\n", i, vardesc->varkind);
|
||||
ok(vardesc->wVarFlags == 0, "[%u] Unexpected wVarFlags 0x%x\n", i, vardesc->wVarFlags);
|
||||
ok(vardesc->elemdescVar.tdesc.vt == VT_VARIANT,
|
||||
"[%u] Unexpected variable type vt %d (expected %d)\n", i, vardesc->elemdescVar.tdesc.vt, 0);
|
||||
ok(vardesc->elemdescVar.paramdesc.pparamdescex == NULL,
|
||||
"[%u] Unexpected variable type pparamdescex %p\n", i, vardesc->elemdescVar.paramdesc.pparamdescex);
|
||||
ok(vardesc->elemdescVar.paramdesc.wParamFlags == PARAMFLAG_NONE,
|
||||
"[%u] Unexpected variable type wParamFlags 0x%x\n", i, vardesc->elemdescVar.paramdesc.wParamFlags);
|
||||
ITypeInfo_ReleaseVarDesc(typeinfo, vardesc);
|
||||
}
|
||||
|
||||
/* Check function descriptions */
|
||||
hr = ITypeInfo_GetFuncDesc(typeinfo, 0, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetFuncDesc returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetFuncDesc(typeinfo, 1337, &funcdesc);
|
||||
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetFuncDesc returned: %08x\n", hr);
|
||||
for (i = 0; i < expected_funcs_cnt; i++)
|
||||
{
|
||||
hr = ITypeInfo_GetFuncDesc(typeinfo, i, &funcdesc);
|
||||
ok(hr == S_OK, "GetFuncDesc(%u) failed: %08x\n", i, hr);
|
||||
ok(funcdesc->memid <= 0xFFFF, "[%u] Unexpected memid 0x%x\n", i, funcdesc->memid);
|
||||
ok(funcdesc->lprgscode == NULL, "[%u] Unexpected lprgscode %p\n", i, funcdesc->lprgscode);
|
||||
ok(func[i].num_args ? (funcdesc->lprgelemdescParam != NULL) : (funcdesc->lprgelemdescParam == NULL),
|
||||
"[%u] Unexpected lprgelemdescParam %p\n", i, funcdesc->lprgelemdescParam);
|
||||
ok(funcdesc->funckind == FUNC_DISPATCH, "[%u] Unexpected funckind %u\n", i, funcdesc->funckind);
|
||||
ok(funcdesc->invkind == INVOKE_FUNC, "[%u] Unexpected invkind %u\n", i, funcdesc->invkind);
|
||||
ok(funcdesc->callconv == CC_STDCALL, "[%u] Unexpected callconv %u\n", i, funcdesc->callconv);
|
||||
ok(funcdesc->cParams == func[i].num_args, "[%u] Unexpected cParams %d (expected %d)\n",
|
||||
i, funcdesc->cParams, func[i].num_args);
|
||||
ok(funcdesc->cParamsOpt == 0, "[%u] Unexpected cParamsOpt %d\n", i, funcdesc->cParamsOpt);
|
||||
ok(funcdesc->cScodes == 0, "[%u] Unexpected cScodes %d\n", i, funcdesc->cScodes);
|
||||
ok(funcdesc->wFuncFlags == 0, "[%u] Unexpected wFuncFlags 0x%x\n", i, funcdesc->wFuncFlags);
|
||||
ok(funcdesc->elemdescFunc.tdesc.vt == VT_VARIANT,
|
||||
"[%u] Unexpected return type vt %d\n", i, funcdesc->elemdescFunc.tdesc.vt);
|
||||
ok(funcdesc->elemdescFunc.paramdesc.pparamdescex == NULL,
|
||||
"[%u] Unexpected return type pparamdescex %p\n", i, funcdesc->elemdescFunc.paramdesc.pparamdescex);
|
||||
ok(funcdesc->elemdescFunc.paramdesc.wParamFlags == PARAMFLAG_NONE,
|
||||
"[%u] Unexpected return type wParamFlags 0x%x\n", i, funcdesc->elemdescFunc.paramdesc.wParamFlags);
|
||||
if (funcdesc->lprgelemdescParam)
|
||||
for (index = 0; index < funcdesc->cParams; index++)
|
||||
{
|
||||
ok(funcdesc->lprgelemdescParam[index].tdesc.vt == VT_VARIANT,
|
||||
"[%u] Unexpected parameter %u vt %d\n", i, index, funcdesc->lprgelemdescParam[index].tdesc.vt);
|
||||
ok(funcdesc->lprgelemdescParam[index].paramdesc.pparamdescex == NULL,
|
||||
"[%u] Unexpected parameter %u pparamdescex %p\n", i, index, funcdesc->lprgelemdescParam[index].paramdesc.pparamdescex);
|
||||
ok(funcdesc->lprgelemdescParam[index].paramdesc.wParamFlags == PARAMFLAG_NONE,
|
||||
"[%u] Unexpected parameter %u wParamFlags 0x%x\n", i, index, funcdesc->lprgelemdescParam[index].paramdesc.wParamFlags);
|
||||
}
|
||||
ITypeInfo_ReleaseFuncDesc(typeinfo, funcdesc);
|
||||
}
|
||||
|
||||
/* Test TypeComp Binds */
|
||||
hr = ITypeInfo_QueryInterface(typeinfo, &IID_ITypeComp, (void**)&typecomp);
|
||||
ok(hr == S_OK, "QueryInterface(IID_ITypeComp) failed: %08x\n", hr);
|
||||
hr = ITypeInfo_GetTypeComp(typeinfo, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetTypeComp returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetTypeComp(typeinfo, &typecomp2);
|
||||
ok(hr == S_OK, "GetTypeComp failed: %08x\n", hr);
|
||||
ok(typecomp == typecomp2, "QueryInterface(IID_ITypeComp) and GetTypeComp returned different TypeComps\n");
|
||||
ITypeComp_Release(typecomp2);
|
||||
wcscpy(str, L"not_found");
|
||||
hr = ITypeComp_Bind(typecomp, NULL, 0, 0, &typeinfo2, &desckind, &bindptr);
|
||||
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, 0, NULL, &desckind, &bindptr);
|
||||
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, NULL, &bindptr);
|
||||
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, &desckind, NULL);
|
||||
ok(hr == E_INVALIDARG, "Bind returned: %08x\n", hr);
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, &desckind, &bindptr);
|
||||
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
||||
ok(desckind == DESCKIND_NONE, "Unexpected desckind %u\n", desckind);
|
||||
wcscpy(str, L"addRef");
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, 0, &typeinfo2, &desckind, &bindptr);
|
||||
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
||||
ok(desckind == DESCKIND_FUNCDESC, "Unexpected desckind %u\n", desckind);
|
||||
ok(!lstrcmpW(str, L"addRef"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
||||
ITypeInfo_ReleaseFuncDesc(typeinfo2, bindptr.lpfuncdesc);
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
for (i = 0; i < expected_vars_cnt; i++)
|
||||
{
|
||||
wcscpy(str, var[i].name);
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, INVOKE_PROPERTYGET, &typeinfo2, &desckind, &bindptr);
|
||||
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
||||
ok(desckind == DESCKIND_VARDESC, "Unexpected desckind %u\n", desckind);
|
||||
ITypeInfo_ReleaseVarDesc(typeinfo2, bindptr.lpvardesc);
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
}
|
||||
for (i = 0; i < expected_funcs_cnt; i++)
|
||||
{
|
||||
wcscpy(str, func[i].name);
|
||||
hr = ITypeComp_Bind(typecomp, str, 0, INVOKE_FUNC, &typeinfo2, &desckind, &bindptr);
|
||||
ok(hr == S_OK, "Bind failed: %08x\n", hr);
|
||||
ok(desckind == DESCKIND_FUNCDESC, "Unexpected desckind %u\n", desckind);
|
||||
ITypeInfo_ReleaseFuncDesc(typeinfo2, bindptr.lpfuncdesc);
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
}
|
||||
wcscpy(str, L"JScriptTypeInfo");
|
||||
hr = ITypeComp_BindType(typecomp, NULL, 0, &typeinfo2, &typecomp2);
|
||||
ok(hr == E_INVALIDARG, "BindType returned: %08x\n", hr);
|
||||
hr = ITypeComp_BindType(typecomp, str, 0, NULL, &typecomp2);
|
||||
ok(hr == E_INVALIDARG, "BindType returned: %08x\n", hr);
|
||||
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, NULL);
|
||||
ok(hr == E_INVALIDARG, "BindType returned: %08x\n", hr);
|
||||
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, &typecomp2);
|
||||
ok(hr == S_OK, "BindType failed: %08x\n", hr);
|
||||
ok(!typeinfo2, "Unexpected TypeInfo %p (expected null)\n", typeinfo2);
|
||||
ok(!typecomp2, "Unexpected TypeComp %p (expected null)\n", typecomp2);
|
||||
wcscpy(str, L"C");
|
||||
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, &typecomp2);
|
||||
ok(hr == S_OK, "BindType failed: %08x\n", hr);
|
||||
ok(!typeinfo2, "Unexpected TypeInfo %p (expected null)\n", typeinfo2);
|
||||
ok(!typecomp2, "Unexpected TypeComp %p (expected null)\n", typecomp2);
|
||||
wcscpy(str, L"IDispatch");
|
||||
hr = ITypeComp_BindType(typecomp, str, 0, &typeinfo2, &typecomp2);
|
||||
ok(hr == S_OK, "BindType failed: %08x\n", hr);
|
||||
ok(!typeinfo2, "Unexpected TypeInfo %p (expected null)\n", typeinfo2);
|
||||
ok(!typecomp2, "Unexpected TypeComp %p (expected null)\n", typecomp2);
|
||||
ITypeComp_Release(typecomp);
|
||||
|
||||
/* Updating the script won't update the typeinfo obtained before,
|
||||
but it will be reflected in any typeinfo obtained afterwards. */
|
||||
if (!parse_func_name)
|
||||
{
|
||||
parse_script(parser, L""
|
||||
"var new_var;\n"
|
||||
"function new_func() { }\n");
|
||||
|
||||
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo2);
|
||||
ok(hr == S_OK, "GetTypeInfo failed: %08x\n", hr);
|
||||
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
||||
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
||||
ok(attr->cFuncs == expected_funcs_cnt, "Unexpected cFuncs %u\n", attr->cFuncs);
|
||||
ok(attr->cVars == expected_vars_cnt, "Unexpected cVars %u\n", attr->cVars);
|
||||
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
||||
hr = ITypeInfo_GetTypeAttr(typeinfo2, &attr);
|
||||
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
||||
ok(attr->cFuncs == expected_funcs_cnt + 1, "Unexpected cFuncs %u\n", attr->cFuncs);
|
||||
ok(attr->cVars == expected_vars_cnt + 1, "Unexpected cVars %u\n", attr->cVars);
|
||||
ITypeInfo_ReleaseTypeAttr(typeinfo2, attr);
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
|
||||
/* Adding an identifier that differs only in case gives an error
|
||||
when retrieving the TypeInfo, even though it is valid jscript. */
|
||||
parse_script(parser, L"var NEW_FUNC;\n");
|
||||
hr = IDispatchEx_GetTypeInfo(disp, 0, LOCALE_USER_DEFAULT, &typeinfo2);
|
||||
ok(hr == TYPE_E_AMBIGUOUSNAME, "GetTypeInfo returned: %08x\n", hr);
|
||||
}
|
||||
|
||||
ITypeInfo_Release(typeinfo);
|
||||
IDispatchEx_Release(disp);
|
||||
IActiveScriptParse_Release(parser);
|
||||
|
||||
SET_EXPECT(OnStateChange_DISCONNECTED);
|
||||
SET_EXPECT(OnStateChange_INITIALIZED);
|
||||
SET_EXPECT(OnStateChange_CLOSED);
|
||||
hr = IActiveScript_Close(script);
|
||||
ok(hr == S_OK, "Close failed: %08x\n", hr);
|
||||
CHECK_CALLED(OnStateChange_DISCONNECTED);
|
||||
CHECK_CALLED(OnStateChange_INITIALIZED);
|
||||
CHECK_CALLED(OnStateChange_CLOSED);
|
||||
|
||||
IActiveScript_Release(script);
|
||||
}
|
||||
|
||||
static BOOL check_jscript(void)
|
||||
{
|
||||
IActiveScriptProperty *script_prop;
|
||||
|
@ -931,6 +1291,8 @@ START_TEST(jscript)
|
|||
test_jscript_uninitializing();
|
||||
test_aggregation();
|
||||
test_code_persistence();
|
||||
test_typeinfo(NULL);
|
||||
test_typeinfo(L"some_func_name");
|
||||
|
||||
trace("Testing JScriptEncode object...\n");
|
||||
engine_clsid = &CLSID_JScriptEncode;
|
||||
|
|
Loading…
Reference in a new issue