1c2c66affSColin Finck /*
2c2c66affSColin Finck * Copyright 2008 Jacek Caban for CodeWeavers
3c2c66affSColin Finck *
4c2c66affSColin Finck * This library is free software; you can redistribute it and/or
5c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
6c2c66affSColin Finck * License as published by the Free Software Foundation; either
7c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
8c2c66affSColin Finck *
9c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
10c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
11c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12c2c66affSColin Finck * Lesser General Public License for more details.
13c2c66affSColin Finck *
14c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
15c2c66affSColin Finck * License along with this library; if not, write to the Free Software
16c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17c2c66affSColin Finck */
18c2c66affSColin Finck
19c2c66affSColin Finck #include <stdio.h>
20c2c66affSColin Finck
21c2c66affSColin Finck #define COBJMACROS
22c2c66affSColin Finck #define CONST_VTABLE
23c2c66affSColin Finck
24c2c66affSColin Finck #include <ole2.h>
25c2c66affSColin Finck #include <dispex.h>
26c2c66affSColin Finck #include <activscp.h>
27c2c66affSColin Finck
28e68a367aSAmine Khaldi #include "wine/test.h"
29c2c66affSColin Finck
30c2c66affSColin Finck #ifdef _WIN64
31c2c66affSColin Finck
32c2c66affSColin Finck #define IActiveScriptParse_QueryInterface IActiveScriptParse64_QueryInterface
33c2c66affSColin Finck #define IActiveScriptParse_Release IActiveScriptParse64_Release
34c2c66affSColin Finck #define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
35c2c66affSColin Finck #define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
36c2c66affSColin Finck #define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_64_Release
37c2c66affSColin Finck #define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_64_ParseProcedureText
38c2c66affSColin Finck
39c2c66affSColin Finck #else
40c2c66affSColin Finck
41c2c66affSColin Finck #define IActiveScriptParse_QueryInterface IActiveScriptParse32_QueryInterface
42c2c66affSColin Finck #define IActiveScriptParse_Release IActiveScriptParse32_Release
43c2c66affSColin Finck #define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
44c2c66affSColin Finck #define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
45c2c66affSColin Finck #define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_32_Release
46c2c66affSColin Finck #define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_32_ParseProcedureText
47c2c66affSColin Finck
48c2c66affSColin Finck #endif
49c2c66affSColin Finck
50c2c66affSColin Finck static const CLSID CLSID_JScript =
51c2c66affSColin Finck {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
52c2c66affSColin Finck static const CLSID CLSID_JScriptEncode =
53c2c66affSColin Finck {0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
54c2c66affSColin Finck
55c2c66affSColin Finck #define DEFINE_EXPECT(func) \
56c2c66affSColin Finck static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
57c2c66affSColin Finck
58c2c66affSColin Finck #define SET_EXPECT(func) \
59c2c66affSColin Finck expect_ ## func = TRUE
60c2c66affSColin Finck
61c2c66affSColin Finck #define CHECK_EXPECT2(func) \
62c2c66affSColin Finck do { \
63c2c66affSColin Finck ok(expect_ ##func, "unexpected call " #func "\n"); \
64c2c66affSColin Finck called_ ## func = TRUE; \
65c2c66affSColin Finck }while(0)
66c2c66affSColin Finck
67c2c66affSColin Finck #define CHECK_EXPECT(func) \
68c2c66affSColin Finck do { \
69c2c66affSColin Finck CHECK_EXPECT2(func); \
70c2c66affSColin Finck expect_ ## func = FALSE; \
71c2c66affSColin Finck }while(0)
72c2c66affSColin Finck
73c2c66affSColin Finck #define CHECK_CALLED(func) \
74c2c66affSColin Finck do { \
75c2c66affSColin Finck ok(called_ ## func, "expected " #func "\n"); \
76c2c66affSColin Finck expect_ ## func = called_ ## func = FALSE; \
77c2c66affSColin Finck }while(0)
78c2c66affSColin Finck
79c2c66affSColin Finck DEFINE_EXPECT(global_propget_d);
80c2c66affSColin Finck DEFINE_EXPECT(global_propget_i);
81c2c66affSColin Finck DEFINE_EXPECT(global_propput_d);
82c2c66affSColin Finck DEFINE_EXPECT(global_propput_i);
83c2c66affSColin Finck DEFINE_EXPECT(global_propputref_d);
84c2c66affSColin Finck DEFINE_EXPECT(global_propputref_i);
85c2c66affSColin Finck DEFINE_EXPECT(global_propdelete_d);
86c2c66affSColin Finck DEFINE_EXPECT(global_nopropdelete_d);
87c2c66affSColin Finck DEFINE_EXPECT(global_propdeleteerror_d);
88c2c66affSColin Finck DEFINE_EXPECT(global_success_d);
89c2c66affSColin Finck DEFINE_EXPECT(global_success_i);
90c2c66affSColin Finck DEFINE_EXPECT(global_notexists_d);
91c2c66affSColin Finck DEFINE_EXPECT(global_propargput_d);
92c2c66affSColin Finck DEFINE_EXPECT(global_propargput_i);
93021b5c1fSAmine Khaldi DEFINE_EXPECT(global_propargputop_d);
94021b5c1fSAmine Khaldi DEFINE_EXPECT(global_propargputop_get_i);
95021b5c1fSAmine Khaldi DEFINE_EXPECT(global_propargputop_put_i);
96c2c66affSColin Finck DEFINE_EXPECT(global_testargtypes_i);
97021b5c1fSAmine Khaldi DEFINE_EXPECT(global_calleval_i);
98c2c66affSColin Finck DEFINE_EXPECT(puredisp_prop_d);
99c2c66affSColin Finck DEFINE_EXPECT(puredisp_noprop_d);
100c2c66affSColin Finck DEFINE_EXPECT(puredisp_value);
101c2c66affSColin Finck DEFINE_EXPECT(dispexfunc_value);
102c2c66affSColin Finck DEFINE_EXPECT(testobj_delete_test);
103c2c66affSColin Finck DEFINE_EXPECT(testobj_delete_nodelete);
104c2c66affSColin Finck DEFINE_EXPECT(testobj_value);
105c2c66affSColin Finck DEFINE_EXPECT(testobj_construct);
106c2c66affSColin Finck DEFINE_EXPECT(testobj_prop_d);
107c2c66affSColin Finck DEFINE_EXPECT(testobj_withprop_d);
108c2c66affSColin Finck DEFINE_EXPECT(testobj_withprop_i);
109c2c66affSColin Finck DEFINE_EXPECT(testobj_noprop_d);
110c2c66affSColin Finck DEFINE_EXPECT(testobj_onlydispid_d);
111c2c66affSColin Finck DEFINE_EXPECT(testobj_onlydispid_i);
112c2c66affSColin Finck DEFINE_EXPECT(testobj_notexists_d);
113021b5c1fSAmine Khaldi DEFINE_EXPECT(testobj_newenum);
114021b5c1fSAmine Khaldi DEFINE_EXPECT(enumvariant_next_0);
115021b5c1fSAmine Khaldi DEFINE_EXPECT(enumvariant_next_1);
116021b5c1fSAmine Khaldi DEFINE_EXPECT(enumvariant_reset);
117c2c66affSColin Finck DEFINE_EXPECT(GetItemInfo_testVal);
118c2c66affSColin Finck DEFINE_EXPECT(ActiveScriptSite_OnScriptError);
119c2c66affSColin Finck DEFINE_EXPECT(invoke_func);
120c2c66affSColin Finck DEFINE_EXPECT(DeleteMemberByDispID);
121c2c66affSColin Finck DEFINE_EXPECT(DeleteMemberByDispID_false);
122c2c66affSColin Finck DEFINE_EXPECT(DeleteMemberByDispID_error);
123c2c66affSColin Finck DEFINE_EXPECT(BindHandler);
124c2c66affSColin Finck
125c2c66affSColin Finck #define DISPID_GLOBAL_TESTPROPGET 0x1000
126c2c66affSColin Finck #define DISPID_GLOBAL_TESTPROPPUT 0x1001
127c2c66affSColin Finck #define DISPID_GLOBAL_REPORTSUCCESS 0x1002
128c2c66affSColin Finck #define DISPID_GLOBAL_TRACE 0x1003
129c2c66affSColin Finck #define DISPID_GLOBAL_OK 0x1004
130c2c66affSColin Finck #define DISPID_GLOBAL_GETVT 0x1005
131c2c66affSColin Finck #define DISPID_GLOBAL_TESTOBJ 0x1006
132c2c66affSColin Finck #define DISPID_GLOBAL_GETNULLBSTR 0x1007
133c2c66affSColin Finck #define DISPID_GLOBAL_NULL_DISP 0x1008
134c2c66affSColin Finck #define DISPID_GLOBAL_TESTTHIS 0x1009
135c2c66affSColin Finck #define DISPID_GLOBAL_TESTTHIS2 0x100a
136c2c66affSColin Finck #define DISPID_GLOBAL_INVOKEVERSION 0x100b
137c2c66affSColin Finck #define DISPID_GLOBAL_CREATEARRAY 0x100c
138c2c66affSColin Finck #define DISPID_GLOBAL_PROPGETFUNC 0x100d
139c2c66affSColin Finck #define DISPID_GLOBAL_OBJECT_FLAG 0x100e
140c2c66affSColin Finck #define DISPID_GLOBAL_ISWIN64 0x100f
141c2c66affSColin Finck #define DISPID_GLOBAL_PUREDISP 0x1010
142c2c66affSColin Finck #define DISPID_GLOBAL_ISNULLBSTR 0x1011
143c2c66affSColin Finck #define DISPID_GLOBAL_PROPARGPUT 0x1012
144c2c66affSColin Finck #define DISPID_GLOBAL_SHORTPROP 0x1013
145c2c66affSColin Finck #define DISPID_GLOBAL_GETSHORT 0x1014
146c2c66affSColin Finck #define DISPID_GLOBAL_TESTARGTYPES 0x1015
147c2c66affSColin Finck #define DISPID_GLOBAL_INTPROP 0x1016
148c2c66affSColin Finck #define DISPID_GLOBAL_DISPUNK 0x1017
149c2c66affSColin Finck #define DISPID_GLOBAL_TESTRES 0x1018
150c2c66affSColin Finck #define DISPID_GLOBAL_TESTNORES 0x1019
151c2c66affSColin Finck #define DISPID_GLOBAL_DISPEXFUNC 0x101a
152c2c66affSColin Finck #define DISPID_GLOBAL_TESTPROPPUTREF 0x101b
153c2c66affSColin Finck #define DISPID_GLOBAL_GETSCRIPTSTATE 0x101c
154c2c66affSColin Finck #define DISPID_GLOBAL_BINDEVENTHANDLER 0x101d
155021b5c1fSAmine Khaldi #define DISPID_GLOBAL_TESTENUMOBJ 0x101e
156021b5c1fSAmine Khaldi #define DISPID_GLOBAL_CALLEVAL 0x101f
157021b5c1fSAmine Khaldi #define DISPID_GLOBAL_PROPARGPUTOP 0x1020
158c2c66affSColin Finck
159c2c66affSColin Finck #define DISPID_GLOBAL_TESTPROPDELETE 0x2000
160c2c66affSColin Finck #define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001
161c2c66affSColin Finck #define DISPID_GLOBAL_TESTPROPDELETEERROR 0x2002
162c2c66affSColin Finck
163c2c66affSColin Finck #define DISPID_TESTOBJ_PROP 0x2000
164c2c66affSColin Finck #define DISPID_TESTOBJ_ONLYDISPID 0x2001
165c2c66affSColin Finck #define DISPID_TESTOBJ_WITHPROP 0x2002
166c2c66affSColin Finck
167c2c66affSColin Finck #define JS_E_OUT_OF_MEMORY 0x800a03ec
168c2c66affSColin Finck #define JS_E_INVALID_CHAR 0x800a03f6
169c2c66affSColin Finck
170c2c66affSColin Finck static const WCHAR testW[] = {'t','e','s','t',0};
171c2c66affSColin Finck static const CHAR testA[] = "test";
172c2c66affSColin Finck static const WCHAR test_valW[] = {'t','e','s','t','V','a','l',0};
173c2c66affSColin Finck static const CHAR test_valA[] = "testVal";
174c2c66affSColin Finck static const WCHAR emptyW[] = {0};
175c2c66affSColin Finck
176c2c66affSColin Finck static BOOL strict_dispid_check, testing_expr;
177c2c66affSColin Finck static const char *test_name = "(null)";
178c2c66affSColin Finck static IDispatch *script_disp;
179c2c66affSColin Finck static int invoke_version;
180c2c66affSColin Finck static IActiveScriptError *script_error;
181c2c66affSColin Finck static IActiveScript *script_engine;
182c2c66affSColin Finck static const CLSID *engine_clsid = &CLSID_JScript;
183c2c66affSColin Finck
184c2c66affSColin Finck /* Returns true if the user interface is in English. Note that this does not
185c2c66affSColin Finck * presume of the formatting of dates, numbers, etc.
186c2c66affSColin Finck */
is_lang_english(void)187c2c66affSColin Finck static BOOL is_lang_english(void)
188c2c66affSColin Finck {
189c2c66affSColin Finck static HMODULE hkernel32 = NULL;
190c2c66affSColin Finck static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
191c2c66affSColin Finck static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
192c2c66affSColin Finck
193c2c66affSColin Finck if (!hkernel32)
194c2c66affSColin Finck {
195c2c66affSColin Finck hkernel32 = GetModuleHandleA("kernel32.dll");
196c2c66affSColin Finck pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
197c2c66affSColin Finck pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
198c2c66affSColin Finck }
199c2c66affSColin Finck if (pGetThreadUILanguage)
200c2c66affSColin Finck return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
201c2c66affSColin Finck if (pGetUserDefaultUILanguage)
202c2c66affSColin Finck return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
203c2c66affSColin Finck
204c2c66affSColin Finck return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
205c2c66affSColin Finck }
206c2c66affSColin Finck
a2bstr(const char * str)207c2c66affSColin Finck static BSTR a2bstr(const char *str)
208c2c66affSColin Finck {
209c2c66affSColin Finck BSTR ret;
210c2c66affSColin Finck int len;
211c2c66affSColin Finck
212c2c66affSColin Finck len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
213c2c66affSColin Finck ret = SysAllocStringLen(NULL, len-1);
214c2c66affSColin Finck MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
215c2c66affSColin Finck
216c2c66affSColin Finck return ret;
217c2c66affSColin Finck }
218c2c66affSColin Finck
strcmp_wa(LPCWSTR strw,const char * stra)219c2c66affSColin Finck static int strcmp_wa(LPCWSTR strw, const char *stra)
220c2c66affSColin Finck {
221c2c66affSColin Finck CHAR buf[512];
222c2c66affSColin Finck WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
223c2c66affSColin Finck return lstrcmpA(buf, stra);
224c2c66affSColin Finck }
225c2c66affSColin Finck
226c2c66affSColin Finck #define test_grfdex(a,b) _test_grfdex(__LINE__,a,b)
_test_grfdex(unsigned line,DWORD grfdex,DWORD expect)227c2c66affSColin Finck static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect)
228c2c66affSColin Finck {
229c2c66affSColin Finck expect |= invoke_version << 28;
230c2c66affSColin Finck ok_(__FILE__,line)(grfdex == expect, "grfdex = %x, expected %x\n", grfdex, expect);
231c2c66affSColin Finck }
232c2c66affSColin Finck
EnumVARIANT_QueryInterface(IEnumVARIANT * iface,REFIID riid,void ** ppv)233021b5c1fSAmine Khaldi static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
234021b5c1fSAmine Khaldi {
235021b5c1fSAmine Khaldi *ppv = NULL;
236021b5c1fSAmine Khaldi
237021b5c1fSAmine Khaldi if (IsEqualGUID(riid, &IID_IEnumVARIANT))
238021b5c1fSAmine Khaldi *ppv = iface;
239021b5c1fSAmine Khaldi else
240021b5c1fSAmine Khaldi return E_NOINTERFACE;
241021b5c1fSAmine Khaldi
242021b5c1fSAmine Khaldi return S_OK;
243021b5c1fSAmine Khaldi }
244021b5c1fSAmine Khaldi
EnumVARIANT_AddRef(IEnumVARIANT * iface)245021b5c1fSAmine Khaldi static ULONG WINAPI EnumVARIANT_AddRef(IEnumVARIANT *iface)
246021b5c1fSAmine Khaldi {
247021b5c1fSAmine Khaldi return 2;
248021b5c1fSAmine Khaldi }
249021b5c1fSAmine Khaldi
EnumVARIANT_Release(IEnumVARIANT * iface)250021b5c1fSAmine Khaldi static ULONG WINAPI EnumVARIANT_Release(IEnumVARIANT *iface)
251021b5c1fSAmine Khaldi {
252021b5c1fSAmine Khaldi return 1;
253021b5c1fSAmine Khaldi }
254021b5c1fSAmine Khaldi
255021b5c1fSAmine Khaldi static int EnumVARIANT_index = 0;
256021b5c1fSAmine Khaldi static int EnumVARIANT_next_0_count = 0;
EnumVARIANT_Next(IEnumVARIANT * This,ULONG celt,VARIANT * rgVar,ULONG * pCeltFetched)257021b5c1fSAmine Khaldi static HRESULT WINAPI EnumVARIANT_Next(
258021b5c1fSAmine Khaldi IEnumVARIANT *This,
259021b5c1fSAmine Khaldi ULONG celt,
260021b5c1fSAmine Khaldi VARIANT *rgVar,
261021b5c1fSAmine Khaldi ULONG *pCeltFetched)
262021b5c1fSAmine Khaldi {
263021b5c1fSAmine Khaldi ok(rgVar != NULL, "rgVar is NULL\n");
264021b5c1fSAmine Khaldi ok(celt == 1, "celt = %d\n", celt);
265021b5c1fSAmine Khaldi ok(pCeltFetched == NULL, "pCeltFetched is not NULL\n");
266021b5c1fSAmine Khaldi
267021b5c1fSAmine Khaldi if (!rgVar)
268021b5c1fSAmine Khaldi return S_FALSE;
269021b5c1fSAmine Khaldi
270021b5c1fSAmine Khaldi if (EnumVARIANT_index == 0)
271021b5c1fSAmine Khaldi {
272021b5c1fSAmine Khaldi EnumVARIANT_next_0_count--;
273021b5c1fSAmine Khaldi if (EnumVARIANT_next_0_count <= 0)
274021b5c1fSAmine Khaldi CHECK_EXPECT(enumvariant_next_0);
275021b5c1fSAmine Khaldi
276021b5c1fSAmine Khaldi V_VT(rgVar) = VT_I4;
277021b5c1fSAmine Khaldi V_I4(rgVar) = 123;
278021b5c1fSAmine Khaldi
279021b5c1fSAmine Khaldi if (pCeltFetched)
280021b5c1fSAmine Khaldi *pCeltFetched = 1;
281021b5c1fSAmine Khaldi EnumVARIANT_index++;
282021b5c1fSAmine Khaldi return S_OK;
283021b5c1fSAmine Khaldi }
284021b5c1fSAmine Khaldi
285021b5c1fSAmine Khaldi CHECK_EXPECT(enumvariant_next_1);
286021b5c1fSAmine Khaldi
287021b5c1fSAmine Khaldi if (pCeltFetched)
288021b5c1fSAmine Khaldi *pCeltFetched = 0;
289021b5c1fSAmine Khaldi return S_FALSE;
290021b5c1fSAmine Khaldi
291021b5c1fSAmine Khaldi }
292021b5c1fSAmine Khaldi
EnumVARIANT_Skip(IEnumVARIANT * This,ULONG celt)293021b5c1fSAmine Khaldi static HRESULT WINAPI EnumVARIANT_Skip(
294021b5c1fSAmine Khaldi IEnumVARIANT *This,
295021b5c1fSAmine Khaldi ULONG celt)
296021b5c1fSAmine Khaldi {
297021b5c1fSAmine Khaldi ok(0, "EnumVariant_Skip: unexpected call\n");
298021b5c1fSAmine Khaldi return E_NOTIMPL;
299021b5c1fSAmine Khaldi }
EnumVARIANT_Reset(IEnumVARIANT * This)300021b5c1fSAmine Khaldi static HRESULT WINAPI EnumVARIANT_Reset(
301021b5c1fSAmine Khaldi IEnumVARIANT *This)
302021b5c1fSAmine Khaldi {
303021b5c1fSAmine Khaldi CHECK_EXPECT(enumvariant_reset);
304021b5c1fSAmine Khaldi EnumVARIANT_index = 0;
305021b5c1fSAmine Khaldi return S_OK;
306021b5c1fSAmine Khaldi }
307021b5c1fSAmine Khaldi
EnumVARIANT_Clone(IEnumVARIANT * This,IEnumVARIANT ** ppEnum)308021b5c1fSAmine Khaldi static HRESULT WINAPI EnumVARIANT_Clone(
309021b5c1fSAmine Khaldi IEnumVARIANT *This,
310021b5c1fSAmine Khaldi IEnumVARIANT **ppEnum)
311021b5c1fSAmine Khaldi {
312021b5c1fSAmine Khaldi ok(0, "EnumVariant_Clone: unexpected call\n");
313021b5c1fSAmine Khaldi return E_NOTIMPL;
314021b5c1fSAmine Khaldi }
315021b5c1fSAmine Khaldi
316021b5c1fSAmine Khaldi static IEnumVARIANTVtbl testEnumVARIANTVtbl = {
317021b5c1fSAmine Khaldi EnumVARIANT_QueryInterface,
318021b5c1fSAmine Khaldi EnumVARIANT_AddRef,
319021b5c1fSAmine Khaldi EnumVARIANT_Release,
320021b5c1fSAmine Khaldi EnumVARIANT_Next,
321021b5c1fSAmine Khaldi EnumVARIANT_Skip,
322021b5c1fSAmine Khaldi EnumVARIANT_Reset,
323021b5c1fSAmine Khaldi EnumVARIANT_Clone
324021b5c1fSAmine Khaldi };
325021b5c1fSAmine Khaldi
326021b5c1fSAmine Khaldi static IEnumVARIANT testEnumVARIANT = { &testEnumVARIANTVtbl };
327021b5c1fSAmine Khaldi
DispatchEx_QueryInterface(IDispatchEx * iface,REFIID riid,void ** ppv)328c2c66affSColin Finck static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
329c2c66affSColin Finck {
330c2c66affSColin Finck *ppv = NULL;
331c2c66affSColin Finck
332c2c66affSColin Finck if(IsEqualGUID(riid, &IID_IUnknown)
333c2c66affSColin Finck || IsEqualGUID(riid, &IID_IDispatch)
334c2c66affSColin Finck || IsEqualGUID(riid, &IID_IDispatchEx))
335c2c66affSColin Finck *ppv = iface;
336c2c66affSColin Finck else
337c2c66affSColin Finck return E_NOINTERFACE;
338c2c66affSColin Finck
339c2c66affSColin Finck return S_OK;
340c2c66affSColin Finck }
341c2c66affSColin Finck
DispatchEx_AddRef(IDispatchEx * iface)342c2c66affSColin Finck static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
343c2c66affSColin Finck {
344c2c66affSColin Finck return 2;
345c2c66affSColin Finck }
346c2c66affSColin Finck
DispatchEx_Release(IDispatchEx * iface)347c2c66affSColin Finck static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
348c2c66affSColin Finck {
349c2c66affSColin Finck return 1;
350c2c66affSColin Finck }
351c2c66affSColin Finck
DispatchEx_GetTypeInfoCount(IDispatchEx * iface,UINT * pctinfo)352c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
353c2c66affSColin Finck {
354c2c66affSColin Finck ok(0, "unexpected call\n");
355c2c66affSColin Finck return E_NOTIMPL;
356c2c66affSColin Finck }
357c2c66affSColin Finck
DispatchEx_GetTypeInfo(IDispatchEx * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)358c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
359c2c66affSColin Finck LCID lcid, ITypeInfo **ppTInfo)
360c2c66affSColin Finck {
361c2c66affSColin Finck return E_NOTIMPL;
362c2c66affSColin Finck }
363c2c66affSColin Finck
DispatchEx_GetIDsOfNames(IDispatchEx * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)364c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
365c2c66affSColin Finck LPOLESTR *rgszNames, UINT cNames,
366c2c66affSColin Finck LCID lcid, DISPID *rgDispId)
367c2c66affSColin Finck {
368c2c66affSColin Finck ok(0, "unexpected call\n");
369c2c66affSColin Finck return E_NOTIMPL;
370c2c66affSColin Finck }
371c2c66affSColin Finck
DispatchEx_Invoke(IDispatchEx * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)372c2c66affSColin Finck static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
373c2c66affSColin Finck REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
374c2c66affSColin Finck VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
375c2c66affSColin Finck {
376c2c66affSColin Finck ok(0, "unexpected call\n");
377c2c66affSColin Finck return E_NOTIMPL;
378c2c66affSColin Finck }
379c2c66affSColin Finck
DispatchEx_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)380c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
381c2c66affSColin Finck {
382c2c66affSColin Finck ok(0, "unexpected call\n");
383c2c66affSColin Finck return E_NOTIMPL;
384c2c66affSColin Finck }
385c2c66affSColin Finck
DispatchEx_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * res,EXCEPINFO * pei,IServiceProvider * pspCaller)386c2c66affSColin Finck static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
387c2c66affSColin Finck VARIANT *res, EXCEPINFO *pei, IServiceProvider *pspCaller)
388c2c66affSColin Finck {
389c2c66affSColin Finck ok(0, "unexpected call\n");
390c2c66affSColin Finck return E_NOTIMPL;
391c2c66affSColin Finck }
392c2c66affSColin Finck
DispatchEx_DeleteMemberByName(IDispatchEx * iface,BSTR bstrName,DWORD grfdex)393c2c66affSColin Finck static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
394c2c66affSColin Finck {
395c2c66affSColin Finck ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
396c2c66affSColin Finck return E_NOTIMPL;
397c2c66affSColin Finck }
398c2c66affSColin Finck
DispatchEx_DeleteMemberByDispID(IDispatchEx * iface,DISPID id)399c2c66affSColin Finck static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
400c2c66affSColin Finck {
401c2c66affSColin Finck ok(0, "unexpected call\n");
402c2c66affSColin Finck return E_NOTIMPL;
403c2c66affSColin Finck }
404c2c66affSColin Finck
DispatchEx_GetMemberProperties(IDispatchEx * iface,DISPID id,DWORD grfdexFetch,DWORD * pgrfdex)405c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
406c2c66affSColin Finck {
407c2c66affSColin Finck ok(0, "unexpected call\n");
408c2c66affSColin Finck return E_NOTIMPL;
409c2c66affSColin Finck }
410c2c66affSColin Finck
DispatchEx_GetMemberName(IDispatchEx * iface,DISPID id,BSTR * pbstrName)411c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
412c2c66affSColin Finck {
413c2c66affSColin Finck ok(0, "unexpected call\n");
414c2c66affSColin Finck return E_NOTIMPL;
415c2c66affSColin Finck }
416c2c66affSColin Finck
DispatchEx_GetNextDispID(IDispatchEx * iface,DWORD grfdex,DISPID id,DISPID * pid)417c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
418c2c66affSColin Finck {
419c2c66affSColin Finck ok(0, "unexpected call\n");
420c2c66affSColin Finck return E_NOTIMPL;
421c2c66affSColin Finck }
422c2c66affSColin Finck
DispatchEx_GetNameSpaceParent(IDispatchEx * iface,IUnknown ** ppunk)423c2c66affSColin Finck static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
424c2c66affSColin Finck {
425c2c66affSColin Finck ok(0, "unexpected call\n");
426c2c66affSColin Finck return E_NOTIMPL;
427c2c66affSColin Finck }
428c2c66affSColin Finck
testObj_Invoke(IDispatchEx * iface,DISPID id,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,UINT * puArgErr)429021b5c1fSAmine Khaldi static HRESULT WINAPI testObj_Invoke(IDispatchEx *iface, DISPID id,
430021b5c1fSAmine Khaldi REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
431021b5c1fSAmine Khaldi VARIANT *pvarRes, EXCEPINFO *pei, UINT *puArgErr)
432021b5c1fSAmine Khaldi {
433021b5c1fSAmine Khaldi switch(id) {
434021b5c1fSAmine Khaldi case DISPID_NEWENUM:
435021b5c1fSAmine Khaldi ok(pdp != NULL, "pdp == NULL\n");
436021b5c1fSAmine Khaldi ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
437021b5c1fSAmine Khaldi ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
438021b5c1fSAmine Khaldi ok(pvarRes != NULL, "pvarRes == NULL\n");
439021b5c1fSAmine Khaldi ok(pei == NULL, "pei != NULL\n");
440021b5c1fSAmine Khaldi
441021b5c1fSAmine Khaldi CHECK_EXPECT(testobj_newenum);
442021b5c1fSAmine Khaldi V_VT(pvarRes) = VT_DISPATCH;
443021b5c1fSAmine Khaldi V_DISPATCH(pvarRes) = (IDispatch*)&testEnumVARIANT;
444021b5c1fSAmine Khaldi return S_OK;
445021b5c1fSAmine Khaldi }
446021b5c1fSAmine Khaldi
447021b5c1fSAmine Khaldi ok(0, "unexpected call %x\n", id);
448021b5c1fSAmine Khaldi return DISP_E_MEMBERNOTFOUND;
449021b5c1fSAmine Khaldi }
450021b5c1fSAmine Khaldi
testObj_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)451c2c66affSColin Finck static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
452c2c66affSColin Finck {
453c2c66affSColin Finck if(!strcmp_wa(bstrName, "prop")) {
454c2c66affSColin Finck CHECK_EXPECT(testobj_prop_d);
455c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
456c2c66affSColin Finck *pid = DISPID_TESTOBJ_PROP;
457c2c66affSColin Finck return S_OK;
458c2c66affSColin Finck }
459c2c66affSColin Finck if(!strcmp_wa(bstrName, "withProp")) {
460c2c66affSColin Finck CHECK_EXPECT(testobj_withprop_d);
461c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive|fdexNameImplicit);
462c2c66affSColin Finck *pid = DISPID_TESTOBJ_WITHPROP;
463c2c66affSColin Finck return S_OK;
464c2c66affSColin Finck }
465c2c66affSColin Finck if(!strcmp_wa(bstrName, "noprop")) {
466c2c66affSColin Finck CHECK_EXPECT(testobj_noprop_d);
467c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
468c2c66affSColin Finck return DISP_E_UNKNOWNNAME;
469c2c66affSColin Finck }
470c2c66affSColin Finck if(!strcmp_wa(bstrName, "onlyDispID")) {
471c2c66affSColin Finck if(strict_dispid_check)
472c2c66affSColin Finck CHECK_EXPECT(testobj_onlydispid_d);
473c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
474c2c66affSColin Finck *pid = DISPID_TESTOBJ_ONLYDISPID;
475c2c66affSColin Finck return S_OK;
476c2c66affSColin Finck }
477c2c66affSColin Finck if(!strcmp_wa(bstrName, "notExists")) {
478c2c66affSColin Finck CHECK_EXPECT(testobj_notexists_d);
479c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
480c2c66affSColin Finck return DISP_E_UNKNOWNNAME;
481c2c66affSColin Finck }
482c2c66affSColin Finck
483c2c66affSColin Finck ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
484c2c66affSColin Finck return E_NOTIMPL;
485c2c66affSColin Finck }
486c2c66affSColin Finck
testObj_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,IServiceProvider * pspCaller)487c2c66affSColin Finck static HRESULT WINAPI testObj_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
488c2c66affSColin Finck VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
489c2c66affSColin Finck {
490c2c66affSColin Finck ok(pspCaller != NULL, "pspCaller = NULL\n");
491c2c66affSColin Finck
492c2c66affSColin Finck switch(id) {
493c2c66affSColin Finck case DISPID_VALUE:
494c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
495c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
496c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
497c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
498c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
499c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
500c2c66affSColin Finck
501c2c66affSColin Finck switch(wFlags) {
502c2c66affSColin Finck case INVOKE_PROPERTYGET:
503c2c66affSColin Finck CHECK_EXPECT(testobj_value);
504c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
505c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
506c2c66affSColin Finck break;
507c2c66affSColin Finck case INVOKE_FUNC:
508c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
509c2c66affSColin Finck break;
510c2c66affSColin Finck case INVOKE_FUNC|INVOKE_PROPERTYGET:
511c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
512c2c66affSColin Finck break;
513c2c66affSColin Finck case DISPATCH_CONSTRUCT:
514c2c66affSColin Finck CHECK_EXPECT(testobj_construct);
515c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
516c2c66affSColin Finck break;
517c2c66affSColin Finck default:
518c2c66affSColin Finck ok(0, "invalid flag (%x)\n", wFlags);
519c2c66affSColin Finck }
520c2c66affSColin Finck
521c2c66affSColin Finck V_VT(pvarRes) = VT_I4;
522c2c66affSColin Finck V_I4(pvarRes) = 1;
523c2c66affSColin Finck return S_OK;
524c2c66affSColin Finck case DISPID_TESTOBJ_ONLYDISPID:
525c2c66affSColin Finck if(strict_dispid_check)
526c2c66affSColin Finck CHECK_EXPECT(testobj_onlydispid_i);
527c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
528c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
529c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
530c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
531c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
532c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
533c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
534c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
535c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
536c2c66affSColin Finck return DISP_E_MEMBERNOTFOUND;
537c2c66affSColin Finck case DISPID_TESTOBJ_WITHPROP:
538c2c66affSColin Finck CHECK_EXPECT(testobj_withprop_i);
539c2c66affSColin Finck
540c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
541c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
542c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
543c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
544c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
545c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
546c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
547c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
548c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
549c2c66affSColin Finck
550c2c66affSColin Finck V_VT(pvarRes) = VT_I4;
551c2c66affSColin Finck V_I4(pvarRes) = 1;
552c2c66affSColin Finck
553c2c66affSColin Finck return S_OK;
554c2c66affSColin Finck }
555c2c66affSColin Finck
556c2c66affSColin Finck ok(0, "unexpected call %x\n", id);
557c2c66affSColin Finck return DISP_E_MEMBERNOTFOUND;
558c2c66affSColin Finck }
559c2c66affSColin Finck
testObj_DeleteMemberByName(IDispatchEx * iface,BSTR bstrName,DWORD grfdex)560c2c66affSColin Finck static HRESULT WINAPI testObj_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
561c2c66affSColin Finck {
562c2c66affSColin Finck if(!strcmp_wa(bstrName, "deleteTest")) {
563c2c66affSColin Finck CHECK_EXPECT(testobj_delete_test);
564c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
565c2c66affSColin Finck return S_OK;
566c2c66affSColin Finck }
567c2c66affSColin Finck if(!strcmp_wa(bstrName, "noDeleteTest")) {
568c2c66affSColin Finck CHECK_EXPECT(testobj_delete_nodelete);
569c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
570c2c66affSColin Finck return S_FALSE;
571c2c66affSColin Finck }
572c2c66affSColin Finck
573c2c66affSColin Finck ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName));
574c2c66affSColin Finck return E_FAIL;
575c2c66affSColin Finck }
576c2c66affSColin Finck
577c2c66affSColin Finck static IDispatchExVtbl testObjVtbl = {
578c2c66affSColin Finck DispatchEx_QueryInterface,
579c2c66affSColin Finck DispatchEx_AddRef,
580c2c66affSColin Finck DispatchEx_Release,
581c2c66affSColin Finck DispatchEx_GetTypeInfoCount,
582c2c66affSColin Finck DispatchEx_GetTypeInfo,
583c2c66affSColin Finck DispatchEx_GetIDsOfNames,
584021b5c1fSAmine Khaldi testObj_Invoke,
585c2c66affSColin Finck testObj_GetDispID,
586c2c66affSColin Finck testObj_InvokeEx,
587c2c66affSColin Finck testObj_DeleteMemberByName,
588c2c66affSColin Finck DispatchEx_DeleteMemberByDispID,
589c2c66affSColin Finck DispatchEx_GetMemberProperties,
590c2c66affSColin Finck DispatchEx_GetMemberName,
591c2c66affSColin Finck DispatchEx_GetNextDispID,
592c2c66affSColin Finck DispatchEx_GetNameSpaceParent
593c2c66affSColin Finck };
594c2c66affSColin Finck
595c2c66affSColin Finck static IDispatchEx testObj = { &testObjVtbl };
596c2c66affSColin Finck
dispexFunc_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * res,EXCEPINFO * pei,IServiceProvider * pspCaller)597c2c66affSColin Finck static HRESULT WINAPI dispexFunc_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
598c2c66affSColin Finck VARIANT *res, EXCEPINFO *pei, IServiceProvider *pspCaller)
599c2c66affSColin Finck {
600c2c66affSColin Finck ok(pspCaller != NULL, "pspCaller = NULL\n");
601c2c66affSColin Finck
602c2c66affSColin Finck switch(id) {
603c2c66affSColin Finck case DISPID_VALUE:
604c2c66affSColin Finck CHECK_EXPECT(dispexfunc_value);
605c2c66affSColin Finck
606c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
607c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
608c2c66affSColin Finck ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs != NULL\n");
609c2c66affSColin Finck ok(*pdp->rgdispidNamedArgs == DISPID_THIS, "*rgdispidNamedArgs = %d\n", *pdp->rgdispidNamedArgs);
610c2c66affSColin Finck ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
611c2c66affSColin Finck ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
612c2c66affSColin Finck ok(res != NULL, "res == NULL\n");
613c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
614c2c66affSColin Finck
615c2c66affSColin Finck ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
616c2c66affSColin Finck
617c2c66affSColin Finck if(V_BOOL(pdp->rgvarg+1))
618c2c66affSColin Finck /* NOTE: If called by Function.apply(), native doesn't set DISPATCH_PROPERTYGET flag. */
619c2c66affSColin Finck todo_wine ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
620c2c66affSColin Finck else
621c2c66affSColin Finck ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
622c2c66affSColin Finck
623c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
624c2c66affSColin Finck ok(V_DISPATCH(pdp->rgvarg) != NULL, "V_DISPATCH(pdp->rgvarg) == NULL\n");
625c2c66affSColin Finck
626c2c66affSColin Finck if(res)
627c2c66affSColin Finck V_VT(res) = VT_NULL;
628c2c66affSColin Finck return S_OK;
629c2c66affSColin Finck default:
630c2c66affSColin Finck ok(0, "unexpected call %x\n", id);
631c2c66affSColin Finck return DISP_E_MEMBERNOTFOUND;
632c2c66affSColin Finck }
633c2c66affSColin Finck }
634c2c66affSColin Finck
635c2c66affSColin Finck static IDispatchExVtbl dispexFuncVtbl = {
636c2c66affSColin Finck DispatchEx_QueryInterface,
637c2c66affSColin Finck DispatchEx_AddRef,
638c2c66affSColin Finck DispatchEx_Release,
639c2c66affSColin Finck DispatchEx_GetTypeInfoCount,
640c2c66affSColin Finck DispatchEx_GetTypeInfo,
641c2c66affSColin Finck DispatchEx_GetIDsOfNames,
642c2c66affSColin Finck DispatchEx_Invoke,
643c2c66affSColin Finck DispatchEx_GetDispID,
644c2c66affSColin Finck dispexFunc_InvokeEx,
645c2c66affSColin Finck DispatchEx_DeleteMemberByName,
646c2c66affSColin Finck DispatchEx_DeleteMemberByDispID,
647c2c66affSColin Finck DispatchEx_GetMemberProperties,
648c2c66affSColin Finck DispatchEx_GetMemberName,
649c2c66affSColin Finck DispatchEx_GetNextDispID,
650c2c66affSColin Finck DispatchEx_GetNameSpaceParent
651c2c66affSColin Finck };
652c2c66affSColin Finck
653c2c66affSColin Finck static IDispatchEx dispexFunc = { &dispexFuncVtbl };
654c2c66affSColin Finck
pureDisp_QueryInterface(IDispatchEx * iface,REFIID riid,void ** ppv)655c2c66affSColin Finck static HRESULT WINAPI pureDisp_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
656c2c66affSColin Finck {
657c2c66affSColin Finck if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch)) {
658c2c66affSColin Finck *ppv = iface;
659c2c66affSColin Finck return S_OK;
660c2c66affSColin Finck }
661c2c66affSColin Finck
662c2c66affSColin Finck *ppv = NULL;
663c2c66affSColin Finck return E_NOINTERFACE;
664c2c66affSColin Finck }
665c2c66affSColin Finck
pureDisp_GetIDsOfNames(IDispatchEx * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)666c2c66affSColin Finck static HRESULT WINAPI pureDisp_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
667c2c66affSColin Finck LPOLESTR *rgszNames, UINT cNames,
668c2c66affSColin Finck LCID lcid, DISPID *rgDispId)
669c2c66affSColin Finck {
670c2c66affSColin Finck ok(IsEqualGUID(riid, &IID_NULL), "Expected IID_NULL\n");
671c2c66affSColin Finck ok(cNames==1, "cNames = %d\n", cNames);
672c2c66affSColin Finck
673c2c66affSColin Finck if(!strcmp_wa(*rgszNames, "prop")) {
674c2c66affSColin Finck CHECK_EXPECT(puredisp_prop_d);
675c2c66affSColin Finck *rgDispId = DISPID_TESTOBJ_PROP;
676c2c66affSColin Finck return S_OK;
677c2c66affSColin Finck } else if(!strcmp_wa(*rgszNames, "noprop")) {
678c2c66affSColin Finck CHECK_EXPECT(puredisp_noprop_d);
679c2c66affSColin Finck return DISP_E_UNKNOWNNAME;
680c2c66affSColin Finck }
681c2c66affSColin Finck
682c2c66affSColin Finck ok(0, "unexpected call\n");
683c2c66affSColin Finck return E_NOTIMPL;
684c2c66affSColin Finck }
685c2c66affSColin Finck
pureDisp_Invoke(IDispatchEx * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * res,EXCEPINFO * ei,UINT * puArgErr)686c2c66affSColin Finck static HRESULT WINAPI pureDisp_Invoke(IDispatchEx *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
687c2c66affSColin Finck WORD wFlags, DISPPARAMS *pdp, VARIANT *res, EXCEPINFO *ei, UINT *puArgErr)
688c2c66affSColin Finck {
689c2c66affSColin Finck ok(IsEqualGUID(&IID_NULL, riid), "unexpected riid\n");
690c2c66affSColin Finck
691c2c66affSColin Finck switch(dispIdMember) {
692c2c66affSColin Finck case DISPID_VALUE:
693c2c66affSColin Finck CHECK_EXPECT(puredisp_value);
694c2c66affSColin Finck
695c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
696c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
697c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
698c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
699c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
700c2c66affSColin Finck ok(res != NULL, "res == NULL\n");
701c2c66affSColin Finck ok(ei != NULL, "ei == NULL\n");
702c2c66affSColin Finck ok(puArgErr != NULL, "puArgErr == NULL\n");
703c2c66affSColin Finck
704c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_BOOL, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
705c2c66affSColin Finck
706c2c66affSColin Finck if(V_BOOL(pdp->rgvarg))
707c2c66affSColin Finck todo_wine ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
708c2c66affSColin Finck else
709c2c66affSColin Finck ok(wFlags == (DISPATCH_PROPERTYGET|DISPATCH_METHOD), "wFlags = %x\n", wFlags);
710c2c66affSColin Finck
711c2c66affSColin Finck if(res)
712c2c66affSColin Finck V_VT(res) = VT_NULL;
713c2c66affSColin Finck return S_OK;
714c2c66affSColin Finck default:
715c2c66affSColin Finck ok(0, "unexpected call\n");
716c2c66affSColin Finck return E_NOTIMPL;
717c2c66affSColin Finck }
718c2c66affSColin Finck }
719c2c66affSColin Finck
720c2c66affSColin Finck static IDispatchExVtbl pureDispVtbl = {
721c2c66affSColin Finck pureDisp_QueryInterface,
722c2c66affSColin Finck DispatchEx_AddRef,
723c2c66affSColin Finck DispatchEx_Release,
724c2c66affSColin Finck DispatchEx_GetTypeInfoCount,
725c2c66affSColin Finck DispatchEx_GetTypeInfo,
726c2c66affSColin Finck pureDisp_GetIDsOfNames,
727c2c66affSColin Finck pureDisp_Invoke
728c2c66affSColin Finck };
729c2c66affSColin Finck
730c2c66affSColin Finck static IDispatchEx pureDisp = { &pureDispVtbl };
731c2c66affSColin Finck
BindEventHandler_QueryInterface(IBindEventHandler * iface,REFIID riid,void ** ppv)732c2c66affSColin Finck static HRESULT WINAPI BindEventHandler_QueryInterface(IBindEventHandler *iface, REFIID riid, void **ppv)
733c2c66affSColin Finck {
734c2c66affSColin Finck ok(0, "unexpected call\n");
735c2c66affSColin Finck return E_NOINTERFACE;
736c2c66affSColin Finck }
737c2c66affSColin Finck
BindEventHandler_AddRef(IBindEventHandler * iface)738c2c66affSColin Finck static ULONG WINAPI BindEventHandler_AddRef(IBindEventHandler *iface)
739c2c66affSColin Finck {
740c2c66affSColin Finck return 2;
741c2c66affSColin Finck }
742c2c66affSColin Finck
BindEventHandler_Release(IBindEventHandler * iface)743c2c66affSColin Finck static ULONG WINAPI BindEventHandler_Release(IBindEventHandler *iface)
744c2c66affSColin Finck {
745c2c66affSColin Finck return 1;
746c2c66affSColin Finck }
747c2c66affSColin Finck
BindEventHandler_BindHandler(IBindEventHandler * iface,const WCHAR * event,IDispatch * disp)748c2c66affSColin Finck static HRESULT WINAPI BindEventHandler_BindHandler(IBindEventHandler *iface, const WCHAR *event, IDispatch *disp)
749c2c66affSColin Finck {
750c2c66affSColin Finck CHECK_EXPECT(BindHandler);
751c2c66affSColin Finck ok(!strcmp_wa(event, "eventName"), "event = %s\n", wine_dbgstr_w(event));
752c2c66affSColin Finck ok(disp != NULL, "disp = NULL\n");
753c2c66affSColin Finck return S_OK;
754c2c66affSColin Finck }
755c2c66affSColin Finck
756c2c66affSColin Finck static const IBindEventHandlerVtbl BindEventHandlerVtbl = {
757c2c66affSColin Finck BindEventHandler_QueryInterface,
758c2c66affSColin Finck BindEventHandler_AddRef,
759c2c66affSColin Finck BindEventHandler_Release,
760c2c66affSColin Finck BindEventHandler_BindHandler
761c2c66affSColin Finck };
762c2c66affSColin Finck
763c2c66affSColin Finck static IBindEventHandler BindEventHandler = { &BindEventHandlerVtbl };
764c2c66affSColin Finck
bindEventHandlerDisp_QueryInterface(IDispatchEx * iface,REFIID riid,void ** ppv)765c2c66affSColin Finck static HRESULT WINAPI bindEventHandlerDisp_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
766c2c66affSColin Finck {
767c2c66affSColin Finck if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch) || IsEqualGUID(riid, &IID_IDispatchEx)) {
768c2c66affSColin Finck *ppv = iface;
769c2c66affSColin Finck return S_OK;
770c2c66affSColin Finck }
771c2c66affSColin Finck
772c2c66affSColin Finck if(IsEqualGUID(riid, &IID_IBindEventHandler)) {
773c2c66affSColin Finck *ppv = &BindEventHandler;
774c2c66affSColin Finck return S_OK;
775c2c66affSColin Finck }
776c2c66affSColin Finck
777c2c66affSColin Finck *ppv = NULL;
778c2c66affSColin Finck return E_NOINTERFACE;
779c2c66affSColin Finck }
780c2c66affSColin Finck
781c2c66affSColin Finck static IDispatchExVtbl bindEventHandlerDispVtbl = {
782c2c66affSColin Finck bindEventHandlerDisp_QueryInterface,
783c2c66affSColin Finck DispatchEx_AddRef,
784c2c66affSColin Finck DispatchEx_Release,
785c2c66affSColin Finck DispatchEx_GetTypeInfoCount,
786c2c66affSColin Finck DispatchEx_GetTypeInfo,
787c2c66affSColin Finck DispatchEx_GetIDsOfNames,
788c2c66affSColin Finck DispatchEx_Invoke,
789c2c66affSColin Finck DispatchEx_GetDispID,
790c2c66affSColin Finck DispatchEx_InvokeEx,
791c2c66affSColin Finck DispatchEx_DeleteMemberByName,
792c2c66affSColin Finck DispatchEx_DeleteMemberByDispID,
793c2c66affSColin Finck DispatchEx_GetMemberProperties,
794c2c66affSColin Finck DispatchEx_GetMemberName,
795c2c66affSColin Finck DispatchEx_GetNextDispID,
796c2c66affSColin Finck DispatchEx_GetNameSpaceParent
797c2c66affSColin Finck };
798c2c66affSColin Finck
799c2c66affSColin Finck static IDispatchEx bindEventHandlerDisp = { &bindEventHandlerDispVtbl };
800c2c66affSColin Finck
Global_GetDispID(IDispatchEx * iface,BSTR bstrName,DWORD grfdex,DISPID * pid)801c2c66affSColin Finck static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
802c2c66affSColin Finck {
803c2c66affSColin Finck if(!strcmp_wa(bstrName, "ok")) {
804c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
805c2c66affSColin Finck *pid = DISPID_GLOBAL_OK;
806c2c66affSColin Finck return S_OK;
807c2c66affSColin Finck }
808c2c66affSColin Finck if(!strcmp_wa(bstrName, "trace")) {
809c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
810c2c66affSColin Finck *pid = DISPID_GLOBAL_TRACE;
811c2c66affSColin Finck return S_OK;
812c2c66affSColin Finck }
813c2c66affSColin Finck if(!strcmp_wa(bstrName, "reportSuccess")) {
814c2c66affSColin Finck CHECK_EXPECT(global_success_d);
815c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
816c2c66affSColin Finck *pid = DISPID_GLOBAL_REPORTSUCCESS;
817c2c66affSColin Finck return S_OK;
818c2c66affSColin Finck }
819c2c66affSColin Finck if(!strcmp_wa(bstrName, "testPropGet")) {
820c2c66affSColin Finck CHECK_EXPECT(global_propget_d);
821c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
822c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTPROPGET;
823c2c66affSColin Finck return S_OK;
824c2c66affSColin Finck }
825c2c66affSColin Finck if(!strcmp_wa(bstrName, "testPropPut")) {
826c2c66affSColin Finck CHECK_EXPECT(global_propput_d);
827c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
828c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTPROPPUT;
829c2c66affSColin Finck return S_OK;
830c2c66affSColin Finck }
831c2c66affSColin Finck if(!strcmp_wa(bstrName, "testPropPutRef")) {
832c2c66affSColin Finck CHECK_EXPECT(global_propputref_d);
833c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
834c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTPROPPUTREF;
835c2c66affSColin Finck return S_OK;
836c2c66affSColin Finck }
837c2c66affSColin Finck if(!strcmp_wa(bstrName, "testPropDelete")) {
838c2c66affSColin Finck CHECK_EXPECT(global_propdelete_d);
839c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
840c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTPROPDELETE;
841c2c66affSColin Finck return S_OK;
842c2c66affSColin Finck }
843c2c66affSColin Finck if(!strcmp_wa(bstrName, "testNoPropDelete")) {
844c2c66affSColin Finck CHECK_EXPECT(global_nopropdelete_d);
845c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
846c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTNOPROPDELETE;
847c2c66affSColin Finck return S_OK;
848c2c66affSColin Finck }
849c2c66affSColin Finck if(!strcmp_wa(bstrName, "testPropDeleteError")) {
850c2c66affSColin Finck CHECK_EXPECT(global_propdeleteerror_d);
851c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
852c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTPROPDELETEERROR;
853c2c66affSColin Finck return S_OK;
854c2c66affSColin Finck }
855c2c66affSColin Finck if(!strcmp_wa(bstrName, "getVT")) {
856c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
857c2c66affSColin Finck *pid = DISPID_GLOBAL_GETVT;
858c2c66affSColin Finck return S_OK;
859c2c66affSColin Finck }
860c2c66affSColin Finck if(!strcmp_wa(bstrName, "testObj")) {
861c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
862c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTOBJ;
863c2c66affSColin Finck return S_OK;
864c2c66affSColin Finck }
865c2c66affSColin Finck if(!strcmp_wa(bstrName, "getNullBSTR")) {
866c2c66affSColin Finck *pid = DISPID_GLOBAL_GETNULLBSTR;
867c2c66affSColin Finck return S_OK;
868c2c66affSColin Finck }
869c2c66affSColin Finck if(!strcmp_wa(bstrName, "isNullBSTR")) {
870c2c66affSColin Finck *pid = DISPID_GLOBAL_ISNULLBSTR;
871c2c66affSColin Finck return S_OK;
872c2c66affSColin Finck }
873c2c66affSColin Finck if(!strcmp_wa(bstrName, "nullDisp")) {
874c2c66affSColin Finck *pid = DISPID_GLOBAL_NULL_DISP;
875c2c66affSColin Finck return S_OK;
876c2c66affSColin Finck }
877c2c66affSColin Finck if(!strcmp_wa(bstrName, "notExists")) {
878c2c66affSColin Finck CHECK_EXPECT(global_notexists_d);
879c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
880c2c66affSColin Finck return DISP_E_UNKNOWNNAME;
881c2c66affSColin Finck }
882c2c66affSColin Finck
883c2c66affSColin Finck if(!strcmp_wa(bstrName, "testThis")) {
884c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
885c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTTHIS;
886c2c66affSColin Finck return S_OK;
887c2c66affSColin Finck }
888c2c66affSColin Finck
889c2c66affSColin Finck if(!strcmp_wa(bstrName, "testThis2")) {
890c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
891c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTTHIS2;
892c2c66affSColin Finck return S_OK;
893c2c66affSColin Finck }
894c2c66affSColin Finck
895c2c66affSColin Finck if(!strcmp_wa(bstrName, "invokeVersion")) {
896c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
897c2c66affSColin Finck *pid = DISPID_GLOBAL_INVOKEVERSION;
898c2c66affSColin Finck return S_OK;
899c2c66affSColin Finck }
900c2c66affSColin Finck if(!strcmp_wa(bstrName, "createArray")) {
901c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
902c2c66affSColin Finck *pid = DISPID_GLOBAL_CREATEARRAY;
903c2c66affSColin Finck return S_OK;
904c2c66affSColin Finck }
905c2c66affSColin Finck if(!strcmp_wa(bstrName, "propGetFunc")) {
906c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
907c2c66affSColin Finck *pid = DISPID_GLOBAL_PROPGETFUNC;
908c2c66affSColin Finck return S_OK;
909c2c66affSColin Finck }
910c2c66affSColin Finck if(!strcmp_wa(bstrName, "objectFlag")) {
911c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
912c2c66affSColin Finck *pid = DISPID_GLOBAL_OBJECT_FLAG;
913c2c66affSColin Finck return S_OK;
914c2c66affSColin Finck }
915c2c66affSColin Finck
916c2c66affSColin Finck if(!strcmp_wa(bstrName, "isWin64")) {
917c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
918c2c66affSColin Finck *pid = DISPID_GLOBAL_ISWIN64;
919c2c66affSColin Finck return S_OK;
920c2c66affSColin Finck }
921c2c66affSColin Finck
922c2c66affSColin Finck if(!strcmp_wa(bstrName, "pureDisp")) {
923c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
924c2c66affSColin Finck *pid = DISPID_GLOBAL_PUREDISP;
925c2c66affSColin Finck return S_OK;
926c2c66affSColin Finck }
927c2c66affSColin Finck
928c2c66affSColin Finck if(!strcmp_wa(bstrName, "propArgPutG")) {
929c2c66affSColin Finck CHECK_EXPECT(global_propargput_d);
930c2c66affSColin Finck test_grfdex(grfdex, fdexNameCaseSensitive);
931c2c66affSColin Finck *pid = DISPID_GLOBAL_PROPARGPUT;
932c2c66affSColin Finck return S_OK;
933c2c66affSColin Finck }
934c2c66affSColin Finck
935021b5c1fSAmine Khaldi if(!strcmp_wa(bstrName, "propArgPutOp")) {
936021b5c1fSAmine Khaldi CHECK_EXPECT(global_propargputop_d);
937021b5c1fSAmine Khaldi test_grfdex(grfdex, fdexNameCaseSensitive);
938021b5c1fSAmine Khaldi *pid = DISPID_GLOBAL_PROPARGPUTOP;
939021b5c1fSAmine Khaldi return S_OK;
940021b5c1fSAmine Khaldi }
941021b5c1fSAmine Khaldi
942c2c66affSColin Finck if(!strcmp_wa(bstrName, "propArgPutO")) {
943c2c66affSColin Finck CHECK_EXPECT(global_propargput_d);
944c2c66affSColin Finck test_grfdex(grfdex, fdexNameEnsure|fdexNameCaseSensitive);
945c2c66affSColin Finck *pid = DISPID_GLOBAL_PROPARGPUT;
946c2c66affSColin Finck return S_OK;
947c2c66affSColin Finck }
948c2c66affSColin Finck
949c2c66affSColin Finck if(!strcmp_wa(bstrName, "shortProp")) {
950c2c66affSColin Finck *pid = DISPID_GLOBAL_SHORTPROP;
951c2c66affSColin Finck return S_OK;
952c2c66affSColin Finck }
953c2c66affSColin Finck
954c2c66affSColin Finck if(!strcmp_wa(bstrName, "getShort")) {
955c2c66affSColin Finck *pid = DISPID_GLOBAL_GETSHORT;
956c2c66affSColin Finck return S_OK;
957c2c66affSColin Finck }
958c2c66affSColin Finck
959c2c66affSColin Finck if(!strcmp_wa(bstrName, "testArgTypes")) {
960c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTARGTYPES;
961c2c66affSColin Finck return S_OK;
962c2c66affSColin Finck }
963c2c66affSColin Finck
964c2c66affSColin Finck if(!strcmp_wa(bstrName, "intProp")) {
965c2c66affSColin Finck *pid = DISPID_GLOBAL_INTPROP;
966c2c66affSColin Finck return S_OK;
967c2c66affSColin Finck }
968c2c66affSColin Finck
969c2c66affSColin Finck if(!strcmp_wa(bstrName, "dispUnk")) {
970c2c66affSColin Finck *pid = DISPID_GLOBAL_DISPUNK;
971c2c66affSColin Finck return S_OK;
972c2c66affSColin Finck }
973c2c66affSColin Finck
974c2c66affSColin Finck if(!strcmp_wa(bstrName, "testRes")) {
975c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTRES;
976c2c66affSColin Finck return S_OK;
977c2c66affSColin Finck }
978c2c66affSColin Finck
979c2c66affSColin Finck if(!strcmp_wa(bstrName, "testNoRes")) {
980c2c66affSColin Finck *pid = DISPID_GLOBAL_TESTNORES;
981c2c66affSColin Finck return S_OK;
982c2c66affSColin Finck }
983c2c66affSColin Finck
984c2c66affSColin Finck if(!strcmp_wa(bstrName, "dispexFunc")) {
985c2c66affSColin Finck *pid = DISPID_GLOBAL_DISPEXFUNC;
986c2c66affSColin Finck return S_OK;
987c2c66affSColin Finck }
988c2c66affSColin Finck
989c2c66affSColin Finck if(!strcmp_wa(bstrName, "getScriptState")) {
990c2c66affSColin Finck *pid = DISPID_GLOBAL_GETSCRIPTSTATE;
991c2c66affSColin Finck return S_OK;
992c2c66affSColin Finck }
993c2c66affSColin Finck
994c2c66affSColin Finck if(!strcmp_wa(bstrName, "bindEventHandler")) {
995c2c66affSColin Finck *pid = DISPID_GLOBAL_BINDEVENTHANDLER;
996c2c66affSColin Finck return S_OK;
997c2c66affSColin Finck }
998c2c66affSColin Finck
999021b5c1fSAmine Khaldi if(!strcmp_wa(bstrName, "testEnumObj")) {
1000021b5c1fSAmine Khaldi *pid = DISPID_GLOBAL_TESTENUMOBJ;
1001021b5c1fSAmine Khaldi return S_OK;
1002021b5c1fSAmine Khaldi }
1003021b5c1fSAmine Khaldi
1004021b5c1fSAmine Khaldi if(!strcmp_wa(bstrName, "callEval")) {
1005021b5c1fSAmine Khaldi *pid = DISPID_GLOBAL_CALLEVAL;
1006021b5c1fSAmine Khaldi return S_OK;
1007021b5c1fSAmine Khaldi }
1008021b5c1fSAmine Khaldi
1009c2c66affSColin Finck if(strict_dispid_check && strcmp_wa(bstrName, "t"))
1010c2c66affSColin Finck ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName));
1011c2c66affSColin Finck return DISP_E_UNKNOWNNAME;
1012c2c66affSColin Finck }
1013c2c66affSColin Finck
Global_InvokeEx(IDispatchEx * iface,DISPID id,LCID lcid,WORD wFlags,DISPPARAMS * pdp,VARIANT * pvarRes,EXCEPINFO * pei,IServiceProvider * pspCaller)1014c2c66affSColin Finck static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1015c2c66affSColin Finck VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1016c2c66affSColin Finck {
1017c2c66affSColin Finck ok(pspCaller != NULL, "pspCaller = NULL\n");
1018c2c66affSColin Finck
1019c2c66affSColin Finck switch(id) {
1020c2c66affSColin Finck case DISPID_GLOBAL_OK:
1021c2c66affSColin Finck ok(wFlags == INVOKE_FUNC || wFlags == (INVOKE_FUNC|INVOKE_PROPERTYGET), "wFlags = %x\n", wFlags);
1022c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1023c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1024c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1025c2c66affSColin Finck ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
1026c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1027c2c66affSColin Finck if(wFlags & INVOKE_PROPERTYGET)
1028c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1029c2c66affSColin Finck else
1030c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1031c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1032c2c66affSColin Finck
1033c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1034c2c66affSColin Finck ok(V_VT(pdp->rgvarg+1) == VT_BOOL, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
1035*b2920363STimo Kreuzer #ifndef __REACTOS__ // Fails on Windows 2003
1036c2c66affSColin Finck ok(V_BOOL(pdp->rgvarg+1), "%s: %s\n", test_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
1037*b2920363STimo Kreuzer #endif
1038c2c66affSColin Finck
1039c2c66affSColin Finck return S_OK;
1040c2c66affSColin Finck
1041c2c66affSColin Finck case DISPID_GLOBAL_TRACE:
1042c2c66affSColin Finck ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1043c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1044c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1045c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1046c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1047c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1048c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1049c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1050c2c66affSColin Finck
1051c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1052c2c66affSColin Finck if(V_VT(pdp->rgvarg) == VT_BSTR)
1053c2c66affSColin Finck trace("%s: %s\n", test_name, wine_dbgstr_w(V_BSTR(pdp->rgvarg)));
1054c2c66affSColin Finck
1055c2c66affSColin Finck return S_OK;
1056c2c66affSColin Finck
1057c2c66affSColin Finck case DISPID_GLOBAL_REPORTSUCCESS:
1058c2c66affSColin Finck CHECK_EXPECT(global_success_i);
1059c2c66affSColin Finck
1060c2c66affSColin Finck ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1061c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1062c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1063c2c66affSColin Finck ok(pdp->cArgs == 0, "cArgs = %d\n", pdp->cArgs);
1064c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1065c2c66affSColin Finck if(!testing_expr)
1066c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1067c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1068c2c66affSColin Finck
1069c2c66affSColin Finck return S_OK;
1070c2c66affSColin Finck
1071c2c66affSColin Finck case DISPID_GLOBAL_TESTPROPGET:
1072c2c66affSColin Finck CHECK_EXPECT(global_propget_i);
1073c2c66affSColin Finck
1074c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
1075c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1076c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
1077c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1078c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1079c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1080c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1081c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1082c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1083c2c66affSColin Finck
1084c2c66affSColin Finck V_VT(pvarRes) = VT_I4;
1085c2c66affSColin Finck V_I4(pvarRes) = 1;
1086c2c66affSColin Finck
1087c2c66affSColin Finck return S_OK;
1088c2c66affSColin Finck
1089c2c66affSColin Finck case DISPID_GLOBAL_TESTPROPPUT:
1090c2c66affSColin Finck CHECK_EXPECT(global_propput_i);
1091c2c66affSColin Finck
1092c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYPUT, "wFlags = %x\n", wFlags);
1093c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1094c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1095c2c66affSColin Finck ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1096c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1097c2c66affSColin Finck ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1098c2c66affSColin Finck ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1099c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1100c2c66affSColin Finck
1101c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg)=%d\n", V_VT(pdp->rgvarg));
1102c2c66affSColin Finck ok(V_I4(pdp->rgvarg) == 1, "V_I4(pdp->rgvarg)=%d\n", V_I4(pdp->rgvarg));
1103c2c66affSColin Finck return S_OK;
1104c2c66affSColin Finck
1105c2c66affSColin Finck case DISPID_GLOBAL_TESTPROPPUTREF:
1106c2c66affSColin Finck CHECK_EXPECT(global_propputref_i);
1107c2c66affSColin Finck
1108c2c66affSColin Finck ok(wFlags == (INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF), "wFlags = %x\n", wFlags);
1109c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1110c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1111c2c66affSColin Finck ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1112c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1113c2c66affSColin Finck ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1114c2c66affSColin Finck ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1115c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1116c2c66affSColin Finck
1117c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg)=%d\n", V_VT(pdp->rgvarg));
1118c2c66affSColin Finck return S_OK;
1119c2c66affSColin Finck
1120c2c66affSColin Finck case DISPID_GLOBAL_GETVT:
1121c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1122c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1123c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1124c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1125c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1126c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1127c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1128c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1129c2c66affSColin Finck
1130c2c66affSColin Finck V_VT(pvarRes) = VT_BSTR;
1131c2c66affSColin Finck switch(V_VT(pdp->rgvarg)) {
1132c2c66affSColin Finck case VT_EMPTY:
1133c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_EMPTY");
1134c2c66affSColin Finck break;
1135c2c66affSColin Finck case VT_NULL:
1136c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_NULL");
1137c2c66affSColin Finck break;
1138c2c66affSColin Finck case VT_I4:
1139c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_I4");
1140c2c66affSColin Finck break;
1141c2c66affSColin Finck case VT_R8:
1142c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_R8");
1143c2c66affSColin Finck break;
1144c2c66affSColin Finck case VT_BSTR:
1145c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_BSTR");
1146c2c66affSColin Finck break;
1147c2c66affSColin Finck case VT_DISPATCH:
1148c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_DISPATCH");
1149c2c66affSColin Finck break;
1150c2c66affSColin Finck case VT_BOOL:
1151c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_BOOL");
1152c2c66affSColin Finck break;
1153c2c66affSColin Finck case VT_ARRAY|VT_VARIANT:
1154c2c66affSColin Finck V_BSTR(pvarRes) = a2bstr("VT_ARRAY|VT_VARIANT");
1155c2c66affSColin Finck break;
1156c2c66affSColin Finck default:
1157c2c66affSColin Finck ok(0, "unknown vt %d\n", V_VT(pdp->rgvarg));
1158c2c66affSColin Finck return E_FAIL;
1159c2c66affSColin Finck }
1160c2c66affSColin Finck
1161c2c66affSColin Finck return S_OK;
1162c2c66affSColin Finck
1163c2c66affSColin Finck case DISPID_GLOBAL_TESTRES:
1164c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes = NULL\n");
1165c2c66affSColin Finck if(pvarRes) {
1166c2c66affSColin Finck V_VT(pvarRes) = VT_BOOL;
1167c2c66affSColin Finck V_BOOL(pvarRes) = VARIANT_TRUE;
1168c2c66affSColin Finck }
1169c2c66affSColin Finck return S_OK;
1170c2c66affSColin Finck
1171c2c66affSColin Finck case DISPID_GLOBAL_TESTNORES:
1172c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1173c2c66affSColin Finck if(pvarRes)
1174c2c66affSColin Finck V_VT(pvarRes) = VT_NULL;
1175c2c66affSColin Finck return S_OK;
1176c2c66affSColin Finck
1177c2c66affSColin Finck case DISPID_GLOBAL_TESTOBJ:
1178c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
1179c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1180c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
1181c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1182c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1183c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1184c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1185c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1186c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1187c2c66affSColin Finck
1188c2c66affSColin Finck V_VT(pvarRes) = VT_DISPATCH;
1189c2c66affSColin Finck V_DISPATCH(pvarRes) = (IDispatch*)&testObj;
1190c2c66affSColin Finck return S_OK;
1191c2c66affSColin Finck
1192c2c66affSColin Finck case DISPID_GLOBAL_PUREDISP:
1193c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
1194c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1195c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
1196c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1197c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1198c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1199c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1200c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1201c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1202c2c66affSColin Finck
1203c2c66affSColin Finck V_VT(pvarRes) = VT_DISPATCH;
1204c2c66affSColin Finck V_DISPATCH(pvarRes) = (IDispatch*)&pureDisp;
1205c2c66affSColin Finck return S_OK;
1206c2c66affSColin Finck
1207c2c66affSColin Finck case DISPID_GLOBAL_DISPEXFUNC:
1208c2c66affSColin Finck V_VT(pvarRes) = VT_DISPATCH;
1209c2c66affSColin Finck V_DISPATCH(pvarRes) = (IDispatch*)&dispexFunc;
1210c2c66affSColin Finck return S_OK;
1211c2c66affSColin Finck
1212c2c66affSColin Finck case DISPID_GLOBAL_GETNULLBSTR:
1213c2c66affSColin Finck if(pvarRes) {
1214c2c66affSColin Finck V_VT(pvarRes) = VT_BSTR;
1215c2c66affSColin Finck V_BSTR(pvarRes) = NULL;
1216c2c66affSColin Finck }
1217c2c66affSColin Finck return S_OK;
1218c2c66affSColin Finck
1219c2c66affSColin Finck case DISPID_GLOBAL_ISNULLBSTR:
1220c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1221c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1222c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1223c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1224c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1225c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1226c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1227c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1228c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_BSTR, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1229c2c66affSColin Finck
1230c2c66affSColin Finck V_VT(pvarRes) = VT_BOOL;
1231c2c66affSColin Finck V_BOOL(pvarRes) = V_BSTR(pdp->rgvarg) ? VARIANT_FALSE : VARIANT_TRUE;
1232c2c66affSColin Finck return S_OK;
1233c2c66affSColin Finck
1234c2c66affSColin Finck case DISPID_GLOBAL_ISWIN64:
1235c2c66affSColin Finck if(pvarRes) {
1236c2c66affSColin Finck V_VT(pvarRes) = VT_BOOL;
1237c2c66affSColin Finck V_BOOL(pvarRes) = sizeof(void*) == 8 ? VARIANT_TRUE : VARIANT_FALSE;
1238c2c66affSColin Finck }
1239c2c66affSColin Finck return S_OK;
1240c2c66affSColin Finck
1241c2c66affSColin Finck case DISPID_GLOBAL_NULL_DISP:
1242c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
1243c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1244c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
1245c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1246c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1247c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1248c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1249c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1250c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1251c2c66affSColin Finck
1252c2c66affSColin Finck V_VT(pvarRes) = VT_DISPATCH;
1253c2c66affSColin Finck V_DISPATCH(pvarRes) = NULL;
1254c2c66affSColin Finck return S_OK;
1255c2c66affSColin Finck
1256c2c66affSColin Finck case DISPID_GLOBAL_TESTTHIS:
1257c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1258c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1259c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1260c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1261c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1262c2c66affSColin Finck ok(pvarRes == NULL, "pvarRes != NULL\n");
1263c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1264c2c66affSColin Finck
1265c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1266c2c66affSColin Finck ok(V_DISPATCH(pdp->rgvarg) == (IDispatch*)iface, "disp != iface\n");
1267c2c66affSColin Finck
1268c2c66affSColin Finck return S_OK;
1269c2c66affSColin Finck
1270c2c66affSColin Finck case DISPID_GLOBAL_TESTTHIS2:
1271c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1272c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1273c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1274c2c66affSColin Finck ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1275c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1276c2c66affSColin Finck ok(pvarRes == NULL, "pvarRes != NULL\n");
1277c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1278c2c66affSColin Finck
1279c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg));
1280c2c66affSColin Finck ok(V_DISPATCH(pdp->rgvarg) != (IDispatch*)iface, "disp == iface\n");
1281c2c66affSColin Finck ok(V_DISPATCH(pdp->rgvarg) == script_disp, "disp != script_disp\n");
1282c2c66affSColin Finck
1283c2c66affSColin Finck return S_OK;
1284c2c66affSColin Finck
1285c2c66affSColin Finck case DISPID_GLOBAL_INVOKEVERSION:
1286c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYGET, "wFlags = %x\n", wFlags);
1287c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1288c2c66affSColin Finck ok(!pdp->rgvarg, "rgvarg != NULL\n");
1289c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1290c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1291c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1292c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1293c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1294c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1295c2c66affSColin Finck
1296c2c66affSColin Finck V_VT(pvarRes) = VT_I4;
1297c2c66affSColin Finck V_I4(pvarRes) = invoke_version;
1298c2c66affSColin Finck
1299c2c66affSColin Finck return S_OK;
1300c2c66affSColin Finck
1301c2c66affSColin Finck case DISPID_GLOBAL_CREATEARRAY: {
1302c2c66affSColin Finck SAFEARRAYBOUND bound[2];
1303c2c66affSColin Finck VARIANT *data;
1304c2c66affSColin Finck int i,j;
1305c2c66affSColin Finck
1306c2c66affSColin Finck ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
1307c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1308c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1309c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1310c2c66affSColin Finck ok(!pdp->cArgs, "cArgs = %d\n", pdp->cArgs);
1311c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1312c2c66affSColin Finck ok(pvarRes != NULL, "pvarRes == NULL\n");
1313c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1314c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1315c2c66affSColin Finck
1316c2c66affSColin Finck bound[0].lLbound = 0;
1317c2c66affSColin Finck bound[0].cElements = 5;
1318c2c66affSColin Finck bound[1].lLbound = 2;
1319c2c66affSColin Finck bound[1].cElements = 2;
1320c2c66affSColin Finck
1321c2c66affSColin Finck V_VT(pvarRes) = VT_ARRAY|VT_VARIANT;
1322c2c66affSColin Finck V_ARRAY(pvarRes) = SafeArrayCreate(VT_VARIANT, 2, bound);
1323c2c66affSColin Finck
1324c2c66affSColin Finck SafeArrayAccessData(V_ARRAY(pvarRes), (void**)&data);
1325c2c66affSColin Finck for(i=0; i<5; i++) {
1326c2c66affSColin Finck for(j=2; j<4; j++) {
1327c2c66affSColin Finck V_VT(data) = VT_I4;
1328c2c66affSColin Finck V_I4(data) = i*10+j;
1329c2c66affSColin Finck data++;
1330c2c66affSColin Finck }
1331c2c66affSColin Finck }
1332c2c66affSColin Finck SafeArrayUnaccessData(V_ARRAY(pvarRes));
1333c2c66affSColin Finck
1334c2c66affSColin Finck return S_OK;
1335c2c66affSColin Finck }
1336c2c66affSColin Finck
1337c2c66affSColin Finck case DISPID_GLOBAL_PROPGETFUNC:
1338c2c66affSColin Finck switch(wFlags) {
1339c2c66affSColin Finck case INVOKE_FUNC:
1340c2c66affSColin Finck CHECK_EXPECT(invoke_func);
1341c2c66affSColin Finck break;
1342c2c66affSColin Finck case INVOKE_FUNC|INVOKE_PROPERTYGET:
1343c2c66affSColin Finck ok(pdp->cArgs != 0, "pdp->cArgs = %d\n", pdp->cArgs);
1344c2c66affSColin Finck ok(pvarRes != NULL, "pdp->pvarRes == NULL\n");
1345c2c66affSColin Finck break;
1346c2c66affSColin Finck default:
1347c2c66affSColin Finck ok(0, "invalid flag (%x)\n", wFlags);
1348c2c66affSColin Finck }
1349c2c66affSColin Finck
1350c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1351c2c66affSColin Finck ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1352c2c66affSColin Finck ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1353c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1354c2c66affSColin Finck
1355c2c66affSColin Finck if(pvarRes) {
1356c2c66affSColin Finck ok(V_VT(pvarRes) == VT_EMPTY, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1357c2c66affSColin Finck V_VT(pvarRes) = VT_I4;
1358c2c66affSColin Finck V_I4(pvarRes) = pdp->cArgs;
1359c2c66affSColin Finck }
1360c2c66affSColin Finck
1361c2c66affSColin Finck return S_OK;
1362c2c66affSColin Finck
1363c2c66affSColin Finck case DISPID_GLOBAL_GETSCRIPTSTATE: {
1364c2c66affSColin Finck SCRIPTSTATE state;
1365c2c66affSColin Finck HRESULT hres;
1366c2c66affSColin Finck
1367c2c66affSColin Finck hres = IActiveScript_GetScriptState(script_engine, &state);
1368c2c66affSColin Finck ok(hres == S_OK, "GetScriptState failed: %08x\n", hres);
1369c2c66affSColin Finck
1370c2c66affSColin Finck V_VT(pvarRes) = VT_I4;
1371c2c66affSColin Finck V_I4(pvarRes) = state;
1372c2c66affSColin Finck return S_OK;
1373c2c66affSColin Finck }
1374c2c66affSColin Finck
1375c2c66affSColin Finck case DISPID_GLOBAL_BINDEVENTHANDLER:
1376c2c66affSColin Finck V_VT(pvarRes) = VT_DISPATCH;
1377c2c66affSColin Finck V_DISPATCH(pvarRes) = (IDispatch*)&bindEventHandlerDisp;
1378c2c66affSColin Finck return S_OK;
1379c2c66affSColin Finck
1380c2c66affSColin Finck case DISPID_GLOBAL_PROPARGPUT:
1381c2c66affSColin Finck CHECK_EXPECT(global_propargput_i);
1382c2c66affSColin Finck ok(wFlags == INVOKE_PROPERTYPUT, "wFlags = %x\n", wFlags);
1383c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1384c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
1385c2c66affSColin Finck ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1386c2c66affSColin Finck ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs);
1387c2c66affSColin Finck ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1388c2c66affSColin Finck ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1389c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1390c2c66affSColin Finck ok(pei != NULL, "pei == NULL\n");
1391c2c66affSColin Finck
1392c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1393c2c66affSColin Finck ok(V_I4(pdp->rgvarg) == 2, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp->rgvarg));
1394c2c66affSColin Finck
1395c2c66affSColin Finck ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
1396c2c66affSColin Finck ok(V_I4(pdp->rgvarg+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1));
1397c2c66affSColin Finck
1398c2c66affSColin Finck ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp->rgvarg+2));
1399c2c66affSColin Finck ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2));
1400c2c66affSColin Finck return S_OK;
1401c2c66affSColin Finck
1402021b5c1fSAmine Khaldi case DISPID_GLOBAL_PROPARGPUTOP:
1403021b5c1fSAmine Khaldi ok(pdp != NULL, "pdp == NULL\n");
1404021b5c1fSAmine Khaldi ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
1405021b5c1fSAmine Khaldi ok(pei != NULL, "pei == NULL\n");
1406021b5c1fSAmine Khaldi
1407021b5c1fSAmine Khaldi switch(wFlags) {
1408021b5c1fSAmine Khaldi case INVOKE_PROPERTYGET | INVOKE_FUNC:
1409021b5c1fSAmine Khaldi CHECK_EXPECT(global_propargputop_get_i);
1410021b5c1fSAmine Khaldi
1411021b5c1fSAmine Khaldi ok(pdp->cNamedArgs == 0, "cNamedArgs = %d\n", pdp->cNamedArgs);
1412021b5c1fSAmine Khaldi ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1413021b5c1fSAmine Khaldi ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs);
1414021b5c1fSAmine Khaldi ok(pdp->cNamedArgs == 0, "cNamedArgs = %d\n", pdp->cNamedArgs);
1415021b5c1fSAmine Khaldi ok(pvarRes != NULL, "pvarRes = NULL\n");
1416021b5c1fSAmine Khaldi
1417021b5c1fSAmine Khaldi ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1418021b5c1fSAmine Khaldi ok(V_I4(pdp->rgvarg) == 1, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp->rgvarg));
1419021b5c1fSAmine Khaldi
1420021b5c1fSAmine Khaldi ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
1421021b5c1fSAmine Khaldi ok(V_I4(pdp->rgvarg+1) == 0, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1));
1422021b5c1fSAmine Khaldi
1423021b5c1fSAmine Khaldi V_VT(pvarRes) = VT_I4;
1424021b5c1fSAmine Khaldi V_I4(pvarRes) = 6;
1425021b5c1fSAmine Khaldi break;
1426021b5c1fSAmine Khaldi case INVOKE_PROPERTYPUT:
1427021b5c1fSAmine Khaldi CHECK_EXPECT(global_propargputop_put_i);
1428021b5c1fSAmine Khaldi
1429021b5c1fSAmine Khaldi ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1430021b5c1fSAmine Khaldi ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]);
1431021b5c1fSAmine Khaldi ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n");
1432021b5c1fSAmine Khaldi ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs);
1433021b5c1fSAmine Khaldi ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs);
1434021b5c1fSAmine Khaldi ok(!pvarRes, "pvarRes != NULL\n");
1435021b5c1fSAmine Khaldi
1436021b5c1fSAmine Khaldi ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1437021b5c1fSAmine Khaldi ok(V_I4(pdp->rgvarg) == 8, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp->rgvarg));
1438021b5c1fSAmine Khaldi
1439021b5c1fSAmine Khaldi ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
1440021b5c1fSAmine Khaldi ok(V_I4(pdp->rgvarg+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1));
1441021b5c1fSAmine Khaldi
1442021b5c1fSAmine Khaldi ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp->rgvarg+2));
1443021b5c1fSAmine Khaldi ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2));
1444021b5c1fSAmine Khaldi break;
1445021b5c1fSAmine Khaldi default:
1446021b5c1fSAmine Khaldi ok(0, "wFlags = %x\n", wFlags);
1447021b5c1fSAmine Khaldi }
1448021b5c1fSAmine Khaldi
1449021b5c1fSAmine Khaldi return S_OK;
1450021b5c1fSAmine Khaldi
1451c2c66affSColin Finck case DISPID_GLOBAL_OBJECT_FLAG: {
1452c2c66affSColin Finck IDispatchEx *dispex;
1453c2c66affSColin Finck BSTR str;
1454c2c66affSColin Finck HRESULT hres;
1455c2c66affSColin Finck
1456c2c66affSColin Finck hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&dispex);
1457c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1458c2c66affSColin Finck
1459c2c66affSColin Finck str = a2bstr("Object");
1460c2c66affSColin Finck hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
1461c2c66affSColin Finck SysFreeString(str);
1462c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1463c2c66affSColin Finck
1464c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_METHOD, pdp, NULL, pei, pspCaller);
1465c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1466c2c66affSColin Finck
1467c2c66affSColin Finck V_VT(pvarRes) = VT_EMPTY;
1468c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_METHOD, pdp, pvarRes, pei, pspCaller);
1469c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1470c2c66affSColin Finck ok(V_VT(pvarRes) == VT_DISPATCH, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1471c2c66affSColin Finck VariantClear(pvarRes);
1472c2c66affSColin Finck
1473c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_METHOD|DISPATCH_PROPERTYGET, pdp, NULL, pei, pspCaller);
1474c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1475c2c66affSColin Finck
1476c2c66affSColin Finck V_VT(pvarRes) = VT_EMPTY;
1477c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_CONSTRUCT, pdp, pvarRes, pei, pspCaller);
1478c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1479c2c66affSColin Finck ok(V_VT(pvarRes) == VT_DISPATCH, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1480c2c66affSColin Finck VariantClear(pvarRes);
1481c2c66affSColin Finck
1482c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_CONSTRUCT, pdp, NULL, pei, pspCaller);
1483c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1484c2c66affSColin Finck
1485c2c66affSColin Finck V_VT(pvarRes) = VT_EMPTY;
1486c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, DISPATCH_CONSTRUCT|DISPATCH_PROPERTYGET, pdp, pvarRes, pei, pspCaller);
1487c2c66affSColin Finck ok(hres == E_INVALIDARG, "hres = %x\n", hres);
1488c2c66affSColin Finck
1489c2c66affSColin Finck V_VT(pvarRes) = VT_EMPTY;
1490c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1491c2c66affSColin Finck ok(hres == S_OK, "hres = %x\n", hres);
1492c2c66affSColin Finck ok(V_VT(pvarRes) == VT_DISPATCH, "V_VT(pvarRes) = %d\n", V_VT(pvarRes));
1493c2c66affSColin Finck IDispatchEx_Release(dispex);
1494c2c66affSColin Finck return S_OK;
1495c2c66affSColin Finck }
1496c2c66affSColin Finck case DISPID_GLOBAL_SHORTPROP:
1497c2c66affSColin Finck case DISPID_GLOBAL_GETSHORT:
1498c2c66affSColin Finck V_VT(pvarRes) = VT_I2;
1499c2c66affSColin Finck V_I2(pvarRes) = 10;
1500c2c66affSColin Finck return S_OK;
1501c2c66affSColin Finck
1502c2c66affSColin Finck case DISPID_GLOBAL_INTPROP:
1503c2c66affSColin Finck V_VT(pvarRes) = VT_INT;
1504c2c66affSColin Finck V_INT(pvarRes) = 22;
1505c2c66affSColin Finck return S_OK;
1506c2c66affSColin Finck
1507c2c66affSColin Finck case DISPID_GLOBAL_DISPUNK:
1508c2c66affSColin Finck V_VT(pvarRes) = VT_UNKNOWN;
1509c2c66affSColin Finck V_UNKNOWN(pvarRes) = (IUnknown*)&testObj;
1510c2c66affSColin Finck return S_OK;
1511c2c66affSColin Finck
1512c2c66affSColin Finck case DISPID_GLOBAL_TESTARGTYPES: {
1513021b5c1fSAmine Khaldi VARIANT args[10], v;
151420f9fb61SAmine Khaldi DISPPARAMS dp = {args, NULL, ARRAY_SIZE(args), 0};
1515c2c66affSColin Finck HRESULT hres;
1516c2c66affSColin Finck
1517c2c66affSColin Finck CHECK_EXPECT(global_testargtypes_i);
1518c2c66affSColin Finck ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
1519c2c66affSColin Finck ok(pdp != NULL, "pdp == NULL\n");
1520c2c66affSColin Finck ok(pdp->rgvarg != NULL, "rgvarg != NULL\n");
1521c2c66affSColin Finck ok(pdp->cArgs == 6, "cArgs = %d\n", pdp->cArgs);
1522c2c66affSColin Finck ok(!pvarRes, "pvarRes != NULL\n");
1523c2c66affSColin Finck
1524c2c66affSColin Finck ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1));
1525c2c66affSColin Finck ok(V_I4(pdp->rgvarg+1) == 10, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1));
1526c2c66affSColin Finck
1527c2c66affSColin Finck ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp->rgvarg+2));
1528c2c66affSColin Finck ok(V_I4(pdp->rgvarg+2) == 10, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2));
1529c2c66affSColin Finck
1530c2c66affSColin Finck ok(V_VT(pdp->rgvarg+3) == VT_I4, "V_VT(pdp->rgvarg+3) = %d\n", V_VT(pdp->rgvarg+3));
1531c2c66affSColin Finck ok(V_I4(pdp->rgvarg+3) == 22, "V_I4(pdp->rgvarg+3) = %d\n", V_I4(pdp->rgvarg+3));
1532c2c66affSColin Finck
1533c2c66affSColin Finck ok(V_VT(pdp->rgvarg+4) == VT_I4, "V_VT(pdp->rgvarg+4) = %d\n", V_VT(pdp->rgvarg+4));
1534c2c66affSColin Finck ok(V_I4(pdp->rgvarg+4) == 22, "V_I4(pdp->rgvarg+4) = %d\n", V_I4(pdp->rgvarg+4));
1535c2c66affSColin Finck
1536c2c66affSColin Finck ok(V_VT(pdp->rgvarg+5) == VT_DISPATCH, "V_VT(pdp->rgvarg+5) = %d\n", V_VT(pdp->rgvarg+5));
1537c2c66affSColin Finck ok(V_DISPATCH(pdp->rgvarg+5) == (IDispatch*)&testObj, "V_DISPATCH(pdp->rgvarg+5) != testObj\n");
1538c2c66affSColin Finck
1539c2c66affSColin Finck ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg));
1540c2c66affSColin Finck
1541c2c66affSColin Finck V_VT(args) = VT_I2;
1542c2c66affSColin Finck V_I2(args) = 2;
1543c2c66affSColin Finck V_VT(args+1) = VT_INT;
1544c2c66affSColin Finck V_INT(args+1) = 22;
1545c2c66affSColin Finck V_VT(args+2) = VT_UNKNOWN;
1546c2c66affSColin Finck V_UNKNOWN(args+2) = (IUnknown*)&testObj;
1547c2c66affSColin Finck V_VT(args+3) = VT_UNKNOWN;
1548c2c66affSColin Finck V_UNKNOWN(args+3) = NULL;
1549c2c66affSColin Finck V_VT(args+4) = VT_UI4;
1550c2c66affSColin Finck V_UI4(args+4) = 0xffffffff;
1551c2c66affSColin Finck V_VT(args+5) = VT_BYREF|VT_VARIANT;
1552c2c66affSColin Finck V_VARIANTREF(args+5) = &v;
1553c2c66affSColin Finck V_VT(args+6) = VT_R4;
1554c2c66affSColin Finck V_R4(args+6) = 0.5;
1555df52b0e7SAmine Khaldi V_VT(args+7) = VT_UI2;
1556021b5c1fSAmine Khaldi V_UI2(args+7) = 3;
1557021b5c1fSAmine Khaldi V_VT(args+8) = VT_UI1;
1558021b5c1fSAmine Khaldi V_UI1(args+8) = 4;
1559021b5c1fSAmine Khaldi V_VT(args+9) = VT_I1;
1560021b5c1fSAmine Khaldi V_I1(args+9) = 5;
1561c2c66affSColin Finck V_VT(&v) = VT_I4;
1562c2c66affSColin Finck V_I4(&v) = 2;
1563c2c66affSColin Finck hres = IDispatch_Invoke(V_DISPATCH(pdp->rgvarg), DISPID_VALUE, &IID_NULL, 0, DISPATCH_METHOD, &dp, NULL, NULL, NULL);
1564c2c66affSColin Finck ok(hres == S_OK, "Invoke failed: %08x\n", hres);
1565c2c66affSColin Finck
1566c2c66affSColin Finck return S_OK;
1567c2c66affSColin Finck }
1568021b5c1fSAmine Khaldi
1569021b5c1fSAmine Khaldi case DISPID_GLOBAL_CALLEVAL: {
1570021b5c1fSAmine Khaldi IDispatchEx *eval_func;
1571021b5c1fSAmine Khaldi DISPPARAMS params;
1572021b5c1fSAmine Khaldi VARIANT arg, res;
1573021b5c1fSAmine Khaldi HRESULT hres;
1574021b5c1fSAmine Khaldi
1575021b5c1fSAmine Khaldi CHECK_EXPECT(global_calleval_i);
1576021b5c1fSAmine Khaldi
1577021b5c1fSAmine Khaldi ok(pdp != NULL, "pdp == NULL\n");
1578021b5c1fSAmine Khaldi ok(pdp->rgvarg != NULL, "rgvarg == NULL\n");
1579021b5c1fSAmine Khaldi ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
1580021b5c1fSAmine Khaldi ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
1581021b5c1fSAmine Khaldi ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs);
1582021b5c1fSAmine Khaldi ok(pvarRes == NULL, "pvarRes != NULL\n");
1583021b5c1fSAmine Khaldi ok(pei != NULL, "pei == NULL\n");
1584021b5c1fSAmine Khaldi
1585021b5c1fSAmine Khaldi ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg));
1586021b5c1fSAmine Khaldi hres = IDispatch_QueryInterface(V_DISPATCH(pdp->rgvarg), &IID_IDispatchEx, (void**)&eval_func);
1587021b5c1fSAmine Khaldi ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
1588021b5c1fSAmine Khaldi
1589021b5c1fSAmine Khaldi params.rgvarg = &arg;
1590021b5c1fSAmine Khaldi params.rgdispidNamedArgs = NULL;
1591021b5c1fSAmine Khaldi params.cArgs = 1;
1592021b5c1fSAmine Khaldi params.cNamedArgs = 0;
1593021b5c1fSAmine Khaldi V_VT(&arg) = VT_BSTR;
1594021b5c1fSAmine Khaldi
1595021b5c1fSAmine Khaldi V_BSTR(&arg) = a2bstr("var x = 5; v");
1596021b5c1fSAmine Khaldi V_VT(&res) = VT_ERROR;
1597021b5c1fSAmine Khaldi hres = IDispatchEx_InvokeEx(eval_func, DISPID_VALUE, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
1598021b5c1fSAmine Khaldi ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1599021b5c1fSAmine Khaldi ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
1600021b5c1fSAmine Khaldi ok(V_I4(&res) == 2, "eval returned %d\n", V_I4(&res));
1601021b5c1fSAmine Khaldi SysFreeString(V_BSTR(&arg));
1602021b5c1fSAmine Khaldi IDispatchEx_Release(eval_func);
1603021b5c1fSAmine Khaldi return S_OK;
1604021b5c1fSAmine Khaldi }
1605c2c66affSColin Finck }
1606c2c66affSColin Finck
1607c2c66affSColin Finck ok(0, "unexpected call %x\n", id);
1608c2c66affSColin Finck return DISP_E_MEMBERNOTFOUND;
1609c2c66affSColin Finck }
1610c2c66affSColin Finck
Global_DeleteMemberByDispID(IDispatchEx * iface,DISPID id)1611c2c66affSColin Finck static HRESULT WINAPI Global_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1612c2c66affSColin Finck {
1613c2c66affSColin Finck switch(id) {
1614c2c66affSColin Finck case DISPID_GLOBAL_TESTPROPDELETE:
1615c2c66affSColin Finck CHECK_EXPECT(DeleteMemberByDispID);
1616c2c66affSColin Finck return S_OK;
1617c2c66affSColin Finck case DISPID_GLOBAL_TESTNOPROPDELETE:
1618c2c66affSColin Finck CHECK_EXPECT(DeleteMemberByDispID_false);
1619c2c66affSColin Finck return S_FALSE;
1620c2c66affSColin Finck case DISPID_GLOBAL_TESTPROPDELETEERROR:
1621c2c66affSColin Finck CHECK_EXPECT(DeleteMemberByDispID_error);
1622c2c66affSColin Finck return E_FAIL;
1623c2c66affSColin Finck default:
1624c2c66affSColin Finck ok(0, "id = %d\n", id);
1625c2c66affSColin Finck }
1626c2c66affSColin Finck
1627c2c66affSColin Finck return E_FAIL;
1628c2c66affSColin Finck }
1629c2c66affSColin Finck
1630c2c66affSColin Finck static IDispatchExVtbl GlobalVtbl = {
1631c2c66affSColin Finck DispatchEx_QueryInterface,
1632c2c66affSColin Finck DispatchEx_AddRef,
1633c2c66affSColin Finck DispatchEx_Release,
1634c2c66affSColin Finck DispatchEx_GetTypeInfoCount,
1635c2c66affSColin Finck DispatchEx_GetTypeInfo,
1636c2c66affSColin Finck DispatchEx_GetIDsOfNames,
1637c2c66affSColin Finck DispatchEx_Invoke,
1638c2c66affSColin Finck Global_GetDispID,
1639c2c66affSColin Finck Global_InvokeEx,
1640c2c66affSColin Finck DispatchEx_DeleteMemberByName,
1641c2c66affSColin Finck Global_DeleteMemberByDispID,
1642c2c66affSColin Finck DispatchEx_GetMemberProperties,
1643c2c66affSColin Finck DispatchEx_GetMemberName,
1644c2c66affSColin Finck DispatchEx_GetNextDispID,
1645c2c66affSColin Finck DispatchEx_GetNameSpaceParent
1646c2c66affSColin Finck };
1647c2c66affSColin Finck
1648c2c66affSColin Finck static IDispatchEx Global = { &GlobalVtbl };
1649c2c66affSColin Finck
ActiveScriptSite_QueryInterface(IActiveScriptSite * iface,REFIID riid,void ** ppv)1650c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
1651c2c66affSColin Finck {
1652c2c66affSColin Finck *ppv = NULL;
1653c2c66affSColin Finck
1654c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid))
1655c2c66affSColin Finck *ppv = iface;
1656c2c66affSColin Finck else if(IsEqualGUID(&IID_IActiveScriptSite, riid))
1657c2c66affSColin Finck *ppv = iface;
1658c2c66affSColin Finck else
1659c2c66affSColin Finck return E_NOINTERFACE;
1660c2c66affSColin Finck
1661c2c66affSColin Finck IUnknown_AddRef((IUnknown*)*ppv);
1662c2c66affSColin Finck return S_OK;
1663c2c66affSColin Finck }
1664c2c66affSColin Finck
ActiveScriptSite_AddRef(IActiveScriptSite * iface)1665c2c66affSColin Finck static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
1666c2c66affSColin Finck {
1667c2c66affSColin Finck return 2;
1668c2c66affSColin Finck }
1669c2c66affSColin Finck
ActiveScriptSite_Release(IActiveScriptSite * iface)1670c2c66affSColin Finck static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
1671c2c66affSColin Finck {
1672c2c66affSColin Finck return 1;
1673c2c66affSColin Finck }
1674c2c66affSColin Finck
ActiveScriptSite_GetLCID(IActiveScriptSite * iface,LCID * plcid)1675c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
1676c2c66affSColin Finck {
1677c2c66affSColin Finck *plcid = GetUserDefaultLCID();
1678c2c66affSColin Finck return S_OK;
1679c2c66affSColin Finck }
1680c2c66affSColin Finck
ActiveScriptSite_GetItemInfo(IActiveScriptSite * iface,LPCOLESTR pstrName,DWORD dwReturnMask,IUnknown ** ppiunkItem,ITypeInfo ** ppti)1681c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName,
1682c2c66affSColin Finck DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
1683c2c66affSColin Finck {
1684c2c66affSColin Finck ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "unexpected dwReturnMask %x\n", dwReturnMask);
1685c2c66affSColin Finck ok(!ppti, "ppti != NULL\n");
1686c2c66affSColin Finck
1687c2c66affSColin Finck if(!strcmp_wa(pstrName, test_valA))
1688c2c66affSColin Finck CHECK_EXPECT(GetItemInfo_testVal);
1689c2c66affSColin Finck else if(strcmp_wa(pstrName, testA))
1690c2c66affSColin Finck ok(0, "unexpected pstrName %s\n", wine_dbgstr_w(pstrName));
1691c2c66affSColin Finck
1692c2c66affSColin Finck *ppiunkItem = (IUnknown*)&Global;
1693c2c66affSColin Finck return S_OK;
1694c2c66affSColin Finck }
1695c2c66affSColin Finck
ActiveScriptSite_GetDocVersionString(IActiveScriptSite * iface,BSTR * pbstrVersion)1696c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
1697c2c66affSColin Finck {
1698c2c66affSColin Finck return E_NOTIMPL;
1699c2c66affSColin Finck }
1700c2c66affSColin Finck
ActiveScriptSite_OnScriptTerminate(IActiveScriptSite * iface,const VARIANT * pvarResult,const EXCEPINFO * pexcepinfo)1701c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface,
1702c2c66affSColin Finck const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
1703c2c66affSColin Finck {
1704c2c66affSColin Finck return E_NOTIMPL;
1705c2c66affSColin Finck }
1706c2c66affSColin Finck
ActiveScriptSite_OnStateChange(IActiveScriptSite * iface,SCRIPTSTATE ssScriptState)1707c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
1708c2c66affSColin Finck {
1709c2c66affSColin Finck return E_NOTIMPL;
1710c2c66affSColin Finck }
1711c2c66affSColin Finck
ActiveScriptSite_OnScriptError(IActiveScriptSite * iface,IActiveScriptError * pscripterror)1712c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
1713c2c66affSColin Finck {
1714c2c66affSColin Finck return E_NOTIMPL;
1715c2c66affSColin Finck }
1716c2c66affSColin Finck
ActiveScriptSite_OnEnterScript(IActiveScriptSite * iface)1717c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
1718c2c66affSColin Finck {
1719c2c66affSColin Finck return E_NOTIMPL;
1720c2c66affSColin Finck }
1721c2c66affSColin Finck
ActiveScriptSite_OnLeaveScript(IActiveScriptSite * iface)1722c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
1723c2c66affSColin Finck {
1724c2c66affSColin Finck return E_NOTIMPL;
1725c2c66affSColin Finck }
1726c2c66affSColin Finck
1727c2c66affSColin Finck #undef ACTSCPSITE_THIS
1728c2c66affSColin Finck
1729c2c66affSColin Finck static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
1730c2c66affSColin Finck ActiveScriptSite_QueryInterface,
1731c2c66affSColin Finck ActiveScriptSite_AddRef,
1732c2c66affSColin Finck ActiveScriptSite_Release,
1733c2c66affSColin Finck ActiveScriptSite_GetLCID,
1734c2c66affSColin Finck ActiveScriptSite_GetItemInfo,
1735c2c66affSColin Finck ActiveScriptSite_GetDocVersionString,
1736c2c66affSColin Finck ActiveScriptSite_OnScriptTerminate,
1737c2c66affSColin Finck ActiveScriptSite_OnStateChange,
1738c2c66affSColin Finck ActiveScriptSite_OnScriptError,
1739c2c66affSColin Finck ActiveScriptSite_OnEnterScript,
1740c2c66affSColin Finck ActiveScriptSite_OnLeaveScript
1741c2c66affSColin Finck };
1742c2c66affSColin Finck
1743c2c66affSColin Finck static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
1744c2c66affSColin Finck
ActiveScriptSite_OnScriptError_CheckError(IActiveScriptSite * iface,IActiveScriptError * pscripterror)1745c2c66affSColin Finck static HRESULT WINAPI ActiveScriptSite_OnScriptError_CheckError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
1746c2c66affSColin Finck {
1747c2c66affSColin Finck ok(pscripterror != NULL, "ActiveScriptSite_OnScriptError -- expected pscripterror to be set, got NULL\n");
1748c2c66affSColin Finck
1749c2c66affSColin Finck script_error = pscripterror;
1750c2c66affSColin Finck IActiveScriptError_AddRef(script_error);
1751c2c66affSColin Finck
1752c2c66affSColin Finck CHECK_EXPECT(ActiveScriptSite_OnScriptError);
1753c2c66affSColin Finck
1754c2c66affSColin Finck return S_OK;
1755c2c66affSColin Finck }
1756c2c66affSColin Finck
1757c2c66affSColin Finck static const IActiveScriptSiteVtbl ActiveScriptSite_CheckErrorVtbl = {
1758c2c66affSColin Finck ActiveScriptSite_QueryInterface,
1759c2c66affSColin Finck ActiveScriptSite_AddRef,
1760c2c66affSColin Finck ActiveScriptSite_Release,
1761c2c66affSColin Finck ActiveScriptSite_GetLCID,
1762c2c66affSColin Finck ActiveScriptSite_GetItemInfo,
1763c2c66affSColin Finck ActiveScriptSite_GetDocVersionString,
1764c2c66affSColin Finck ActiveScriptSite_OnScriptTerminate,
1765c2c66affSColin Finck ActiveScriptSite_OnStateChange,
1766c2c66affSColin Finck ActiveScriptSite_OnScriptError_CheckError,
1767c2c66affSColin Finck ActiveScriptSite_OnEnterScript,
1768c2c66affSColin Finck ActiveScriptSite_OnLeaveScript
1769c2c66affSColin Finck };
1770c2c66affSColin Finck
1771c2c66affSColin Finck static IActiveScriptSite ActiveScriptSite_CheckError = { &ActiveScriptSite_CheckErrorVtbl };
1772c2c66affSColin Finck
set_script_prop(IActiveScript * engine,DWORD property,VARIANT * val)1773c2c66affSColin Finck static HRESULT set_script_prop(IActiveScript *engine, DWORD property, VARIANT *val)
1774c2c66affSColin Finck {
1775c2c66affSColin Finck IActiveScriptProperty *script_prop;
1776c2c66affSColin Finck HRESULT hres;
1777c2c66affSColin Finck
1778c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptProperty,
1779c2c66affSColin Finck (void**)&script_prop);
1780c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptProperty iface: %08x\n", hres);
1781c2c66affSColin Finck
1782c2c66affSColin Finck hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val);
1783c2c66affSColin Finck IActiveScriptProperty_Release(script_prop);
1784c2c66affSColin Finck
1785c2c66affSColin Finck return hres;
1786c2c66affSColin Finck }
1787c2c66affSColin Finck
create_script(void)1788c2c66affSColin Finck static IActiveScript *create_script(void)
1789c2c66affSColin Finck {
1790c2c66affSColin Finck IActiveScript *script;
1791c2c66affSColin Finck VARIANT v;
1792c2c66affSColin Finck HRESULT hres;
1793c2c66affSColin Finck
1794c2c66affSColin Finck hres = CoCreateInstance(engine_clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1795c2c66affSColin Finck &IID_IActiveScript, (void**)&script);
1796c2c66affSColin Finck ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
1797c2c66affSColin Finck
1798c2c66affSColin Finck V_VT(&v) = VT_I4;
1799c2c66affSColin Finck V_I4(&v) = invoke_version;
1800c2c66affSColin Finck hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
1801c2c66affSColin Finck ok(hres == S_OK || broken(hres == E_NOTIMPL), "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
1802c2c66affSColin Finck if(invoke_version && FAILED(hres)) {
1803c2c66affSColin Finck IActiveScript_Release(script);
1804c2c66affSColin Finck return NULL;
1805c2c66affSColin Finck }
1806c2c66affSColin Finck
1807c2c66affSColin Finck return script;
1808c2c66affSColin Finck }
1809c2c66affSColin Finck
parse_script(DWORD flags,BSTR script_str)1810c2c66affSColin Finck static HRESULT parse_script(DWORD flags, BSTR script_str)
1811c2c66affSColin Finck {
1812c2c66affSColin Finck IActiveScriptParse *parser;
1813c2c66affSColin Finck IActiveScript *engine;
1814c2c66affSColin Finck HRESULT hres;
1815c2c66affSColin Finck
1816c2c66affSColin Finck engine = create_script();
1817c2c66affSColin Finck if(!engine)
1818c2c66affSColin Finck return S_OK;
1819c2c66affSColin Finck
1820c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
1821c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
1822c2c66affSColin Finck if (FAILED(hres))
1823c2c66affSColin Finck {
1824c2c66affSColin Finck IActiveScript_Release(engine);
1825c2c66affSColin Finck return hres;
1826c2c66affSColin Finck }
1827c2c66affSColin Finck
1828c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
1829c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
1830c2c66affSColin Finck
1831c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
1832c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
1833c2c66affSColin Finck
1834c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, testW,
1835c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|flags);
1836c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
1837c2c66affSColin Finck
1838c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
1839c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
1840c2c66affSColin Finck
1841c2c66affSColin Finck hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
1842c2c66affSColin Finck ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
1843c2c66affSColin Finck ok(script_disp != NULL, "script_disp == NULL\n");
1844c2c66affSColin Finck ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
1845c2c66affSColin Finck
1846c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
1847c2c66affSColin Finck
1848c2c66affSColin Finck IDispatch_Release(script_disp);
1849c2c66affSColin Finck IActiveScript_Release(engine);
1850c2c66affSColin Finck IActiveScriptParse_Release(parser);
1851c2c66affSColin Finck
1852c2c66affSColin Finck return hres;
1853c2c66affSColin Finck }
1854c2c66affSColin Finck
invoke_procedure(const char * argsa,const char * sourcea,DISPPARAMS * dp)1855c2c66affSColin Finck static HRESULT invoke_procedure(const char *argsa, const char *sourcea, DISPPARAMS *dp)
1856c2c66affSColin Finck {
1857c2c66affSColin Finck IActiveScriptParseProcedure2 *parse_proc;
1858c2c66affSColin Finck IActiveScriptParse *parser;
1859c2c66affSColin Finck IActiveScript *engine;
1860c2c66affSColin Finck IDispatchEx *dispex;
1861c2c66affSColin Finck EXCEPINFO ei = {0};
1862c2c66affSColin Finck BSTR source, args;
1863c2c66affSColin Finck IDispatch *disp;
1864c2c66affSColin Finck VARIANT res;
1865c2c66affSColin Finck HRESULT hres;
1866c2c66affSColin Finck
1867c2c66affSColin Finck engine = create_script();
1868c2c66affSColin Finck if(!engine)
1869c2c66affSColin Finck return S_OK;
1870c2c66affSColin Finck
1871c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
1872c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
1873c2c66affSColin Finck
1874c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
1875c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
1876c2c66affSColin Finck
1877c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
1878c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
1879c2c66affSColin Finck
1880c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
1881c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
1882c2c66affSColin Finck
1883c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
1884c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
1885c2c66affSColin Finck
1886c2c66affSColin Finck source = a2bstr(sourcea);
1887c2c66affSColin Finck args = argsa ? a2bstr(argsa) : NULL;
1888c2c66affSColin Finck hres = IActiveScriptParseProcedure2_ParseProcedureText(parse_proc, source, args, emptyW, NULL, NULL, NULL, 0, 0,
1889c2c66affSColin Finck SCRIPTPROC_HOSTMANAGESSOURCE|SCRIPTPROC_IMPLICIT_THIS|SCRIPTPROC_IMPLICIT_PARENTS, &disp);
1890c2c66affSColin Finck ok(hres == S_OK, "ParseProcedureText failed: %08x\n", hres);
1891c2c66affSColin Finck SysFreeString(source);
1892c2c66affSColin Finck SysFreeString(args);
1893c2c66affSColin Finck
1894c2c66affSColin Finck hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
1895c2c66affSColin Finck ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
1896c2c66affSColin Finck IDispatch_Release(disp);
1897c2c66affSColin Finck
1898c2c66affSColin Finck V_VT(&res) = VT_EMPTY;
1899c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, 0, DISPATCH_METHOD, dp, &res, &ei, NULL);
1900c2c66affSColin Finck ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1901c2c66affSColin Finck ok(V_VT(&res) == VT_BOOL && V_BOOL(&res), "InvokeEx returned vt %d (%x)\n", V_VT(&res), V_I4(&res));
1902c2c66affSColin Finck IDispatchEx_Release(dispex);
1903c2c66affSColin Finck
1904c2c66affSColin Finck IActiveScriptParseProcedure2_Release(parse_proc);
1905c2c66affSColin Finck IActiveScript_Release(engine);
1906c2c66affSColin Finck IActiveScriptParse_Release(parser);
1907c2c66affSColin Finck
1908c2c66affSColin Finck return hres;
1909c2c66affSColin Finck }
1910c2c66affSColin Finck
parse_htmlscript(BSTR script_str)1911c2c66affSColin Finck static HRESULT parse_htmlscript(BSTR script_str)
1912c2c66affSColin Finck {
1913c2c66affSColin Finck IActiveScriptParse *parser;
1914c2c66affSColin Finck IActiveScript *engine;
1915c2c66affSColin Finck HRESULT hres;
1916c2c66affSColin Finck BSTR tmp = a2bstr("</SCRIPT>");
1917c2c66affSColin Finck
1918c2c66affSColin Finck engine = create_script();
1919c2c66affSColin Finck if(!engine)
1920c2c66affSColin Finck return E_FAIL;
1921c2c66affSColin Finck
1922c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
1923c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
1924c2c66affSColin Finck if (FAILED(hres))
1925c2c66affSColin Finck {
1926c2c66affSColin Finck IActiveScript_Release(engine);
1927c2c66affSColin Finck return E_FAIL;
1928c2c66affSColin Finck }
1929c2c66affSColin Finck
1930c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
1931c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
1932c2c66affSColin Finck
1933c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
1934c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
1935c2c66affSColin Finck
1936c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, testW,
1937c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
1938c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
1939c2c66affSColin Finck
1940c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
1941c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
1942c2c66affSColin Finck
1943c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, tmp, 0, 0, 0, NULL, NULL);
1944c2c66affSColin Finck
1945c2c66affSColin Finck IActiveScript_Release(engine);
1946c2c66affSColin Finck IActiveScriptParse_Release(parser);
1947c2c66affSColin Finck SysFreeString(tmp);
1948c2c66affSColin Finck
1949c2c66affSColin Finck return hres;
1950c2c66affSColin Finck }
1951c2c66affSColin Finck
test_IActiveScriptError(IActiveScriptError * error,SCODE errorcode,ULONG line,LONG pos,BSTR script_source,BSTR description,BSTR line_text)1952c2c66affSColin Finck static void test_IActiveScriptError(IActiveScriptError *error, SCODE errorcode, ULONG line, LONG pos, BSTR script_source, BSTR description, BSTR line_text)
1953c2c66affSColin Finck {
1954c2c66affSColin Finck HRESULT hres;
1955c2c66affSColin Finck DWORD source_context;
1956c2c66affSColin Finck ULONG line_number;
1957c2c66affSColin Finck LONG char_position;
1958c2c66affSColin Finck BSTR linetext;
1959c2c66affSColin Finck EXCEPINFO excep;
1960c2c66affSColin Finck
1961c2c66affSColin Finck /* IActiveScriptError_GetSourcePosition */
1962c2c66affSColin Finck
1963c2c66affSColin Finck hres = IActiveScriptError_GetSourcePosition(error, NULL, NULL, NULL);
1964c2c66affSColin Finck ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
1965c2c66affSColin Finck
1966c2c66affSColin Finck source_context = 0xdeadbeef;
1967c2c66affSColin Finck hres = IActiveScriptError_GetSourcePosition(error, &source_context, NULL, NULL);
1968c2c66affSColin Finck ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
1969c2c66affSColin Finck ok(source_context == 0, "IActiveScriptError_GetSourcePosition -- source_context: expected 0, got 0x%08x\n", source_context);
1970c2c66affSColin Finck
1971c2c66affSColin Finck line_number = 0xdeadbeef;
1972c2c66affSColin Finck hres = IActiveScriptError_GetSourcePosition(error, NULL, &line_number, NULL);
1973c2c66affSColin Finck ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
1974c2c66affSColin Finck ok(line_number == line, "IActiveScriptError_GetSourcePosition -- line_number: expected %d, got %d\n", line, line_number);
1975c2c66affSColin Finck
1976c2c66affSColin Finck char_position = 0xdeadbeef;
1977c2c66affSColin Finck hres = IActiveScriptError_GetSourcePosition(error, NULL, NULL, &char_position);
1978c2c66affSColin Finck ok(hres == S_OK, "IActiveScriptError_GetSourcePosition -- hres: expected S_OK, got 0x%08x\n", hres);
1979c2c66affSColin Finck ok(char_position == pos, "IActiveScriptError_GetSourcePosition -- char_position: expected %d, got %d\n", pos, char_position);
1980c2c66affSColin Finck
1981c2c66affSColin Finck /* IActiveScriptError_GetSourceLineText */
1982c2c66affSColin Finck
1983c2c66affSColin Finck hres = IActiveScriptError_GetSourceLineText(error, NULL);
1984c2c66affSColin Finck ok(hres == E_POINTER, "IActiveScriptError_GetSourceLineText -- hres: expected E_POINTER, got 0x%08x\n", hres);
1985c2c66affSColin Finck
1986c2c66affSColin Finck linetext = NULL;
1987c2c66affSColin Finck hres = IActiveScriptError_GetSourceLineText(error, &linetext);
1988c2c66affSColin Finck if (line_text) {
1989c2c66affSColin Finck ok(hres == S_OK, "IActiveScriptError_GetSourceLineText -- hres: expected S_OK, got 0x%08x\n", hres);
1990c2c66affSColin Finck ok(linetext != NULL && !lstrcmpW(linetext, line_text),
1991c2c66affSColin Finck "IActiveScriptError_GetSourceLineText -- expected %s, got %s\n", wine_dbgstr_w(line_text), wine_dbgstr_w(linetext));
1992c2c66affSColin Finck } else {
1993c2c66affSColin Finck ok(hres == E_FAIL, "IActiveScriptError_GetSourceLineText -- hres: expected S_OK, got 0x%08x\n", hres);
1994c2c66affSColin Finck ok(linetext == NULL,
1995c2c66affSColin Finck "IActiveScriptError_GetSourceLineText -- expected NULL, got %s\n", wine_dbgstr_w(linetext));
1996c2c66affSColin Finck }
1997c2c66affSColin Finck SysFreeString(linetext);
1998c2c66affSColin Finck
1999c2c66affSColin Finck /* IActiveScriptError_GetExceptionInfo */
2000c2c66affSColin Finck
2001c2c66affSColin Finck hres = IActiveScriptError_GetExceptionInfo(error, NULL);
2002c2c66affSColin Finck ok(hres == E_POINTER, "IActiveScriptError_GetExceptionInfo -- hres: expected E_POINTER, got 0x%08x\n", hres);
2003c2c66affSColin Finck
2004c2c66affSColin Finck excep.wCode = 0xdead;
2005c2c66affSColin Finck excep.wReserved = 0xdead;
2006c2c66affSColin Finck excep.bstrSource = (BSTR)0xdeadbeef;
2007c2c66affSColin Finck excep.bstrDescription = (BSTR)0xdeadbeef;
2008c2c66affSColin Finck excep.bstrHelpFile = (BSTR)0xdeadbeef;
2009c2c66affSColin Finck excep.dwHelpContext = 0xdeadbeef;
2010c2c66affSColin Finck excep.pvReserved = (void *)0xdeadbeef;
2011c2c66affSColin Finck excep.pfnDeferredFillIn = (void *)0xdeadbeef;
2012c2c66affSColin Finck excep.scode = 0xdeadbeef;
2013c2c66affSColin Finck
2014c2c66affSColin Finck hres = IActiveScriptError_GetExceptionInfo(error, &excep);
2015c2c66affSColin Finck ok(hres == S_OK, "IActiveScriptError_GetExceptionInfo -- hres: expected S_OK, got 0x%08x\n", hres);
2016c2c66affSColin Finck
2017c2c66affSColin Finck ok(excep.wCode == 0, "IActiveScriptError_GetExceptionInfo -- excep.wCode: expected 0, got 0x%08x\n", excep.wCode);
2018c2c66affSColin Finck ok(excep.wReserved == 0, "IActiveScriptError_GetExceptionInfo -- excep.wReserved: expected 0, got %d\n", excep.wReserved);
2019c2c66affSColin Finck if (!is_lang_english())
2020c2c66affSColin Finck skip("Non-english UI (test with hardcoded strings)\n");
2021c2c66affSColin Finck else {
2022c2c66affSColin Finck ok(excep.bstrSource != NULL && !lstrcmpW(excep.bstrSource, script_source),
2023c2c66affSColin Finck "IActiveScriptError_GetExceptionInfo -- excep.bstrSource is not valid: expected %s, got %s\n",
2024c2c66affSColin Finck wine_dbgstr_w(script_source), wine_dbgstr_w(excep.bstrSource));
2025c2c66affSColin Finck ok(excep.bstrDescription != NULL && !lstrcmpW(excep.bstrDescription, description),
2026c2c66affSColin Finck "IActiveScriptError_GetExceptionInfo -- excep.bstrDescription is not valid: got %s\n", wine_dbgstr_w(excep.bstrDescription));
2027c2c66affSColin Finck }
2028c2c66affSColin Finck ok(excep.bstrHelpFile == NULL,
2029c2c66affSColin Finck "IActiveScriptError_GetExceptionInfo -- excep.bstrHelpFile: expected NULL, got %s\n", wine_dbgstr_w(excep.bstrHelpFile));
2030c2c66affSColin Finck ok(excep.dwHelpContext == 0, "IActiveScriptError_GetExceptionInfo -- excep.dwHelpContext: expected 0, got %d\n", excep.dwHelpContext);
2031c2c66affSColin Finck ok(excep.pvReserved == NULL, "IActiveScriptError_GetExceptionInfo -- excep.pvReserved: expected NULL, got %p\n", excep.pvReserved);
2032c2c66affSColin Finck ok(excep.pfnDeferredFillIn == NULL, "IActiveScriptError_GetExceptionInfo -- excep.pfnDeferredFillIn: expected NULL, got %p\n", excep.pfnDeferredFillIn);
2033c2c66affSColin Finck ok(excep.scode == errorcode, "IActiveScriptError_GetExceptionInfo -- excep.scode: expected 0x%08x, got 0x%08x\n", errorcode, excep.scode);
2034c2c66affSColin Finck
2035c2c66affSColin Finck SysFreeString(excep.bstrSource);
2036c2c66affSColin Finck SysFreeString(excep.bstrDescription);
2037c2c66affSColin Finck SysFreeString(excep.bstrHelpFile);
2038c2c66affSColin Finck }
2039c2c66affSColin Finck
parse_script_with_error(DWORD flags,BSTR script_str,SCODE errorcode,ULONG line,LONG pos,BSTR script_source,BSTR description,BSTR line_text)2040c2c66affSColin Finck static void parse_script_with_error(DWORD flags, BSTR script_str, SCODE errorcode, ULONG line, LONG pos, BSTR script_source, BSTR description, BSTR line_text)
2041c2c66affSColin Finck {
2042c2c66affSColin Finck IActiveScriptParse *parser;
2043c2c66affSColin Finck IActiveScript *engine;
2044c2c66affSColin Finck HRESULT hres;
2045c2c66affSColin Finck
2046c2c66affSColin Finck engine = create_script();
2047c2c66affSColin Finck if(!engine)
2048c2c66affSColin Finck return;
2049c2c66affSColin Finck
2050c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2051c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2052c2c66affSColin Finck if (FAILED(hres))
2053c2c66affSColin Finck {
2054c2c66affSColin Finck IActiveScript_Release(engine);
2055c2c66affSColin Finck return;
2056c2c66affSColin Finck }
2057c2c66affSColin Finck
2058c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
2059c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2060c2c66affSColin Finck
2061c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite_CheckError);
2062c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2063c2c66affSColin Finck
2064c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, testW,
2065c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|flags);
2066c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2067c2c66affSColin Finck
2068c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2069c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2070c2c66affSColin Finck
2071c2c66affSColin Finck hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
2072c2c66affSColin Finck ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
2073c2c66affSColin Finck ok(script_disp != NULL, "script_disp == NULL\n");
2074c2c66affSColin Finck ok(script_disp != (IDispatch*)&Global, "script_disp == Global\n");
2075c2c66affSColin Finck
2076c2c66affSColin Finck script_error = NULL;
2077c2c66affSColin Finck SET_EXPECT(ActiveScriptSite_OnScriptError);
2078c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2079c2c66affSColin Finck todo_wine ok(hres == 0x80020101, "parse_script_with_error should have returned 0x80020101, got: 0x%08x\n", hres);
2080c2c66affSColin Finck todo_wine CHECK_CALLED(ActiveScriptSite_OnScriptError);
2081c2c66affSColin Finck
2082c2c66affSColin Finck if (script_error)
2083c2c66affSColin Finck {
2084c2c66affSColin Finck test_IActiveScriptError(script_error, errorcode, line, pos, script_source, description, line_text);
2085c2c66affSColin Finck
2086c2c66affSColin Finck IActiveScriptError_Release(script_error);
2087c2c66affSColin Finck }
2088c2c66affSColin Finck
2089c2c66affSColin Finck IDispatch_Release(script_disp);
2090c2c66affSColin Finck IActiveScript_Release(engine);
2091c2c66affSColin Finck IActiveScriptParse_Release(parser);
2092c2c66affSColin Finck }
2093c2c66affSColin Finck
parse_script_af(DWORD flags,const char * src)2094c2c66affSColin Finck static void parse_script_af(DWORD flags, const char *src)
2095c2c66affSColin Finck {
2096c2c66affSColin Finck BSTR tmp;
2097c2c66affSColin Finck HRESULT hres;
2098c2c66affSColin Finck
2099c2c66affSColin Finck tmp = a2bstr(src);
2100c2c66affSColin Finck hres = parse_script(flags, tmp);
2101c2c66affSColin Finck SysFreeString(tmp);
2102c2c66affSColin Finck ok(hres == S_OK, "parse_script failed: %08x\n", hres);
2103c2c66affSColin Finck }
2104c2c66affSColin Finck
parse_script_a(const char * src)2105c2c66affSColin Finck static void parse_script_a(const char *src)
2106c2c66affSColin Finck {
2107c2c66affSColin Finck parse_script_af(SCRIPTITEM_GLOBALMEMBERS, src);
2108c2c66affSColin Finck }
2109c2c66affSColin Finck
parse_script_ae(const char * src,HRESULT exhres)2110c2c66affSColin Finck static void parse_script_ae(const char *src, HRESULT exhres)
2111c2c66affSColin Finck {
2112c2c66affSColin Finck BSTR tmp;
2113c2c66affSColin Finck HRESULT hres;
2114c2c66affSColin Finck
2115c2c66affSColin Finck tmp = a2bstr(src);
2116c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, tmp);
2117c2c66affSColin Finck SysFreeString(tmp);
2118c2c66affSColin Finck ok(hres == exhres, "parse_script failed: %08x, expected %08x\n", hres, exhres);
2119c2c66affSColin Finck }
2120c2c66affSColin Finck
parse_script_with_error_a(const char * src,SCODE errorcode,ULONG line,LONG pos,LPCSTR source,LPCSTR desc,LPCSTR linetext)2121c2c66affSColin Finck static void parse_script_with_error_a(const char *src, SCODE errorcode, ULONG line, LONG pos, LPCSTR source, LPCSTR desc, LPCSTR linetext)
2122c2c66affSColin Finck {
2123c2c66affSColin Finck BSTR tmp, script_source, description, line_text;
2124c2c66affSColin Finck
2125c2c66affSColin Finck tmp = a2bstr(src);
2126c2c66affSColin Finck script_source = a2bstr(source);
2127c2c66affSColin Finck description = a2bstr(desc);
2128c2c66affSColin Finck line_text = a2bstr(linetext);
2129c2c66affSColin Finck
2130c2c66affSColin Finck parse_script_with_error(SCRIPTITEM_GLOBALMEMBERS, tmp, errorcode, line, pos, script_source, description, line_text);
2131c2c66affSColin Finck
2132c2c66affSColin Finck SysFreeString(line_text);
2133c2c66affSColin Finck SysFreeString(description);
2134c2c66affSColin Finck SysFreeString(script_source);
2135c2c66affSColin Finck SysFreeString(tmp);
2136c2c66affSColin Finck }
2137c2c66affSColin Finck
parse_htmlscript_a(const char * src)2138c2c66affSColin Finck static HRESULT parse_htmlscript_a(const char *src)
2139c2c66affSColin Finck {
2140c2c66affSColin Finck HRESULT hres;
2141c2c66affSColin Finck BSTR tmp = a2bstr(src);
2142c2c66affSColin Finck hres = parse_htmlscript(tmp);
2143c2c66affSColin Finck SysFreeString(tmp);
2144c2c66affSColin Finck
2145c2c66affSColin Finck return hres;
2146c2c66affSColin Finck }
2147c2c66affSColin Finck
get_script_from_file(const char * filename)2148c2c66affSColin Finck static BSTR get_script_from_file(const char *filename)
2149c2c66affSColin Finck {
2150c2c66affSColin Finck DWORD size, len;
2151c2c66affSColin Finck HANDLE file, map;
2152c2c66affSColin Finck const char *file_map;
2153c2c66affSColin Finck BSTR ret;
2154c2c66affSColin Finck
2155c2c66affSColin Finck file = CreateFileA(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
2156c2c66affSColin Finck if(file == INVALID_HANDLE_VALUE) {
2157c2c66affSColin Finck trace("Could not open file: %u\n", GetLastError());
2158c2c66affSColin Finck return NULL;
2159c2c66affSColin Finck }
2160c2c66affSColin Finck
2161c2c66affSColin Finck size = GetFileSize(file, NULL);
2162c2c66affSColin Finck
2163c2c66affSColin Finck map = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
2164c2c66affSColin Finck CloseHandle(file);
2165c2c66affSColin Finck if(map == INVALID_HANDLE_VALUE) {
2166c2c66affSColin Finck trace("Could not create file mapping: %u\n", GetLastError());
2167c2c66affSColin Finck return NULL;
2168c2c66affSColin Finck }
2169c2c66affSColin Finck
2170c2c66affSColin Finck file_map = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
2171c2c66affSColin Finck CloseHandle(map);
2172c2c66affSColin Finck if(!file_map) {
2173c2c66affSColin Finck trace("MapViewOfFile failed: %u\n", GetLastError());
2174c2c66affSColin Finck return NULL;
2175c2c66affSColin Finck }
2176c2c66affSColin Finck
2177c2c66affSColin Finck len = MultiByteToWideChar(CP_ACP, 0, file_map, size, NULL, 0);
2178c2c66affSColin Finck ret = SysAllocStringLen(NULL, len);
2179c2c66affSColin Finck MultiByteToWideChar(CP_ACP, 0, file_map, size, ret, len);
2180c2c66affSColin Finck
2181c2c66affSColin Finck UnmapViewOfFile(file_map);
2182c2c66affSColin Finck
2183c2c66affSColin Finck return ret;
2184c2c66affSColin Finck }
2185c2c66affSColin Finck
run_from_file(const char * filename)2186c2c66affSColin Finck static void run_from_file(const char *filename)
2187c2c66affSColin Finck {
2188c2c66affSColin Finck BSTR script_str;
2189c2c66affSColin Finck HRESULT hres;
2190c2c66affSColin Finck
2191c2c66affSColin Finck script_str = get_script_from_file(filename);
2192c2c66affSColin Finck if(!script_str)
2193c2c66affSColin Finck return;
2194c2c66affSColin Finck
2195c2c66affSColin Finck strict_dispid_check = FALSE;
2196c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, script_str);
2197c2c66affSColin Finck SysFreeString(script_str);
2198c2c66affSColin Finck ok(hres == S_OK, "parse_script failed: %08x\n", hres);
2199c2c66affSColin Finck }
2200c2c66affSColin Finck
load_res(const char * name)2201c2c66affSColin Finck static BSTR load_res(const char *name)
2202c2c66affSColin Finck {
2203c2c66affSColin Finck const char *data;
2204c2c66affSColin Finck DWORD size, len;
2205c2c66affSColin Finck BSTR str;
2206c2c66affSColin Finck HRSRC src;
2207c2c66affSColin Finck
2208c2c66affSColin Finck strict_dispid_check = FALSE;
2209c2c66affSColin Finck test_name = name;
2210c2c66affSColin Finck
2211c2c66affSColin Finck src = FindResourceA(NULL, name, (LPCSTR)40);
2212c2c66affSColin Finck ok(src != NULL, "Could not find resource %s\n", name);
2213c2c66affSColin Finck
2214c2c66affSColin Finck size = SizeofResource(NULL, src);
2215c2c66affSColin Finck data = LoadResource(NULL, src);
2216c2c66affSColin Finck
2217c2c66affSColin Finck len = MultiByteToWideChar(CP_ACP, 0, data, size, NULL, 0);
2218c2c66affSColin Finck str = SysAllocStringLen(NULL, len);
2219c2c66affSColin Finck MultiByteToWideChar(CP_ACP, 0, data, size, str, len);
2220c2c66affSColin Finck
2221c2c66affSColin Finck return str;
2222c2c66affSColin Finck }
2223c2c66affSColin Finck
run_from_res(const char * name)2224c2c66affSColin Finck static void run_from_res(const char *name)
2225c2c66affSColin Finck {
2226c2c66affSColin Finck BSTR str;
2227c2c66affSColin Finck HRESULT hres;
2228c2c66affSColin Finck
2229c2c66affSColin Finck str = load_res(name);
2230c2c66affSColin Finck
2231c2c66affSColin Finck SET_EXPECT(global_success_d);
2232c2c66affSColin Finck SET_EXPECT(global_success_i);
2233c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, str);
2234c2c66affSColin Finck CHECK_CALLED(global_success_d);
2235c2c66affSColin Finck CHECK_CALLED(global_success_i);
2236c2c66affSColin Finck
2237c2c66affSColin Finck ok(hres == S_OK, "parse_script failed: %08x\n", hres);
2238c2c66affSColin Finck SysFreeString(str);
2239c2c66affSColin Finck }
2240c2c66affSColin Finck
test_isvisible(BOOL global_members)2241c2c66affSColin Finck static void test_isvisible(BOOL global_members)
2242c2c66affSColin Finck {
2243c2c66affSColin Finck IActiveScriptParse *parser;
2244c2c66affSColin Finck IActiveScript *engine;
2245c2c66affSColin Finck HRESULT hres;
2246c2c66affSColin Finck
2247c2c66affSColin Finck static const WCHAR script_textW[] =
2248c2c66affSColin Finck {'v','a','r',' ','v',' ','=',' ','t','e','s','t','V','a','l',';',0};
2249c2c66affSColin Finck
2250c2c66affSColin Finck engine = create_script();
2251c2c66affSColin Finck if(!engine)
2252c2c66affSColin Finck return;
2253c2c66affSColin Finck
2254c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2255c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2256c2c66affSColin Finck if (FAILED(hres))
2257c2c66affSColin Finck {
2258c2c66affSColin Finck IActiveScript_Release(engine);
2259c2c66affSColin Finck return;
2260c2c66affSColin Finck }
2261c2c66affSColin Finck
2262c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
2263c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2264c2c66affSColin Finck
2265c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2266c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2267c2c66affSColin Finck
2268c2c66affSColin Finck if(global_members)
2269c2c66affSColin Finck SET_EXPECT(GetItemInfo_testVal);
2270c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, test_valW,
2271c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|
2272c2c66affSColin Finck (global_members ? SCRIPTITEM_GLOBALMEMBERS : 0));
2273c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2274c2c66affSColin Finck if(global_members)
2275c2c66affSColin Finck CHECK_CALLED(GetItemInfo_testVal);
2276c2c66affSColin Finck
2277c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2278c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2279c2c66affSColin Finck
2280c2c66affSColin Finck if(!global_members)
2281c2c66affSColin Finck SET_EXPECT(GetItemInfo_testVal);
2282c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, script_textW, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2283c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2284c2c66affSColin Finck if(!global_members)
2285c2c66affSColin Finck CHECK_CALLED(GetItemInfo_testVal);
2286c2c66affSColin Finck
2287c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, script_textW, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2288c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2289c2c66affSColin Finck
2290c2c66affSColin Finck IActiveScript_Release(engine);
2291c2c66affSColin Finck IActiveScriptParse_Release(parser);
2292c2c66affSColin Finck }
2293c2c66affSColin Finck
test_start(void)2294c2c66affSColin Finck static void test_start(void)
2295c2c66affSColin Finck {
2296c2c66affSColin Finck IActiveScriptParse *parser;
2297c2c66affSColin Finck IActiveScript *engine;
2298c2c66affSColin Finck BSTR str;
2299c2c66affSColin Finck HRESULT hres;
2300c2c66affSColin Finck
2301c2c66affSColin Finck script_engine = engine = create_script();
2302c2c66affSColin Finck if(!engine)
2303c2c66affSColin Finck return;
2304c2c66affSColin Finck
2305c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2306c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2307c2c66affSColin Finck
2308c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
2309c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2310c2c66affSColin Finck
2311c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2312c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2313c2c66affSColin Finck
2314c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2315c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2316c2c66affSColin Finck
2317c2c66affSColin Finck str = a2bstr("ok(getScriptState() === 5, \"getScriptState = \" + getScriptState());\n"
2318c2c66affSColin Finck "reportSuccess();");
2319c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2320c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2321c2c66affSColin Finck SysFreeString(str);
2322c2c66affSColin Finck
2323c2c66affSColin Finck SET_EXPECT(global_success_d);
2324c2c66affSColin Finck SET_EXPECT(global_success_i);
2325c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2326c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2327c2c66affSColin Finck CHECK_CALLED(global_success_d);
2328c2c66affSColin Finck CHECK_CALLED(global_success_i);
2329c2c66affSColin Finck
2330c2c66affSColin Finck IActiveScript_Release(engine);
2331c2c66affSColin Finck IActiveScriptParse_Release(parser);
2332c2c66affSColin Finck script_engine = NULL;
2333c2c66affSColin Finck }
2334c2c66affSColin Finck
test_automagic(void)2335c2c66affSColin Finck static void test_automagic(void)
2336c2c66affSColin Finck {
2337c2c66affSColin Finck IActiveScriptParse *parser;
2338c2c66affSColin Finck IActiveScript *engine;
2339c2c66affSColin Finck BSTR str;
2340c2c66affSColin Finck HRESULT hres;
2341c2c66affSColin Finck
2342c2c66affSColin Finck script_engine = engine = create_script();
2343c2c66affSColin Finck if(!engine)
2344c2c66affSColin Finck return;
2345c2c66affSColin Finck
2346c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2347c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2348c2c66affSColin Finck
2349c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
2350c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2351c2c66affSColin Finck
2352c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2353c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2354c2c66affSColin Finck
2355c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, testW, SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2356c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2357c2c66affSColin Finck
2358c2c66affSColin Finck str = a2bstr("function bindEventHandler::eventName() {}\n"
2359c2c66affSColin Finck "reportSuccess();");
2360c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2361c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2362c2c66affSColin Finck SysFreeString(str);
2363c2c66affSColin Finck
2364c2c66affSColin Finck SET_EXPECT(BindHandler);
2365c2c66affSColin Finck SET_EXPECT(global_success_d);
2366c2c66affSColin Finck SET_EXPECT(global_success_i);
2367c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2368c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2369c2c66affSColin Finck CHECK_CALLED(BindHandler);
2370c2c66affSColin Finck CHECK_CALLED(global_success_d);
2371c2c66affSColin Finck CHECK_CALLED(global_success_i);
2372c2c66affSColin Finck
2373c2c66affSColin Finck IActiveScript_Release(engine);
2374c2c66affSColin Finck IActiveScriptParse_Release(parser);
2375c2c66affSColin Finck script_engine = NULL;
2376c2c66affSColin Finck }
2377c2c66affSColin Finck
parse_script_expr(const char * expr,VARIANT * res,IActiveScript ** engine_ret)2378c2c66affSColin Finck static HRESULT parse_script_expr(const char *expr, VARIANT *res, IActiveScript **engine_ret)
2379c2c66affSColin Finck {
2380c2c66affSColin Finck IActiveScriptParse *parser;
2381c2c66affSColin Finck IActiveScript *engine;
2382c2c66affSColin Finck BSTR str;
2383c2c66affSColin Finck HRESULT hres;
2384c2c66affSColin Finck
2385c2c66affSColin Finck engine = create_script();
2386df52b0e7SAmine Khaldi if(!engine)
2387df52b0e7SAmine Khaldi return E_FAIL;
2388c2c66affSColin Finck
2389c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2390c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2391c2c66affSColin Finck
2392c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
2393c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2394c2c66affSColin Finck
2395c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2396c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2397c2c66affSColin Finck
2398c2c66affSColin Finck SET_EXPECT(GetItemInfo_testVal);
2399c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, test_valW,
2400c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2401c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2402c2c66affSColin Finck CHECK_CALLED(GetItemInfo_testVal);
2403c2c66affSColin Finck
2404c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2405c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2406c2c66affSColin Finck
2407c2c66affSColin Finck str = a2bstr(expr);
2408c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, res, NULL);
2409c2c66affSColin Finck SysFreeString(str);
2410c2c66affSColin Finck
2411c2c66affSColin Finck IActiveScriptParse_Release(parser);
2412c2c66affSColin Finck
2413c2c66affSColin Finck if(engine_ret) {
2414c2c66affSColin Finck *engine_ret = engine;
2415c2c66affSColin Finck }else {
2416c2c66affSColin Finck IActiveScript_Close(engine);
2417c2c66affSColin Finck IActiveScript_Release(engine);
2418c2c66affSColin Finck }
2419c2c66affSColin Finck return hres;
2420c2c66affSColin Finck }
2421c2c66affSColin Finck
test_retval(void)2422c2c66affSColin Finck static void test_retval(void)
2423c2c66affSColin Finck {
2424c2c66affSColin Finck BSTR str = a2bstr("reportSuccess(), true");
2425c2c66affSColin Finck IActiveScriptParse *parser;
2426c2c66affSColin Finck IActiveScript *engine;
2427c2c66affSColin Finck SCRIPTSTATE state;
2428c2c66affSColin Finck VARIANT res;
2429c2c66affSColin Finck HRESULT hres;
2430c2c66affSColin Finck
2431c2c66affSColin Finck engine = create_script();
2432df52b0e7SAmine Khaldi if(!engine)
2433df52b0e7SAmine Khaldi return;
2434c2c66affSColin Finck
2435c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2436c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2437c2c66affSColin Finck
2438c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
2439c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2440c2c66affSColin Finck
2441c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2442c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2443c2c66affSColin Finck
2444c2c66affSColin Finck SET_EXPECT(GetItemInfo_testVal);
2445c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, test_valW,
2446c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2447c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2448c2c66affSColin Finck CHECK_CALLED(GetItemInfo_testVal);
2449c2c66affSColin Finck
2450c2c66affSColin Finck V_VT(&res) = VT_NULL;
2451c2c66affSColin Finck SET_EXPECT(global_success_d);
2452c2c66affSColin Finck SET_EXPECT(global_success_i);
2453c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, &res, NULL);
2454c2c66affSColin Finck CHECK_CALLED(global_success_d);
2455c2c66affSColin Finck CHECK_CALLED(global_success_i);
2456c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2457c2c66affSColin Finck ok(V_VT(&res) == VT_EMPTY, "V_VT(&res) = %d\n", V_VT(&res));
2458c2c66affSColin Finck
2459c2c66affSColin Finck hres = IActiveScript_GetScriptState(engine, &state);
2460c2c66affSColin Finck ok(hres == S_OK, "GetScriptState failed: %08x\n", hres);
2461c2c66affSColin Finck ok(state == SCRIPTSTATE_INITIALIZED, "state = %d\n", state);
2462c2c66affSColin Finck
2463c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2464c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2465c2c66affSColin Finck
2466c2c66affSColin Finck hres = IActiveScript_Close(engine);
2467c2c66affSColin Finck ok(hres == S_OK, "Close failed: %08x\n", hres);
2468c2c66affSColin Finck
2469c2c66affSColin Finck IActiveScriptParse_Release(parser);
2470c2c66affSColin Finck IActiveScript_Release(engine);
2471c2c66affSColin Finck SysFreeString(str);
2472c2c66affSColin Finck }
2473c2c66affSColin Finck
test_default_value(void)2474c2c66affSColin Finck static void test_default_value(void)
2475c2c66affSColin Finck {
2476c2c66affSColin Finck DISPPARAMS dp = {0};
2477c2c66affSColin Finck IDispatch *disp;
2478c2c66affSColin Finck VARIANT v;
2479c2c66affSColin Finck HRESULT hres;
2480c2c66affSColin Finck
2481c2c66affSColin Finck hres = parse_script_expr("new Date()", &v, NULL);
2482c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2483c2c66affSColin Finck ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
2484c2c66affSColin Finck disp = V_DISPATCH(&v);
2485c2c66affSColin Finck
2486c2c66affSColin Finck V_VT(&v) = VT_EMPTY;
2487c2c66affSColin Finck hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
2488c2c66affSColin Finck ok(hres == S_OK || broken(hres == 0x8000ffff), "Invoke failed: %08x\n", hres);
2489c2c66affSColin Finck if(hres == S_OK)
2490c2c66affSColin Finck {
2491c2c66affSColin Finck ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
2492c2c66affSColin Finck }
2493c2c66affSColin Finck
2494c2c66affSColin Finck VariantClear(&v);
2495c2c66affSColin Finck IDispatch_Release(disp);
2496c2c66affSColin Finck }
2497c2c66affSColin Finck
test_script_exprs(void)2498c2c66affSColin Finck static void test_script_exprs(void)
2499c2c66affSColin Finck {
2500c2c66affSColin Finck VARIANT v;
2501c2c66affSColin Finck HRESULT hres;
2502c2c66affSColin Finck
2503c2c66affSColin Finck testing_expr = TRUE;
2504c2c66affSColin Finck
2505c2c66affSColin Finck hres = parse_script_expr("true", &v, NULL);
2506c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2507c2c66affSColin Finck ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
2508c2c66affSColin Finck ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
2509c2c66affSColin Finck
2510c2c66affSColin Finck hres = parse_script_expr("false, true", &v, NULL);
2511c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2512c2c66affSColin Finck ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
2513c2c66affSColin Finck ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
2514c2c66affSColin Finck
2515c2c66affSColin Finck SET_EXPECT(global_success_d);
2516c2c66affSColin Finck SET_EXPECT(global_success_i);
2517c2c66affSColin Finck hres = parse_script_expr("reportSuccess(); true", &v, NULL);
2518c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2519c2c66affSColin Finck ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v));
2520c2c66affSColin Finck ok(V_BOOL(&v) == VARIANT_TRUE, "V_BOOL(v) = %x\n", V_BOOL(&v));
2521c2c66affSColin Finck CHECK_CALLED(global_success_d);
2522c2c66affSColin Finck CHECK_CALLED(global_success_i);
2523c2c66affSColin Finck
2524c2c66affSColin Finck hres = parse_script_expr("if(false) true", &v, NULL);
2525c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2526c2c66affSColin Finck ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
2527c2c66affSColin Finck
2528c2c66affSColin Finck hres = parse_script_expr("return testPropGet", &v, NULL);
2529c2c66affSColin Finck ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
2530c2c66affSColin Finck
2531c2c66affSColin Finck hres = parse_script_expr("reportSuccess(); return true", &v, NULL);
2532c2c66affSColin Finck ok(hres == 0x800a03fa, "parse_script_expr failed: %08x\n", hres);
2533c2c66affSColin Finck
2534c2c66affSColin Finck SET_EXPECT(global_success_d);
2535c2c66affSColin Finck SET_EXPECT(global_success_i);
2536c2c66affSColin Finck hres = parse_script_expr("reportSuccess(); true", NULL, NULL);
2537c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2538c2c66affSColin Finck CHECK_CALLED(global_success_d);
2539c2c66affSColin Finck CHECK_CALLED(global_success_i);
2540c2c66affSColin Finck
2541c2c66affSColin Finck test_default_value();
2542c2c66affSColin Finck test_retval();
2543c2c66affSColin Finck
2544c2c66affSColin Finck testing_expr = FALSE;
2545c2c66affSColin Finck }
2546c2c66affSColin Finck
test_invokeex(void)2547c2c66affSColin Finck static void test_invokeex(void)
2548c2c66affSColin Finck {
2549c2c66affSColin Finck DISPID func_id, prop_id;
2550c2c66affSColin Finck DISPPARAMS dp = {NULL};
2551c2c66affSColin Finck IActiveScript *script;
2552c2c66affSColin Finck IDispatchEx *dispex;
2553c2c66affSColin Finck VARIANT v;
2554c2c66affSColin Finck BSTR str;
2555c2c66affSColin Finck HRESULT hres;
2556c2c66affSColin Finck
2557c2c66affSColin Finck hres = parse_script_expr("var o = {func: function() {return 3;}, prop: 6}; o", &v, &script);
2558c2c66affSColin Finck ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
2559c2c66affSColin Finck ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
2560c2c66affSColin Finck
2561c2c66affSColin Finck hres = IDispatch_QueryInterface(V_DISPATCH(&v), &IID_IDispatchEx, (void**)&dispex);
2562c2c66affSColin Finck ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
2563c2c66affSColin Finck VariantClear(&v);
2564c2c66affSColin Finck
2565c2c66affSColin Finck str = a2bstr("func");
2566c2c66affSColin Finck hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
2567c2c66affSColin Finck SysFreeString(str);
2568c2c66affSColin Finck ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
2569c2c66affSColin Finck
2570c2c66affSColin Finck str = a2bstr("prop");
2571c2c66affSColin Finck hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id);
2572c2c66affSColin Finck SysFreeString(str);
2573c2c66affSColin Finck ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
2574c2c66affSColin Finck
2575c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_METHOD, &dp, &v, NULL, NULL);
2576c2c66affSColin Finck ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2577c2c66affSColin Finck ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2578c2c66affSColin Finck ok(V_I4(&v) == 3, "V_I4(v) = %d\n", V_I4(&v));
2579c2c66affSColin Finck
2580c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
2581c2c66affSColin Finck ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2582c2c66affSColin Finck ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2583c2c66affSColin Finck ok(V_I4(&v) == 6, "V_I4(v) = %d\n", V_I4(&v));
2584c2c66affSColin Finck
2585c2c66affSColin Finck hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
2586c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2587c2c66affSColin Finck
2588c2c66affSColin Finck str = a2bstr("func");
2589c2c66affSColin Finck hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
2590c2c66affSColin Finck SysFreeString(str);
2591c2c66affSColin Finck ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
2592c2c66affSColin Finck
2593c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, func_id, 0, DISPATCH_METHOD, &dp, &v, NULL, NULL);
2594c2c66affSColin Finck ok(hres == E_UNEXPECTED || broken(hres == 0x800a1393), "InvokeEx failed: %08x\n", hres);
2595c2c66affSColin Finck
2596c2c66affSColin Finck hres = IDispatchEx_InvokeEx(dispex, prop_id, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
2597c2c66affSColin Finck ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2598c2c66affSColin Finck ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
2599c2c66affSColin Finck ok(V_I4(&v) == 6, "V_I4(v) = %d\n", V_I4(&v));
2600c2c66affSColin Finck
2601c2c66affSColin Finck IDispatchEx_Release(dispex);
2602c2c66affSColin Finck IActiveScript_Release(script);
2603c2c66affSColin Finck }
2604c2c66affSColin Finck
test_eval(void)2605021b5c1fSAmine Khaldi static void test_eval(void)
2606021b5c1fSAmine Khaldi {
2607021b5c1fSAmine Khaldi IActiveScriptParse *parser;
2608021b5c1fSAmine Khaldi IDispatchEx *script_dispex;
2609021b5c1fSAmine Khaldi IDispatch *script_disp;
2610021b5c1fSAmine Khaldi IActiveScript *engine;
2611021b5c1fSAmine Khaldi VARIANT arg, res;
2612021b5c1fSAmine Khaldi DISPPARAMS params;
2613021b5c1fSAmine Khaldi DISPID id, v_id;
2614021b5c1fSAmine Khaldi BSTR str;
2615021b5c1fSAmine Khaldi HRESULT hres;
2616021b5c1fSAmine Khaldi
2617021b5c1fSAmine Khaldi engine = create_script();
2618021b5c1fSAmine Khaldi
2619021b5c1fSAmine Khaldi hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
2620021b5c1fSAmine Khaldi ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
2621021b5c1fSAmine Khaldi
2622021b5c1fSAmine Khaldi hres = IActiveScriptParse_InitNew(parser);
2623021b5c1fSAmine Khaldi ok(hres == S_OK, "InitNew failed: %08x\n", hres);
2624021b5c1fSAmine Khaldi
2625021b5c1fSAmine Khaldi hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
2626021b5c1fSAmine Khaldi ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
2627021b5c1fSAmine Khaldi
2628021b5c1fSAmine Khaldi SET_EXPECT(GetItemInfo_testVal);
2629021b5c1fSAmine Khaldi hres = IActiveScript_AddNamedItem(engine, test_valW,
2630021b5c1fSAmine Khaldi SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
2631021b5c1fSAmine Khaldi ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
2632021b5c1fSAmine Khaldi CHECK_CALLED(GetItemInfo_testVal);
2633021b5c1fSAmine Khaldi
2634021b5c1fSAmine Khaldi hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
2635021b5c1fSAmine Khaldi ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
2636021b5c1fSAmine Khaldi
2637021b5c1fSAmine Khaldi hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp);
2638021b5c1fSAmine Khaldi ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
2639021b5c1fSAmine Khaldi ok(script_disp != NULL, "script_disp == NULL\n");
2640021b5c1fSAmine Khaldi
2641021b5c1fSAmine Khaldi hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&script_dispex);
2642021b5c1fSAmine Khaldi ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
2643021b5c1fSAmine Khaldi IDispatch_Release(script_disp);
2644021b5c1fSAmine Khaldi
2645021b5c1fSAmine Khaldi str = a2bstr("eval");
2646021b5c1fSAmine Khaldi hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
2647021b5c1fSAmine Khaldi ok(hres == S_OK, "Could not get eval dispid: %08x\n", hres);
2648021b5c1fSAmine Khaldi SysFreeString(str);
2649021b5c1fSAmine Khaldi
2650021b5c1fSAmine Khaldi params.rgvarg = &arg;
2651021b5c1fSAmine Khaldi params.rgdispidNamedArgs = NULL;
2652021b5c1fSAmine Khaldi params.cArgs = 1;
2653021b5c1fSAmine Khaldi params.cNamedArgs = 0;
2654021b5c1fSAmine Khaldi V_VT(&arg) = VT_BSTR;
2655021b5c1fSAmine Khaldi
2656021b5c1fSAmine Khaldi V_BSTR(&arg) = a2bstr("var v = 1;");
2657021b5c1fSAmine Khaldi V_VT(&res) = VT_ERROR;
2658021b5c1fSAmine Khaldi hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
2659021b5c1fSAmine Khaldi ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2660021b5c1fSAmine Khaldi ok(V_VT(&res) == VT_EMPTY, "eval returned type %u\n", V_VT(&res));
2661021b5c1fSAmine Khaldi SysFreeString(V_BSTR(&arg));
2662021b5c1fSAmine Khaldi
2663021b5c1fSAmine Khaldi V_BSTR(&arg) = a2bstr("v");
2664021b5c1fSAmine Khaldi V_VT(&res) = VT_ERROR;
2665021b5c1fSAmine Khaldi hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL);
2666021b5c1fSAmine Khaldi ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2667021b5c1fSAmine Khaldi ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
2668021b5c1fSAmine Khaldi ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
2669021b5c1fSAmine Khaldi SysFreeString(V_BSTR(&arg));
2670021b5c1fSAmine Khaldi
2671021b5c1fSAmine Khaldi str = a2bstr("v");
2672021b5c1fSAmine Khaldi hres = IDispatchEx_GetDispID(script_dispex, str, 0, &v_id);
2673021b5c1fSAmine Khaldi ok(hres == S_OK, "Could not get v dispid: %08x\n", hres);
2674021b5c1fSAmine Khaldi SysFreeString(str);
2675021b5c1fSAmine Khaldi
2676021b5c1fSAmine Khaldi params.rgvarg = NULL;
2677021b5c1fSAmine Khaldi params.cArgs = 0;
2678021b5c1fSAmine Khaldi V_VT(&res) = VT_ERROR;
2679021b5c1fSAmine Khaldi hres = IDispatchEx_InvokeEx(script_dispex, v_id, 0, DISPATCH_PROPERTYGET, ¶ms, &res, NULL, NULL);
2680021b5c1fSAmine Khaldi ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
2681021b5c1fSAmine Khaldi ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res));
2682021b5c1fSAmine Khaldi ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res));
2683021b5c1fSAmine Khaldi
2684021b5c1fSAmine Khaldi SET_EXPECT(global_calleval_i);
2685021b5c1fSAmine Khaldi str = a2bstr("(function(){"
2686021b5c1fSAmine Khaldi " var v = 2;"
2687021b5c1fSAmine Khaldi " callEval(eval);"
2688021b5c1fSAmine Khaldi " ok(x === 5, 'x = ' + x);"
2689021b5c1fSAmine Khaldi "})();");
2690021b5c1fSAmine Khaldi hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
2691021b5c1fSAmine Khaldi ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
2692021b5c1fSAmine Khaldi SysFreeString(str);
2693021b5c1fSAmine Khaldi CHECK_CALLED(global_calleval_i);
2694021b5c1fSAmine Khaldi
2695021b5c1fSAmine Khaldi str = a2bstr("x");
2696021b5c1fSAmine Khaldi hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id);
2697021b5c1fSAmine Khaldi ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(x) returned %08x\n", hres);
2698021b5c1fSAmine Khaldi SysFreeString(str);
2699021b5c1fSAmine Khaldi
2700021b5c1fSAmine Khaldi IDispatchEx_Release(script_dispex);
2701021b5c1fSAmine Khaldi IActiveScriptParse_Release(parser);
2702021b5c1fSAmine Khaldi IActiveScript_Close(engine);
2703021b5c1fSAmine Khaldi IActiveScript_Release(engine);
2704021b5c1fSAmine Khaldi }
2705021b5c1fSAmine Khaldi
2706c2c66affSColin Finck struct bom_test
2707c2c66affSColin Finck {
2708c2c66affSColin Finck WCHAR str[1024];
2709c2c66affSColin Finck HRESULT hres;
2710c2c66affSColin Finck };
2711c2c66affSColin Finck
run_bom_tests(void)2712c2c66affSColin Finck static void run_bom_tests(void)
2713c2c66affSColin Finck {
2714c2c66affSColin Finck BSTR src;
2715c2c66affSColin Finck int i;
2716c2c66affSColin Finck HRESULT hres;
2717c2c66affSColin Finck struct bom_test bom_tests[] = {
2718c2c66affSColin Finck {{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
2719c2c66affSColin Finck {{0xFEFF,'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
2720c2c66affSColin Finck {{'v',0xFEFF,'a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, JS_E_OUT_OF_MEMORY},
2721c2c66affSColin Finck {{'v','a','r',0xFEFF,' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
2722c2c66affSColin Finck {{'v','a','r',' ','a',' ','=',' ','1',';',' ',0xFEFF,'r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
2723c2c66affSColin Finck {{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t',0xFEFF,'S','u','c','c','e','s','s','(',')',';','\0'}, JS_E_OUT_OF_MEMORY},
2724c2c66affSColin Finck {{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s',0xFEFF,'(',')',';','\0'}, S_OK},
2725c2c66affSColin Finck {{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
2726c2c66affSColin Finck {{'v','a','r',' ','a',' ','=',0xFEFF,' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
2727c2c66affSColin Finck {{0xFEFF,'v','a','r',' ','a',' ','=',0xFEFF,0xFEFF,' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
2728c2c66affSColin Finck {{0}}
2729c2c66affSColin Finck };
2730c2c66affSColin Finck
2731c2c66affSColin Finck engine_clsid = &CLSID_JScript;
2732c2c66affSColin Finck
2733c2c66affSColin Finck for (i = 0; bom_tests[i].str[0]; i++)
2734c2c66affSColin Finck {
2735c2c66affSColin Finck if(bom_tests[i].hres == S_OK)
2736c2c66affSColin Finck {
2737c2c66affSColin Finck SET_EXPECT(global_success_d);
2738c2c66affSColin Finck SET_EXPECT(global_success_i);
2739c2c66affSColin Finck src = SysAllocString(bom_tests[i].str);
2740c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
2741c2c66affSColin Finck ok(hres == S_OK, "test %s failed with %08x\n", wine_dbgstr_w(src), hres);
2742c2c66affSColin Finck SysFreeString(src);
2743c2c66affSColin Finck CHECK_CALLED(global_success_d);
2744c2c66affSColin Finck CHECK_CALLED(global_success_i);
2745c2c66affSColin Finck }
2746c2c66affSColin Finck else
2747c2c66affSColin Finck {
2748c2c66affSColin Finck src = SysAllocString(bom_tests[i].str);
2749c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
2750c2c66affSColin Finck todo_wine ok(hres == bom_tests[i].hres, "test %s returned with %08x\n", wine_dbgstr_w(src), hres);
2751c2c66affSColin Finck SysFreeString(src);
2752c2c66affSColin Finck }
2753c2c66affSColin Finck }
2754c2c66affSColin Finck }
2755c2c66affSColin Finck
run_tests(void)2756c2c66affSColin Finck static BOOL run_tests(void)
2757c2c66affSColin Finck {
2758c2c66affSColin Finck HRESULT hres;
2759c2c66affSColin Finck
2760c2c66affSColin Finck if(invoke_version) {
2761c2c66affSColin Finck IActiveScript *script;
2762c2c66affSColin Finck
2763c2c66affSColin Finck script = create_script();
2764c2c66affSColin Finck if(!script) {
2765c2c66affSColin Finck win_skip("Could not create script\n");
2766c2c66affSColin Finck return FALSE;
2767c2c66affSColin Finck }
2768c2c66affSColin Finck IActiveScript_Release(script);
2769c2c66affSColin Finck }
2770c2c66affSColin Finck
2771c2c66affSColin Finck strict_dispid_check = TRUE;
2772c2c66affSColin Finck
2773c2c66affSColin Finck parse_script_a("");
2774c2c66affSColin Finck parse_script_a("/* empty */ ;");
2775c2c66affSColin Finck
2776c2c66affSColin Finck SET_EXPECT(global_propget_d);
2777c2c66affSColin Finck SET_EXPECT(global_propget_i);
2778c2c66affSColin Finck parse_script_a("testPropGet;");
2779c2c66affSColin Finck CHECK_CALLED(global_propget_d);
2780c2c66affSColin Finck CHECK_CALLED(global_propget_i);
2781c2c66affSColin Finck
2782c2c66affSColin Finck SET_EXPECT(global_propput_d);
2783c2c66affSColin Finck SET_EXPECT(global_propput_i);
2784c2c66affSColin Finck parse_script_a("testPropPut = 1;");
2785c2c66affSColin Finck CHECK_CALLED(global_propput_d);
2786c2c66affSColin Finck CHECK_CALLED(global_propput_i);
2787c2c66affSColin Finck
2788c2c66affSColin Finck SET_EXPECT(global_propputref_d);
2789c2c66affSColin Finck SET_EXPECT(global_propputref_i);
2790c2c66affSColin Finck parse_script_a("testPropPutRef = new Object();");
2791c2c66affSColin Finck CHECK_CALLED(global_propputref_d);
2792c2c66affSColin Finck CHECK_CALLED(global_propputref_i);
2793c2c66affSColin Finck
2794c2c66affSColin Finck SET_EXPECT(global_propputref_d);
2795c2c66affSColin Finck SET_EXPECT(global_propputref_i);
2796c2c66affSColin Finck parse_script_a("testPropPutRef = testObj;");
2797c2c66affSColin Finck CHECK_CALLED(global_propputref_d);
2798c2c66affSColin Finck CHECK_CALLED(global_propputref_i);
2799c2c66affSColin Finck
2800c2c66affSColin Finck SET_EXPECT(global_success_d);
2801c2c66affSColin Finck SET_EXPECT(global_success_i);
2802c2c66affSColin Finck parse_script_a("reportSuccess();");
2803c2c66affSColin Finck CHECK_CALLED(global_success_d);
2804c2c66affSColin Finck CHECK_CALLED(global_success_i);
2805c2c66affSColin Finck
2806c2c66affSColin Finck SET_EXPECT(testobj_delete_test);
2807c2c66affSColin Finck parse_script_a("ok((delete testObj.deleteTest) === true, 'delete testObj.deleteTest did not return true');");
2808c2c66affSColin Finck CHECK_CALLED(testobj_delete_test);
2809c2c66affSColin Finck
2810c2c66affSColin Finck SET_EXPECT(testobj_delete_nodelete);
2811c2c66affSColin Finck parse_script_a("ok((delete testObj.noDeleteTest) === false, 'delete testObj.noDeleteTest did not return false');");
2812c2c66affSColin Finck CHECK_CALLED(testobj_delete_nodelete);
2813c2c66affSColin Finck
2814c2c66affSColin Finck SET_EXPECT(global_propdelete_d);
2815c2c66affSColin Finck SET_EXPECT(DeleteMemberByDispID);
2816c2c66affSColin Finck parse_script_a("ok((delete testPropDelete) === true, 'delete testPropDelete did not return true');");
2817c2c66affSColin Finck CHECK_CALLED(global_propdelete_d);
2818c2c66affSColin Finck CHECK_CALLED(DeleteMemberByDispID);
2819c2c66affSColin Finck
2820c2c66affSColin Finck SET_EXPECT(global_nopropdelete_d);
2821c2c66affSColin Finck SET_EXPECT(DeleteMemberByDispID_false);
2822c2c66affSColin Finck parse_script_a("ok((delete testNoPropDelete) === false, 'delete testPropDelete did not return false');");
2823c2c66affSColin Finck CHECK_CALLED(global_nopropdelete_d);
2824c2c66affSColin Finck CHECK_CALLED(DeleteMemberByDispID_false);
2825c2c66affSColin Finck
2826c2c66affSColin Finck SET_EXPECT(global_propdeleteerror_d);
2827c2c66affSColin Finck SET_EXPECT(DeleteMemberByDispID_error);
2828c2c66affSColin Finck parse_script_ae("delete testPropDeleteError;", E_FAIL);
2829c2c66affSColin Finck CHECK_CALLED(global_propdeleteerror_d);
2830c2c66affSColin Finck CHECK_CALLED(DeleteMemberByDispID_error);
2831c2c66affSColin Finck
2832c2c66affSColin Finck SET_EXPECT(puredisp_prop_d);
2833c2c66affSColin Finck parse_script_a("ok((delete pureDisp.prop) === false, 'delete pureDisp.prop did not return true');");
2834c2c66affSColin Finck CHECK_CALLED(puredisp_prop_d);
2835c2c66affSColin Finck
2836c2c66affSColin Finck SET_EXPECT(puredisp_noprop_d);
2837c2c66affSColin Finck parse_script_a("ok((delete pureDisp.noprop) === true, 'delete pureDisp.noprop did not return false');");
2838c2c66affSColin Finck CHECK_CALLED(puredisp_noprop_d);
2839c2c66affSColin Finck
2840c2c66affSColin Finck SET_EXPECT(puredisp_value);
2841c2c66affSColin Finck parse_script_a("var t=pureDisp; t=t(false);");
2842c2c66affSColin Finck CHECK_CALLED(puredisp_value);
2843c2c66affSColin Finck
2844c2c66affSColin Finck SET_EXPECT(puredisp_value);
2845c2c66affSColin Finck parse_script_a("var t = {func: pureDisp}; t = t.func(false);");
2846c2c66affSColin Finck CHECK_CALLED(puredisp_value);
2847c2c66affSColin Finck
2848c2c66affSColin Finck SET_EXPECT(dispexfunc_value);
2849c2c66affSColin Finck parse_script_a("var t = dispexFunc; t = t(false);");
2850c2c66affSColin Finck CHECK_CALLED(dispexfunc_value);
2851c2c66affSColin Finck
2852c2c66affSColin Finck SET_EXPECT(dispexfunc_value);
2853c2c66affSColin Finck parse_script_a("var t = {func: dispexFunc}; t = t.func(false);");
2854c2c66affSColin Finck CHECK_CALLED(dispexfunc_value);
2855c2c66affSColin Finck
2856c2c66affSColin Finck SET_EXPECT(dispexfunc_value);
2857c2c66affSColin Finck parse_script_a("Function.prototype.apply.call(dispexFunc, testObj, [true]);");
2858c2c66affSColin Finck CHECK_CALLED(dispexfunc_value);
2859c2c66affSColin Finck
2860c2c66affSColin Finck SET_EXPECT(puredisp_value);
2861c2c66affSColin Finck parse_script_a("Function.prototype.apply.call(pureDisp, testObj, [true]);");
2862c2c66affSColin Finck CHECK_CALLED(puredisp_value);
2863c2c66affSColin Finck
2864c2c66affSColin Finck parse_script_a("(function reportSuccess() {})()");
2865c2c66affSColin Finck
2866c2c66affSColin Finck parse_script_a("ok(typeof(test) === 'object', \"typeof(test) != 'object'\");");
2867c2c66affSColin Finck
2868c2c66affSColin Finck parse_script_a("function reportSuccess() {}; reportSuccess();");
2869c2c66affSColin Finck
2870c2c66affSColin Finck SET_EXPECT(global_propget_d);
2871c2c66affSColin Finck parse_script_a("var testPropGet");
2872c2c66affSColin Finck CHECK_CALLED(global_propget_d);
2873c2c66affSColin Finck
2874c2c66affSColin Finck SET_EXPECT(global_propget_d);
2875c2c66affSColin Finck parse_script_a("eval('var testPropGet;');");
2876c2c66affSColin Finck CHECK_CALLED(global_propget_d);
2877c2c66affSColin Finck
2878c2c66affSColin Finck parse_script_a("var testPropGet; function testPropGet() {}");
2879c2c66affSColin Finck
2880c2c66affSColin Finck SET_EXPECT(global_notexists_d);
2881c2c66affSColin Finck parse_script_a("var notExists; notExists = 1;");
2882c2c66affSColin Finck CHECK_CALLED(global_notexists_d);
2883c2c66affSColin Finck
2884c2c66affSColin Finck SET_EXPECT(testobj_notexists_d);
2885c2c66affSColin Finck parse_script_a("testObj.notExists;");
2886c2c66affSColin Finck CHECK_CALLED(testobj_notexists_d);
2887c2c66affSColin Finck
2888c2c66affSColin Finck parse_script_a("function f() { var testPropGet; }");
2889c2c66affSColin Finck parse_script_a("(function () { var testPropGet; })();");
2890c2c66affSColin Finck parse_script_a("(function () { eval('var testPropGet;'); })();");
2891c2c66affSColin Finck
2892c2c66affSColin Finck SET_EXPECT(invoke_func);
2893c2c66affSColin Finck parse_script_a("ok(propGetFunc() == 0, \"Incorrect propGetFunc value\");");
2894c2c66affSColin Finck CHECK_CALLED(invoke_func);
2895c2c66affSColin Finck parse_script_a("ok(propGetFunc(1) == 1, \"Incorrect propGetFunc value\");");
2896c2c66affSColin Finck parse_script_a("ok(propGetFunc(1, 2) == 2, \"Incorrect propGetFunc value\");");
2897c2c66affSColin Finck SET_EXPECT(invoke_func);
2898c2c66affSColin Finck parse_script_a("ok(propGetFunc().toString() == 0, \"Incorrect propGetFunc value\");");
2899c2c66affSColin Finck CHECK_CALLED(invoke_func);
2900c2c66affSColin Finck parse_script_a("ok(propGetFunc(1).toString() == 1, \"Incorrect propGetFunc value\");");
2901c2c66affSColin Finck SET_EXPECT(invoke_func);
2902c2c66affSColin Finck parse_script_a("propGetFunc(1);");
2903c2c66affSColin Finck CHECK_CALLED(invoke_func);
2904c2c66affSColin Finck
2905c2c66affSColin Finck parse_script_a("objectFlag(1).toString();");
2906c2c66affSColin Finck
2907c2c66affSColin Finck parse_script_a("(function() { var tmp = (function () { return testObj; })()(1);})();");
2908c2c66affSColin Finck parse_script_a("(function() { var tmp = (function () { return testObj; })()();})();");
2909c2c66affSColin Finck
2910c2c66affSColin Finck parse_script_a("ok((testObj instanceof Object) === false, 'testObj is instance of Object');");
2911c2c66affSColin Finck
2912c2c66affSColin Finck SET_EXPECT(testobj_prop_d);
2913c2c66affSColin Finck parse_script_a("ok(('prop' in testObj) === true, 'prop is not in testObj');");
2914c2c66affSColin Finck CHECK_CALLED(testobj_prop_d);
2915c2c66affSColin Finck
2916c2c66affSColin Finck SET_EXPECT(testobj_noprop_d);
2917c2c66affSColin Finck parse_script_a("ok(('noprop' in testObj) === false, 'noprop is in testObj');");
2918c2c66affSColin Finck CHECK_CALLED(testobj_noprop_d);
2919c2c66affSColin Finck
2920c2c66affSColin Finck SET_EXPECT(testobj_prop_d);
2921c2c66affSColin Finck parse_script_a("ok(Object.prototype.hasOwnProperty.call(testObj, 'prop') === true, 'hasOwnProperty(\\\"prop\\\") returned false');");
2922c2c66affSColin Finck CHECK_CALLED(testobj_prop_d);
2923c2c66affSColin Finck
2924c2c66affSColin Finck SET_EXPECT(testobj_noprop_d);
2925c2c66affSColin Finck parse_script_a("ok(Object.prototype.hasOwnProperty.call(testObj, 'noprop') === false, 'hasOwnProperty(\\\"noprop\\\") returned true');");
2926c2c66affSColin Finck CHECK_CALLED(testobj_noprop_d);
2927c2c66affSColin Finck
2928c2c66affSColin Finck SET_EXPECT(puredisp_prop_d);
2929c2c66affSColin Finck parse_script_a("ok(Object.prototype.hasOwnProperty.call(pureDisp, 'prop') === true, 'hasOwnProperty(\\\"noprop\\\") returned false');");
2930c2c66affSColin Finck CHECK_CALLED(puredisp_prop_d);
2931c2c66affSColin Finck
2932c2c66affSColin Finck SET_EXPECT(puredisp_noprop_d);
2933c2c66affSColin Finck parse_script_a("ok(Object.prototype.hasOwnProperty.call(pureDisp, 'noprop') === false, 'hasOwnProperty(\\\"noprop\\\") returned true');");
2934c2c66affSColin Finck CHECK_CALLED(puredisp_noprop_d);
2935c2c66affSColin Finck
2936c2c66affSColin Finck SET_EXPECT(testobj_value);
2937c2c66affSColin Finck parse_script_a("ok(String(testObj) === '1', 'wrong testObj value');");
2938c2c66affSColin Finck CHECK_CALLED(testobj_value);
2939c2c66affSColin Finck
2940c2c66affSColin Finck SET_EXPECT(testobj_value);
2941c2c66affSColin Finck parse_script_a("ok(String.prototype.concat.call(testObj, ' OK') === '1 OK', 'wrong concat result');");
2942c2c66affSColin Finck CHECK_CALLED(testobj_value);
2943c2c66affSColin Finck
2944c2c66affSColin Finck SET_EXPECT(testobj_construct);
2945c2c66affSColin Finck parse_script_a("var t = new testObj(1);");
2946c2c66affSColin Finck CHECK_CALLED(testobj_construct);
2947c2c66affSColin Finck
2948c2c66affSColin Finck SET_EXPECT(global_propget_d);
2949c2c66affSColin Finck SET_EXPECT(global_propget_i);
2950c2c66affSColin Finck parse_script_a("this.testPropGet;");
2951c2c66affSColin Finck CHECK_CALLED(global_propget_d);
2952c2c66affSColin Finck CHECK_CALLED(global_propget_i);
2953c2c66affSColin Finck
2954c2c66affSColin Finck SET_EXPECT(global_propputref_d);
2955c2c66affSColin Finck SET_EXPECT(global_propputref_i);
2956c2c66affSColin Finck parse_script_a("testPropPutRef = nullDisp;");
2957c2c66affSColin Finck CHECK_CALLED(global_propputref_d);
2958c2c66affSColin Finck CHECK_CALLED(global_propputref_i);
2959c2c66affSColin Finck
2960c2c66affSColin Finck SET_EXPECT(global_propget_d);
2961c2c66affSColin Finck SET_EXPECT(global_propget_i);
2962c2c66affSColin Finck parse_script_a("(function () { this.testPropGet; })();");
2963c2c66affSColin Finck CHECK_CALLED(global_propget_d);
2964c2c66affSColin Finck CHECK_CALLED(global_propget_i);
2965c2c66affSColin Finck
2966c2c66affSColin Finck parse_script_a("testThis(this);");
2967c2c66affSColin Finck parse_script_a("(function () { testThis(this); })();");
2968c2c66affSColin Finck parse_script_a("function x() { testThis(this); }; x();");
2969c2c66affSColin Finck parse_script_a("var t = {func: function () { ok(this === t, 'this !== t'); }}; with(t) { func(); }");
2970c2c66affSColin Finck parse_script_a("function x() { testThis(this); }; with({y: 1}) { x(); }");
2971c2c66affSColin Finck parse_script_a("(function () { function x() { testThis(this);} x(); })();");
2972c2c66affSColin Finck
2973c2c66affSColin Finck SET_EXPECT(testobj_onlydispid_d);
2974c2c66affSColin Finck SET_EXPECT(testobj_onlydispid_i);
2975c2c66affSColin Finck parse_script_a("ok(typeof(testObj.onlyDispID) === 'unknown', 'unexpected typeof(testObj.onlyDispID)');");
2976c2c66affSColin Finck CHECK_CALLED(testobj_onlydispid_d);
2977c2c66affSColin Finck CHECK_CALLED(testobj_onlydispid_i);
2978c2c66affSColin Finck
2979c2c66affSColin Finck SET_EXPECT(global_propargput_d);
2980c2c66affSColin Finck SET_EXPECT(global_propargput_i);
2981c2c66affSColin Finck parse_script_a("var t=0; propArgPutG(t++, t++) = t++;");
2982c2c66affSColin Finck CHECK_CALLED(global_propargput_d);
2983c2c66affSColin Finck CHECK_CALLED(global_propargput_i);
2984c2c66affSColin Finck
2985c2c66affSColin Finck SET_EXPECT(global_propargput_d);
2986c2c66affSColin Finck SET_EXPECT(global_propargput_i);
2987c2c66affSColin Finck parse_script_a("var t=0; test.propArgPutO(t++, t++) = t++;");
2988c2c66affSColin Finck CHECK_CALLED(global_propargput_d);
2989c2c66affSColin Finck CHECK_CALLED(global_propargput_i);
2990c2c66affSColin Finck
2991021b5c1fSAmine Khaldi SET_EXPECT(global_propargputop_d);
2992021b5c1fSAmine Khaldi SET_EXPECT(global_propargputop_get_i);
2993021b5c1fSAmine Khaldi SET_EXPECT(global_propargputop_put_i);
2994021b5c1fSAmine Khaldi parse_script_a("var t=0; propArgPutOp(t++, t++) += t++;");
2995021b5c1fSAmine Khaldi CHECK_CALLED(global_propargputop_d);
2996021b5c1fSAmine Khaldi CHECK_CALLED(global_propargputop_get_i);
2997021b5c1fSAmine Khaldi CHECK_CALLED(global_propargputop_put_i);
2998021b5c1fSAmine Khaldi
2999021b5c1fSAmine Khaldi SET_EXPECT(global_propargputop_d);
3000021b5c1fSAmine Khaldi SET_EXPECT(global_propargputop_get_i);
3001021b5c1fSAmine Khaldi SET_EXPECT(global_propargputop_put_i);
3002021b5c1fSAmine Khaldi parse_script_a("var t=0; propArgPutOp(t++, t++) ^= 14;");
3003021b5c1fSAmine Khaldi CHECK_CALLED(global_propargputop_d);
3004021b5c1fSAmine Khaldi CHECK_CALLED(global_propargputop_get_i);
3005021b5c1fSAmine Khaldi CHECK_CALLED(global_propargputop_put_i);
3006021b5c1fSAmine Khaldi
3007c2c66affSColin Finck SET_EXPECT(global_testargtypes_i);
3008c2c66affSColin Finck parse_script_a("testArgTypes(dispUnk, intProp(), intProp, getShort(), shortProp,"
3009021b5c1fSAmine Khaldi "function(i1,ui1,ui2,r4,i4ref,ui4,nullunk,d,i,s) {"
3010c2c66affSColin Finck " ok(getVT(i) === 'VT_I4', 'getVT(i) = ' + getVT(i));"
3011c2c66affSColin Finck " ok(getVT(s) === 'VT_I4', 'getVT(s) = ' + getVT(s));"
3012c2c66affSColin Finck " ok(getVT(d) === 'VT_DISPATCH', 'getVT(d) = ' + getVT(d));"
3013c2c66affSColin Finck " ok(getVT(nullunk) === 'VT_DISPATCH', 'getVT(nullunk) = ' + getVT(nullunk));"
3014c2c66affSColin Finck " ok(nullunk === null, 'nullunk !== null');"
3015c2c66affSColin Finck " ok(getVT(ui4) === 'VT_R8', 'getVT(ui4) = ' + getVT(ui4));"
3016c2c66affSColin Finck " ok(ui4 > 0, 'ui4 = ' + ui4);"
3017c2c66affSColin Finck " ok(getVT(i4ref) === 'VT_I4', 'getVT(i4ref) = ' + getVT(i4ref));"
3018c2c66affSColin Finck " ok(i4ref === 2, 'i4ref = ' + i4ref);"
3019c2c66affSColin Finck " ok(r4 === 0.5, 'r4 = ' + r4);"
3020c2c66affSColin Finck " ok(getVT(r4) === 'VT_R8', 'getVT(r4) = ' + getVT(r4));"
3021df52b0e7SAmine Khaldi " ok(getVT(ui2) === 'VT_I4', 'getVT(ui2) = ' + getVT(ui2));"
3022021b5c1fSAmine Khaldi " ok(getVT(ui1) === 'VT_I4', 'getVT(ui1) = ' + getVT(ui1));"
3023021b5c1fSAmine Khaldi " ok(ui1 === 4, 'ui1 = ' + ui1);"
3024021b5c1fSAmine Khaldi " ok(getVT(i1) === 'VT_I4', 'getVT(i1) = ' + getVT(i1));"
3025021b5c1fSAmine Khaldi " ok(i1 === 5, 'i1 = ' + i1);"
3026c2c66affSColin Finck "});");
3027c2c66affSColin Finck CHECK_CALLED(global_testargtypes_i);
3028c2c66affSColin Finck
3029c2c66affSColin Finck SET_EXPECT(testobj_withprop_d);
3030c2c66affSColin Finck SET_EXPECT(testobj_withprop_i);
3031c2c66affSColin Finck parse_script_a("var t = (function () { with(testObj) { return withProp; }})(); ok(t === 1, 't = ' + t);");
3032c2c66affSColin Finck CHECK_CALLED(testobj_withprop_d);
3033c2c66affSColin Finck CHECK_CALLED(testobj_withprop_i);
3034c2c66affSColin Finck
3035c2c66affSColin Finck parse_script_a("@set @t=2\nok(@t === 2, '@t = ' + @t);");
3036c2c66affSColin Finck
3037c2c66affSColin Finck SET_EXPECT(global_success_d);
3038c2c66affSColin Finck SET_EXPECT(global_success_i);
3039c2c66affSColin Finck parse_script_a("@if(true)\nif(@_jscript) reportSuccess();\n@end");
3040c2c66affSColin Finck CHECK_CALLED(global_success_d);
3041c2c66affSColin Finck CHECK_CALLED(global_success_i);
3042c2c66affSColin Finck
3043021b5c1fSAmine Khaldi EnumVARIANT_index = 0;
3044021b5c1fSAmine Khaldi EnumVARIANT_next_0_count = 1;
3045021b5c1fSAmine Khaldi SET_EXPECT(testobj_newenum);
3046021b5c1fSAmine Khaldi SET_EXPECT(enumvariant_next_0);
3047021b5c1fSAmine Khaldi parse_script_a("new Enumerator(testObj);");
3048021b5c1fSAmine Khaldi CHECK_CALLED(testobj_newenum);
3049021b5c1fSAmine Khaldi CHECK_CALLED(enumvariant_next_0);
3050021b5c1fSAmine Khaldi
3051021b5c1fSAmine Khaldi EnumVARIANT_index = 0;
3052021b5c1fSAmine Khaldi EnumVARIANT_next_0_count = 2;
3053021b5c1fSAmine Khaldi SET_EXPECT(testobj_newenum);
3054021b5c1fSAmine Khaldi SET_EXPECT(enumvariant_next_0);
3055021b5c1fSAmine Khaldi SET_EXPECT(enumvariant_reset);
3056021b5c1fSAmine Khaldi parse_script_a("(function () {"
3057021b5c1fSAmine Khaldi " var testEnumObj = new Enumerator(testObj);"
3058021b5c1fSAmine Khaldi " var tmp = testEnumObj.moveFirst();"
3059021b5c1fSAmine Khaldi " ok(tmp == undefined, \"testEnumObj.moveFirst() = \" + tmp);"
3060021b5c1fSAmine Khaldi "})()");
3061021b5c1fSAmine Khaldi CHECK_CALLED(testobj_newenum);
3062021b5c1fSAmine Khaldi CHECK_CALLED(enumvariant_next_0);
3063021b5c1fSAmine Khaldi CHECK_CALLED(enumvariant_reset);
3064021b5c1fSAmine Khaldi
3065021b5c1fSAmine Khaldi EnumVARIANT_index = 0;
3066021b5c1fSAmine Khaldi EnumVARIANT_next_0_count = 1;
3067021b5c1fSAmine Khaldi SET_EXPECT(testobj_newenum);
3068021b5c1fSAmine Khaldi SET_EXPECT(enumvariant_next_0);
3069021b5c1fSAmine Khaldi SET_EXPECT(enumvariant_next_1);
3070021b5c1fSAmine Khaldi parse_script_a("(function () {"
3071021b5c1fSAmine Khaldi " var testEnumObj = new Enumerator(testObj);"
3072021b5c1fSAmine Khaldi " while (!testEnumObj.atEnd())"
3073021b5c1fSAmine Khaldi " {"
3074021b5c1fSAmine Khaldi " ok(testEnumObj.item() == 123, "
3075021b5c1fSAmine Khaldi " \"testEnumObj.item() = \"+testEnumObj.item());"
3076021b5c1fSAmine Khaldi " testEnumObj.moveNext();"
3077021b5c1fSAmine Khaldi " }"
3078021b5c1fSAmine Khaldi "})()");
3079021b5c1fSAmine Khaldi CHECK_CALLED(testobj_newenum);
3080021b5c1fSAmine Khaldi CHECK_CALLED(enumvariant_next_0);
3081021b5c1fSAmine Khaldi CHECK_CALLED(enumvariant_next_1);
3082021b5c1fSAmine Khaldi
3083c2c66affSColin Finck run_from_res("lang.js");
3084c2c66affSColin Finck run_from_res("api.js");
3085c2c66affSColin Finck run_from_res("regexp.js");
3086c2c66affSColin Finck run_from_res("cc.js");
3087c2c66affSColin Finck
3088c2c66affSColin Finck test_isvisible(FALSE);
3089c2c66affSColin Finck test_isvisible(TRUE);
3090c2c66affSColin Finck test_start();
3091c2c66affSColin Finck test_automagic();
3092c2c66affSColin Finck
3093c2c66affSColin Finck parse_script_af(0, "test.testThis2(this);");
3094c2c66affSColin Finck parse_script_af(0, "(function () { test.testThis2(this); })();");
3095c2c66affSColin Finck
3096c2c66affSColin Finck hres = parse_htmlscript_a("<!--");
3097c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
3098c2c66affSColin Finck hres = parse_htmlscript_a("-->");
3099c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
3100c2c66affSColin Finck hres = parse_htmlscript_a("<!--\nvar a=1;\n-->\n");
3101c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
3102c2c66affSColin Finck hres = parse_htmlscript_a("<!--\n<!-- ignore this\n-->\n");
3103c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
3104c2c66affSColin Finck hres = parse_htmlscript_a("var a=1;\nif(a-->0) a=5;\n");
3105c2c66affSColin Finck ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
3106c2c66affSColin Finck hres = parse_htmlscript_a("var a=1;\nif(a\n-->0) a=5;\n");
3107c2c66affSColin Finck ok(hres != S_OK, "ParseScriptText have not failed\n");
3108c2c66affSColin Finck
3109c2c66affSColin Finck test_script_exprs();
3110c2c66affSColin Finck test_invokeex();
3111021b5c1fSAmine Khaldi test_eval();
3112c2c66affSColin Finck
3113c2c66affSColin Finck parse_script_with_error_a(
3114c2c66affSColin Finck "?",
3115c2c66affSColin Finck 0x800a03ea, 0, 0,
3116c2c66affSColin Finck "Microsoft JScript compilation error",
3117c2c66affSColin Finck "Syntax error",
3118c2c66affSColin Finck "?");
3119c2c66affSColin Finck
3120c2c66affSColin Finck parse_script_with_error_a(
3121c2c66affSColin Finck "var a=1;\nif(a\n-->0) a=5;\n",
3122c2c66affSColin Finck 0x800a03ee, 2, 0,
3123c2c66affSColin Finck "Microsoft JScript compilation error",
3124c2c66affSColin Finck "Expected ')'",
3125c2c66affSColin Finck "-->0) a=5;");
3126c2c66affSColin Finck
3127c2c66affSColin Finck parse_script_with_error_a(
3128c2c66affSColin Finck "new 3;",
3129c2c66affSColin Finck 0x800a01bd, 0, 0,
3130c2c66affSColin Finck "Microsoft JScript runtime error",
3131c2c66affSColin Finck "Object doesn't support this action",
3132c2c66affSColin Finck NULL);
3133c2c66affSColin Finck
3134c2c66affSColin Finck parse_script_with_error_a(
3135c2c66affSColin Finck "new null;",
3136c2c66affSColin Finck 0x800a138f, 0, 0,
3137c2c66affSColin Finck "Microsoft JScript runtime error",
3138c2c66affSColin Finck "Object expected",
3139c2c66affSColin Finck NULL);
3140c2c66affSColin Finck
3141c2c66affSColin Finck parse_script_with_error_a(
3142c2c66affSColin Finck "var a;\nnew null;",
3143c2c66affSColin Finck 0x800a138f, 1, 0,
3144c2c66affSColin Finck "Microsoft JScript runtime error",
3145c2c66affSColin Finck "Object expected",
3146c2c66affSColin Finck NULL);
3147c2c66affSColin Finck
3148c2c66affSColin Finck parse_script_with_error_a(
3149c2c66affSColin Finck "var a; new null;",
3150c2c66affSColin Finck 0x800a138f, 0, 7,
3151c2c66affSColin Finck "Microsoft JScript runtime error",
3152c2c66affSColin Finck "Object expected",
3153c2c66affSColin Finck NULL);
3154c2c66affSColin Finck
3155c2c66affSColin Finck run_bom_tests();
3156c2c66affSColin Finck
3157c2c66affSColin Finck return TRUE;
3158c2c66affSColin Finck }
3159c2c66affSColin Finck
test_parse_proc(void)3160c2c66affSColin Finck static void test_parse_proc(void)
3161c2c66affSColin Finck {
3162c2c66affSColin Finck VARIANT args[2];
3163c2c66affSColin Finck DISPPARAMS dp = {args};
3164c2c66affSColin Finck
3165c2c66affSColin Finck dp.cArgs = 0;
3166c2c66affSColin Finck invoke_procedure(NULL, "return true;", &dp);
3167c2c66affSColin Finck
3168c2c66affSColin Finck dp.cArgs = 1;
3169c2c66affSColin Finck V_VT(args) = VT_EMPTY;
3170c2c66affSColin Finck invoke_procedure(NULL, "return arguments.length == 1;", &dp);
3171c2c66affSColin Finck
3172c2c66affSColin Finck V_VT(args) = VT_BOOL;
3173c2c66affSColin Finck V_BOOL(args) = VARIANT_TRUE;
3174c2c66affSColin Finck invoke_procedure(" x ", "return x;", &dp);
3175c2c66affSColin Finck
3176c2c66affSColin Finck dp.cArgs = 2;
3177c2c66affSColin Finck V_VT(args) = VT_I4;
3178c2c66affSColin Finck V_I4(args) = 2;
3179c2c66affSColin Finck V_VT(args+1) = VT_I4;
3180c2c66affSColin Finck V_I4(args+1) = 1;
3181c2c66affSColin Finck invoke_procedure(" _x1 , y_2", "return _x1 === 1 && y_2 === 2;", &dp);
3182c2c66affSColin Finck }
3183c2c66affSColin Finck
run_encoded_tests(void)3184c2c66affSColin Finck static void run_encoded_tests(void)
3185c2c66affSColin Finck {
3186c2c66affSColin Finck BSTR src;
3187c2c66affSColin Finck HRESULT hres;
3188c2c66affSColin Finck
3189c2c66affSColin Finck engine_clsid = &CLSID_JScriptEncode;
3190c2c66affSColin Finck
3191c2c66affSColin Finck SET_EXPECT(global_success_d);
3192c2c66affSColin Finck SET_EXPECT(global_success_i);
3193c2c66affSColin Finck /* |reportSuccess(); | */
3194c2c66affSColin Finck parse_script_a("#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3195c2c66affSColin Finck CHECK_CALLED(global_success_d);
3196c2c66affSColin Finck CHECK_CALLED(global_success_i);
3197c2c66affSColin Finck
3198c2c66affSColin Finck SET_EXPECT(global_success_d);
3199c2c66affSColin Finck SET_EXPECT(global_success_i);
3200c2c66affSColin Finck parse_script_a("reportSuccess();");
3201c2c66affSColin Finck CHECK_CALLED(global_success_d);
3202c2c66affSColin Finck CHECK_CALLED(global_success_i);
3203c2c66affSColin Finck
3204c2c66affSColin Finck SET_EXPECT(global_success_d);
3205c2c66affSColin Finck SET_EXPECT(global_success_i);
3206c2c66affSColin Finck /* |Success | */
3207c2c66affSColin Finck parse_script_a("report#@~^BwAAAA==j!m^\x7f/k2QIAAA==^#~@();");
3208c2c66affSColin Finck CHECK_CALLED(global_success_d);
3209c2c66affSColin Finck CHECK_CALLED(global_success_i);
3210c2c66affSColin Finck
3211c2c66affSColin Finck SET_EXPECT(global_success_d);
3212c2c66affSColin Finck SET_EXPECT(global_success_i);
3213c2c66affSColin Finck /* |\r\n\treportSuccess();\r\n | */
3214c2c66affSColin Finck parse_script_a("#@~^GQAAAA==@#@&d.\x7fwKDYUE1^+k/c#p@#@&OAYAAA==^#~@");
3215c2c66affSColin Finck CHECK_CALLED(global_success_d);
3216c2c66affSColin Finck CHECK_CALLED(global_success_i);
3217c2c66affSColin Finck
3218c2c66affSColin Finck /* v */
3219c2c66affSColin Finck src = a2bstr("#@~^EAA*AA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3220c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
3221c2c66affSColin Finck SysFreeString(src);
3222c2c66affSColin Finck ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
3223c2c66affSColin Finck
3224c2c66affSColin Finck /* vv */
3225c2c66affSColin Finck src = a2bstr("#@~^EAAAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3226c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
3227c2c66affSColin Finck SysFreeString(src);
3228c2c66affSColin Finck ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
3229c2c66affSColin Finck
3230c2c66affSColin Finck /* v */
3231c2c66affSColin Finck src = a2bstr("#@~^EAAAAA^=.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3232c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
3233c2c66affSColin Finck SysFreeString(src);
3234c2c66affSColin Finck ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
3235c2c66affSColin Finck
3236c2c66affSColin Finck /* v */
3237c2c66affSColin Finck src = a2bstr("#@~^EAAAAA==.\x7fwGMYUEm1ekd`*iAQYAAA==^#~@");
3238c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
3239c2c66affSColin Finck SysFreeString(src);
3240c2c66affSColin Finck ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
3241c2c66affSColin Finck
3242c2c66affSColin Finck /* vv */
3243c2c66affSColin Finck src = a2bstr("#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^~#@");
3244c2c66affSColin Finck hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
3245c2c66affSColin Finck SysFreeString(src);
3246c2c66affSColin Finck ok(hres == JS_E_INVALID_CHAR, "parse_script failed %08x\n", hres);
3247c2c66affSColin Finck }
3248c2c66affSColin Finck
run_benchmark(const char * script_name)3249c2c66affSColin Finck static void run_benchmark(const char *script_name)
3250c2c66affSColin Finck {
3251c2c66affSColin Finck IActiveScriptParse *parser;
3252c2c66affSColin Finck IActiveScript *engine;
3253c2c66affSColin Finck ULONG start, end;
3254c2c66affSColin Finck BSTR src;
3255c2c66affSColin Finck HRESULT hres;
3256c2c66affSColin Finck
3257c2c66affSColin Finck engine = create_script();
3258c2c66affSColin Finck if(!engine)
3259c2c66affSColin Finck return;
3260c2c66affSColin Finck
3261c2c66affSColin Finck hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser);
3262c2c66affSColin Finck ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
3263c2c66affSColin Finck if (FAILED(hres)) {
3264c2c66affSColin Finck IActiveScript_Release(engine);
3265c2c66affSColin Finck return;
3266c2c66affSColin Finck }
3267c2c66affSColin Finck
3268c2c66affSColin Finck hres = IActiveScriptParse_InitNew(parser);
3269c2c66affSColin Finck ok(hres == S_OK, "InitNew failed: %08x\n", hres);
3270c2c66affSColin Finck
3271c2c66affSColin Finck hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite);
3272c2c66affSColin Finck ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
3273c2c66affSColin Finck
3274c2c66affSColin Finck hres = IActiveScript_AddNamedItem(engine, testW,
3275c2c66affSColin Finck SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE);
3276c2c66affSColin Finck ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
3277c2c66affSColin Finck
3278c2c66affSColin Finck hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED);
3279c2c66affSColin Finck ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
3280c2c66affSColin Finck
3281c2c66affSColin Finck src = load_res(script_name);
3282c2c66affSColin Finck
3283c2c66affSColin Finck start = GetTickCount();
3284c2c66affSColin Finck hres = IActiveScriptParse_ParseScriptText(parser, src, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
3285c2c66affSColin Finck end = GetTickCount();
3286c2c66affSColin Finck ok(hres == S_OK, "%s: ParseScriptText failed: %08x\n", script_name, hres);
3287c2c66affSColin Finck
3288c2c66affSColin Finck trace("%s ran in %u ms\n", script_name, end-start);
3289c2c66affSColin Finck
3290c2c66affSColin Finck IActiveScript_Release(engine);
3291c2c66affSColin Finck IActiveScriptParse_Release(parser);
3292c2c66affSColin Finck SysFreeString(src);
3293c2c66affSColin Finck }
3294c2c66affSColin Finck
run_benchmarks(void)3295c2c66affSColin Finck static void run_benchmarks(void)
3296c2c66affSColin Finck {
3297c2c66affSColin Finck trace("Running benchmarks...\n");
3298c2c66affSColin Finck
3299c2c66affSColin Finck run_benchmark("dna.js");
3300c2c66affSColin Finck run_benchmark("base64.js");
3301c2c66affSColin Finck run_benchmark("validateinput.js");
3302c2c66affSColin Finck }
3303c2c66affSColin Finck
check_jscript(void)3304c2c66affSColin Finck static BOOL check_jscript(void)
3305c2c66affSColin Finck {
3306c2c66affSColin Finck IActiveScriptProperty *script_prop;
3307c2c66affSColin Finck BSTR str;
3308c2c66affSColin Finck HRESULT hres;
3309c2c66affSColin Finck
3310c2c66affSColin Finck hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3311c2c66affSColin Finck &IID_IActiveScriptProperty, (void**)&script_prop);
3312c2c66affSColin Finck if(FAILED(hres))
3313c2c66affSColin Finck return FALSE;
3314c2c66affSColin Finck IActiveScriptProperty_Release(script_prop);
3315c2c66affSColin Finck
3316c2c66affSColin Finck str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
3317c2c66affSColin Finck hres = parse_script(0, str);
3318c2c66affSColin Finck SysFreeString(str);
3319c2c66affSColin Finck
3320c2c66affSColin Finck return hres == S_OK;
3321c2c66affSColin Finck }
3322c2c66affSColin Finck
START_TEST(run)3323c2c66affSColin Finck START_TEST(run)
3324c2c66affSColin Finck {
3325c2c66affSColin Finck int argc;
3326c2c66affSColin Finck char **argv;
3327c2c66affSColin Finck
3328c2c66affSColin Finck argc = winetest_get_mainargs(&argv);
3329c2c66affSColin Finck
3330c2c66affSColin Finck CoInitialize(NULL);
3331c2c66affSColin Finck
3332c2c66affSColin Finck if(!check_jscript()) {
3333c2c66affSColin Finck win_skip("Broken engine, probably too old\n");
3334c2c66affSColin Finck }else if(argc > 2) {
3335c2c66affSColin Finck invoke_version = 2;
3336c2c66affSColin Finck run_from_file(argv[2]);
3337c2c66affSColin Finck }else {
3338c2c66affSColin Finck trace("invoke version 0\n");
3339c2c66affSColin Finck invoke_version = 0;
3340c2c66affSColin Finck run_tests();
3341c2c66affSColin Finck
3342c2c66affSColin Finck trace("invoke version 2\n");
3343c2c66affSColin Finck invoke_version = 2;
3344c2c66affSColin Finck if(run_tests()) {
3345c2c66affSColin Finck trace("JSctipt.Encode tests...\n");
3346c2c66affSColin Finck run_encoded_tests();
3347c2c66affSColin Finck trace("ParseProcedureText tests...\n");
3348c2c66affSColin Finck test_parse_proc();
3349c2c66affSColin Finck }
3350c2c66affSColin Finck
3351c2c66affSColin Finck if(winetest_interactive)
3352c2c66affSColin Finck run_benchmarks();
3353c2c66affSColin Finck }
3354c2c66affSColin Finck
3355c2c66affSColin Finck CoUninitialize();
3356c2c66affSColin Finck }
3357