From c78e87365225bd040f374dc41e32bcd4ae77aa6d Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 4 Jun 2018 03:53:02 +0100 Subject: [PATCH] [VBSCRIPT_WINETEST] Sync with Wine Staging 3.9. CORE-14656 --- modules/rostests/winetests/vbscript/run.c | 73 ++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/modules/rostests/winetests/vbscript/run.c b/modules/rostests/winetests/vbscript/run.c index ee811c6e5b2..6b57540fe83 100644 --- a/modules/rostests/winetests/vbscript/run.c +++ b/modules/rostests/winetests/vbscript/run.c @@ -974,6 +974,18 @@ static IDispatchExVtbl RefObjVtbl = { static IDispatchEx RefObj = { &RefObjVtbl }; +static ULONG global_ref; + +static ULONG WINAPI Global_AddRef(IDispatchEx *iface) +{ + return ++global_ref; +} + +static ULONG WINAPI Global_Release(IDispatchEx *iface) +{ + return --global_ref; +} + static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) { if(!strcmp_wa(bstrName, "ok")) { @@ -1476,8 +1488,8 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, static IDispatchExVtbl GlobalVtbl = { DispatchEx_QueryInterface, - DispatchEx_AddRef, - DispatchEx_Release, + Global_AddRef, + Global_Release, DispatchEx_GetTypeInfoCount, DispatchEx_GetTypeInfo, DispatchEx_GetIDsOfNames, @@ -1619,6 +1631,7 @@ static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPC ok(0, "unexpected pstrName %s\n", wine_dbgstr_w(pstrName)); *ppiunkItem = (IUnknown*)&Global; + IUnknown_AddRef(*ppiunkItem); return S_OK; } @@ -1804,6 +1817,61 @@ static HRESULT parse_script_ar(const char *src) return hres; } +static void test_parse_context(void) +{ + IActiveScriptParse *parser; + IActiveScript *engine; + BSTR str; + HRESULT hres; + + static const WCHAR xW[] = {'x',0}; + static const WCHAR yW[] = {'y',0}; + + global_ref = 1; + engine = create_and_init_script(0); + if(!engine) + return; + + hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser); + ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); + + /* unknown identifier context is not a valid argument */ + str = a2bstr("Call reportSuccess()\n"); + hres = IActiveScriptParse_ParseScriptText(parser, str, yW, NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == E_INVALIDARG, "ParseScriptText failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("class Cl\n" + " Public Sub ClMethod\n" + " Call reportSuccess()\n" + " End Sub\n" + "End Class\n" + "Dim x\n" + "set x = new Cl\n"); + hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + SysFreeString(str); + + /* known global variable is not a valid context */ + str = a2bstr("Call reportSuccess()\n"); + hres = IActiveScriptParse_ParseScriptText(parser, str, xW, NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == E_INVALIDARG, "ParseScriptText failed: %08x\n", hres); + SysFreeString(str); + + SET_EXPECT(global_success_d); + SET_EXPECT(global_success_i); + str = a2bstr("Call reportSuccess()\n"); + hres = IActiveScriptParse_ParseScriptText(parser, str, testW, NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + SysFreeString(str); + CHECK_CALLED(global_success_d); + CHECK_CALLED(global_success_i); + + IActiveScriptParse_Release(parser); + close_script(engine); + ok(global_ref == 1, "global_ref = %u\n", global_ref); +} + static void parse_script_a(const char *src) { parse_script_af(SCRIPTITEM_GLOBALMEMBERS, src); @@ -2334,6 +2402,7 @@ static void run_tests(void) test_procedures(); test_gc(); test_msgbox(); + test_parse_context(); } static BOOL check_vbscript(void) -- 2.17.1