ReactOS 0.4.15-dev-8241-g63935f8
vbscript.c File Reference
#include <initguid.h>
#include <ole2.h>
#include <activscp.h>
#include <objsafe.h>
#include <dispex.h>
#include "vbsregexp55.h"
#include "wine/test.h"
Include dependency graph for vbscript.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define IActiveScriptParse_QueryInterface   IActiveScriptParse32_QueryInterface
 
#define IActiveScriptParse_Release   IActiveScriptParse32_Release
 
#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew
 
#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText
 
#define IActiveScriptParseProcedure2_Release    IActiveScriptParseProcedure2_32_Release
 
#define DEFINE_EXPECT(func)    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
 
#define SET_EXPECT(func)    expect_ ## func = TRUE
 
#define CHECK_EXPECT2(func)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#define test_state(s, ss)   _test_state(__LINE__,s,ss)
 
#define get_disp_id(a, b, c, d)   _get_disp_id(__LINE__,a,b,c,d)
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
 DEFINE_EXPECT (GetLCID)
 
 DEFINE_EXPECT (OnStateChange_UNINITIALIZED)
 
 DEFINE_EXPECT (OnStateChange_STARTED)
 
 DEFINE_EXPECT (OnStateChange_CONNECTED)
 
 DEFINE_EXPECT (OnStateChange_DISCONNECTED)
 
 DEFINE_EXPECT (OnStateChange_CLOSED)
 
 DEFINE_EXPECT (OnStateChange_INITIALIZED)
 
 DEFINE_EXPECT (OnEnterScript)
 
 DEFINE_EXPECT (OnLeaveScript)
 
 DEFINE_EXPECT (GetItemInfo_global)
 
 DEFINE_EXPECT (GetItemInfo_visible)
 
 DEFINE_EXPECT (testCall)
 
 DEFINE_GUID (CLSID_VBScript, 0xb54f3741, 0x5b07, 0x11cf, 0xa4, 0xb0, 0x00, 0xaa, 0x00, 0x4a, 0x55, 0xe8)
 
 DEFINE_GUID (CLSID_VBScriptRegExp, 0x3f4daca4, 0x160d, 0x11d2, 0xa8, 0xe9, 0x00, 0x10, 0x4b, 0x36, 0x5c, 0x9f)
 
static BSTR a2bstr (const char *str)
 
static void _test_state (unsigned line, IActiveScript *script, SCRIPTSTATE exstate)
 
static HRESULT WINAPI Dispatch_QueryInterface (IDispatch *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI global_AddRef (IDispatch *iface)
 
static ULONG WINAPI global_Release (IDispatch *iface)
 
static ULONG WINAPI visible_AddRef (IDispatch *iface)
 
static ULONG WINAPI visible_Release (IDispatch *iface)
 
static HRESULT WINAPI Dispatch_GetTypeInfoCount (IDispatch *iface, UINT *pctinfo)
 
static HRESULT WINAPI Dispatch_GetTypeInfo (IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI Dispatch_GetIDsOfNames (IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, LCID lcid, DISPID *ids)
 
static HRESULT WINAPI Dispatch_Invoke (IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
 
static HRESULT WINAPI ActiveScriptSite_QueryInterface (IActiveScriptSite *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ActiveScriptSite_AddRef (IActiveScriptSite *iface)
 
static ULONG WINAPI ActiveScriptSite_Release (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSite_GetLCID (IActiveScriptSite *iface, LCID *plcid)
 
static HRESULT WINAPI ActiveScriptSite_GetItemInfo (IActiveScriptSite *iface, LPCOLESTR name, DWORD return_mask, IUnknown **item_unk, ITypeInfo **item_ti)
 
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString (IActiveScriptSite *iface, BSTR *pbstrVersion)
 
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate (IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
 
static HRESULT WINAPI ActiveScriptSite_OnStateChange (IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
 
static HRESULT WINAPI ActiveScriptSite_OnScriptError (IActiveScriptSite *iface, IActiveScriptError *pscripterror)
 
static HRESULT WINAPI ActiveScriptSite_OnEnterScript (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript (IActiveScriptSite *iface)
 
static void test_safety (IActiveScript *script)
 
static IDispatchExget_script_dispatch (IActiveScript *script)
 
static void parse_script (IActiveScriptParse *parse, const char *src)
 
static void _get_disp_id (unsigned line, IDispatchEx *dispex, const char *name, HRESULT exhres, DISPID *id)
 
static void test_no_script_dispatch (IActiveScript *script)
 
static IActiveScriptcreate_vbscript (void)
 
static void test_scriptdisp (void)
 
static void test_vbscript (void)
 
static void test_vbscript_uninitializing (void)
 
static void test_vbscript_release (void)
 
static void test_vbscript_simplecreate (void)
 
static void test_vbscript_initializing (void)
 
static void test_named_items (void)
 
static void test_RegExp (void)
 
static BOOL check_vbscript (void)
 
 START_TEST (vbscript)
 

Variables

static ULONG global_named_item_ref
 
static ULONG visible_named_item_ref
 
static const IDispatchVtbl global_named_item_vtbl
 
static IDispatch global_named_item = { &global_named_item_vtbl }
 
static const IDispatchVtbl visible_named_item_vtbl
 
static IDispatch visible_named_item = { &visible_named_item_vtbl }
 
static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
 
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }
 

Macro Definition Documentation

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:29

Definition at line 72 of file vbscript.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 66 of file vbscript.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 60 of file vbscript.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file vbscript.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 20 of file vbscript.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 54 of file vbscript.c.

◆ get_disp_id

#define get_disp_id (   a,
  b,
  c,
  d 
)    _get_disp_id(__LINE__,a,b,c,d)

Definition at line 458 of file vbscript.c.

◆ IActiveScriptParse_InitNew

#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew

Definition at line 45 of file vbscript.c.

◆ IActiveScriptParse_ParseScriptText

#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText

Definition at line 46 of file vbscript.c.

◆ IActiveScriptParse_QueryInterface

#define IActiveScriptParse_QueryInterface   IActiveScriptParse32_QueryInterface

Definition at line 43 of file vbscript.c.

◆ IActiveScriptParse_Release

#define IActiveScriptParse_Release   IActiveScriptParse32_Release

Definition at line 44 of file vbscript.c.

◆ IActiveScriptParseProcedure2_Release

#define IActiveScriptParseProcedure2_Release    IActiveScriptParseProcedure2_32_Release

Definition at line 47 of file vbscript.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     expect_ ## func = TRUE

Definition at line 57 of file vbscript.c.

◆ test_state

#define test_state (   s,
  ss 
)    _test_state(__LINE__,s,ss)

Definition at line 106 of file vbscript.c.

Function Documentation

◆ _get_disp_id()

static void _get_disp_id ( unsigned  line,
IDispatchEx dispex,
const char name,
HRESULT  exhres,
DISPID id 
)
static

Definition at line 459 of file vbscript.c.

460{
461 DISPID id2;
462 BSTR str;
464
465 str = a2bstr(name);
466 hres = IDispatchEx_GetDispID(dispex, str, 0, id);
467 ok_(__FILE__,line)(hres == exhres, "GetDispID(%s) returned %08x, expected %08x\n", name, hres, exhres);
468
469 hres = IDispatchEx_GetIDsOfNames(dispex, &IID_NULL, &str, 1, 0, &id2);
471 ok_(__FILE__,line)(hres == exhres, "GetIDsOfNames(%s) returned %08x, expected %08x\n", name, hres, exhres);
472 ok_(__FILE__,line)(*id == id2, "GetIDsOfNames(%s) id != id2\n", name);
473}
#define ok_(x1, x2)
Definition: atltest.h:61
OLECHAR * BSTR
Definition: compat.h:2293
HRESULT hres
Definition: protocol.c:465
static VARIANTARG static DISPID
Definition: ordinal.c:52
static BSTR a2bstr(const char *str)
Definition: vbscript.c:94
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define IID_NULL
Definition: guiddef.h:98
const WCHAR * str
Definition: parser.c:49
Definition: name.c:39

◆ _test_state()

static void _test_state ( unsigned  line,
IActiveScript script,
SCRIPTSTATE  exstate 
)
static

Definition at line 107 of file vbscript.c.

108{
109 SCRIPTSTATE state = -1;
111
112 hres = IActiveScript_GetScriptState(script, &state);
113 ok_(__FILE__,line) (hres == S_OK, "GetScriptState failed: %08x\n", hres);
114 ok_(__FILE__,line) (state == exstate, "state=%d, expected %d\n", state, exstate);
115}
enum tagSCRIPTSTATE SCRIPTSTATE
static int state
Definition: maze.c:121
#define S_OK
Definition: intsafe.h:52
script
Definition: msipriv.h:383

◆ a2bstr()

static BSTR a2bstr ( const char str)
static

Definition at line 94 of file vbscript.c.

95{
96 BSTR ret;
97 int len;
98
99 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
102
103 return ret;
104}
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
int ret

Referenced by _get_disp_id(), and parse_script().

◆ ActiveScriptSite_AddRef()

static ULONG WINAPI ActiveScriptSite_AddRef ( IActiveScriptSite iface)
static

Definition at line 221 of file vbscript.c.

222{
223 return 2;
224}

◆ ActiveScriptSite_GetDocVersionString()

static HRESULT WINAPI ActiveScriptSite_GetDocVersionString ( IActiveScriptSite iface,
BSTR pbstrVersion 
)
static

Definition at line 257 of file vbscript.c.

258{
259 ok(0, "unexpected call\n");
260 return E_NOTIMPL;
261}
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ActiveScriptSite_GetItemInfo()

static HRESULT WINAPI ActiveScriptSite_GetItemInfo ( IActiveScriptSite iface,
LPCOLESTR  name,
DWORD  return_mask,
IUnknown **  item_unk,
ITypeInfo **  item_ti 
)
static

Definition at line 237 of file vbscript.c.

239{
240 ok(return_mask == SCRIPTINFO_IUNKNOWN, "return_mask = %x\n", return_mask);
241 if(!wcscmp(name, L"globalItem")) {
242 CHECK_EXPECT(GetItemInfo_global);
243 IDispatch_AddRef(&global_named_item);
244 *item_unk = (IUnknown*)&global_named_item;
245 return S_OK;
246 }
247 if(!wcscmp(name, L"visibleItem")) {
248 CHECK_EXPECT(GetItemInfo_visible);
249 IDispatch_AddRef(&visible_named_item);
250 *item_unk = (IUnknown*)&visible_named_item;
251 return S_OK;
252 }
253 ok(0, "unexpected call %s\n", wine_dbgstr_w(name));
254 return E_NOTIMPL;
255}
#define wine_dbgstr_w
Definition: kernel32.h:34
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
static IDispatch visible_named_item
Definition: vbscript.c:204
static IDispatch global_named_item
Definition: vbscript.c:192
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ ActiveScriptSite_GetLCID()

static HRESULT WINAPI ActiveScriptSite_GetLCID ( IActiveScriptSite iface,
LCID plcid 
)
static

Definition at line 231 of file vbscript.c.

232{
233 CHECK_EXPECT(GetLCID);
234 return E_NOTIMPL;
235}

◆ ActiveScriptSite_OnEnterScript()

static HRESULT WINAPI ActiveScriptSite_OnEnterScript ( IActiveScriptSite iface)
static

Definition at line 304 of file vbscript.c.

305{
306 CHECK_EXPECT(OnEnterScript);
307 return S_OK;
308}

◆ ActiveScriptSite_OnLeaveScript()

static HRESULT WINAPI ActiveScriptSite_OnLeaveScript ( IActiveScriptSite iface)
static

Definition at line 310 of file vbscript.c.

311{
312 CHECK_EXPECT(OnLeaveScript);
313 return S_OK;
314}

◆ ActiveScriptSite_OnScriptError()

static HRESULT WINAPI ActiveScriptSite_OnScriptError ( IActiveScriptSite iface,
IActiveScriptError pscripterror 
)
static

Definition at line 298 of file vbscript.c.

299{
300 ok(0, "unexpected call\n");
301 return E_NOTIMPL;
302}

◆ ActiveScriptSite_OnScriptTerminate()

static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate ( IActiveScriptSite iface,
const VARIANT pvarResult,
const EXCEPINFO *  pexcepinfo 
)
static

Definition at line 263 of file vbscript.c.

265{
266 ok(0, "unexpected call\n");
267 return E_NOTIMPL;
268}

◆ ActiveScriptSite_OnStateChange()

static HRESULT WINAPI ActiveScriptSite_OnStateChange ( IActiveScriptSite iface,
SCRIPTSTATE  ssScriptState 
)
static

Definition at line 270 of file vbscript.c.

271{
272 switch(ssScriptState) {
274 CHECK_EXPECT(OnStateChange_UNINITIALIZED);
275 return S_OK;
277 CHECK_EXPECT(OnStateChange_STARTED);
278 return S_OK;
280 CHECK_EXPECT(OnStateChange_CONNECTED);
281 return S_OK;
283 CHECK_EXPECT(OnStateChange_DISCONNECTED);
284 return S_OK;
286 CHECK_EXPECT(OnStateChange_CLOSED);
287 return S_OK;
289 CHECK_EXPECT(OnStateChange_INITIALIZED);
290 return S_OK;
291 default:
292 ok(0, "unexpected call %d\n", ssScriptState);
293 }
294
295 return E_NOTIMPL;
296}
@ SCRIPTSTATE_INITIALIZED
Definition: activscp.idl:62
@ SCRIPTSTATE_DISCONNECTED
Definition: activscp.idl:60
@ SCRIPTSTATE_STARTED
Definition: activscp.idl:58
@ SCRIPTSTATE_UNINITIALIZED
Definition: activscp.idl:57
@ SCRIPTSTATE_CLOSED
Definition: activscp.idl:61
@ SCRIPTSTATE_CONNECTED
Definition: activscp.idl:59

◆ ActiveScriptSite_QueryInterface()

static HRESULT WINAPI ActiveScriptSite_QueryInterface ( IActiveScriptSite iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 206 of file vbscript.c.

207{
208 *ppv = NULL;
209
211 *ppv = iface;
212 else if(IsEqualGUID(&IID_IActiveScriptSite, riid))
213 *ppv = iface;
214 else
215 return E_NOINTERFACE;
216
217 IUnknown_AddRef((IUnknown*)*ppv);
218 return S_OK;
219}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ActiveScriptSite_Release()

static ULONG WINAPI ActiveScriptSite_Release ( IActiveScriptSite iface)
static

Definition at line 226 of file vbscript.c.

227{
228 return 1;
229}

◆ check_vbscript()

static BOOL check_vbscript ( void  )
static

Definition at line 1134 of file vbscript.c.

1135{
1136 IActiveScriptParseProcedure2 *vbscript;
1137 HRESULT hres;
1138
1139 hres = CoCreateInstance(&CLSID_VBScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1140 &IID_IActiveScriptParseProcedure2, (void**)&vbscript);
1141 if(SUCCEEDED(hres))
1143
1144 return hres == S_OK;
1145}
const CLSID CLSID_VBScript
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define IActiveScriptParseProcedure2_Release
Definition: vbscript.c:47

Referenced by START_TEST().

◆ create_vbscript()

static IActiveScript * create_vbscript ( void  )
static

Definition at line 486 of file vbscript.c.

487{
490
491 hres = CoCreateInstance(&CLSID_VBScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
492 &IID_IActiveScript, (void**)&ret);
493 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
494
495 return ret;
496}

Referenced by test_named_items(), test_scriptdisp(), test_vbscript(), test_vbscript_initializing(), test_vbscript_release(), test_vbscript_simplecreate(), and test_vbscript_uninitializing().

◆ DEFINE_EXPECT() [1/12]

DEFINE_EXPECT ( GetItemInfo_global  )

◆ DEFINE_EXPECT() [2/12]

DEFINE_EXPECT ( GetItemInfo_visible  )

◆ DEFINE_EXPECT() [3/12]

DEFINE_EXPECT ( GetLCID  )

◆ DEFINE_EXPECT() [4/12]

DEFINE_EXPECT ( OnEnterScript  )

◆ DEFINE_EXPECT() [5/12]

DEFINE_EXPECT ( OnLeaveScript  )

◆ DEFINE_EXPECT() [6/12]

DEFINE_EXPECT ( OnStateChange_CLOSED  )

◆ DEFINE_EXPECT() [7/12]

DEFINE_EXPECT ( OnStateChange_CONNECTED  )

◆ DEFINE_EXPECT() [8/12]

DEFINE_EXPECT ( OnStateChange_DISCONNECTED  )

◆ DEFINE_EXPECT() [9/12]

DEFINE_EXPECT ( OnStateChange_INITIALIZED  )

◆ DEFINE_EXPECT() [10/12]

DEFINE_EXPECT ( OnStateChange_STARTED  )

◆ DEFINE_EXPECT() [11/12]

DEFINE_EXPECT ( OnStateChange_UNINITIALIZED  )

◆ DEFINE_EXPECT() [12/12]

DEFINE_EXPECT ( testCall  )

◆ DEFINE_GUID() [1/3]

DEFINE_GUID ( CLSID_VBScript  ,
0xb54f3741  ,
0x5b07  ,
0x11cf  ,
0xa4  ,
0xb0  ,
0x00  ,
0xaa  ,
0x00  ,
0x4a  ,
0x55  ,
0xe8   
)

◆ DEFINE_GUID() [2/3]

DEFINE_GUID ( CLSID_VBScriptRegExp  ,
0x3f4daca4  ,
0x160d  ,
0x11d2  ,
0xa8  ,
0xe9  ,
0x00  ,
0x10  ,
0x4b  ,
0x36  ,
0x5c  ,
0x9f   
)

◆ DEFINE_GUID() [3/3]

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ Dispatch_GetIDsOfNames()

static HRESULT WINAPI Dispatch_GetIDsOfNames ( IDispatch iface,
REFIID  riid,
LPOLESTR names,
UINT  name_cnt,
LCID  lcid,
DISPID ids 
)
static

Definition at line 162 of file vbscript.c.

164{
165 ok(name_cnt == 1, "name_cnt = %u\n", name_cnt);
166 ok(!wcscmp(names[0], L"testCall"), "names[0] = %s\n", wine_dbgstr_w(names[0]));
167 *ids = 1;
168 return S_OK;
169}
GLuint * ids
Definition: glext.h:5907
GLuint GLuint * names
Definition: glext.h:11545

◆ Dispatch_GetTypeInfo()

static HRESULT WINAPI Dispatch_GetTypeInfo ( IDispatch iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 157 of file vbscript.c.

158{
159 return DISP_E_BADINDEX;
160}
#define DISP_E_BADINDEX
Definition: winerror.h:2520

◆ Dispatch_GetTypeInfoCount()

static HRESULT WINAPI Dispatch_GetTypeInfoCount ( IDispatch iface,
UINT pctinfo 
)
static

Definition at line 151 of file vbscript.c.

152{
153 ok(0, "unexpected call\n");
154 return E_NOTIMPL;
155}

◆ Dispatch_Invoke()

static HRESULT WINAPI Dispatch_Invoke ( IDispatch iface,
DISPID  id,
REFIID  riid,
LCID  lcid,
WORD  flags,
DISPPARAMS *  dp,
VARIANT res,
EXCEPINFO *  ei,
UINT err 
)
static

Definition at line 171 of file vbscript.c.

173{
174 CHECK_EXPECT(testCall);
175 ok(id == 1, "id = %u\n", id);
176 ok(flags == DISPATCH_METHOD, "flags = %x\n", flags);
177 ok(!dp->cArgs, "cArgs = %u\n", dp->cArgs);
178 ok(!res, "res = %p\n", res);
179 return S_OK;
180}
GLuint res
Definition: glext.h:9613
GLbitfield flags
Definition: glext.h:7161
#define DISPATCH_METHOD
Definition: oleauto.h:1006

◆ Dispatch_QueryInterface()

static HRESULT WINAPI Dispatch_QueryInterface ( IDispatch iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 117 of file vbscript.c.

118{
120 *ppv = iface;
121 IDispatch_AddRef(iface);
122 return S_OK;
123 }
124
125 *ppv = NULL;
126 return E_NOINTERFACE;
127}
const GUID IID_IDispatch

◆ get_script_dispatch()

static IDispatchEx * get_script_dispatch ( IActiveScript script)
static

Definition at line 423 of file vbscript.c.

424{
425 IDispatchEx *dispex;
426 IDispatch *disp;
428
429 disp = (void*)0xdeadbeef;
430 hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
431 ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
432 if(FAILED(hres))
433 return NULL;
434
435 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
436 IDispatch_Release(disp);
437 ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres);
438 return dispex;
439}
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by test_scriptdisp(), and test_vbscript_uninitializing().

◆ global_AddRef()

static ULONG WINAPI global_AddRef ( IDispatch iface)
static

Definition at line 131 of file vbscript.c.

132{
133 return ++global_named_item_ref;
134}
static ULONG global_named_item_ref
Definition: vbscript.c:129

◆ global_Release()

static ULONG WINAPI global_Release ( IDispatch iface)
static

Definition at line 136 of file vbscript.c.

137{
138 return --global_named_item_ref;
139}

◆ parse_script()

static void parse_script ( IActiveScriptParse *  parse,
const char src 
)
static

Definition at line 441 of file vbscript.c.

442{
443 BSTR str;
445
446 SET_EXPECT(OnEnterScript);
447 SET_EXPECT(OnLeaveScript);
448
449 str = a2bstr(src);
452 ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
453
454 CHECK_CALLED(OnEnterScript);
455 CHECK_CALLED(OnLeaveScript);
456}
GLenum src
Definition: glext.h:6340
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define IActiveScriptParse_ParseScriptText
Definition: vbscript.c:46
#define CHECK_CALLED(func)
Definition: vbscript.c:72

Referenced by test_named_items(), and test_scriptdisp().

◆ START_TEST()

START_TEST ( vbscript  )

Definition at line 1147 of file vbscript.c.

1148{
1150
1151 if(check_vbscript()) {
1152 test_vbscript();
1159 test_RegExp();
1160 }else {
1161 win_skip("VBScript engine not available or too old\n");
1162 }
1163
1165}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_vbscript_release(void)
Definition: vbscript.c:809
static void test_vbscript(void)
Definition: vbscript.c:626
static void test_vbscript_simplecreate(void)
Definition: vbscript.c:857
static BOOL check_vbscript(void)
Definition: vbscript.c:1134
static void test_scriptdisp(void)
Definition: vbscript.c:498
static void test_vbscript_initializing(void)
Definition: vbscript.c:872
static void test_named_items(void)
Definition: vbscript.c:912
static void test_vbscript_uninitializing(void)
Definition: vbscript.c:692
static void test_RegExp(void)
Definition: vbscript.c:994
#define win_skip
Definition: test.h:163

◆ test_named_items()

static void test_named_items ( void  )
static

Definition at line 912 of file vbscript.c.

913{
914 IActiveScriptParse *parse;
916 ULONG ref;
918
920
921 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
922 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
923
925
926 hres = IActiveScript_AddNamedItem(script, L"visibleItem", SCRIPTITEM_ISVISIBLE);
927 ok(hres == E_UNEXPECTED, "AddNamedItem returned: %08x\n", hres);
928 hres = IActiveScript_AddNamedItem(script, L"globalItem", SCRIPTITEM_GLOBALMEMBERS);
929 ok(hres == E_UNEXPECTED, "AddNamedItem returned: %08x\n", hres);
930
931 SET_EXPECT(GetLCID);
932 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
933 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
934 CHECK_CALLED(GetLCID);
935
936 SET_EXPECT(GetItemInfo_global);
937 hres = IActiveScript_AddNamedItem(script, L"globalItem", SCRIPTITEM_GLOBALMEMBERS);
938 ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
939 CHECK_CALLED(GetItemInfo_global);
940
941 hres = IActiveScript_AddNamedItem(script, L"visibleItem", SCRIPTITEM_ISVISIBLE);
942 ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
943
944 ok(global_named_item_ref > 0, "global_named_item_ref = %u\n", global_named_item_ref);
945 ok(visible_named_item_ref == 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
946
947 SET_EXPECT(OnStateChange_INITIALIZED);
949 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
950 CHECK_CALLED(OnStateChange_INITIALIZED);
951
952 SET_EXPECT(OnStateChange_CONNECTED);
953 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
954 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
955 CHECK_CALLED(OnStateChange_CONNECTED);
956
957 SET_EXPECT(testCall);
958 parse_script(parse, "testCall\n");
959 CHECK_CALLED(testCall);
960
961 SET_EXPECT(GetItemInfo_visible);
962 SET_EXPECT(testCall);
963 parse_script(parse, "visibleItem.testCall\n");
964 CHECK_CALLED(GetItemInfo_visible);
965 CHECK_CALLED(testCall);
966
967 ok(global_named_item_ref > 0, "global_named_item_ref = %u\n", global_named_item_ref);
968 ok(visible_named_item_ref == 1, "visible_named_item_ref = %u\n", visible_named_item_ref);
969
970 SET_EXPECT(testCall);
971 parse_script(parse, "visibleItem.testCall\n");
972 CHECK_CALLED(testCall);
973
974 SET_EXPECT(OnStateChange_DISCONNECTED);
975 SET_EXPECT(OnStateChange_INITIALIZED);
976 SET_EXPECT(OnStateChange_CLOSED);
977 hres = IActiveScript_Close(script);
978 ok(hres == S_OK, "Close failed: %08x\n", hres);
979 CHECK_CALLED(OnStateChange_DISCONNECTED);
980 CHECK_CALLED(OnStateChange_INITIALIZED);
981 CHECK_CALLED(OnStateChange_CLOSED);
982
983 ok(global_named_item_ref == 0, "global_named_item_ref = %u\n", global_named_item_ref);
984 ok(visible_named_item_ref == 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
985
987
989
990 ref = IActiveScript_Release(script);
991 ok(!ref, "ref = %d\n", ref);
992}
static ULONG visible_named_item_ref
Definition: vbscript.c:129
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
#define IActiveScriptParse_Release
Definition: vbscript.c:44
#define test_state(s, ss)
Definition: vbscript.c:106
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
static void parse_script(IActiveScriptParse *parse, const char *src)
Definition: vbscript.c:441
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
#define E_UNEXPECTED
Definition: winerror.h:2456

Referenced by START_TEST().

◆ test_no_script_dispatch()

static void test_no_script_dispatch ( IActiveScript script)
static

Definition at line 475 of file vbscript.c.

476{
477 IDispatch *disp;
479
480 disp = (void*)0xdeadbeef;
481 hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
482 ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres);
483 ok(!disp, "disp != NULL\n");
484}

Referenced by test_vbscript(), and test_vbscript_uninitializing().

◆ test_RegExp()

static void test_RegExp ( void  )
static

Definition at line 994 of file vbscript.c.

995{
996 IRegExp2 *regexp;
997 IMatchCollection2 *mc;
998 IMatch2 *match;
999 ISubMatches *sm;
1000 IEnumVARIANT *ev;
1001 IUnknown *unk;
1002 IDispatch *disp;
1003 HRESULT hres;
1004 BSTR bstr;
1005 LONG count;
1006 VARIANT v;
1007 ULONG fetched;
1008
1010 CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
1011 &IID_IUnknown, (void**)&unk);
1012 if(hres == REGDB_E_CLASSNOTREG) {
1013 win_skip("VBScriptRegExp is not registered\n");
1014 return;
1015 }
1016 ok(hres == S_OK, "CoCreateInstance(CLSID_VBScriptRegExp) failed: %x\n", hres);
1017
1018 hres = IUnknown_QueryInterface(unk, &IID_IRegExp2, (void**)&regexp);
1019 if(hres == E_NOINTERFACE) {
1020 win_skip("IRegExp2 interface is not available\n");
1021 return;
1022 }
1023 ok(hres == S_OK, "QueryInterface(IID_IRegExp2) failed: %x\n", hres);
1024 IUnknown_Release(unk);
1025
1026 hres = IRegExp2_QueryInterface(regexp, &IID_IRegExp, (void**)&unk);
1027 ok(hres == S_OK, "QueryInterface(IID_IRegExp) returned %x\n", hres);
1028 IUnknown_Release(unk);
1029
1030 hres = IRegExp2_QueryInterface(regexp, &IID_IDispatchEx, (void**)&unk);
1031 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IDispatchEx) returned %x\n", hres);
1032
1033 hres = IRegExp2_get_Pattern(regexp, &bstr);
1034 ok(bstr == NULL, "bstr != NULL\n");
1035 ok(hres == S_OK, "get_Pattern returned %x, expected S_OK\n", hres);
1036
1037 hres = IRegExp2_get_Pattern(regexp, NULL);
1038 ok(hres == E_POINTER, "get_Pattern returned %x, expected E_POINTER\n", hres);
1039
1040 hres = IRegExp2_get_IgnoreCase(regexp, NULL);
1041 ok(hres == E_POINTER, "get_IgnoreCase returned %x, expected E_POINTER\n", hres);
1042
1043 hres = IRegExp2_get_Global(regexp, NULL);
1044 ok(hres == E_POINTER, "get_Global returned %x, expected E_POINTER\n", hres);
1045
1046 hres = IRegExp2_Execute(regexp, NULL, &disp);
1047 ok(hres == S_OK, "Execute returned %x, expected S_OK\n", hres);
1048 hres = IDispatch_QueryInterface(disp, &IID_IMatchCollection2, (void**)&mc);
1049 ok(hres == S_OK, "QueryInterface(IID_IMatchCollection2) returned %x\n", hres);
1050 IDispatch_Release(disp);
1051
1052 hres = IMatchCollection2_QueryInterface(mc, &IID_IMatchCollection, (void**)&unk);
1053 ok(hres == S_OK, "QueryInterface(IID_IMatchCollection) returned %x\n", hres);
1054 IUnknown_Release(unk);
1055
1056 hres = IMatchCollection2_get_Count(mc, NULL);
1057 ok(hres == E_POINTER, "get_Count returned %x, expected E_POINTER\n", hres);
1058
1059 hres = IMatchCollection2_get_Count(mc, &count);
1060 ok(hres == S_OK, "get_Count returned %x, expected S_OK\n", hres);
1061 ok(count == 1, "count = %d\n", count);
1062
1063 hres = IMatchCollection2_get_Item(mc, 1, &disp);
1064 ok(hres == E_INVALIDARG, "get_Item returned %x, expected E_INVALIDARG\n", hres);
1065
1066 hres = IMatchCollection2_get_Item(mc, 1, NULL);
1067 ok(hres == E_POINTER, "get_Item returned %x, expected E_POINTER\n", hres);
1068
1069 hres = IMatchCollection2_get_Item(mc, 0, &disp);
1070 ok(hres == S_OK, "get_Item returned %x, expected S_OK\n", hres);
1071 hres = IDispatch_QueryInterface(disp, &IID_IMatch2, (void**)&match);
1072 ok(hres == S_OK, "QueryInterface(IID_IMatch2) returned %x\n", hres);
1073 IDispatch_Release(disp);
1074
1075 hres = IMatch2_QueryInterface(match, &IID_IMatch, (void**)&unk);
1076 ok(hres == S_OK, "QueryInterface(IID_IMatch) returned %x\n", hres);
1077 IUnknown_Release(unk);
1078
1079 hres = IMatch2_get_Value(match, NULL);
1080 ok(hres == E_POINTER, "get_Value returned %x, expected E_POINTER\n", hres);
1081
1082 hres = IMatch2_get_FirstIndex(match, NULL);
1083 ok(hres == E_POINTER, "get_FirstIndex returned %x, expected E_POINTER\n", hres);
1084
1085 hres = IMatch2_get_Length(match, NULL);
1086 ok(hres == E_POINTER, "get_Length returned %x, expected E_POINTER\n", hres);
1087
1088 hres = IMatch2_get_SubMatches(match, NULL);
1089 ok(hres == E_POINTER, "get_SubMatches returned %x, expected E_POINTER\n", hres);
1090
1091 hres = IMatch2_get_SubMatches(match, &disp);
1092 ok(hres == S_OK, "get_SubMatches returned %x, expected S_OK\n", hres);
1093 IMatch2_Release(match);
1094 hres = IDispatch_QueryInterface(disp, &IID_ISubMatches, (void**)&sm);
1095 ok(hres == S_OK, "QueryInterface(IID_ISubMatches) returned %x\n", hres);
1096 IDispatch_Release(disp);
1097
1098 hres = ISubMatches_get_Item(sm, 0, &v);
1099 ok(hres == E_INVALIDARG, "get_Item returned %x, expected E_INVALIDARG\n", hres);
1100
1101 hres = ISubMatches_get_Item(sm, 0, NULL);
1102 ok(hres == E_POINTER, "get_Item returned %x, expected E_POINTER\n", hres);
1103
1104 hres = ISubMatches_get_Count(sm, NULL);
1105 ok(hres == E_POINTER, "get_Count returned %x, expected E_POINTER\n", hres);
1106 ISubMatches_Release(sm);
1107
1108 hres = IMatchCollection2_get__NewEnum(mc, &unk);
1109 ok(hres == S_OK, "get__NewEnum returned %x, expected S_OK\n", hres);
1110 hres = IUnknown_QueryInterface(unk, &IID_IEnumVARIANT, (void**)&ev);
1111 ok(hres == S_OK, "QueryInterface(IID_IEnumVARIANT) returned %x\n", hres);
1112 IUnknown_Release(unk);
1113 IMatchCollection2_Release(mc);
1114
1115 hres = IEnumVARIANT_Skip(ev, 2);
1116 ok(hres == S_OK, "Skip returned %x\n", hres);
1117
1118 hres = IEnumVARIANT_Next(ev, 1, &v, &fetched);
1119 ok(hres == S_FALSE, "Next returned %x, expected S_FALSE\n", hres);
1120 ok(fetched == 0, "fetched = %d\n", fetched);
1121
1122 hres = IEnumVARIANT_Skip(ev, -1);
1123 ok(hres == S_OK, "Skip returned %x\n", hres);
1124
1125 hres = IEnumVARIANT_Next(ev, 1, &v, &fetched);
1126 ok(hres == S_OK, "Next returned %x\n", hres);
1127 ok(fetched == 1, "fetched = %d\n", fetched);
1128 VariantClear(&v);
1129 IEnumVARIANT_Release(ev);
1130
1131 IRegExp2_Release(regexp);
1132}
#define E_INVALIDARG
Definition: ddrawi.h:101
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
const CLSID CLSID_VBScriptRegExp
long LONG
Definition: pedump.c:60
Definition: match.c:28
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_safety()

static void test_safety ( IActiveScript script)
static

Definition at line 332 of file vbscript.c.

333{
334 IObjectSafety *safety;
335 DWORD supported, enabled;
337
338 hres = IActiveScript_QueryInterface(script, &IID_IObjectSafety, (void**)&safety);
339 ok(hres == S_OK, "Could not get IObjectSafety: %08x\n", hres);
340 if(FAILED(hres))
341 return;
342
343 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, NULL);
344 ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
345 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, NULL, &enabled);
346 ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
347
348 supported = enabled = 0xdeadbeef;
349 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, &enabled);
350 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
351 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
352 "supported=%x\n", supported);
353 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
354
355 supported = enabled = 0xdeadbeef;
356 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScript, &supported, &enabled);
357 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
358 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
359 "supported=%x\n", supported);
360 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
361
362 supported = enabled = 0xdeadbeef;
363 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
364 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
365 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
366 "supported=%x\n", supported);
367 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
368
369 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
370 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER
371 |INTERFACESAFE_FOR_UNTRUSTED_CALLER,
372 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
373 ok(hres == E_FAIL, "SetInterfaceSafetyOptions failed: %08x, expected E_FAIL\n", hres);
374
375 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
376 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER,
377 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
378 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
379
380 supported = enabled = 0xdeadbeef;
381 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
382 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
383 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
384 "supported=%x\n", supported);
385 ok(enabled == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
386 "enabled=%x\n", enabled);
387
388 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, INTERFACESAFE_FOR_UNTRUSTED_DATA, 0);
389 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
390
391 supported = enabled = 0xdeadbeef;
392 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
393 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
394 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
395 "supported=%x\n", supported);
396 ok(enabled == (INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER), "enabled=%x\n", enabled);
397
398 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
399 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER, 0);
400 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
401
402 supported = enabled = 0xdeadbeef;
403 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
404 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
405 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
406 "supported=%x\n", supported);
407 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
408
409 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
410 INTERFACE_USES_DISPEX, 0);
411 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
412
413 supported = enabled = 0xdeadbeef;
414 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
415 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
416 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
417 "supported=%x\n", supported);
418 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
419
420 IObjectSafety_Release(safety);
421}
#define E_FAIL
Definition: ddrawi.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750

Referenced by test_scriptdisp(), test_vbscript(), and test_vbscript_release().

◆ test_scriptdisp()

static void test_scriptdisp ( void  )
static

Definition at line 498 of file vbscript.c.

499{
500 IDispatchEx *script_disp, *script_disp2;
501 IActiveScriptParse *parser;
502 IActiveScript *vbscript;
503 DISPID id, id2;
504 DISPPARAMS dp;
505 EXCEPINFO ei;
506 VARIANT v;
507 ULONG ref;
509
510 vbscript = create_vbscript();
511
512 hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParse, (void**)&parser);
513 ok(hres == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hres);
514
516 test_safety(vbscript);
517
518 SET_EXPECT(GetLCID);
519 hres = IActiveScript_SetScriptSite(vbscript, &ActiveScriptSite);
520 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
521 CHECK_CALLED(GetLCID);
522
523 script_disp2 = get_script_dispatch(vbscript);
524
526
527 SET_EXPECT(OnStateChange_INITIALIZED);
529 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
530 CHECK_CALLED(OnStateChange_INITIALIZED);
531
533
534 SET_EXPECT(OnStateChange_CONNECTED);
535 hres = IActiveScript_SetScriptState(vbscript, SCRIPTSTATE_CONNECTED);
536 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
537 CHECK_CALLED(OnStateChange_CONNECTED);
538
540
542 ok(script_disp == script_disp2, "script_disp != script_disp2\n");
543 IDispatchEx_Release(script_disp2);
544
545 id = 100;
547 ok(id == -1, "id = %d, expected -1\n", id);
548
549 get_disp_id(script_disp, "globalVariable", DISP_E_UNKNOWNNAME, &id);
550 parse_script(parser, "dim globalVariable\nglobalVariable = 3");
551 get_disp_id(script_disp, "globalVariable", S_OK, &id);
552
553 memset(&dp, 0, sizeof(dp));
554 memset(&ei, 0, sizeof(ei));
555 V_VT(&v) = VT_EMPTY;
556 hres = IDispatchEx_InvokeEx(script_disp, id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
557 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
558 ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
559 ok(V_I2(&v) == 3, "V_I2(v) = %d\n", V_I2(&v));
560
561 get_disp_id(script_disp, "globalVariable2", DISP_E_UNKNOWNNAME, &id);
562 parse_script(parser, "globalVariable2 = 4");
563 get_disp_id(script_disp, "globalVariable2", S_OK, &id);
564
565 get_disp_id(script_disp, "globalFunction", DISP_E_UNKNOWNNAME, &id);
566 parse_script(parser, "function globalFunction()\nglobalFunction=5\nend function");
567 get_disp_id(script_disp, "globalFunction", S_OK, &id);
568
569 SET_EXPECT(OnEnterScript);
570 SET_EXPECT(OnLeaveScript);
571
572 memset(&dp, 0, sizeof(dp));
573 memset(&ei, 0, sizeof(ei));
574 V_VT(&v) = VT_EMPTY;
575 hres = IDispatchEx_InvokeEx(script_disp, id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
576 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
577 ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
578 ok(V_I2(&v) == 5, "V_I2(v) = %d\n", V_I2(&v));
579
580 CHECK_CALLED(OnEnterScript);
581 CHECK_CALLED(OnLeaveScript);
582
583 SET_EXPECT(OnEnterScript);
584 SET_EXPECT(OnLeaveScript);
585
586 memset(&dp, 0, sizeof(dp));
587 memset(&ei, 0, sizeof(ei));
588 V_VT(&v) = VT_EMPTY;
589 hres = IDispatchEx_Invoke(script_disp, id, &IID_NULL, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
590 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
591 ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
592 ok(V_I2(&v) == 5, "V_I2(v) = %d\n", V_I2(&v));
593
594 CHECK_CALLED(OnEnterScript);
595 CHECK_CALLED(OnLeaveScript);
596
597 get_disp_id(script_disp, "globalSub", DISP_E_UNKNOWNNAME, &id);
598 parse_script(parser, "sub globalSub()\nend sub");
599 get_disp_id(script_disp, "globalSub", S_OK, &id);
600 get_disp_id(script_disp, "globalSub", S_OK, &id2);
601 ok(id == id2, "id != id2\n");
602
603 get_disp_id(script_disp, "constVariable", DISP_E_UNKNOWNNAME, &id);
604 parse_script(parser, "const constVariable = 6");
605 get_disp_id(script_disp, "ConstVariable", S_OK, &id);
606 get_disp_id(script_disp, "Constvariable", S_OK, &id2);
607 ok(id == id2, "id != id2\n");
608
609 IDispatchEx_Release(script_disp);
610
612
613 SET_EXPECT(OnStateChange_DISCONNECTED);
614 SET_EXPECT(OnStateChange_INITIALIZED);
615 SET_EXPECT(OnStateChange_CLOSED);
616 hres = IActiveScript_Close(vbscript);
617 ok(hres == S_OK, "Close failed: %08x\n", hres);
618 CHECK_CALLED(OnStateChange_DISCONNECTED);
619 CHECK_CALLED(OnStateChange_INITIALIZED);
620 CHECK_CALLED(OnStateChange_CLOSED);
621
622 ref = IActiveScript_Release(vbscript);
623 ok(!ref, "ref = %d\n", ref);
624}
@ VT_I2
Definition: compat.h:2297
@ VT_EMPTY
Definition: compat.h:2295
GLuint id
Definition: glext.h:5910
static IDispatch * script_disp
Definition: run.c:178
#define get_disp_id(a, b, c, d)
Definition: vbscript.c:458
static void test_safety(IActiveScript *script)
Definition: vbscript.c:332
static IDispatchEx * get_script_dispatch(IActiveScript *script)
Definition: vbscript.c:423
struct stdole::DISPPARAMS DISPPARAMS
struct stdole::EXCEPINFO EXCEPINFO
#define V_VT(A)
Definition: oleauto.h:211
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define V_I2(A)
Definition: oleauto.h:245
#define memset(x, y, z)
Definition: compat.h:39
Definition: import.c:81
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515

Referenced by START_TEST().

◆ test_vbscript()

static void test_vbscript ( void  )
static

Definition at line 626 of file vbscript.c.

627{
628 IActiveScriptParseProcedure2 *parse_proc;
629 IActiveScriptParse *parser;
630 IActiveScript *vbscript;
631 ULONG ref;
633
634 vbscript = create_vbscript();
635
636 hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParse, (void**)&parser);
637 ok(hres == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hres);
638
640 test_safety(vbscript);
641 test_no_script_dispatch(vbscript);
642
643 SET_EXPECT(GetLCID);
644 hres = IActiveScript_SetScriptSite(vbscript, &ActiveScriptSite);
645 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
646 CHECK_CALLED(GetLCID);
647
649
650 SET_EXPECT(OnStateChange_INITIALIZED);
652 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
653 CHECK_CALLED(OnStateChange_INITIALIZED);
654
656
658 ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
659
660 SET_EXPECT(OnStateChange_CONNECTED);
661 hres = IActiveScript_SetScriptState(vbscript, SCRIPTSTATE_CONNECTED);
662 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
663 CHECK_CALLED(OnStateChange_CONNECTED);
664
666
667 SET_EXPECT(OnStateChange_DISCONNECTED);
668 SET_EXPECT(OnStateChange_INITIALIZED);
669 SET_EXPECT(OnStateChange_CLOSED);
670 hres = IActiveScript_Close(vbscript);
671 ok(hres == S_OK, "Close failed: %08x\n", hres);
672 CHECK_CALLED(OnStateChange_DISCONNECTED);
673 CHECK_CALLED(OnStateChange_INITIALIZED);
674 CHECK_CALLED(OnStateChange_CLOSED);
675
677 test_no_script_dispatch(vbscript);
678
680
681 hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParseProcedure, (void**)&parse_proc);
682 ok(hres == E_NOINTERFACE, "Got IActiveScriptParseProcedure interface, expected E_NOTIMPL\n");
683
684 hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParseProcedure2, (void**)&parse_proc);
685 ok(hres == S_OK, "Could not get IActiveScriptParseProcedure2 interface\n");
687
688 ref = IActiveScript_Release(vbscript);
689 ok(!ref, "ref = %d\n", ref);
690}
static void test_no_script_dispatch(IActiveScript *script)
Definition: vbscript.c:475

Referenced by START_TEST().

◆ test_vbscript_initializing()

static void test_vbscript_initializing ( void  )
static

Definition at line 872 of file vbscript.c.

873{
874 IActiveScriptParse *parse;
876 ULONG ref;
878
880
881 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
882 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
883
885
886 SET_EXPECT(GetLCID);
887 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
888 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
889 CHECK_CALLED(GetLCID);
890
891 SET_EXPECT(OnStateChange_INITIALIZED);
893 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
894 CHECK_CALLED(OnStateChange_INITIALIZED);
895
896 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
897 ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
898
899 SET_EXPECT(OnStateChange_CLOSED);
900 hres = IActiveScript_Close(script);
901 ok(hres == S_OK, "Close failed: %08x\n", hres);
902 CHECK_CALLED(OnStateChange_CLOSED);
903
905
907
908 ref = IActiveScript_Release(script);
909 ok(!ref, "ref = %d\n", ref);
910}

Referenced by START_TEST().

◆ test_vbscript_release()

static void test_vbscript_release ( void  )
static

Definition at line 809 of file vbscript.c.

810{
811 IActiveScriptParse *parser;
812 IActiveScript *vbscript;
813 ULONG ref;
815
816 vbscript = create_vbscript();
817
818 hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParse, (void**)&parser);
819 ok(hres == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hres);
820
822 test_safety(vbscript);
823
824 SET_EXPECT(GetLCID);
825 hres = IActiveScript_SetScriptSite(vbscript, &ActiveScriptSite);
826 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
827 CHECK_CALLED(GetLCID);
828
830
831 SET_EXPECT(OnStateChange_INITIALIZED);
833 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
834 CHECK_CALLED(OnStateChange_INITIALIZED);
835
837
838 SET_EXPECT(OnStateChange_CONNECTED);
839 hres = IActiveScript_SetScriptState(vbscript, SCRIPTSTATE_CONNECTED);
840 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
841 CHECK_CALLED(OnStateChange_CONNECTED);
842
844
846
847 SET_EXPECT(OnStateChange_DISCONNECTED);
848 SET_EXPECT(OnStateChange_INITIALIZED);
849 SET_EXPECT(OnStateChange_CLOSED);
850 ref = IActiveScript_Release(vbscript);
851 ok(!ref, "ref = %d\n", ref);
852 CHECK_CALLED(OnStateChange_DISCONNECTED);
853 CHECK_CALLED(OnStateChange_INITIALIZED);
854 CHECK_CALLED(OnStateChange_CLOSED);
855}

Referenced by START_TEST().

◆ test_vbscript_simplecreate()

static void test_vbscript_simplecreate ( void  )
static

Definition at line 857 of file vbscript.c.

858{
860 ULONG ref;
862
864
865 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
866 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
867
868 ref = IActiveScript_Release(script);
869 ok(!ref, "ref = %d\n", ref);
870}

Referenced by START_TEST().

◆ test_vbscript_uninitializing()

static void test_vbscript_uninitializing ( void  )
static

Definition at line 692 of file vbscript.c.

693{
694 IActiveScriptParse *parse;
696 IDispatchEx *dispex;
697 ULONG ref;
699
700 static const WCHAR script_textW[] =
701 {'F','u','n','c','t','i','o','n',' ','f','\n','E','n','d',' ','F','u','n','c','t','i','o','n','\n',0};
702
704
705 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
706 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
707
709
711 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
712
714
715 SET_EXPECT(GetLCID);
716 SET_EXPECT(OnStateChange_INITIALIZED);
717 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
718 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
719 CHECK_CALLED(GetLCID);
720 CHECK_CALLED(OnStateChange_INITIALIZED);
721
723
724 hres = IActiveScriptParse_ParseScriptText(parse, script_textW, NULL, NULL, NULL, 0, 1, 0x42, NULL, NULL);
725 ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
726
727 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
728 ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
729
730 SET_EXPECT(OnStateChange_UNINITIALIZED);
731 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
732 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
733 CHECK_CALLED(OnStateChange_UNINITIALIZED);
734
736
737 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
738 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
739
740 SET_EXPECT(GetLCID);
741 SET_EXPECT(OnStateChange_INITIALIZED);
742 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
743 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
744 CHECK_CALLED(GetLCID);
745 CHECK_CALLED(OnStateChange_INITIALIZED);
746
747 SET_EXPECT(OnStateChange_CONNECTED);
748 SET_EXPECT(OnEnterScript);
749 SET_EXPECT(OnLeaveScript);
750 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
751 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
752 CHECK_CALLED(OnStateChange_CONNECTED);
753 CHECK_CALLED(OnEnterScript);
754 CHECK_CALLED(OnLeaveScript);
755
757
758 dispex = get_script_dispatch(script);
759 ok(dispex != NULL, "dispex == NULL\n");
760 if(dispex)
761 IDispatchEx_Release(dispex);
762
763 SET_EXPECT(OnStateChange_DISCONNECTED);
764 SET_EXPECT(OnStateChange_INITIALIZED);
765 SET_EXPECT(OnStateChange_UNINITIALIZED);
766 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
767 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
768 CHECK_CALLED(OnStateChange_DISCONNECTED);
769 CHECK_CALLED(OnStateChange_INITIALIZED);
770 CHECK_CALLED(OnStateChange_UNINITIALIZED);
771
773
774 hres = IActiveScript_Close(script);
775 ok(hres == S_OK, "Close failed: %08x\n", hres);
776
778
779 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
780 ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x, expected E_UNEXPECTED\n", hres);
781
783
784 SET_EXPECT(GetLCID);
785 SET_EXPECT(OnStateChange_INITIALIZED);
786 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
787 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
788 CHECK_CALLED(GetLCID);
789 CHECK_CALLED(OnStateChange_INITIALIZED);
790
792
793 SET_EXPECT(OnStateChange_CLOSED);
794 hres = IActiveScript_Close(script);
795 ok(hres == S_OK, "Close failed: %08x\n", hres);
796 CHECK_CALLED(OnStateChange_CLOSED);
797
799
801 ok(hres == E_UNEXPECTED, "InitNew failed: %08x\n", hres);
802
804
805 ref = IActiveScript_Release(script);
806 ok(!ref, "ref = %d\n", ref);
807}
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ visible_AddRef()

static ULONG WINAPI visible_AddRef ( IDispatch iface)
static

Definition at line 141 of file vbscript.c.

142{
143 return ++visible_named_item_ref;
144}

◆ visible_Release()

static ULONG WINAPI visible_Release ( IDispatch iface)
static

Definition at line 146 of file vbscript.c.

147{
148 return --visible_named_item_ref;
149}

Variable Documentation

◆ ActiveScriptSite

◆ ActiveScriptSiteVtbl

const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
static
Initial value:
= {
}
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
Definition: vbscript.c:226
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
Definition: vbscript.c:310
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
Definition: vbscript.c:270
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
Definition: vbscript.c:257
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
Definition: vbscript.c:206
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
Definition: vbscript.c:304
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
Definition: vbscript.c:221
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
Definition: vbscript.c:263
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
Definition: vbscript.c:231
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
Definition: vbscript.c:298
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR name, DWORD return_mask, IUnknown **item_unk, ITypeInfo **item_ti)
Definition: vbscript.c:237

Definition at line 316 of file vbscript.c.

◆ global_named_item

IDispatch global_named_item = { &global_named_item_vtbl }
static

Definition at line 192 of file vbscript.c.

Referenced by ActiveScriptSite_GetItemInfo().

◆ global_named_item_ref

ULONG global_named_item_ref
static

Definition at line 129 of file vbscript.c.

Referenced by global_AddRef(), global_Release(), and test_named_items().

◆ global_named_item_vtbl

const IDispatchVtbl global_named_item_vtbl
static
Initial value:
= {
}
static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
Definition: vbscript.c:151
static ULONG WINAPI global_Release(IDispatch *iface)
Definition: vbscript.c:136
static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, LCID lcid, DISPID *ids)
Definition: vbscript.c:162
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: vbscript.c:157
static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
Definition: vbscript.c:171
static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: vbscript.c:117
static ULONG WINAPI global_AddRef(IDispatch *iface)
Definition: vbscript.c:131

Definition at line 182 of file vbscript.c.

◆ visible_named_item

IDispatch visible_named_item = { &visible_named_item_vtbl }
static

Definition at line 204 of file vbscript.c.

Referenced by ActiveScriptSite_GetItemInfo().

◆ visible_named_item_ref

ULONG visible_named_item_ref
static

Definition at line 129 of file vbscript.c.

Referenced by test_named_items(), visible_AddRef(), and visible_Release().

◆ visible_named_item_vtbl

const IDispatchVtbl visible_named_item_vtbl
static
Initial value:
= {
}
static ULONG WINAPI visible_Release(IDispatch *iface)
Definition: vbscript.c:146
static ULONG WINAPI visible_AddRef(IDispatch *iface)
Definition: vbscript.c:141

Definition at line 194 of file vbscript.c.