1 /*
2  * Copyright 2012 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include <stdio.h>
20 
21 #define COBJMACROS
22 #define CONST_VTABLE
23 
24 #include <ole2.h>
25 #include <dispex.h>
26 #include <activscp.h>
27 #include <objsafe.h>
28 
29 #include "wine/test.h"
30 
31 #ifdef _WIN64
32 
33 #define IActiveScriptParse_QueryInterface IActiveScriptParse64_QueryInterface
34 #define IActiveScriptParse_Release IActiveScriptParse64_Release
35 #define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
36 #define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
37 
38 #else
39 
40 #define IActiveScriptParse_QueryInterface IActiveScriptParse32_QueryInterface
41 #define IActiveScriptParse_Release IActiveScriptParse32_Release
42 #define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
43 #define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
44 
45 #endif
46 
47 static const CLSID CLSID_JScript =
48     {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
49 
50 #define DEFINE_EXPECT(func) \
51     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
52 
53 #define SET_EXPECT(func) \
54     expect_ ## func = TRUE
55 
56 #define CHECK_EXPECT2(func) \
57     do { \
58         ok(expect_ ##func, "unexpected call " #func "\n"); \
59         called_ ## func = TRUE; \
60     }while(0)
61 
62 #define CHECK_EXPECT(func) \
63     do { \
64         CHECK_EXPECT2(func); \
65         expect_ ## func = FALSE; \
66     }while(0)
67 
68 #define CHECK_CALLED(func) \
69     do { \
70         ok(called_ ## func, "expected " #func "\n"); \
71         expect_ ## func = called_ ## func = FALSE; \
72     }while(0)
73 
74 DEFINE_EXPECT(testArgConv);
75 
76 static const WCHAR testW[] = {'t','e','s','t',0};
77 
78 static IVariantChangeType *script_change_type;
79 static IDispatch *stored_obj;
80 
81 #define DISPID_TEST_TESTARGCONV      0x1000
82 
83 static BSTR a2bstr(const char *str)
84 {
85     BSTR ret;
86     int len;
87 
88     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
89     ret = SysAllocStringLen(NULL, len-1);
90     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
91 
92     return ret;
93 }
94 
95 static int strcmp_wa(LPCWSTR strw, const char *stra)
96 {
97     CHAR buf[512];
98     WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
99     return lstrcmpA(buf, stra);
100 }
101 
102 typedef struct {
103     int int_result;
104     const char *str_result;
105     VARIANT_BOOL bool_result;
106     int test_double;
107     double double_result;
108 } conv_results_t;
109 
110 #define call_change_type(a,b,c,d) _call_change_type(__LINE__,a,b,c,d)
111 static void _call_change_type(unsigned line, IVariantChangeType *change_type, VARIANT *dst, VARIANT *src, VARTYPE vt)
112 {
113     HRESULT hres;
114 
115     VariantInit(dst);
116     hres = IVariantChangeType_ChangeType(change_type, dst, src, 0, vt);
117     ok_(__FILE__,line)(hres == S_OK, "ChangeType(%d) failed: %08x\n", vt, hres);
118     ok_(__FILE__,line)(V_VT(dst) == vt, "V_VT(dst) = %d\n", V_VT(dst));
119 }
120 
121 #define change_type_fail(a,b,c,d) _change_type_fail(__LINE__,a,b,c,d)
122 static void _change_type_fail(unsigned line, IVariantChangeType *change_type, VARIANT *src, VARTYPE vt, HRESULT exhres)
123 {
124     VARIANT v;
125     HRESULT hres;
126 
127     V_VT(&v) = VT_EMPTY;
128     hres = IVariantChangeType_ChangeType(change_type, &v, src, 0, vt);
129     ok_(__FILE__,line)(hres == exhres, "ChangeType failed: %08x, expected %08x\n", hres, exhres);
130 }
131 
132 static void test_change_type(IVariantChangeType *change_type, VARIANT *src, const conv_results_t *ex)
133 {
134     VARIANT v;
135 
136     call_change_type(change_type, &v, src, VT_I4);
137     ok(V_I4(&v) == ex->int_result, "V_I4(v) = %d, expected %d\n", V_I4(&v), ex->int_result);
138 
139     call_change_type(change_type, &v, src, VT_UI2);
140     ok(V_UI2(&v) == (UINT16)ex->int_result, "V_UI2(v) = %u, expected %u\n", V_UI2(&v), (UINT16)ex->int_result);
141 
142     call_change_type(change_type, &v, src, VT_BSTR);
143     ok(!strcmp_wa(V_BSTR(&v), ex->str_result), "V_BSTR(v) = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v)), ex->str_result);
144     VariantClear(&v);
145 
146     call_change_type(change_type, &v, src, VT_BOOL);
147     ok(V_BOOL(&v) == ex->bool_result, "V_BOOL(v) = %x, expected %x\n", V_BOOL(&v), ex->bool_result);
148 
149     if(ex->test_double) {
150         call_change_type(change_type, &v, src, VT_R8);
151         ok(V_R8(&v) == ex->double_result, "V_R8(v) = %lf, expected %lf\n", V_R8(&v), ex->double_result);
152 
153         call_change_type(change_type, &v, src, VT_R4);
154         ok(V_R4(&v) == (float)ex->double_result, "V_R4(v) = %f, expected %f\n", V_R4(&v), (float)ex->double_result);
155     }
156 
157     if(V_VT(src) == VT_NULL)
158         call_change_type(change_type, &v, src, VT_NULL);
159     else
160         change_type_fail(change_type, src, VT_NULL, E_NOTIMPL);
161 
162     if(V_VT(src) == VT_EMPTY)
163         call_change_type(change_type, &v, src, VT_EMPTY);
164     else
165         change_type_fail(change_type, src, VT_EMPTY, E_NOTIMPL);
166 
167     call_change_type(change_type, &v, src, VT_I2);
168     ok(V_I2(&v) == (INT16)ex->int_result, "V_I2(v) = %d, expected %d\n", V_I2(&v), ex->int_result);
169 }
170 
171 static void test_change_types(IVariantChangeType *change_type, IDispatch *obj_disp)
172 {
173     VARIANT v, dst;
174     BSTR str;
175     HRESULT hres;
176 
177     static const conv_results_t bool_results[] = {
178         {0, "false", VARIANT_FALSE, 1,0.0},
179         {1, "true", VARIANT_TRUE, 1,1.0}};
180     static const conv_results_t int_results[] = {
181         {0, "0", VARIANT_FALSE, 1,0.0},
182         {-100, "-100", VARIANT_TRUE, 1,-100.0},
183         {0x10010, "65552", VARIANT_TRUE, 1,65552.0}};
184     static const conv_results_t empty_results =
185         {0, "undefined", VARIANT_FALSE, 0,0};
186     static const conv_results_t null_results =
187         {0, "null", VARIANT_FALSE, 0,0};
188     static const conv_results_t obj_results =
189         {10, "strval", VARIANT_TRUE, 1,10.0};
190 
191     V_VT(&v) = VT_BOOL;
192     V_BOOL(&v) = VARIANT_FALSE;
193     test_change_type(change_type, &v, bool_results);
194     V_BOOL(&v) = VARIANT_TRUE;
195     test_change_type(change_type, &v, bool_results+1);
196 
197     V_VT(&v) = VT_I4;
198     V_I4(&v) = 0;
199     test_change_type(change_type, &v, int_results);
200     V_I4(&v) = -100;
201     test_change_type(change_type, &v, int_results+1);
202     V_I4(&v) = 0x10010;
203     test_change_type(change_type, &v, int_results+2);
204 
205     V_VT(&v) = VT_EMPTY;
206     test_change_type(change_type, &v, &empty_results);
207 
208     V_VT(&v) = VT_NULL;
209     test_change_type(change_type, &v, &null_results);
210 
211     V_VT(&v) = VT_DISPATCH;
212     V_DISPATCH(&v) = obj_disp;
213     test_change_type(change_type, &v, &obj_results);
214 
215     V_VT(&v) = VT_BOOL;
216     V_BOOL(&v) = VARIANT_FALSE;
217     V_VT(&dst) = 0xdead;
218     hres = IVariantChangeType_ChangeType(change_type, &dst, &v, 0, VT_I4);
219     ok(hres == DISP_E_BADVARTYPE, "ChangeType failed: %08x, expected DISP_E_BADVARTYPE\n", hres);
220     ok(V_VT(&dst) == 0xdead, "V_VT(dst) = %d\n", V_VT(&dst));
221 
222     /* Test conversion in place */
223     V_VT(&v) = VT_BSTR;
224     V_BSTR(&v) = str = a2bstr("test");
225     hres = IVariantChangeType_ChangeType(change_type, &v, &v, 0, VT_BSTR);
226     ok(hres == S_OK, "ChangeType failed: %08x\n", hres);
227     ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
228     ok(V_BSTR(&v) != str, "V_BSTR(v) == str\n");
229     ok(!strcmp_wa(V_BSTR(&v), "test"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
230 }
231 
232 static void test_caller(IServiceProvider *caller, IDispatch *arg_obj)
233 {
234     IVariantChangeType *change_type;
235     HRESULT hres;
236 
237     hres = IServiceProvider_QueryService(caller, &SID_VariantConversion, &IID_IVariantChangeType, (void**)&change_type);
238     ok(hres == S_OK, "Could not get SID_VariantConversion service: %08x\n", hres);
239 
240     ok(change_type == script_change_type, "change_type != script_change_type\n");
241     test_change_types(change_type, arg_obj);
242 
243     IVariantChangeType_Release(change_type);
244 }
245 
246 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
247 {
248     if(IsEqualGUID(riid, &IID_IUnknown)) {
249         *ppv = iface;
250     }else if(IsEqualGUID(riid, &IID_IDispatch) || IsEqualGUID(riid, &IID_IDispatchEx)) {
251         *ppv = iface;
252     }else if(IsEqualGUID(&IID_IObjectSafety, riid)) {
253         ok(0, "Unexpected IID_IObjectSafety query\n");
254     }else {
255         *ppv = NULL;
256         return E_NOINTERFACE;
257     }
258 
259     return S_OK;
260 }
261 
262 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
263 {
264     return 2;
265 }
266 
267 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
268 {
269     return 1;
270 }
271 
272 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
273 {
274     ok(0, "unexpected call\n");
275     return E_NOTIMPL;
276 }
277 
278 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
279                                               LCID lcid, ITypeInfo **ppTInfo)
280 {
281     ok(0, "unexpected call\n");
282     return E_NOTIMPL;
283 }
284 
285 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
286                                                 LPOLESTR *rgszNames, UINT cNames,
287                                                 LCID lcid, DISPID *rgDispId)
288 {
289     ok(0, "unexpected call\n");
290     return E_NOTIMPL;
291 }
292 
293 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
294                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
295                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
296 {
297     ok(0, "unexpected call\n");
298     return E_NOTIMPL;
299 }
300 
301 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
302 {
303     ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
304     return E_NOTIMPL;
305 }
306 
307 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
308 {
309     ok(0, "unexpected call\n");
310     return E_NOTIMPL;
311 }
312 
313 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
314 {
315     ok(0, "unexpected call\n");
316     return E_NOTIMPL;
317 }
318 
319 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
320 {
321     ok(0, "unexpected call\n");
322     return E_NOTIMPL;
323 }
324 
325 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
326 {
327     ok(0, "unexpected call\n");
328     return E_NOTIMPL;
329 }
330 
331 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
332 {
333     ok(0, "unexpected call\n");
334     return E_NOTIMPL;
335 }
336 
337 static HRESULT WINAPI Test_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
338 {
339     if(!strcmp_wa(bstrName, "testArgConv")) {
340         ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
341         *pid = DISPID_TEST_TESTARGCONV;
342         return S_OK;
343     }
344 
345     return E_NOTIMPL;
346 }
347 
348 static HRESULT WINAPI Test_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
349         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
350 {
351     ok(pspCaller != NULL, "pspCaller == NULL\n");
352 
353     switch(id) {
354     case DISPID_TEST_TESTARGCONV:
355         CHECK_EXPECT(testArgConv);
356 
357         ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
358         ok(pdp != NULL, "pdp == NULL\n");
359         ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
360         ok(!pvarRes, "pvarRes != NULL\n");
361         ok(pei != NULL, "pei == NULL\n");
362 
363         ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
364         ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(rgvarg) = %d\n", V_VT(pdp->rgvarg));
365 
366         test_caller(pspCaller, V_DISPATCH(pdp->rgvarg));
367 
368         stored_obj = V_DISPATCH(pdp->rgvarg);
369         IDispatch_AddRef(stored_obj);
370         break;
371 
372     default:
373         ok(0, "unexpected call\n");
374         return E_NOTIMPL;
375     }
376 
377     return S_OK;
378 }
379 
380 static IDispatchExVtbl testObjVtbl = {
381     DispatchEx_QueryInterface,
382     DispatchEx_AddRef,
383     DispatchEx_Release,
384     DispatchEx_GetTypeInfoCount,
385     DispatchEx_GetTypeInfo,
386     DispatchEx_GetIDsOfNames,
387     DispatchEx_Invoke,
388     Test_GetDispID,
389     Test_InvokeEx,
390     DispatchEx_DeleteMemberByName,
391     DispatchEx_DeleteMemberByDispID,
392     DispatchEx_GetMemberProperties,
393     DispatchEx_GetMemberName,
394     DispatchEx_GetNextDispID,
395     DispatchEx_GetNameSpaceParent
396 };
397 
398 static IDispatchEx testObj = { &testObjVtbl };
399 
400 static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
401 {
402     if(IsEqualGUID(&IID_IUnknown, riid)) {
403         *ppv = iface;
404     }else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) {
405         *ppv = iface;
406     }else {
407         *ppv = NULL;
408         return E_NOINTERFACE;
409     }
410 
411     IUnknown_AddRef((IUnknown*)*ppv);
412     return S_OK;
413 }
414 
415 static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
416 {
417     return 2;
418 }
419 
420 static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
421 {
422     return 1;
423 }
424 
425 static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
426 {
427     *plcid = GetUserDefaultLCID();
428     return S_OK;
429 }
430 
431 static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName,
432         DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
433 {
434     ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "unexpected dwReturnMask %x\n", dwReturnMask);
435     ok(!ppti, "ppti != NULL\n");
436     ok(!strcmp_wa(pstrName, "test"), "pstrName = %s\n", wine_dbgstr_w(pstrName));
437 
438     *ppiunkItem = (IUnknown*)&testObj;
439     return S_OK;
440 }
441 
442 static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
443 {
444     return E_NOTIMPL;
445 }
446 
447 static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface,
448         const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
449 {
450     return E_NOTIMPL;
451 }
452 
453 static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
454 {
455     return E_NOTIMPL;
456 }
457 
458 static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
459 {
460     return E_NOTIMPL;
461 }
462 
463 static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
464 {
465     return E_NOTIMPL;
466 }
467 
468 static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
469 {
470     return E_NOTIMPL;
471 }
472 
473 static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
474     ActiveScriptSite_QueryInterface,
475     ActiveScriptSite_AddRef,
476     ActiveScriptSite_Release,
477     ActiveScriptSite_GetLCID,
478     ActiveScriptSite_GetItemInfo,
479     ActiveScriptSite_GetDocVersionString,
480     ActiveScriptSite_OnScriptTerminate,
481     ActiveScriptSite_OnStateChange,
482     ActiveScriptSite_OnScriptError,
483     ActiveScriptSite_OnEnterScript,
484     ActiveScriptSite_OnLeaveScript
485 };
486 
487 static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
488 
489 #define parse_script_a(p,s) _parse_script_a(__LINE__,p,s)
490 static void _parse_script_a(unsigned line, IActiveScriptParse *parser, const char *script)
491 {
492     BSTR str;
493     HRESULT hres;
494 
495     str = a2bstr(script);
496     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
497     SysFreeString(str);
498     ok_(__FILE__,line)(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
499 }
500 
501 static IActiveScriptParse *create_script(void)
502 {
503     IActiveScriptParse *parser;
504     IActiveScript *script;
505     HRESULT hres;
506 
507     hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
508             &IID_IActiveScript, (void**)&script);
509     if(FAILED(hres))
510         return NULL;
511 
512     hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
513     ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
514 
515     hres = IActiveScriptParse_InitNew(parser);
516     ok(hres == S_OK, "InitNew failed: %08x\n", hres);
517 
518     hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
519     ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
520 
521     hres = IActiveScript_AddNamedItem(script, testW,
522             SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
523     ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
524 
525     hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
526     ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
527 
528     IActiveScript_Release(script);
529 
530     return parser;
531 }
532 
533 static void run_scripts(void)
534 {
535     IActiveScriptParse *parser;
536     HRESULT hres;
537 
538     parser = create_script();
539 
540     hres = IActiveScriptParse_QueryInterface(parser, &IID_IVariantChangeType, (void**)&script_change_type);
541     ok(hres == S_OK, "Could not get IVariantChangeType iface: %08x\n", hres);
542 
543     SET_EXPECT(testArgConv);
544     parse_script_a(parser,
545                    "var obj = {"
546                    "    toString: function() { return 'strval'; },"
547                    "    valueOf: function()  { return 10; }"
548                    "};"
549                    "testArgConv(obj);");
550     CHECK_CALLED(testArgConv);
551 
552     test_change_types(script_change_type, stored_obj);
553     IDispatch_Release(stored_obj);
554     IVariantChangeType_Release(script_change_type);
555 
556     IActiveScriptParse_Release(parser);
557 }
558 
559 static BOOL check_jscript(void)
560 {
561     IActiveScriptProperty *script_prop;
562     IActiveScriptParse *parser;
563     BSTR str;
564     HRESULT hres;
565 
566     parser = create_script();
567     if(!parser)
568         return FALSE;
569 
570     str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
571     hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL);
572     SysFreeString(str);
573 
574     if(hres == S_OK)
575         hres = IActiveScriptParse_QueryInterface(parser, &IID_IActiveScriptProperty, (void**)&script_prop);
576     IActiveScriptParse_Release(parser);
577     if(hres == S_OK)
578         IActiveScriptProperty_Release(script_prop);
579 
580     return hres == S_OK;
581 }
582 
583 START_TEST(caller)
584 {
585     CoInitialize(NULL);
586 
587     if(check_jscript())
588         run_scripts();
589     else
590         win_skip("Broken (too old) jscript\n");
591 
592     CoUninitialize();
593 }
594