ReactOS 0.4.16-dev-297-gc569aee
jscript.c File Reference
#include <initguid.h>
#include <ole2.h>
#include <activscp.h>
#include <objsafe.h>
#include <dispex.h>
#include "wine/test.h"
Include dependency graph for jscript.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 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)
 

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)
 
static BSTR a2bstr (const char *str)
 
static void _test_state (unsigned line, IActiveScript *script, SCRIPTSTATE exstate)
 
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 pstrName, DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
 
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_script_dispatch (IDispatchEx *dispex)
 
static IDispatchExget_script_dispatch (IActiveScript *script)
 
static void test_no_script_dispatch (IActiveScript *script)
 
static void test_safety (IUnknown *unk)
 
static HRESULT set_script_prop (IActiveScript *engine, DWORD property, VARIANT *val)
 
static void test_invoke_versioning (IActiveScript *script)
 
static IActiveScriptcreate_jscript (void)
 
static void test_jscript (void)
 
static void test_jscript2 (void)
 
static void test_jscript_uninitializing (void)
 
static void test_aggregation (void)
 
static BOOL check_jscript (void)
 
 START_TEST (jscript)
 

Variables

static const CLSID CLSID_JScript
 
static const CLSID CLSID_JScriptEncode
 
static const CLSIDengine_clsid = &CLSID_JScript
 
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 71 of file jscript.c.

◆ CHECK_EXPECT

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

Definition at line 65 of file jscript.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 59 of file jscript.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file jscript.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 20 of file jscript.c.

◆ DEFINE_EXPECT

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

Definition at line 53 of file jscript.c.

◆ IActiveScriptParse_InitNew

#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew

Definition at line 41 of file jscript.c.

◆ IActiveScriptParse_ParseScriptText

#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText

Definition at line 42 of file jscript.c.

◆ IActiveScriptParse_QueryInterface

#define IActiveScriptParse_QueryInterface   IActiveScriptParse32_QueryInterface

Definition at line 39 of file jscript.c.

◆ IActiveScriptParse_Release

#define IActiveScriptParse_Release   IActiveScriptParse32_Release

Definition at line 40 of file jscript.c.

◆ SET_EXPECT

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

Definition at line 56 of file jscript.c.

◆ test_state

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

Definition at line 101 of file jscript.c.

Function Documentation

◆ _test_state()

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

Definition at line 102 of file jscript.c.

103{
104 SCRIPTSTATE state = -1;
106
107 hres = IActiveScript_GetScriptState(script, &state);
108 ok_(__FILE__,line) (hres == S_OK, "GetScriptState failed: %08x\n", hres);
109 ok_(__FILE__,line) (state == exstate, "state=%d, expected %d\n", state, exstate);
110}
enum tagSCRIPTSTATE SCRIPTSTATE
static int state
Definition: maze.c:121
#define ok_(x1, x2)
Definition: atltest.h:61
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:465
script
Definition: msipriv.h:383
Definition: parser.c:49

◆ a2bstr()

static BSTR a2bstr ( const char str)
static

Definition at line 89 of file jscript.c.

90{
91 BSTR ret;
92 int len;
93
94 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
97
98 return ret;
99}
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
OLECHAR * BSTR
Definition: compat.h:2293
#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
const WCHAR * str
int ret

Referenced by test_script_dispatch().

◆ ActiveScriptSite_AddRef()

static ULONG WINAPI ActiveScriptSite_AddRef ( IActiveScriptSite iface)
static

Definition at line 127 of file jscript.c.

128{
129 return 2;
130}

◆ ActiveScriptSite_GetDocVersionString()

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

Definition at line 150 of file jscript.c.

151{
152 ok(0, "unexpected call\n");
153 return E_NOTIMPL;
154}
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ActiveScriptSite_GetItemInfo()

static HRESULT WINAPI ActiveScriptSite_GetItemInfo ( IActiveScriptSite iface,
LPCOLESTR  pstrName,
DWORD  dwReturnMask,
IUnknown **  ppiunkItem,
ITypeInfo **  ppti 
)
static

Definition at line 143 of file jscript.c.

145{
146 ok(0, "unexpected call\n");
147 return E_NOTIMPL;
148}

◆ ActiveScriptSite_GetLCID()

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

Definition at line 137 of file jscript.c.

138{
139 CHECK_EXPECT(GetLCID);
140 return E_NOTIMPL;
141}
#define CHECK_EXPECT(func)
Definition: jscript.c:65

◆ ActiveScriptSite_OnEnterScript()

static HRESULT WINAPI ActiveScriptSite_OnEnterScript ( IActiveScriptSite iface)
static

Definition at line 197 of file jscript.c.

198{
199 CHECK_EXPECT(OnEnterScript);
200 return S_OK;
201}

◆ ActiveScriptSite_OnLeaveScript()

static HRESULT WINAPI ActiveScriptSite_OnLeaveScript ( IActiveScriptSite iface)
static

Definition at line 203 of file jscript.c.

204{
205 CHECK_EXPECT(OnLeaveScript);
206 return S_OK;
207}

◆ ActiveScriptSite_OnScriptError()

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

Definition at line 191 of file jscript.c.

192{
193 ok(0, "unexpected call\n");
194 return E_NOTIMPL;
195}

◆ ActiveScriptSite_OnScriptTerminate()

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

Definition at line 156 of file jscript.c.

158{
159 ok(0, "unexpected call\n");
160 return E_NOTIMPL;
161}

◆ ActiveScriptSite_OnStateChange()

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

Definition at line 163 of file jscript.c.

164{
165 switch(ssScriptState) {
167 CHECK_EXPECT(OnStateChange_UNINITIALIZED);
168 return S_OK;
170 CHECK_EXPECT(OnStateChange_STARTED);
171 return S_OK;
173 CHECK_EXPECT(OnStateChange_CONNECTED);
174 return S_OK;
176 CHECK_EXPECT(OnStateChange_DISCONNECTED);
177 return S_OK;
179 CHECK_EXPECT(OnStateChange_CLOSED);
180 return S_OK;
182 CHECK_EXPECT(OnStateChange_INITIALIZED);
183 return S_OK;
184 default:
185 ok(0, "unexpected call %d\n", ssScriptState);
186 }
187
188 return E_NOTIMPL;
189}
@ 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 112 of file jscript.c.

113{
114 *ppv = NULL;
115
117 *ppv = iface;
118 else if(IsEqualGUID(&IID_IActiveScriptSite, riid))
119 *ppv = iface;
120 else
121 return E_NOINTERFACE;
122
123 IUnknown_AddRef((IUnknown*)*ppv);
124 return S_OK;
125}
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 132 of file jscript.c.

133{
134 return 1;
135}

◆ check_jscript()

static BOOL check_jscript ( void  )
static

Definition at line 667 of file jscript.c.

668{
669 IActiveScriptProperty *script_prop;
671
672 hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
673 &IID_IActiveScriptProperty, (void**)&script_prop);
674 if(SUCCEEDED(hres))
675 IActiveScriptProperty_Release(script_prop);
676
677 return hres == S_OK;
678}
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
static const CLSID CLSID_JScript
Definition: jscript.c:48

Referenced by START_TEST().

◆ create_jscript()

static IActiveScript * create_jscript ( void  )
static

Definition at line 427 of file jscript.c.

428{
431
432 hres = CoCreateInstance(engine_clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
433 &IID_IActiveScript, (void**)&ret);
434 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
435
436 return ret;
437}
static const CLSID * engine_clsid
Definition: jscript.c:87

Referenced by test_jscript(), test_jscript2(), and test_jscript_uninitializing().

◆ DEFINE_EXPECT() [1/9]

DEFINE_EXPECT ( GetLCID  )

◆ DEFINE_EXPECT() [2/9]

DEFINE_EXPECT ( OnEnterScript  )

◆ DEFINE_EXPECT() [3/9]

DEFINE_EXPECT ( OnLeaveScript  )

◆ DEFINE_EXPECT() [4/9]

DEFINE_EXPECT ( OnStateChange_CLOSED  )

◆ DEFINE_EXPECT() [5/9]

DEFINE_EXPECT ( OnStateChange_CONNECTED  )

◆ DEFINE_EXPECT() [6/9]

DEFINE_EXPECT ( OnStateChange_DISCONNECTED  )

◆ DEFINE_EXPECT() [7/9]

DEFINE_EXPECT ( OnStateChange_INITIALIZED  )

◆ DEFINE_EXPECT() [8/9]

DEFINE_EXPECT ( OnStateChange_STARTED  )

◆ DEFINE_EXPECT() [9/9]

DEFINE_EXPECT ( OnStateChange_UNINITIALIZED  )

◆ DEFINE_GUID()

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

◆ get_script_dispatch()

static IDispatchEx * get_script_dispatch ( IActiveScript script)
static

Definition at line 264 of file jscript.c.

265{
266 IDispatchEx *dispex;
267 IDispatch *disp;
269
270 disp = (void*)0xdeadbeef;
271 hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
272 ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres);
273
274 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
275 IDispatch_Release(disp);
276 ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres);
277 return dispex;
278}

Referenced by test_jscript(), and test_jscript_uninitializing().

◆ set_script_prop()

static HRESULT set_script_prop ( IActiveScript engine,
DWORD  property,
VARIANT val 
)
static

Definition at line 382 of file jscript.c.

383{
384 IActiveScriptProperty *script_prop;
386
387 hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptProperty,
388 (void**)&script_prop);
389 ok(hres == S_OK, "Could not get IActiveScriptProperty: %08x\n", hres);
390 if(FAILED(hres))
391 return hres;
392
393 hres = IActiveScriptProperty_SetProperty(script_prop, property, NULL, val);
394 IActiveScriptProperty_Release(script_prop);
395 return hres;
396}
GLuint GLfloat * val
Definition: glext.h:7180
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by test_invoke_versioning().

◆ START_TEST()

START_TEST ( jscript  )

Definition at line 680 of file jscript.c.

681{
683
684 if(check_jscript()) {
685 trace("Testing JScript object...\n");
686 test_jscript();
690
691 trace("Testing JScriptEncode object...\n");
693 test_jscript();
694 }else {
695 win_skip("Broken engine, probably too old\n");
696 }
697
699}
#define trace
Definition: atltest.h:70
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static BOOL check_jscript(void)
Definition: jscript.c:667
static void test_jscript_uninitializing(void)
Definition: jscript.c:560
static void test_aggregation(void)
Definition: jscript.c:655
static void test_jscript(void)
Definition: jscript.c:439
static const CLSID CLSID_JScriptEncode
Definition: jscript.c:50
static void test_jscript2(void)
Definition: jscript.c:506
#define win_skip
Definition: test.h:163

◆ test_aggregation()

static void test_aggregation ( void  )
static

Definition at line 655 of file jscript.c.

656{
657 IUnknown *unk = (IUnknown*)0xdeadbeef;
659
660 hres = CoCreateInstance(&CLSID_JScript, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
661 &IID_IUnknown, (void**)&unk);
663 "CoCreateInstance failed: %08x, expected CLASS_E_NOAGGREGATION\n", hres);
664 ok(!unk || broken(unk != NULL), "unk = %p\n", unk);
665}
#define broken(x)
Definition: atltest.h:178
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662

Referenced by START_TEST().

◆ test_invoke_versioning()

static void test_invoke_versioning ( IActiveScript script)
static

Definition at line 398 of file jscript.c.

399{
400 VARIANT v;
402
403 V_VT(&v) = VT_NULL;
404 hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
405 if(hres == E_NOTIMPL) {
406 win_skip("SCRIPTPROP_INVOKESTRING not supported\n");
407 return;
408 }
409 ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
410
411 V_VT(&v) = VT_I2;
412 V_I2(&v) = 0;
413 hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
414 ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
415
416 V_VT(&v) = VT_I4;
417 V_I4(&v) = 16;
418 hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
419 ok(hres == E_INVALIDARG, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
420
421 V_VT(&v) = VT_I4;
422 V_I4(&v) = 2;
423 hres = set_script_prop(script, SCRIPTPROP_INVOKEVERSIONING, &v);
424 ok(hres == S_OK, "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres);
425}
#define E_INVALIDARG
Definition: ddrawi.h:101
@ VT_NULL
Definition: compat.h:2296
@ VT_I4
Definition: compat.h:2298
@ VT_I2
Definition: compat.h:2297
const GLdouble * v
Definition: gl.h:2040
static HRESULT set_script_prop(IActiveScript *engine, DWORD property, VARIANT *val)
Definition: jscript.c:382
#define V_VT(A)
Definition: oleauto.h:211
#define V_I4(A)
Definition: oleauto.h:247
#define V_I2(A)
Definition: oleauto.h:245

Referenced by test_jscript().

◆ test_jscript()

static void test_jscript ( void  )
static

Definition at line 439 of file jscript.c.

440{
441 IActiveScriptParse *parse;
443 IDispatchEx *dispex;
444 ULONG ref;
446
448
449 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
450 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
451
455
457 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
458
460 ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
461
462 hres = IActiveScript_SetScriptSite(script, NULL);
463 ok(hres == E_POINTER, "SetScriptSite failed: %08x, expected E_POINTER\n", hres);
464
467
468 SET_EXPECT(GetLCID);
469 SET_EXPECT(OnStateChange_INITIALIZED);
470 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
471 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
472 CHECK_CALLED(GetLCID);
473 CHECK_CALLED(OnStateChange_INITIALIZED);
474
476
477 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
478 ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
479
480 dispex = get_script_dispatch(script);
481 test_script_dispatch(dispex);
482
483 SET_EXPECT(OnStateChange_STARTED);
484 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
485 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
486 CHECK_CALLED(OnStateChange_STARTED);
487
489
490 SET_EXPECT(OnStateChange_CLOSED);
491 hres = IActiveScript_Close(script);
492 ok(hres == S_OK, "Close failed: %08x\n", hres);
493 CHECK_CALLED(OnStateChange_CLOSED);
494
497 test_script_dispatch(dispex);
498 IDispatchEx_Release(dispex);
499
501
502 ref = IActiveScript_Release(script);
503 ok(!ref, "ref = %d\n", ref);
504}
#define SET_EXPECT(func)
Definition: jscript.c:56
static IActiveScript * create_jscript(void)
Definition: jscript.c:427
static void test_invoke_versioning(IActiveScript *script)
Definition: jscript.c:398
static void test_script_dispatch(IDispatchEx *dispex)
Definition: jscript.c:225
#define IActiveScriptParse_InitNew
Definition: jscript.c:41
#define IActiveScriptParse_Release
Definition: jscript.c:40
#define test_state(s, ss)
Definition: jscript.c:101
#define CHECK_CALLED(func)
Definition: jscript.c:71
static void test_safety(IUnknown *unk)
Definition: jscript.c:291
static void test_no_script_dispatch(IActiveScript *script)
Definition: jscript.c:280
static IDispatchEx * get_script_dispatch(IActiveScript *script)
Definition: jscript.c:264
static IActiveScriptSite ActiveScriptSite
Definition: jscript.c:223
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
#define E_UNEXPECTED
Definition: winerror.h:2456
#define E_POINTER
Definition: winerror.h:2365

Referenced by START_TEST().

◆ test_jscript2()

static void test_jscript2 ( void  )
static

Definition at line 506 of file jscript.c.

507{
508 IActiveScriptParse *parse;
510 ULONG ref;
512
514
515 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
516 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
517
519
520 SET_EXPECT(GetLCID);
521 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
522 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
523 CHECK_CALLED(GetLCID);
524
526
527 SET_EXPECT(OnStateChange_INITIALIZED);
529 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
530 CHECK_CALLED(OnStateChange_INITIALIZED);
531
533 ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
534
535 SET_EXPECT(OnStateChange_CONNECTED);
536 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
537 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
538 CHECK_CALLED(OnStateChange_CONNECTED);
539
541
542 SET_EXPECT(OnStateChange_DISCONNECTED);
543 SET_EXPECT(OnStateChange_INITIALIZED);
544 SET_EXPECT(OnStateChange_CLOSED);
545 hres = IActiveScript_Close(script);
546 ok(hres == S_OK, "Close failed: %08x\n", hres);
547 CHECK_CALLED(OnStateChange_DISCONNECTED);
548 CHECK_CALLED(OnStateChange_INITIALIZED);
549 CHECK_CALLED(OnStateChange_CLOSED);
550
553
555
556 ref = IActiveScript_Release(script);
557 ok(!ref, "ref = %d\n", ref);
558}

Referenced by START_TEST().

◆ test_jscript_uninitializing()

static void test_jscript_uninitializing ( void  )
static

Definition at line 560 of file jscript.c.

561{
562 IActiveScriptParse *parse;
564 IDispatchEx *dispex;
565 ULONG ref;
567
568 static const WCHAR script_textW[] =
569 {'f','u','n','c','t','i','o','n',' ','f','(',')',' ','{','}',0};
570
572
573 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parse);
574 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
575
577
579 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
580
581 SET_EXPECT(GetLCID);
582 SET_EXPECT(OnStateChange_INITIALIZED);
583 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
584 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
585 CHECK_CALLED(GetLCID);
586 CHECK_CALLED(OnStateChange_INITIALIZED);
587
589
590 hres = IActiveScriptParse_ParseScriptText(parse, script_textW, NULL, NULL, NULL, 0, 1, 0x42, NULL, NULL);
591 ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
592
593 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
594 ok(hres == E_UNEXPECTED, "SetScriptSite failed: %08x, expected E_UNEXPECTED\n", hres);
595
596 SET_EXPECT(OnStateChange_UNINITIALIZED);
597 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
598 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
599 CHECK_CALLED(OnStateChange_UNINITIALIZED);
600
602
603 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
604 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
605
606 SET_EXPECT(GetLCID);
607 SET_EXPECT(OnStateChange_INITIALIZED);
608 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
609 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
610 CHECK_CALLED(GetLCID);
611 CHECK_CALLED(OnStateChange_INITIALIZED);
612
613 SET_EXPECT(OnStateChange_CONNECTED);
614 SET_EXPECT(OnEnterScript);
615 SET_EXPECT(OnLeaveScript);
616 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
617 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
618 CHECK_CALLED(OnStateChange_CONNECTED);
619 CHECK_CALLED(OnEnterScript);
620 CHECK_CALLED(OnLeaveScript);
621
623
624 dispex = get_script_dispatch(script);
625 ok(dispex != NULL, "dispex == NULL\n");
626 IDispatchEx_Release(dispex);
627
628 SET_EXPECT(OnStateChange_DISCONNECTED);
629 SET_EXPECT(OnStateChange_INITIALIZED);
630 SET_EXPECT(OnStateChange_UNINITIALIZED);
631 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
632 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x\n", hres);
633 CHECK_CALLED(OnStateChange_DISCONNECTED);
634 CHECK_CALLED(OnStateChange_INITIALIZED);
635 CHECK_CALLED(OnStateChange_UNINITIALIZED);
636
638
639 hres = IActiveScript_Close(script);
640 ok(hres == S_OK, "Close failed: %08x\n", hres);
641
643
644 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_UNINITIALIZED);
645 ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_UNINITIALIZED) failed: %08x, expected E_UNEXPECTED\n", hres);
646
648
650
651 ref = IActiveScript_Release(script);
652 ok(!ref, "ref = %d\n", ref);
653}
#define IActiveScriptParse_ParseScriptText
Definition: jscript.c:42
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_no_script_dispatch()

static void test_no_script_dispatch ( IActiveScript script)
static

Definition at line 280 of file jscript.c.

281{
282 IDispatch *disp;
284
285 disp = (void*)0xdeadbeef;
286 hres = IActiveScript_GetScriptDispatch(script, NULL, &disp);
287 ok(hres == E_UNEXPECTED, "hres = %08x, expected E_UNEXPECTED\n", hres);
288 ok(!disp, "disp != NULL\n");
289}

Referenced by test_jscript(), and test_jscript2().

◆ test_safety()

static void test_safety ( IUnknown unk)
static

Definition at line 291 of file jscript.c.

292{
293 IObjectSafety *safety;
294 DWORD supported, enabled;
296
297 hres = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&safety);
298 ok(hres == S_OK, "Could not get IObjectSafety: %08x\n", hres);
299 if(FAILED(hres))
300 return;
301
302 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, NULL);
303 ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
304 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, NULL, &enabled);
305 ok(hres == E_POINTER, "GetInterfaceSafetyOptions failed: %08x, expected E_POINTER\n", hres);
306
307 supported = enabled = 0xdeadbeef;
308 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_NULL, &supported, &enabled);
309 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
310 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
311 "supported=%x\n", supported);
312 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
313
314 supported = enabled = 0xdeadbeef;
315 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScript, &supported, &enabled);
316 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
317 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
318 "supported=%x\n", supported);
319 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
320
321 supported = enabled = 0xdeadbeef;
322 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
323 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
324 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
325 "supported=%x\n", supported);
326 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
327
328 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
329 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER
330 |INTERFACESAFE_FOR_UNTRUSTED_CALLER,
331 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
332 ok(hres == E_FAIL, "SetInterfaceSafetyOptions failed: %08x, expected E_FAIL\n", hres);
333
334 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
335 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER,
336 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER);
337 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
338
339 supported = enabled = 0xdeadbeef;
340 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
341 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
342 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
343 "supported=%x\n", supported);
344 ok(enabled == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
345 "enabled=%x\n", enabled);
346
347 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, INTERFACESAFE_FOR_UNTRUSTED_DATA, 0);
348 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
349
350 supported = enabled = 0xdeadbeef;
351 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
352 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
353 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
354 "supported=%x\n", supported);
355 ok(enabled == (INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER), "enabled=%x\n", enabled);
356
357 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
358 INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER, 0);
359 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
360
361 supported = enabled = 0xdeadbeef;
362 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
363 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
364 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
365 "supported=%x\n", supported);
366 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
367
368 hres = IObjectSafety_SetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse,
369 INTERFACE_USES_DISPEX, 0);
370 ok(hres == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hres);
371
372 supported = enabled = 0xdeadbeef;
373 hres = IObjectSafety_GetInterfaceSafetyOptions(safety, &IID_IActiveScriptParse, &supported, &enabled);
374 ok(hres == S_OK, "GetInterfaceSafetyOptions failed: %08x\n", hres);
375 ok(supported == (INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_DISPEX|INTERFACE_USES_SECURITY_MANAGER),
376 "supported=%x\n", supported);
377 ok(enabled == INTERFACE_USES_DISPEX, "enabled=%x\n", enabled);
378
379 IObjectSafety_Release(safety);
380}
#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
#define IID_NULL
Definition: guiddef.h:98

Referenced by test_jscript().

◆ test_script_dispatch()

static void test_script_dispatch ( IDispatchEx dispex)
static

Definition at line 225 of file jscript.c.

226{
227 DISPPARAMS dp = {NULL,NULL,0,0};
228 EXCEPINFO ei;
229 BSTR str;
230 DISPID id;
231 VARIANT v;
233
234 str = a2bstr("ActiveXObject");
235 hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
237 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
238
239 str = a2bstr("Math");
240 hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
242 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
243
244 memset(&ei, 0, sizeof(ei));
245 hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
246 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
247 ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
248 ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
249 VariantClear(&v);
250
251 str = a2bstr("String");
252 hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
254 ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
255
256 memset(&ei, 0, sizeof(ei));
257 hres = IDispatchEx_InvokeEx(dispex, id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
258 ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
259 ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
260 ok(V_DISPATCH(&v) != NULL, "V_DISPATCH(v) = NULL\n");
261 VariantClear(&v);
262}
@ VT_DISPATCH
Definition: compat.h:2304
GLuint id
Definition: glext.h:5910
static BSTR a2bstr(const char *str)
Definition: jscript.c:89
static VARIANTARG static DISPID
Definition: ordinal.c:52
struct stdole::DISPPARAMS DISPPARAMS
struct stdole::EXCEPINFO EXCEPINFO
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define memset(x, y, z)
Definition: compat.h:39
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648

Referenced by test_jscript().

Variable Documentation

◆ ActiveScriptSite

IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }
static

Definition at line 223 of file jscript.c.

Referenced by test_jscript(), test_jscript2(), and test_jscript_uninitializing().

◆ ActiveScriptSiteVtbl

const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
static
Initial value:
= {
}
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
Definition: jscript.c:132
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
Definition: jscript.c:203
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
Definition: jscript.c:163
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
Definition: jscript.c:150
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
Definition: jscript.c:143
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
Definition: jscript.c:112
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
Definition: jscript.c:197
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
Definition: jscript.c:127
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
Definition: jscript.c:156
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
Definition: jscript.c:137
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
Definition: jscript.c:191

Definition at line 209 of file jscript.c.

◆ CLSID_JScript

const CLSID CLSID_JScript
static
Initial value:
=
{0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}}

Definition at line 48 of file jscript.c.

Referenced by check_jscript(), and test_aggregation().

◆ CLSID_JScriptEncode

const CLSID CLSID_JScriptEncode
static
Initial value:
=
{0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}}

Definition at line 50 of file jscript.c.

Referenced by DllGetClassObject(), and START_TEST().

◆ engine_clsid

const CLSID* engine_clsid = &CLSID_JScript
static

Definition at line 87 of file jscript.c.

Referenced by create_jscript(), and START_TEST().