ReactOS  0.4.15-dev-1070-ge1a01de
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 IDispatchEx * get_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)
GLenum func
Definition: glext.h:6028
#define FALSE
Definition: types.h:117

Definition at line 72 of file vbscript.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)
GLenum func
Definition: glext.h:6028
#define FALSE
Definition: types.h:117

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)
GLenum func
Definition: glext.h:6028
#define TRUE
Definition: types.h:120
#define expect_(expected, got, precision)
Definition: font.c:29

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;
463  HRESULT hres;
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 }
static BSTR a2bstr(const char *str)
Definition: vbscript.c:94
OLECHAR * BSTR
Definition: compat.h:2041
const WCHAR * str
Definition: parser.c:48
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define IID_NULL
Definition: guiddef.h:98
static VARIANTARG static DISPID
Definition: ordinal.c:49
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
Definition: name.c:38
#define ok_(x1, x2)
Definition: atltest.h:61
GLuint const GLchar * name
Definition: glext.h:6031

◆ _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;
110  HRESULT hres;
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 }
script
Definition: msipriv.h:374
Definition: parser.c:48
enum tagSCRIPTSTATE SCRIPTSTATE
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static int state
Definition: maze.c:121
#define S_OK
Definition: intsafe.h:51
#define ok_(x1, x2)
Definition: atltest.h:61

◆ 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);
101  MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
102 
103  return ret;
104 }
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define CP_ACP
Definition: compat.h:109
OLECHAR * BSTR
Definition: compat.h:2041
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:110

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 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
static IDispatch visible_named_item
Definition: vbscript.c:204
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
static const WCHAR L[]
Definition: oid.c:1250
static IDispatch global_named_item
Definition: vbscript.c:192
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: name.c:38

◆ 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 }
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
#define S_OK
Definition: intsafe.h:51

◆ 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 }
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
#define S_OK
Definition: intsafe.h:51

◆ 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 }
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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;
276  case SCRIPTSTATE_STARTED:
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;
285  case SCRIPTSTATE_CLOSED:
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 }
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ 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
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define IActiveScriptParseProcedure2_Release
Definition: vbscript.c:47
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:51
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by START_TEST().

◆ create_vbscript()

static IActiveScript* create_vbscript ( void  )
static

Definition at line 486 of file vbscript.c.

487 {
489  HRESULT hres;
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 }
const CLSID CLSID_VBScript
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
int ret
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57

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 ( GetLCID  )

◆ DEFINE_EXPECT() [2/12]

DEFINE_EXPECT ( OnStateChange_UNINITIALIZED  )

◆ DEFINE_EXPECT() [3/12]

DEFINE_EXPECT ( OnStateChange_STARTED  )

◆ DEFINE_EXPECT() [4/12]

DEFINE_EXPECT ( OnStateChange_CONNECTED  )

◆ DEFINE_EXPECT() [5/12]

DEFINE_EXPECT ( OnStateChange_DISCONNECTED  )

◆ DEFINE_EXPECT() [6/12]

DEFINE_EXPECT ( OnStateChange_CLOSED  )

◆ DEFINE_EXPECT() [7/12]

DEFINE_EXPECT ( OnStateChange_INITIALIZED  )

◆ DEFINE_EXPECT() [8/12]

DEFINE_EXPECT ( OnEnterScript  )

◆ DEFINE_EXPECT() [9/12]

DEFINE_EXPECT ( OnLeaveScript  )

◆ DEFINE_EXPECT() [10/12]

DEFINE_EXPECT ( GetItemInfo_global  )

◆ DEFINE_EXPECT() [11/12]

DEFINE_EXPECT ( GetItemInfo_visible  )

◆ DEFINE_EXPECT() [12/12]

DEFINE_EXPECT ( testCall  )

◆ DEFINE_GUID() [1/3]

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

◆ DEFINE_GUID() [2/3]

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

◆ DEFINE_GUID() [3/3]

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

◆ 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 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
GLuint GLuint * names
Definition: glext.h:11545
GLuint * ids
Definition: glext.h:5907
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57

◆ 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 }
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define CHECK_EXPECT(func)
Definition: vbscript.c:66
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
GLuint res
Definition: glext.h:9613

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
const GUID IID_IDispatch
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ 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;
427  HRESULT hres;
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 }
disp
Definition: i386-dis.c:3181
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57

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 }
static ULONG global_named_item_ref
Definition: vbscript.c:129

◆ parse_script()

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

Definition at line 441 of file vbscript.c.

442 {
443  BSTR str;
444  HRESULT hres;
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 }
static BSTR a2bstr(const char *str)
Definition: vbscript.c:94
OLECHAR * BSTR
Definition: compat.h:2041
#define IActiveScriptParse_ParseScriptText
Definition: vbscript.c:46
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
GLenum src
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:51
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define SET_EXPECT(func)
Definition: vbscript.c:57

Referenced by test_named_items(), and test_scriptdisp().

◆ START_TEST()

START_TEST ( vbscript  )

Definition at line 1147 of file vbscript.c.

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

◆ 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;
917  HRESULT hres;
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 void parse_script(IActiveScriptParse *parse, const char *src)
Definition: vbscript.c:441
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:51
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
static ULONG visible_named_item_ref
Definition: vbscript.c:129
static ULONG global_named_item_ref
Definition: vbscript.c:129
#define E_UNEXPECTED
Definition: winerror.h:2456
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
#define IActiveScriptParse_Release
Definition: vbscript.c:44
unsigned int ULONG
Definition: retypes.h:1
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define test_state(s, ss)
Definition: vbscript.c:106

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;
478  HRESULT hres;
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 }
disp
Definition: i386-dis.c:3181
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define ok(value,...)
Definition: atltest.h:57
#define E_UNEXPECTED
Definition: winerror.h:2456

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 }
disp
Definition: i386-dis.c:3181
#define E_NOINTERFACE
Definition: winerror.h:2364
Definition: match.c:28
GLuint GLuint GLsizei count
Definition: gl.h:1545
OLECHAR * BSTR
Definition: compat.h:2041
long LONG
Definition: pedump.c:60
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
const CLSID CLSID_VBScriptRegExp
struct match match
Definition: match.c:33
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:51
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
const GLdouble * v
Definition: gl.h:2040
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
#define E_POINTER
Definition: winerror.h:2365
#define win_skip
Definition: test.h:149

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;
336  HRESULT hres;
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
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IID_NULL
Definition: guiddef.h:98
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
#define E_POINTER
Definition: winerror.h:2365

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;
508  HRESULT hres;
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 
541  script_disp = get_script_dispatch(vbscript);
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 }
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static void parse_script(IActiveScriptParse *parse, const char *src)
Definition: vbscript.c:441
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
#define V_I2(A)
Definition: oleauto.h:245
static void test_safety(IActiveScript *script)
Definition: vbscript.c:332
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
Definition: send.c:48
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
static IDispatchEx * get_script_dispatch(IActiveScript *script)
Definition: vbscript.c:423
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define IID_NULL
Definition: guiddef.h:98
#define V_VT(A)
Definition: oleauto.h:211
static IDispatch * script_disp
Definition: run.c:178
struct stdole::EXCEPINFO EXCEPINFO
#define S_OK
Definition: intsafe.h:51
static VARIANTARG static DISPID
Definition: ordinal.c:49
const GLdouble * v
Definition: gl.h:2040
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
#define IActiveScriptParse_Release
Definition: vbscript.c:44
Definition: import.c:85
struct stdole::DISPPARAMS DISPPARAMS
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define test_state(s, ss)
Definition: vbscript.c:106
#define memset(x, y, z)
Definition: compat.h:39
Definition: compat.h:2045
#define get_disp_id(a, b, c, d)
Definition: vbscript.c:458

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;
632  HRESULT hres;
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 
676  test_state(vbscript, SCRIPTSTATE_CLOSED);
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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
static void test_safety(IActiveScript *script)
Definition: vbscript.c:332
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static void test_no_script_dispatch(IActiveScript *script)
Definition: vbscript.c:475
#define IActiveScriptParseProcedure2_Release
Definition: vbscript.c:47
#define S_OK
Definition: intsafe.h:51
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
#define E_UNEXPECTED
Definition: winerror.h:2456
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
#define IActiveScriptParse_Release
Definition: vbscript.c:44
Definition: import.c:85
unsigned int ULONG
Definition: retypes.h:1
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define test_state(s, ss)
Definition: vbscript.c:106

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;
877  HRESULT hres;
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 }
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
#define E_UNEXPECTED
Definition: winerror.h:2456
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
#define IActiveScriptParse_Release
Definition: vbscript.c:44
unsigned int ULONG
Definition: retypes.h:1
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define test_state(s, ss)
Definition: vbscript.c:106

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;
814  HRESULT hres;
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 }
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
static void test_safety(IActiveScript *script)
Definition: vbscript.c:332
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
#define IActiveScriptParse_Release
Definition: vbscript.c:44
Definition: import.c:85
unsigned int ULONG
Definition: retypes.h:1
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define test_state(s, ss)
Definition: vbscript.c:106

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;
861  HRESULT hres;
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 }
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
Definition: send.c:48
GLenum GLint ref
Definition: glext.h:6028
script
Definition: msipriv.h:374
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1

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;
698  HRESULT hres;
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 }
static IActiveScript * create_vbscript(void)
Definition: vbscript.c:486
#define IActiveScriptParse_InitNew
Definition: vbscript.c:45
Definition: send.c:48
#define IActiveScriptParse_ParseScriptText
Definition: vbscript.c:46
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
static IDispatchEx * get_script_dispatch(IActiveScript *script)
Definition: vbscript.c:423
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static void test_no_script_dispatch(IActiveScript *script)
Definition: vbscript.c:475
#define S_OK
Definition: intsafe.h:51
#define CHECK_CALLED(func)
Definition: vbscript.c:72
#define ok(value,...)
Definition: atltest.h:57
#define E_UNEXPECTED
Definition: winerror.h:2456
static IActiveScriptSite ActiveScriptSite
Definition: vbscript.c:330
#define IActiveScriptParse_Release
Definition: vbscript.c:44
unsigned int ULONG
Definition: retypes.h:1
#define SET_EXPECT(func)
Definition: vbscript.c:57
#define test_state(s, ss)
Definition: vbscript.c:106

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 }
static ULONG visible_named_item_ref
Definition: vbscript.c:129

◆ 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 }
static ULONG visible_named_item_ref
Definition: vbscript.c:129

Variable Documentation

◆ ActiveScriptSite

◆ ActiveScriptSiteVtbl

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

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 HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: vbscript.c:157
static ULONG WINAPI global_Release(IDispatch *iface)
Definition: vbscript.c:136
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 ULONG WINAPI global_AddRef(IDispatch *iface)
Definition: vbscript.c:131
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_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: vbscript.c:117

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 HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
Definition: vbscript.c:151
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: vbscript.c:157
static ULONG WINAPI visible_AddRef(IDispatch *iface)
Definition: vbscript.c:141
static ULONG WINAPI visible_Release(IDispatch *iface)
Definition: vbscript.c:146
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_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, LCID lcid, DISPID *ids)
Definition: vbscript.c:162
static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: vbscript.c:117

Definition at line 194 of file vbscript.c.