2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
28 #include "wine/test.h"
32 #define IActiveScriptParse_QueryInterface IActiveScriptParse64_QueryInterface
33 #define IActiveScriptParse_Release IActiveScriptParse64_Release
34 #define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
35 #define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
36 #define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_64_Release
37 #define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_64_ParseProcedureText
41 #define IActiveScriptParse_QueryInterface IActiveScriptParse32_QueryInterface
42 #define IActiveScriptParse_Release IActiveScriptParse32_Release
43 #define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
44 #define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
45 #define IActiveScriptParseProcedure2_Release IActiveScriptParseProcedure2_32_Release
46 #define IActiveScriptParseProcedure2_ParseProcedureText IActiveScriptParseProcedure2_32_ParseProcedureText
50 static const CLSID CLSID_JScript
=
51 {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
52 static const CLSID CLSID_JScriptEncode
=
53 {0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
55 #define DEFINE_EXPECT(func) \
56 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
58 #define SET_EXPECT(func) \
59 expect_ ## func = TRUE
61 #define CHECK_EXPECT2(func) \
63 ok(expect_ ##func, "unexpected call " #func "\n"); \
64 called_ ## func = TRUE; \
67 #define CHECK_EXPECT(func) \
69 CHECK_EXPECT2(func); \
70 expect_ ## func = FALSE; \
73 #define CHECK_CALLED(func) \
75 ok(called_ ## func, "expected " #func "\n"); \
76 expect_ ## func = called_ ## func = FALSE; \
79 DEFINE_EXPECT(global_propget_d
);
80 DEFINE_EXPECT(global_propget_i
);
81 DEFINE_EXPECT(global_propput_d
);
82 DEFINE_EXPECT(global_propput_i
);
83 DEFINE_EXPECT(global_propputref_d
);
84 DEFINE_EXPECT(global_propputref_i
);
85 DEFINE_EXPECT(global_propdelete_d
);
86 DEFINE_EXPECT(global_nopropdelete_d
);
87 DEFINE_EXPECT(global_propdeleteerror_d
);
88 DEFINE_EXPECT(global_success_d
);
89 DEFINE_EXPECT(global_success_i
);
90 DEFINE_EXPECT(global_notexists_d
);
91 DEFINE_EXPECT(global_propargput_d
);
92 DEFINE_EXPECT(global_propargput_i
);
93 DEFINE_EXPECT(global_propargputop_d
);
94 DEFINE_EXPECT(global_propargputop_get_i
);
95 DEFINE_EXPECT(global_propargputop_put_i
);
96 DEFINE_EXPECT(global_testargtypes_i
);
97 DEFINE_EXPECT(global_calleval_i
);
98 DEFINE_EXPECT(puredisp_prop_d
);
99 DEFINE_EXPECT(puredisp_noprop_d
);
100 DEFINE_EXPECT(puredisp_value
);
101 DEFINE_EXPECT(dispexfunc_value
);
102 DEFINE_EXPECT(testobj_delete_test
);
103 DEFINE_EXPECT(testobj_delete_nodelete
);
104 DEFINE_EXPECT(testobj_value
);
105 DEFINE_EXPECT(testobj_construct
);
106 DEFINE_EXPECT(testobj_prop_d
);
107 DEFINE_EXPECT(testobj_withprop_d
);
108 DEFINE_EXPECT(testobj_withprop_i
);
109 DEFINE_EXPECT(testobj_noprop_d
);
110 DEFINE_EXPECT(testobj_onlydispid_d
);
111 DEFINE_EXPECT(testobj_onlydispid_i
);
112 DEFINE_EXPECT(testobj_notexists_d
);
113 DEFINE_EXPECT(testobj_newenum
);
114 DEFINE_EXPECT(testobj_getidfail_d
);
115 DEFINE_EXPECT(enumvariant_next_0
);
116 DEFINE_EXPECT(enumvariant_next_1
);
117 DEFINE_EXPECT(enumvariant_reset
);
118 DEFINE_EXPECT(GetItemInfo_testVal
);
119 DEFINE_EXPECT(ActiveScriptSite_OnScriptError
);
120 DEFINE_EXPECT(invoke_func
);
121 DEFINE_EXPECT(DeleteMemberByDispID
);
122 DEFINE_EXPECT(DeleteMemberByDispID_false
);
123 DEFINE_EXPECT(DeleteMemberByDispID_error
);
124 DEFINE_EXPECT(BindHandler
);
126 #define JS_E_SUBSCRIPT_OUT_OF_RANGE 0x800a0009
127 #define JS_E_INVALID_ACTION 0x800a01bd
128 #define JS_E_OBJECT_EXPECTED 0x800a138f
129 #define JS_E_UNDEFINED_VARIABLE 0x800a1391
130 #define JS_E_EXCEPTION_THROWN 0x800a139e
131 #define JS_E_SYNTAX 0x800a03ea
132 #define JS_E_MISSING_RBRACKET 0x800a03ee
133 #define JS_E_MISPLACED_RETURN 0x800a03fa
135 #define DISPID_GLOBAL_TESTPROPGET 0x1000
136 #define DISPID_GLOBAL_TESTPROPPUT 0x1001
137 #define DISPID_GLOBAL_REPORTSUCCESS 0x1002
138 #define DISPID_GLOBAL_TRACE 0x1003
139 #define DISPID_GLOBAL_OK 0x1004
140 #define DISPID_GLOBAL_GETVT 0x1005
141 #define DISPID_GLOBAL_TESTOBJ 0x1006
142 #define DISPID_GLOBAL_GETNULLBSTR 0x1007
143 #define DISPID_GLOBAL_NULL_DISP 0x1008
144 #define DISPID_GLOBAL_TESTTHIS 0x1009
145 #define DISPID_GLOBAL_TESTTHIS2 0x100a
146 #define DISPID_GLOBAL_INVOKEVERSION 0x100b
147 #define DISPID_GLOBAL_CREATEARRAY 0x100c
148 #define DISPID_GLOBAL_PROPGETFUNC 0x100d
149 #define DISPID_GLOBAL_OBJECT_FLAG 0x100e
150 #define DISPID_GLOBAL_ISWIN64 0x100f
151 #define DISPID_GLOBAL_PUREDISP 0x1010
152 #define DISPID_GLOBAL_ISNULLBSTR 0x1011
153 #define DISPID_GLOBAL_PROPARGPUT 0x1012
154 #define DISPID_GLOBAL_SHORTPROP 0x1013
155 #define DISPID_GLOBAL_GETSHORT 0x1014
156 #define DISPID_GLOBAL_TESTARGTYPES 0x1015
157 #define DISPID_GLOBAL_INTPROP 0x1016
158 #define DISPID_GLOBAL_DISPUNK 0x1017
159 #define DISPID_GLOBAL_TESTRES 0x1018
160 #define DISPID_GLOBAL_TESTNORES 0x1019
161 #define DISPID_GLOBAL_DISPEXFUNC 0x101a
162 #define DISPID_GLOBAL_TESTPROPPUTREF 0x101b
163 #define DISPID_GLOBAL_GETSCRIPTSTATE 0x101c
164 #define DISPID_GLOBAL_BINDEVENTHANDLER 0x101d
165 #define DISPID_GLOBAL_TESTENUMOBJ 0x101e
166 #define DISPID_GLOBAL_CALLEVAL 0x101f
167 #define DISPID_GLOBAL_PROPARGPUTOP 0x1020
168 #define DISPID_GLOBAL_THROWINT 0x1021
169 #define DISPID_GLOBAL_THROWEI 0x1022
170 #define DISPID_GLOBAL_VDATE 0x1023
171 #define DISPID_GLOBAL_VCY 0x1024
172 #define DISPID_GLOBAL_TODOWINE 0x1025
174 #define DISPID_GLOBAL_TESTPROPDELETE 0x2000
175 #define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001
176 #define DISPID_GLOBAL_TESTPROPDELETEERROR 0x2002
178 #define DISPID_TESTOBJ_PROP 0x2000
179 #define DISPID_TESTOBJ_ONLYDISPID 0x2001
180 #define DISPID_TESTOBJ_WITHPROP 0x2002
182 #define JS_E_OUT_OF_MEMORY 0x800a03ec
183 #define JS_E_INVALID_CHAR 0x800a03f6
185 static BOOL strict_dispid_check
, testing_expr
;
186 static const char *test_name
= "(null)";
187 static IDispatch
*script_disp
;
188 static int invoke_version
;
189 static IActiveScriptError
*script_error
;
190 static IActiveScript
*script_engine
;
191 static const CLSID
*engine_clsid
= &CLSID_JScript
;
193 /* Returns true if the user interface is in English. Note that this does not
194 * presume of the formatting of dates, numbers, etc.
196 static BOOL
is_lang_english(void)
198 static HMODULE hkernel32
= NULL
;
199 static LANGID (WINAPI
*pGetThreadUILanguage
)(void) = NULL
;
200 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void) = NULL
;
204 hkernel32
= GetModuleHandleA("kernel32.dll");
205 pGetThreadUILanguage
= (void*)GetProcAddress(hkernel32
, "GetThreadUILanguage");
206 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
208 if (pGetThreadUILanguage
)
209 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH
;
210 if (pGetUserDefaultUILanguage
)
211 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH
;
213 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH
;
216 #define test_grfdex(a,b) _test_grfdex(__LINE__,a,b)
217 static void _test_grfdex(unsigned line
, DWORD grfdex
, DWORD expect
)
219 expect
|= invoke_version
<< 28;
220 ok_(__FILE__
,line
)(grfdex
== expect
, "grfdex = %x, expected %x\n", grfdex
, expect
);
223 static void close_script(IActiveScript
*script
)
228 hres
= IActiveScript_Close(script
);
229 ok(hres
== S_OK
, "Close failed: %08x\n", hres
);
231 ref
= IActiveScript_Release(script
);
232 ok(!ref
, "ref=%u\n", ref
);
235 static HRESULT WINAPI
EnumVARIANT_QueryInterface(IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
239 if (IsEqualGUID(riid
, &IID_IEnumVARIANT
))
242 return E_NOINTERFACE
;
247 static ULONG WINAPI
EnumVARIANT_AddRef(IEnumVARIANT
*iface
)
252 static ULONG WINAPI
EnumVARIANT_Release(IEnumVARIANT
*iface
)
257 static int EnumVARIANT_index
= 0;
258 static int EnumVARIANT_next_0_count
= 0;
259 static HRESULT WINAPI
EnumVARIANT_Next(
265 ok(rgVar
!= NULL
, "rgVar is NULL\n");
266 ok(celt
== 1, "celt = %d\n", celt
);
267 ok(pCeltFetched
== NULL
, "pCeltFetched is not NULL\n");
272 if (EnumVARIANT_index
== 0)
274 EnumVARIANT_next_0_count
--;
275 if (EnumVARIANT_next_0_count
<= 0)
276 CHECK_EXPECT(enumvariant_next_0
);
287 CHECK_EXPECT(enumvariant_next_1
);
295 static HRESULT WINAPI
EnumVARIANT_Skip(
299 ok(0, "EnumVariant_Skip: unexpected call\n");
302 static HRESULT WINAPI
EnumVARIANT_Reset(
305 CHECK_EXPECT(enumvariant_reset
);
306 EnumVARIANT_index
= 0;
310 static HRESULT WINAPI
EnumVARIANT_Clone(
312 IEnumVARIANT
**ppEnum
)
314 ok(0, "EnumVariant_Clone: unexpected call\n");
318 static IEnumVARIANTVtbl testEnumVARIANTVtbl
= {
319 EnumVARIANT_QueryInterface
,
328 static IEnumVARIANT testEnumVARIANT
= { &testEnumVARIANTVtbl
};
330 static HRESULT WINAPI
DispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
334 if(IsEqualGUID(riid
, &IID_IUnknown
)
335 || IsEqualGUID(riid
, &IID_IDispatch
)
336 || IsEqualGUID(riid
, &IID_IDispatchEx
))
339 return E_NOINTERFACE
;
344 static ULONG WINAPI
DispatchEx_AddRef(IDispatchEx
*iface
)
349 static ULONG WINAPI
DispatchEx_Release(IDispatchEx
*iface
)
354 static HRESULT WINAPI
DispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
356 ok(0, "unexpected call\n");
360 static HRESULT WINAPI
DispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
361 LCID lcid
, ITypeInfo
**ppTInfo
)
366 static HRESULT WINAPI
DispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
367 LPOLESTR
*rgszNames
, UINT cNames
,
368 LCID lcid
, DISPID
*rgDispId
)
370 ok(0, "unexpected call\n");
374 static HRESULT WINAPI
DispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
375 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
376 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
378 ok(0, "unexpected call\n");
382 static HRESULT WINAPI
DispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
384 ok(0, "unexpected call\n");
388 static HRESULT WINAPI
DispatchEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
389 VARIANT
*res
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
391 ok(0, "unexpected call\n");
395 static HRESULT WINAPI
DispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
397 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName
), grfdex
);
401 static HRESULT WINAPI
DispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
403 ok(0, "unexpected call\n");
407 static HRESULT WINAPI
DispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
409 ok(0, "unexpected call\n");
413 static HRESULT WINAPI
DispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
415 ok(0, "unexpected call\n");
419 static HRESULT WINAPI
DispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
421 ok(0, "unexpected call\n");
425 static HRESULT WINAPI
DispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
427 ok(0, "unexpected call\n");
431 static HRESULT WINAPI
testObj_Invoke(IDispatchEx
*iface
, DISPID id
,
432 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
433 VARIANT
*pvarRes
, EXCEPINFO
*pei
, UINT
*puArgErr
)
437 ok(pdp
!= NULL
, "pdp == NULL\n");
438 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
439 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
440 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
441 ok(pei
== NULL
, "pei != NULL\n");
443 CHECK_EXPECT(testobj_newenum
);
444 V_VT(pvarRes
) = VT_DISPATCH
;
445 V_DISPATCH(pvarRes
) = (IDispatch
*)&testEnumVARIANT
;
449 ok(0, "unexpected call %x\n", id
);
450 return DISP_E_MEMBERNOTFOUND
;
453 static HRESULT WINAPI
testObj_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
455 if(!lstrcmpW(bstrName
, L
"prop")) {
456 CHECK_EXPECT(testobj_prop_d
);
457 test_grfdex(grfdex
, fdexNameCaseSensitive
);
458 *pid
= DISPID_TESTOBJ_PROP
;
461 if(!lstrcmpW(bstrName
, L
"withProp")) {
462 CHECK_EXPECT(testobj_withprop_d
);
463 test_grfdex(grfdex
, fdexNameCaseSensitive
|fdexNameImplicit
);
464 *pid
= DISPID_TESTOBJ_WITHPROP
;
467 if(!lstrcmpW(bstrName
, L
"noprop")) {
468 CHECK_EXPECT(testobj_noprop_d
);
469 test_grfdex(grfdex
, fdexNameCaseSensitive
);
470 return DISP_E_UNKNOWNNAME
;
472 if(!lstrcmpW(bstrName
, L
"onlyDispID")) {
473 if(strict_dispid_check
)
474 CHECK_EXPECT(testobj_onlydispid_d
);
475 test_grfdex(grfdex
, fdexNameCaseSensitive
);
476 *pid
= DISPID_TESTOBJ_ONLYDISPID
;
479 if(!lstrcmpW(bstrName
, L
"notExists")) {
480 CHECK_EXPECT(testobj_notexists_d
);
481 test_grfdex(grfdex
, fdexNameCaseSensitive
);
482 return DISP_E_UNKNOWNNAME
;
484 if(!lstrcmpW(bstrName
, L
"getIDFail")) {
485 CHECK_EXPECT(testobj_getidfail_d
);
489 ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName
));
493 static HRESULT WINAPI
testObj_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
494 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
496 ok(pspCaller
!= NULL
, "pspCaller = NULL\n");
500 ok(pdp
!= NULL
, "pdp == NULL\n");
501 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
502 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
503 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
504 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
505 ok(pei
!= NULL
, "pei == NULL\n");
508 case INVOKE_PROPERTYGET
:
509 CHECK_EXPECT(testobj_value
);
510 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
511 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
514 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
516 case INVOKE_FUNC
|INVOKE_PROPERTYGET
:
517 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
519 case DISPATCH_CONSTRUCT
:
520 CHECK_EXPECT(testobj_construct
);
521 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
524 ok(0, "invalid flag (%x)\n", wFlags
);
527 V_VT(pvarRes
) = VT_I4
;
530 case DISPID_TESTOBJ_ONLYDISPID
:
531 if(strict_dispid_check
)
532 CHECK_EXPECT(testobj_onlydispid_i
);
533 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
534 ok(pdp
!= NULL
, "pdp == NULL\n");
535 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
536 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
537 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
538 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
539 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
540 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
541 ok(pei
!= NULL
, "pei == NULL\n");
542 return DISP_E_MEMBERNOTFOUND
;
543 case DISPID_TESTOBJ_WITHPROP
:
544 CHECK_EXPECT(testobj_withprop_i
);
546 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
547 ok(pdp
!= NULL
, "pdp == NULL\n");
548 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
549 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
550 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
551 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
552 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
553 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
554 ok(pei
!= NULL
, "pei == NULL\n");
556 V_VT(pvarRes
) = VT_I4
;
562 ok(0, "unexpected call %x\n", id
);
563 return DISP_E_MEMBERNOTFOUND
;
566 static HRESULT WINAPI
testObj_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
568 if(!lstrcmpW(bstrName
, L
"deleteTest")) {
569 CHECK_EXPECT(testobj_delete_test
);
570 test_grfdex(grfdex
, fdexNameCaseSensitive
);
573 if(!lstrcmpW(bstrName
, L
"noDeleteTest")) {
574 CHECK_EXPECT(testobj_delete_nodelete
);
575 test_grfdex(grfdex
, fdexNameCaseSensitive
);
579 ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName
));
583 static IDispatchExVtbl testObjVtbl
= {
584 DispatchEx_QueryInterface
,
587 DispatchEx_GetTypeInfoCount
,
588 DispatchEx_GetTypeInfo
,
589 DispatchEx_GetIDsOfNames
,
593 testObj_DeleteMemberByName
,
594 DispatchEx_DeleteMemberByDispID
,
595 DispatchEx_GetMemberProperties
,
596 DispatchEx_GetMemberName
,
597 DispatchEx_GetNextDispID
,
598 DispatchEx_GetNameSpaceParent
601 static IDispatchEx testObj
= { &testObjVtbl
};
603 static HRESULT WINAPI
dispexFunc_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
604 VARIANT
*res
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
606 ok(pspCaller
!= NULL
, "pspCaller = NULL\n");
610 CHECK_EXPECT(dispexfunc_value
);
612 ok(pdp
!= NULL
, "pdp == NULL\n");
613 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
614 ok(pdp
->rgdispidNamedArgs
!= NULL
, "rgdispidNamedArgs != NULL\n");
615 ok(*pdp
->rgdispidNamedArgs
== DISPID_THIS
, "*rgdispidNamedArgs = %d\n", *pdp
->rgdispidNamedArgs
);
616 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
617 ok(pdp
->cNamedArgs
== 1, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
618 ok(res
!= NULL
, "res == NULL\n");
619 ok(pei
!= NULL
, "pei == NULL\n");
621 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
623 if(V_BOOL(pdp
->rgvarg
+1))
624 /* NOTE: If called by Function.apply(), native doesn't set DISPATCH_PROPERTYGET flag. */
625 todo_wine
ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
627 ok(wFlags
== (DISPATCH_PROPERTYGET
|DISPATCH_METHOD
), "wFlags = %x\n", wFlags
);
629 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
630 ok(V_DISPATCH(pdp
->rgvarg
) != NULL
, "V_DISPATCH(pdp->rgvarg) == NULL\n");
636 ok(0, "unexpected call %x\n", id
);
637 return DISP_E_MEMBERNOTFOUND
;
641 static IDispatchExVtbl dispexFuncVtbl
= {
642 DispatchEx_QueryInterface
,
645 DispatchEx_GetTypeInfoCount
,
646 DispatchEx_GetTypeInfo
,
647 DispatchEx_GetIDsOfNames
,
649 DispatchEx_GetDispID
,
651 DispatchEx_DeleteMemberByName
,
652 DispatchEx_DeleteMemberByDispID
,
653 DispatchEx_GetMemberProperties
,
654 DispatchEx_GetMemberName
,
655 DispatchEx_GetNextDispID
,
656 DispatchEx_GetNameSpaceParent
659 static IDispatchEx dispexFunc
= { &dispexFuncVtbl
};
661 static HRESULT WINAPI
pureDisp_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
663 if(IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_IDispatch
)) {
669 return E_NOINTERFACE
;
672 static HRESULT WINAPI
pureDisp_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
673 LPOLESTR
*rgszNames
, UINT cNames
,
674 LCID lcid
, DISPID
*rgDispId
)
676 ok(IsEqualGUID(riid
, &IID_NULL
), "Expected IID_NULL\n");
677 ok(cNames
==1, "cNames = %d\n", cNames
);
679 if(!lstrcmpW(*rgszNames
, L
"prop")) {
680 CHECK_EXPECT(puredisp_prop_d
);
681 *rgDispId
= DISPID_TESTOBJ_PROP
;
683 } else if(!lstrcmpW(*rgszNames
, L
"noprop")) {
684 CHECK_EXPECT(puredisp_noprop_d
);
685 return DISP_E_UNKNOWNNAME
;
688 ok(0, "unexpected call\n");
692 static HRESULT WINAPI
pureDisp_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
693 WORD wFlags
, DISPPARAMS
*pdp
, VARIANT
*res
, EXCEPINFO
*ei
, UINT
*puArgErr
)
695 ok(IsEqualGUID(&IID_NULL
, riid
), "unexpected riid\n");
697 switch(dispIdMember
) {
699 CHECK_EXPECT(puredisp_value
);
701 ok(pdp
!= NULL
, "pdp == NULL\n");
702 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
703 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
704 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
705 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
706 ok(res
!= NULL
, "res == NULL\n");
707 ok(ei
!= NULL
, "ei == NULL\n");
708 ok(puArgErr
!= NULL
, "puArgErr == NULL\n");
710 ok(V_VT(pdp
->rgvarg
) == VT_BOOL
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
712 if(V_BOOL(pdp
->rgvarg
))
713 todo_wine
ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
715 ok(wFlags
== (DISPATCH_PROPERTYGET
|DISPATCH_METHOD
), "wFlags = %x\n", wFlags
);
721 ok(0, "unexpected call\n");
726 static IDispatchExVtbl pureDispVtbl
= {
727 pureDisp_QueryInterface
,
730 DispatchEx_GetTypeInfoCount
,
731 DispatchEx_GetTypeInfo
,
732 pureDisp_GetIDsOfNames
,
736 static IDispatchEx pureDisp
= { &pureDispVtbl
};
738 static HRESULT WINAPI
BindEventHandler_QueryInterface(IBindEventHandler
*iface
, REFIID riid
, void **ppv
)
740 ok(0, "unexpected call\n");
741 return E_NOINTERFACE
;
744 static ULONG WINAPI
BindEventHandler_AddRef(IBindEventHandler
*iface
)
749 static ULONG WINAPI
BindEventHandler_Release(IBindEventHandler
*iface
)
754 static HRESULT WINAPI
BindEventHandler_BindHandler(IBindEventHandler
*iface
, const WCHAR
*event
, IDispatch
*disp
)
756 CHECK_EXPECT(BindHandler
);
757 ok(!lstrcmpW(event
, L
"eventName"), "event = %s\n", wine_dbgstr_w(event
));
758 ok(disp
!= NULL
, "disp = NULL\n");
762 static const IBindEventHandlerVtbl BindEventHandlerVtbl
= {
763 BindEventHandler_QueryInterface
,
764 BindEventHandler_AddRef
,
765 BindEventHandler_Release
,
766 BindEventHandler_BindHandler
769 static IBindEventHandler BindEventHandler
= { &BindEventHandlerVtbl
};
771 static HRESULT WINAPI
bindEventHandlerDisp_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
773 if(IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_IDispatch
) || IsEqualGUID(riid
, &IID_IDispatchEx
)) {
778 if(IsEqualGUID(riid
, &IID_IBindEventHandler
)) {
779 *ppv
= &BindEventHandler
;
784 return E_NOINTERFACE
;
787 static IDispatchExVtbl bindEventHandlerDispVtbl
= {
788 bindEventHandlerDisp_QueryInterface
,
791 DispatchEx_GetTypeInfoCount
,
792 DispatchEx_GetTypeInfo
,
793 DispatchEx_GetIDsOfNames
,
795 DispatchEx_GetDispID
,
797 DispatchEx_DeleteMemberByName
,
798 DispatchEx_DeleteMemberByDispID
,
799 DispatchEx_GetMemberProperties
,
800 DispatchEx_GetMemberName
,
801 DispatchEx_GetNextDispID
,
802 DispatchEx_GetNameSpaceParent
805 static IDispatchEx bindEventHandlerDisp
= { &bindEventHandlerDispVtbl
};
807 static HRESULT WINAPI
Global_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
809 if(!lstrcmpW(bstrName
, L
"ok")) {
810 test_grfdex(grfdex
, fdexNameCaseSensitive
);
811 *pid
= DISPID_GLOBAL_OK
;
814 if(!lstrcmpW(bstrName
, L
"trace")) {
815 test_grfdex(grfdex
, fdexNameCaseSensitive
);
816 *pid
= DISPID_GLOBAL_TRACE
;
819 if(!lstrcmpW(bstrName
, L
"todo_wine_ok")) {
820 test_grfdex(grfdex
, fdexNameCaseSensitive
);
821 *pid
= DISPID_GLOBAL_TODOWINE
;
824 if(!lstrcmpW(bstrName
, L
"reportSuccess")) {
825 CHECK_EXPECT(global_success_d
);
826 test_grfdex(grfdex
, fdexNameCaseSensitive
);
827 *pid
= DISPID_GLOBAL_REPORTSUCCESS
;
830 if(!lstrcmpW(bstrName
, L
"testPropGet")) {
831 CHECK_EXPECT(global_propget_d
);
832 test_grfdex(grfdex
, fdexNameCaseSensitive
);
833 *pid
= DISPID_GLOBAL_TESTPROPGET
;
836 if(!lstrcmpW(bstrName
, L
"testPropPut")) {
837 CHECK_EXPECT(global_propput_d
);
838 test_grfdex(grfdex
, fdexNameCaseSensitive
);
839 *pid
= DISPID_GLOBAL_TESTPROPPUT
;
842 if(!lstrcmpW(bstrName
, L
"testPropPutRef")) {
843 CHECK_EXPECT(global_propputref_d
);
844 test_grfdex(grfdex
, fdexNameCaseSensitive
);
845 *pid
= DISPID_GLOBAL_TESTPROPPUTREF
;
848 if(!lstrcmpW(bstrName
, L
"testPropDelete")) {
849 CHECK_EXPECT(global_propdelete_d
);
850 test_grfdex(grfdex
, fdexNameCaseSensitive
);
851 *pid
= DISPID_GLOBAL_TESTPROPDELETE
;
854 if(!lstrcmpW(bstrName
, L
"testNoPropDelete")) {
855 CHECK_EXPECT(global_nopropdelete_d
);
856 test_grfdex(grfdex
, fdexNameCaseSensitive
);
857 *pid
= DISPID_GLOBAL_TESTNOPROPDELETE
;
860 if(!lstrcmpW(bstrName
, L
"testPropDeleteError")) {
861 CHECK_EXPECT(global_propdeleteerror_d
);
862 test_grfdex(grfdex
, fdexNameCaseSensitive
);
863 *pid
= DISPID_GLOBAL_TESTPROPDELETEERROR
;
866 if(!lstrcmpW(bstrName
, L
"getVT")) {
867 test_grfdex(grfdex
, fdexNameCaseSensitive
);
868 *pid
= DISPID_GLOBAL_GETVT
;
871 if(!lstrcmpW(bstrName
, L
"testObj")) {
872 test_grfdex(grfdex
, fdexNameCaseSensitive
);
873 *pid
= DISPID_GLOBAL_TESTOBJ
;
876 if(!lstrcmpW(bstrName
, L
"getNullBSTR")) {
877 *pid
= DISPID_GLOBAL_GETNULLBSTR
;
880 if(!lstrcmpW(bstrName
, L
"isNullBSTR")) {
881 *pid
= DISPID_GLOBAL_ISNULLBSTR
;
884 if(!lstrcmpW(bstrName
, L
"nullDisp")) {
885 *pid
= DISPID_GLOBAL_NULL_DISP
;
888 if(!lstrcmpW(bstrName
, L
"notExists")) {
889 CHECK_EXPECT(global_notexists_d
);
890 test_grfdex(grfdex
, fdexNameCaseSensitive
);
891 return DISP_E_UNKNOWNNAME
;
894 if(!lstrcmpW(bstrName
, L
"testThis")) {
895 test_grfdex(grfdex
, fdexNameCaseSensitive
);
896 *pid
= DISPID_GLOBAL_TESTTHIS
;
900 if(!lstrcmpW(bstrName
, L
"testThis2")) {
901 test_grfdex(grfdex
, fdexNameCaseSensitive
);
902 *pid
= DISPID_GLOBAL_TESTTHIS2
;
906 if(!lstrcmpW(bstrName
, L
"invokeVersion")) {
907 test_grfdex(grfdex
, fdexNameCaseSensitive
);
908 *pid
= DISPID_GLOBAL_INVOKEVERSION
;
911 if(!lstrcmpW(bstrName
, L
"createArray")) {
912 test_grfdex(grfdex
, fdexNameCaseSensitive
);
913 *pid
= DISPID_GLOBAL_CREATEARRAY
;
916 if(!lstrcmpW(bstrName
, L
"propGetFunc")) {
917 test_grfdex(grfdex
, fdexNameCaseSensitive
);
918 *pid
= DISPID_GLOBAL_PROPGETFUNC
;
921 if(!lstrcmpW(bstrName
, L
"objectFlag")) {
922 test_grfdex(grfdex
, fdexNameCaseSensitive
);
923 *pid
= DISPID_GLOBAL_OBJECT_FLAG
;
927 if(!lstrcmpW(bstrName
, L
"isWin64")) {
928 test_grfdex(grfdex
, fdexNameCaseSensitive
);
929 *pid
= DISPID_GLOBAL_ISWIN64
;
933 if(!lstrcmpW(bstrName
, L
"pureDisp")) {
934 test_grfdex(grfdex
, fdexNameCaseSensitive
);
935 *pid
= DISPID_GLOBAL_PUREDISP
;
939 if(!lstrcmpW(bstrName
, L
"propArgPutG")) {
940 CHECK_EXPECT(global_propargput_d
);
941 test_grfdex(grfdex
, fdexNameCaseSensitive
);
942 *pid
= DISPID_GLOBAL_PROPARGPUT
;
946 if(!lstrcmpW(bstrName
, L
"propArgPutOp")) {
947 CHECK_EXPECT(global_propargputop_d
);
948 test_grfdex(grfdex
, fdexNameCaseSensitive
);
949 *pid
= DISPID_GLOBAL_PROPARGPUTOP
;
953 if(!lstrcmpW(bstrName
, L
"throwInt")) {
954 test_grfdex(grfdex
, fdexNameCaseSensitive
);
955 *pid
= DISPID_GLOBAL_THROWINT
;
959 if(!lstrcmpW(bstrName
, L
"throwEI")) {
960 test_grfdex(grfdex
, fdexNameCaseSensitive
);
961 *pid
= DISPID_GLOBAL_THROWEI
;
965 if(!lstrcmpW(bstrName
, L
"propArgPutO")) {
966 CHECK_EXPECT(global_propargput_d
);
967 test_grfdex(grfdex
, fdexNameEnsure
|fdexNameCaseSensitive
);
968 *pid
= DISPID_GLOBAL_PROPARGPUT
;
972 if(!lstrcmpW(bstrName
, L
"shortProp")) {
973 *pid
= DISPID_GLOBAL_SHORTPROP
;
977 if(!lstrcmpW(bstrName
, L
"getShort")) {
978 *pid
= DISPID_GLOBAL_GETSHORT
;
982 if(!lstrcmpW(bstrName
, L
"v_date")) {
983 *pid
= DISPID_GLOBAL_VDATE
;
987 if(!lstrcmpW(bstrName
, L
"v_cy")) {
988 *pid
= DISPID_GLOBAL_VCY
;
992 if(!lstrcmpW(bstrName
, L
"testArgTypes")) {
993 *pid
= DISPID_GLOBAL_TESTARGTYPES
;
997 if(!lstrcmpW(bstrName
, L
"intProp")) {
998 *pid
= DISPID_GLOBAL_INTPROP
;
1002 if(!lstrcmpW(bstrName
, L
"dispUnk")) {
1003 *pid
= DISPID_GLOBAL_DISPUNK
;
1007 if(!lstrcmpW(bstrName
, L
"testRes")) {
1008 *pid
= DISPID_GLOBAL_TESTRES
;
1012 if(!lstrcmpW(bstrName
, L
"testNoRes")) {
1013 *pid
= DISPID_GLOBAL_TESTNORES
;
1017 if(!lstrcmpW(bstrName
, L
"dispexFunc")) {
1018 *pid
= DISPID_GLOBAL_DISPEXFUNC
;
1022 if(!lstrcmpW(bstrName
, L
"getScriptState")) {
1023 *pid
= DISPID_GLOBAL_GETSCRIPTSTATE
;
1027 if(!lstrcmpW(bstrName
, L
"bindEventHandler")) {
1028 *pid
= DISPID_GLOBAL_BINDEVENTHANDLER
;
1032 if(!lstrcmpW(bstrName
, L
"testEnumObj")) {
1033 *pid
= DISPID_GLOBAL_TESTENUMOBJ
;
1037 if(!lstrcmpW(bstrName
, L
"callEval")) {
1038 *pid
= DISPID_GLOBAL_CALLEVAL
;
1042 if(strict_dispid_check
&& lstrcmpW(bstrName
, L
"t"))
1043 ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName
));
1044 return DISP_E_UNKNOWNNAME
;
1047 static HRESULT WINAPI
Global_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1048 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1050 ok(pspCaller
!= NULL
, "pspCaller = NULL\n");
1053 case DISPID_GLOBAL_OK
:
1054 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
1055 ok(pdp
!= NULL
, "pdp == NULL\n");
1056 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1057 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1058 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
1059 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1060 if(wFlags
& INVOKE_PROPERTYGET
)
1061 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1063 ok(!pvarRes
, "pvarRes != NULL\n");
1064 ok(pei
!= NULL
, "pei == NULL\n");
1066 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1067 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
1068 ok(V_BOOL(pdp
->rgvarg
+1), "%s: %s\n", test_name
, wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
1072 case DISPID_GLOBAL_TODOWINE
:
1073 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
1074 ok(pdp
!= NULL
, "pdp == NULL\n");
1075 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1076 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1077 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
1078 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1079 if(wFlags
& INVOKE_PROPERTYGET
)
1080 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1082 ok(!pvarRes
, "pvarRes != NULL\n");
1083 ok(pei
!= NULL
, "pei == NULL\n");
1085 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1086 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
1087 todo_wine
ok(V_BOOL(pdp
->rgvarg
+1), "%s: %s\n", test_name
, wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
1091 case DISPID_GLOBAL_TRACE
:
1092 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
1093 ok(pdp
!= NULL
, "pdp == NULL\n");
1094 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1095 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1096 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1097 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1098 ok(!pvarRes
, "pvarRes != NULL\n");
1099 ok(pei
!= NULL
, "pei == NULL\n");
1101 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1102 if(V_VT(pdp
->rgvarg
) == VT_BSTR
)
1103 trace("%s: %s\n", test_name
, wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
1107 case DISPID_GLOBAL_REPORTSUCCESS
:
1108 CHECK_EXPECT(global_success_i
);
1110 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
1111 ok(pdp
!= NULL
, "pdp == NULL\n");
1112 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1113 ok(pdp
->cArgs
== 0, "cArgs = %d\n", pdp
->cArgs
);
1114 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1116 ok(!pvarRes
, "pvarRes != NULL\n");
1117 ok(pei
!= NULL
, "pei == NULL\n");
1121 case DISPID_GLOBAL_TESTPROPGET
:
1122 CHECK_EXPECT(global_propget_i
);
1124 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
1125 ok(pdp
!= NULL
, "pdp == NULL\n");
1126 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
1127 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1128 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
1129 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1130 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1131 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1132 ok(pei
!= NULL
, "pei == NULL\n");
1134 V_VT(pvarRes
) = VT_I4
;
1139 case DISPID_GLOBAL_TESTPROPPUT
:
1140 CHECK_EXPECT(global_propput_i
);
1142 ok(wFlags
== INVOKE_PROPERTYPUT
, "wFlags = %x\n", wFlags
);
1143 ok(pdp
!= NULL
, "pdp == NULL\n");
1144 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1145 ok(pdp
->rgdispidNamedArgs
!= NULL
, "rgdispidNamedArgs == NULL\n");
1146 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1147 ok(pdp
->cNamedArgs
== 1, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1148 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_PROPERTYPUT
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
1149 ok(!pvarRes
, "pvarRes != NULL\n");
1151 ok(V_VT(pdp
->rgvarg
) == VT_I4
, "V_VT(pdp->rgvarg)=%d\n", V_VT(pdp
->rgvarg
));
1152 ok(V_I4(pdp
->rgvarg
) == 1, "V_I4(pdp->rgvarg)=%d\n", V_I4(pdp
->rgvarg
));
1155 case DISPID_GLOBAL_TESTPROPPUTREF
:
1156 CHECK_EXPECT(global_propputref_i
);
1158 ok(wFlags
== (INVOKE_PROPERTYPUT
|INVOKE_PROPERTYPUTREF
), "wFlags = %x\n", wFlags
);
1159 ok(pdp
!= NULL
, "pdp == NULL\n");
1160 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1161 ok(pdp
->rgdispidNamedArgs
!= NULL
, "rgdispidNamedArgs == NULL\n");
1162 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1163 ok(pdp
->cNamedArgs
== 1, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1164 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_PROPERTYPUT
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
1165 ok(!pvarRes
, "pvarRes != NULL\n");
1167 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(pdp->rgvarg)=%d\n", V_VT(pdp
->rgvarg
));
1170 case DISPID_GLOBAL_GETVT
:
1171 ok(pdp
!= NULL
, "pdp == NULL\n");
1172 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1173 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1174 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1175 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1176 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1177 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1178 ok(pei
!= NULL
, "pei == NULL\n");
1180 V_VT(pvarRes
) = VT_BSTR
;
1181 switch(V_VT(pdp
->rgvarg
)) {
1183 V_BSTR(pvarRes
) = SysAllocString(L
"VT_EMPTY");
1186 V_BSTR(pvarRes
) = SysAllocString(L
"VT_NULL");
1189 V_BSTR(pvarRes
) = SysAllocString(L
"VT_I4");
1192 V_BSTR(pvarRes
) = SysAllocString(L
"VT_R8");
1195 V_BSTR(pvarRes
) = SysAllocString(L
"VT_BSTR");
1198 V_BSTR(pvarRes
) = SysAllocString(L
"VT_DISPATCH");
1201 V_BSTR(pvarRes
) = SysAllocString(L
"VT_BOOL");
1203 case VT_ARRAY
|VT_VARIANT
:
1204 V_BSTR(pvarRes
) = SysAllocString(L
"VT_ARRAY|VT_VARIANT");
1207 V_BSTR(pvarRes
) = SysAllocString(L
"VT_DATE");
1210 ok(0, "unknown vt %d\n", V_VT(pdp
->rgvarg
));
1216 case DISPID_GLOBAL_TESTRES
:
1217 ok(pvarRes
!= NULL
, "pvarRes = NULL\n");
1219 V_VT(pvarRes
) = VT_BOOL
;
1220 V_BOOL(pvarRes
) = VARIANT_TRUE
;
1224 case DISPID_GLOBAL_TESTNORES
:
1225 ok(!pvarRes
, "pvarRes != NULL\n");
1227 V_VT(pvarRes
) = VT_NULL
;
1230 case DISPID_GLOBAL_TESTOBJ
:
1231 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
1232 ok(pdp
!= NULL
, "pdp == NULL\n");
1233 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
1234 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1235 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
1236 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1237 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1238 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1239 ok(pei
!= NULL
, "pei == NULL\n");
1241 V_VT(pvarRes
) = VT_DISPATCH
;
1242 V_DISPATCH(pvarRes
) = (IDispatch
*)&testObj
;
1245 case DISPID_GLOBAL_PUREDISP
:
1246 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
1247 ok(pdp
!= NULL
, "pdp == NULL\n");
1248 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
1249 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1250 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
1251 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1252 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1253 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1254 ok(pei
!= NULL
, "pei == NULL\n");
1256 V_VT(pvarRes
) = VT_DISPATCH
;
1257 V_DISPATCH(pvarRes
) = (IDispatch
*)&pureDisp
;
1260 case DISPID_GLOBAL_DISPEXFUNC
:
1261 V_VT(pvarRes
) = VT_DISPATCH
;
1262 V_DISPATCH(pvarRes
) = (IDispatch
*)&dispexFunc
;
1265 case DISPID_GLOBAL_GETNULLBSTR
:
1267 V_VT(pvarRes
) = VT_BSTR
;
1268 V_BSTR(pvarRes
) = NULL
;
1272 case DISPID_GLOBAL_ISNULLBSTR
:
1273 ok(pdp
!= NULL
, "pdp == NULL\n");
1274 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1275 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1276 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1277 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1278 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1279 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1280 ok(pei
!= NULL
, "pei == NULL\n");
1281 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1283 V_VT(pvarRes
) = VT_BOOL
;
1284 V_BOOL(pvarRes
) = V_BSTR(pdp
->rgvarg
) ? VARIANT_FALSE
: VARIANT_TRUE
;
1287 case DISPID_GLOBAL_ISWIN64
:
1289 V_VT(pvarRes
) = VT_BOOL
;
1290 V_BOOL(pvarRes
) = sizeof(void*) == 8 ? VARIANT_TRUE
: VARIANT_FALSE
;
1294 case DISPID_GLOBAL_NULL_DISP
:
1295 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
1296 ok(pdp
!= NULL
, "pdp == NULL\n");
1297 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
1298 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1299 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
1300 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1301 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1302 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1303 ok(pei
!= NULL
, "pei == NULL\n");
1305 V_VT(pvarRes
) = VT_DISPATCH
;
1306 V_DISPATCH(pvarRes
) = NULL
;
1309 case DISPID_GLOBAL_TESTTHIS
:
1310 ok(pdp
!= NULL
, "pdp == NULL\n");
1311 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1312 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1313 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1314 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1315 ok(pvarRes
== NULL
, "pvarRes != NULL\n");
1316 ok(pei
!= NULL
, "pei == NULL\n");
1318 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1319 ok(V_DISPATCH(pdp
->rgvarg
) == (IDispatch
*)iface
, "disp != iface\n");
1323 case DISPID_GLOBAL_TESTTHIS2
:
1324 ok(pdp
!= NULL
, "pdp == NULL\n");
1325 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1326 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1327 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1328 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1329 ok(pvarRes
== NULL
, "pvarRes != NULL\n");
1330 ok(pei
!= NULL
, "pei == NULL\n");
1332 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(arg) = %d\n", V_VT(pdp
->rgvarg
));
1333 ok(V_DISPATCH(pdp
->rgvarg
) != (IDispatch
*)iface
, "disp == iface\n");
1334 ok(V_DISPATCH(pdp
->rgvarg
) == script_disp
, "disp != script_disp\n");
1338 case DISPID_GLOBAL_INVOKEVERSION
:
1339 ok(wFlags
== INVOKE_PROPERTYGET
, "wFlags = %x\n", wFlags
);
1340 ok(pdp
!= NULL
, "pdp == NULL\n");
1341 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
1342 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1343 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
1344 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1345 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1346 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1347 ok(pei
!= NULL
, "pei == NULL\n");
1349 V_VT(pvarRes
) = VT_I4
;
1350 V_I4(pvarRes
) = invoke_version
;
1354 case DISPID_GLOBAL_CREATEARRAY
: {
1355 SAFEARRAYBOUND bound
[2];
1359 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
1360 ok(pdp
!= NULL
, "pdp == NULL\n");
1361 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1362 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1363 ok(!pdp
->cArgs
, "cArgs = %d\n", pdp
->cArgs
);
1364 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1365 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
1366 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1367 ok(pei
!= NULL
, "pei == NULL\n");
1369 bound
[0].lLbound
= 0;
1370 bound
[0].cElements
= 5;
1371 bound
[1].lLbound
= 2;
1372 bound
[1].cElements
= 2;
1374 V_VT(pvarRes
) = VT_ARRAY
|VT_VARIANT
;
1375 V_ARRAY(pvarRes
) = SafeArrayCreate(VT_VARIANT
, 2, bound
);
1377 SafeArrayAccessData(V_ARRAY(pvarRes
), (void**)&data
);
1378 for(i
=0; i
<5; i
++) {
1379 for(j
=2; j
<4; j
++) {
1381 V_I4(data
) = i
*10+j
;
1385 SafeArrayUnaccessData(V_ARRAY(pvarRes
));
1390 case DISPID_GLOBAL_PROPGETFUNC
:
1393 CHECK_EXPECT(invoke_func
);
1395 case INVOKE_FUNC
|INVOKE_PROPERTYGET
:
1396 ok(pdp
->cArgs
!= 0, "pdp->cArgs = %d\n", pdp
->cArgs
);
1397 ok(pvarRes
!= NULL
, "pdp->pvarRes == NULL\n");
1400 ok(0, "invalid flag (%x)\n", wFlags
);
1403 ok(pdp
!= NULL
, "pdp == NULL\n");
1404 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1405 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1406 ok(pei
!= NULL
, "pei == NULL\n");
1409 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1410 V_VT(pvarRes
) = VT_I4
;
1411 V_I4(pvarRes
) = pdp
->cArgs
;
1416 case DISPID_GLOBAL_GETSCRIPTSTATE
: {
1420 hres
= IActiveScript_GetScriptState(script_engine
, &state
);
1421 ok(hres
== S_OK
, "GetScriptState failed: %08x\n", hres
);
1423 V_VT(pvarRes
) = VT_I4
;
1424 V_I4(pvarRes
) = state
;
1428 case DISPID_GLOBAL_BINDEVENTHANDLER
:
1429 V_VT(pvarRes
) = VT_DISPATCH
;
1430 V_DISPATCH(pvarRes
) = (IDispatch
*)&bindEventHandlerDisp
;
1433 case DISPID_GLOBAL_PROPARGPUT
:
1434 CHECK_EXPECT(global_propargput_i
);
1435 ok(wFlags
== INVOKE_PROPERTYPUT
, "wFlags = %x\n", wFlags
);
1436 ok(pdp
!= NULL
, "pdp == NULL\n");
1437 ok(pdp
->rgvarg
!= NULL
, "rgvarg != NULL\n");
1438 ok(pdp
->rgdispidNamedArgs
!= NULL
, "rgdispidNamedArgs == NULL\n");
1439 ok(pdp
->cArgs
== 3, "cArgs = %d\n", pdp
->cArgs
);
1440 ok(pdp
->cNamedArgs
== 1, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1441 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_PROPERTYPUT
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
1442 ok(!pvarRes
, "pvarRes != NULL\n");
1443 ok(pei
!= NULL
, "pei == NULL\n");
1445 ok(V_VT(pdp
->rgvarg
) == VT_I4
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1446 ok(V_I4(pdp
->rgvarg
) == 2, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp
->rgvarg
));
1448 ok(V_VT(pdp
->rgvarg
+1) == VT_I4
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
1449 ok(V_I4(pdp
->rgvarg
+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp
->rgvarg
+1));
1451 ok(V_VT(pdp
->rgvarg
+2) == VT_I4
, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp
->rgvarg
+2));
1452 ok(V_I4(pdp
->rgvarg
+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp
->rgvarg
+2));
1455 case DISPID_GLOBAL_PROPARGPUTOP
:
1456 ok(pdp
!= NULL
, "pdp == NULL\n");
1457 ok(pdp
->rgvarg
!= NULL
, "rgvarg != NULL\n");
1458 ok(pei
!= NULL
, "pei == NULL\n");
1461 case INVOKE_PROPERTYGET
| INVOKE_FUNC
:
1462 CHECK_EXPECT(global_propargputop_get_i
);
1464 ok(pdp
->cNamedArgs
== 0, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1465 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1466 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
1467 ok(pdp
->cNamedArgs
== 0, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1468 ok(pvarRes
!= NULL
, "pvarRes = NULL\n");
1470 ok(V_VT(pdp
->rgvarg
) == VT_I4
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1471 ok(V_I4(pdp
->rgvarg
) == 1, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp
->rgvarg
));
1473 ok(V_VT(pdp
->rgvarg
+1) == VT_I4
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
1474 ok(V_I4(pdp
->rgvarg
+1) == 0, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp
->rgvarg
+1));
1476 V_VT(pvarRes
) = VT_I4
;
1479 case INVOKE_PROPERTYPUT
:
1480 CHECK_EXPECT(global_propargputop_put_i
);
1482 ok(pdp
->cNamedArgs
== 1, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1483 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_PROPERTYPUT
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
1484 ok(pdp
->rgdispidNamedArgs
!= NULL
, "rgdispidNamedArgs == NULL\n");
1485 ok(pdp
->cArgs
== 3, "cArgs = %d\n", pdp
->cArgs
);
1486 ok(pdp
->cNamedArgs
== 1, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1487 ok(!pvarRes
, "pvarRes != NULL\n");
1489 ok(V_VT(pdp
->rgvarg
) == VT_I4
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1490 ok(V_I4(pdp
->rgvarg
) == 8, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp
->rgvarg
));
1492 ok(V_VT(pdp
->rgvarg
+1) == VT_I4
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
1493 ok(V_I4(pdp
->rgvarg
+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp
->rgvarg
+1));
1495 ok(V_VT(pdp
->rgvarg
+2) == VT_I4
, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp
->rgvarg
+2));
1496 ok(V_I4(pdp
->rgvarg
+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp
->rgvarg
+2));
1499 ok(0, "wFlags = %x\n", wFlags
);
1504 case DISPID_GLOBAL_OBJECT_FLAG
: {
1505 IDispatchEx
*dispex
;
1509 hres
= IDispatch_QueryInterface(script_disp
, &IID_IDispatchEx
, (void**)&dispex
);
1510 ok(hres
== S_OK
, "hres = %x\n", hres
);
1512 str
= SysAllocString(L
"Object");
1513 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameCaseSensitive
, &id
);
1515 ok(hres
== S_OK
, "hres = %x\n", hres
);
1517 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, DISPATCH_METHOD
, pdp
, NULL
, pei
, pspCaller
);
1518 ok(hres
== S_OK
, "hres = %x\n", hres
);
1520 V_VT(pvarRes
) = VT_EMPTY
;
1521 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, DISPATCH_METHOD
, pdp
, pvarRes
, pei
, pspCaller
);
1522 ok(hres
== S_OK
, "hres = %x\n", hres
);
1523 ok(V_VT(pvarRes
) == VT_DISPATCH
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1524 VariantClear(pvarRes
);
1526 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, DISPATCH_METHOD
|DISPATCH_PROPERTYGET
, pdp
, NULL
, pei
, pspCaller
);
1527 ok(hres
== S_OK
, "hres = %x\n", hres
);
1529 V_VT(pvarRes
) = VT_EMPTY
;
1530 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, DISPATCH_CONSTRUCT
, pdp
, pvarRes
, pei
, pspCaller
);
1531 ok(hres
== S_OK
, "hres = %x\n", hres
);
1532 ok(V_VT(pvarRes
) == VT_DISPATCH
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1533 VariantClear(pvarRes
);
1535 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, DISPATCH_CONSTRUCT
, pdp
, NULL
, pei
, pspCaller
);
1536 ok(hres
== S_OK
, "hres = %x\n", hres
);
1538 V_VT(pvarRes
) = VT_EMPTY
;
1539 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, DISPATCH_CONSTRUCT
|DISPATCH_PROPERTYGET
, pdp
, pvarRes
, pei
, pspCaller
);
1540 ok(hres
== E_INVALIDARG
, "hres = %x\n", hres
);
1542 V_VT(pvarRes
) = VT_EMPTY
;
1543 hres
= IDispatchEx_InvokeEx(dispex
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1544 ok(hres
== S_OK
, "hres = %x\n", hres
);
1545 ok(V_VT(pvarRes
) == VT_DISPATCH
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1546 IDispatchEx_Release(dispex
);
1549 case DISPID_GLOBAL_SHORTPROP
:
1550 case DISPID_GLOBAL_GETSHORT
:
1551 V_VT(pvarRes
) = VT_I2
;
1555 case DISPID_GLOBAL_VDATE
:
1556 ok(wFlags
== (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
), "wFlags = %x\n", wFlags
);
1557 ok(pdp
!= NULL
, "pdp == NULL\n");
1558 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1559 ok(pvarRes
!= NULL
, "pvarRes != NULL\n");
1560 V_VT(pvarRes
) = VT_DATE
;
1561 switch(V_VT(pdp
->rgvarg
))
1564 V_DATE(pvarRes
) = V_I4(pdp
->rgvarg
);
1567 V_DATE(pvarRes
) = V_R8(pdp
->rgvarg
);
1570 ok(0, "vt = %u\n", V_VT(pdp
->rgvarg
));
1571 return E_INVALIDARG
;
1575 case DISPID_GLOBAL_VCY
:
1576 ok(wFlags
== (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
), "wFlags = %x\n", wFlags
);
1577 ok(pdp
!= NULL
, "pdp == NULL\n");
1578 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1579 ok(pvarRes
!= NULL
, "pvarRes != NULL\n");
1580 V_VT(pvarRes
) = VT_CY
;
1581 switch(V_VT(pdp
->rgvarg
))
1584 V_CY(pvarRes
).int64
= V_I4(pdp
->rgvarg
);
1587 V_CY(pvarRes
).int64
= V_R8(pdp
->rgvarg
);
1590 ok(0, "vt = %u\n", V_VT(pdp
->rgvarg
));
1591 return E_INVALIDARG
;
1595 case DISPID_GLOBAL_INTPROP
:
1596 V_VT(pvarRes
) = VT_INT
;
1597 V_INT(pvarRes
) = 22;
1600 case DISPID_GLOBAL_DISPUNK
:
1601 V_VT(pvarRes
) = VT_UNKNOWN
;
1602 V_UNKNOWN(pvarRes
) = (IUnknown
*)&testObj
;
1605 case DISPID_GLOBAL_TESTARGTYPES
: {
1606 VARIANT args
[10], v
;
1607 DISPPARAMS dp
= {args
, NULL
, ARRAY_SIZE(args
), 0};
1610 CHECK_EXPECT(global_testargtypes_i
);
1611 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
1612 ok(pdp
!= NULL
, "pdp == NULL\n");
1613 ok(pdp
->rgvarg
!= NULL
, "rgvarg != NULL\n");
1614 ok(pdp
->cArgs
== 6, "cArgs = %d\n", pdp
->cArgs
);
1615 ok(!pvarRes
, "pvarRes != NULL\n");
1617 ok(V_VT(pdp
->rgvarg
+1) == VT_I4
, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp
->rgvarg
+1));
1618 ok(V_I4(pdp
->rgvarg
+1) == 10, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp
->rgvarg
+1));
1620 ok(V_VT(pdp
->rgvarg
+2) == VT_I4
, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp
->rgvarg
+2));
1621 ok(V_I4(pdp
->rgvarg
+2) == 10, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp
->rgvarg
+2));
1623 ok(V_VT(pdp
->rgvarg
+3) == VT_I4
, "V_VT(pdp->rgvarg+3) = %d\n", V_VT(pdp
->rgvarg
+3));
1624 ok(V_I4(pdp
->rgvarg
+3) == 22, "V_I4(pdp->rgvarg+3) = %d\n", V_I4(pdp
->rgvarg
+3));
1626 ok(V_VT(pdp
->rgvarg
+4) == VT_I4
, "V_VT(pdp->rgvarg+4) = %d\n", V_VT(pdp
->rgvarg
+4));
1627 ok(V_I4(pdp
->rgvarg
+4) == 22, "V_I4(pdp->rgvarg+4) = %d\n", V_I4(pdp
->rgvarg
+4));
1629 ok(V_VT(pdp
->rgvarg
+5) == VT_DISPATCH
, "V_VT(pdp->rgvarg+5) = %d\n", V_VT(pdp
->rgvarg
+5));
1630 ok(V_DISPATCH(pdp
->rgvarg
+5) == (IDispatch
*)&testObj
, "V_DISPATCH(pdp->rgvarg+5) != testObj\n");
1632 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
1636 V_VT(args
+1) = VT_INT
;
1638 V_VT(args
+2) = VT_UNKNOWN
;
1639 V_UNKNOWN(args
+2) = (IUnknown
*)&testObj
;
1640 V_VT(args
+3) = VT_UNKNOWN
;
1641 V_UNKNOWN(args
+3) = NULL
;
1642 V_VT(args
+4) = VT_UI4
;
1643 V_UI4(args
+4) = 0xffffffff;
1644 V_VT(args
+5) = VT_BYREF
|VT_VARIANT
;
1645 V_VARIANTREF(args
+5) = &v
;
1646 V_VT(args
+6) = VT_R4
;
1648 V_VT(args
+7) = VT_UI2
;
1650 V_VT(args
+8) = VT_UI1
;
1652 V_VT(args
+9) = VT_I1
;
1656 hres
= IDispatch_Invoke(V_DISPATCH(pdp
->rgvarg
), DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dp
, NULL
, NULL
, NULL
);
1657 ok(hres
== S_OK
, "Invoke failed: %08x\n", hres
);
1662 case DISPID_GLOBAL_CALLEVAL
: {
1663 IDispatchEx
*eval_func
;
1668 CHECK_EXPECT(global_calleval_i
);
1670 ok(pdp
!= NULL
, "pdp == NULL\n");
1671 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1672 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1673 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1674 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1675 ok(pvarRes
== NULL
, "pvarRes != NULL\n");
1676 ok(pei
!= NULL
, "pei == NULL\n");
1678 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(arg) = %d\n", V_VT(pdp
->rgvarg
));
1679 hres
= IDispatch_QueryInterface(V_DISPATCH(pdp
->rgvarg
), &IID_IDispatchEx
, (void**)&eval_func
);
1680 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
1682 params
.rgvarg
= &arg
;
1683 params
.rgdispidNamedArgs
= NULL
;
1685 params
.cNamedArgs
= 0;
1686 V_VT(&arg
) = VT_BSTR
;
1688 V_BSTR(&arg
) = SysAllocString(L
"var x = 5; v");
1689 V_VT(&res
) = VT_ERROR
;
1690 hres
= IDispatchEx_InvokeEx(eval_func
, DISPID_VALUE
, 0, DISPATCH_METHOD
, ¶ms
, &res
, NULL
, NULL
);
1691 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1692 ok(V_VT(&res
) == VT_I4
, "eval returned type %u\n", V_VT(&res
));
1693 ok(V_I4(&res
) == 2, "eval returned %d\n", V_I4(&res
));
1694 SysFreeString(V_BSTR(&arg
));
1695 IDispatchEx_Release(eval_func
);
1698 case DISPID_GLOBAL_THROWINT
: {
1699 VARIANT
*v
= pdp
->rgvarg
;
1702 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
1703 ok(pdp
!= NULL
, "pdp == NULL\n");
1704 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1705 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1706 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
1707 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1708 ok(pei
!= NULL
, "pei == NULL\n");
1710 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1711 V_VT(pvarRes
) = VT_BOOL
;
1712 V_BOOL(pvarRes
) = VARIANT_FALSE
;
1720 hres
= (HRESULT
)V_R8(v
);
1723 ok(0, "unexpected vt %d\n", V_VT(v
));
1724 return E_INVALIDARG
;
1729 case DISPID_GLOBAL_THROWEI
: {
1730 VARIANT
*v
= pdp
->rgvarg
+ pdp
->cArgs
- 1;
1733 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
1734 ok(pdp
!= NULL
, "pdp == NULL\n");
1735 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
1736 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
1737 ok(pdp
->cArgs
== 1 || pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
1738 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
1739 ok(pei
!= NULL
, "pei == NULL\n");
1741 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pvarRes) = %d\n", V_VT(pvarRes
));
1742 V_VT(pvarRes
) = VT_BOOL
;
1743 V_BOOL(pvarRes
) = VARIANT_FALSE
;
1751 hres
= (HRESULT
)V_R8(v
);
1754 ok(0, "unexpected vt %d\n", V_VT(v
));
1755 return E_INVALIDARG
;
1759 if(pdp
->cArgs
== 1) {
1760 pei
->bstrSource
= SysAllocString(L
"test source");
1761 pei
->bstrDescription
= SysAllocString(L
"test description");
1763 return DISP_E_EXCEPTION
;
1767 ok(0, "unexpected call %x\n", id
);
1768 return DISP_E_MEMBERNOTFOUND
;
1771 static HRESULT WINAPI
Global_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
1774 case DISPID_GLOBAL_TESTPROPDELETE
:
1775 CHECK_EXPECT(DeleteMemberByDispID
);
1777 case DISPID_GLOBAL_TESTNOPROPDELETE
:
1778 CHECK_EXPECT(DeleteMemberByDispID_false
);
1780 case DISPID_GLOBAL_TESTPROPDELETEERROR
:
1781 CHECK_EXPECT(DeleteMemberByDispID_error
);
1784 ok(0, "id = %d\n", id
);
1790 static IDispatchExVtbl GlobalVtbl
= {
1791 DispatchEx_QueryInterface
,
1794 DispatchEx_GetTypeInfoCount
,
1795 DispatchEx_GetTypeInfo
,
1796 DispatchEx_GetIDsOfNames
,
1800 DispatchEx_DeleteMemberByName
,
1801 Global_DeleteMemberByDispID
,
1802 DispatchEx_GetMemberProperties
,
1803 DispatchEx_GetMemberName
,
1804 DispatchEx_GetNextDispID
,
1805 DispatchEx_GetNameSpaceParent
1808 static IDispatchEx Global
= { &GlobalVtbl
};
1810 static HRESULT WINAPI
ActiveScriptSite_QueryInterface(IActiveScriptSite
*iface
, REFIID riid
, void **ppv
)
1814 if(IsEqualGUID(&IID_IUnknown
, riid
))
1816 else if(IsEqualGUID(&IID_IActiveScriptSite
, riid
))
1819 return E_NOINTERFACE
;
1821 IUnknown_AddRef((IUnknown
*)*ppv
);
1825 static ULONG WINAPI
ActiveScriptSite_AddRef(IActiveScriptSite
*iface
)
1830 static ULONG WINAPI
ActiveScriptSite_Release(IActiveScriptSite
*iface
)
1835 static HRESULT WINAPI
ActiveScriptSite_GetLCID(IActiveScriptSite
*iface
, LCID
*plcid
)
1837 *plcid
= GetUserDefaultLCID();
1841 static HRESULT WINAPI
ActiveScriptSite_GetItemInfo(IActiveScriptSite
*iface
, LPCOLESTR pstrName
,
1842 DWORD dwReturnMask
, IUnknown
**ppiunkItem
, ITypeInfo
**ppti
)
1844 ok(dwReturnMask
== SCRIPTINFO_IUNKNOWN
, "unexpected dwReturnMask %x\n", dwReturnMask
);
1845 ok(!ppti
, "ppti != NULL\n");
1847 if(!lstrcmpW(pstrName
, L
"testVal"))
1848 CHECK_EXPECT(GetItemInfo_testVal
);
1849 else if(lstrcmpW(pstrName
, L
"test"))
1850 ok(0, "unexpected pstrName %s\n", wine_dbgstr_w(pstrName
));
1852 *ppiunkItem
= (IUnknown
*)&Global
;
1856 static HRESULT WINAPI
ActiveScriptSite_GetDocVersionString(IActiveScriptSite
*iface
, BSTR
*pbstrVersion
)
1861 static HRESULT WINAPI
ActiveScriptSite_OnScriptTerminate(IActiveScriptSite
*iface
,
1862 const VARIANT
*pvarResult
, const EXCEPINFO
*pexcepinfo
)
1867 static HRESULT WINAPI
ActiveScriptSite_OnStateChange(IActiveScriptSite
*iface
, SCRIPTSTATE ssScriptState
)
1872 static HRESULT WINAPI
ActiveScriptSite_OnScriptError(IActiveScriptSite
*iface
, IActiveScriptError
*pscripterror
)
1877 static HRESULT WINAPI
ActiveScriptSite_OnEnterScript(IActiveScriptSite
*iface
)
1882 static HRESULT WINAPI
ActiveScriptSite_OnLeaveScript(IActiveScriptSite
*iface
)
1887 static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
= {
1888 ActiveScriptSite_QueryInterface
,
1889 ActiveScriptSite_AddRef
,
1890 ActiveScriptSite_Release
,
1891 ActiveScriptSite_GetLCID
,
1892 ActiveScriptSite_GetItemInfo
,
1893 ActiveScriptSite_GetDocVersionString
,
1894 ActiveScriptSite_OnScriptTerminate
,
1895 ActiveScriptSite_OnStateChange
,
1896 ActiveScriptSite_OnScriptError
,
1897 ActiveScriptSite_OnEnterScript
,
1898 ActiveScriptSite_OnLeaveScript
1901 static IActiveScriptSite ActiveScriptSite
= { &ActiveScriptSiteVtbl
};
1903 static HRESULT WINAPI
ActiveScriptSite_OnScriptError_CheckError(IActiveScriptSite
*iface
, IActiveScriptError
*pscripterror
)
1905 ok(pscripterror
!= NULL
, "ActiveScriptSite_OnScriptError -- expected pscripterror to be set, got NULL\n");
1907 script_error
= pscripterror
;
1908 IActiveScriptError_AddRef(script_error
);
1910 CHECK_EXPECT(ActiveScriptSite_OnScriptError
);
1915 static const IActiveScriptSiteVtbl ActiveScriptSite_CheckErrorVtbl
= {
1916 ActiveScriptSite_QueryInterface
,
1917 ActiveScriptSite_AddRef
,
1918 ActiveScriptSite_Release
,
1919 ActiveScriptSite_GetLCID
,
1920 ActiveScriptSite_GetItemInfo
,
1921 ActiveScriptSite_GetDocVersionString
,
1922 ActiveScriptSite_OnScriptTerminate
,
1923 ActiveScriptSite_OnStateChange
,
1924 ActiveScriptSite_OnScriptError_CheckError
,
1925 ActiveScriptSite_OnEnterScript
,
1926 ActiveScriptSite_OnLeaveScript
1929 static IActiveScriptSite ActiveScriptSite_CheckError
= { &ActiveScriptSite_CheckErrorVtbl
};
1931 static HRESULT
set_script_prop(IActiveScript
*engine
, DWORD property
, VARIANT
*val
)
1933 IActiveScriptProperty
*script_prop
;
1936 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptProperty
,
1937 (void**)&script_prop
);
1938 ok(hres
== S_OK
, "Could not get IActiveScriptProperty iface: %08x\n", hres
);
1940 hres
= IActiveScriptProperty_SetProperty(script_prop
, property
, NULL
, val
);
1941 IActiveScriptProperty_Release(script_prop
);
1946 static IActiveScript
*create_script(void)
1948 IActiveScript
*script
;
1952 hres
= CoCreateInstance(engine_clsid
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1953 &IID_IActiveScript
, (void**)&script
);
1954 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1957 V_I4(&v
) = invoke_version
;
1958 hres
= set_script_prop(script
, SCRIPTPROP_INVOKEVERSIONING
, &v
);
1959 ok(hres
== S_OK
|| broken(hres
== E_NOTIMPL
), "SetProperty(SCRIPTPROP_INVOKEVERSIONING) failed: %08x\n", hres
);
1960 if(invoke_version
&& FAILED(hres
)) {
1961 IActiveScript_Release(script
);
1968 static HRESULT
parse_script(DWORD flags
, const WCHAR
*script_str
)
1970 IActiveScriptParse
*parser
;
1971 IActiveScript
*engine
;
1974 engine
= create_script();
1978 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
1979 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
1982 IActiveScript_Release(engine
);
1986 hres
= IActiveScriptParse_InitNew(parser
);
1987 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
1989 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
1990 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
1992 hres
= IActiveScript_AddNamedItem(engine
, L
"test",
1993 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|flags
);
1994 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
1996 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
1997 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
1999 hres
= IActiveScript_GetScriptDispatch(engine
, NULL
, &script_disp
);
2000 ok(hres
== S_OK
, "GetScriptDispatch failed: %08x\n", hres
);
2001 ok(script_disp
!= NULL
, "script_disp == NULL\n");
2002 ok(script_disp
!= (IDispatch
*)&Global
, "script_disp == Global\n");
2004 hres
= IActiveScriptParse_ParseScriptText(parser
, script_str
, NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
2006 IDispatch_Release(script_disp
);
2007 IActiveScript_Release(engine
);
2008 IActiveScriptParse_Release(parser
);
2013 static HRESULT
invoke_procedure(const WCHAR
*args
, const WCHAR
*source
, DISPPARAMS
*dp
)
2015 IActiveScriptParseProcedure2
*parse_proc
;
2016 IActiveScriptParse
*parser
;
2017 IActiveScript
*engine
;
2018 IDispatchEx
*dispex
;
2024 engine
= create_script();
2028 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2029 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2031 hres
= IActiveScriptParse_InitNew(parser
);
2032 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2034 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2035 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2037 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2038 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2040 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParseProcedure2
, (void**)&parse_proc
);
2041 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2043 hres
= IActiveScriptParseProcedure2_ParseProcedureText(parse_proc
, source
, args
, L
"", NULL
, NULL
, NULL
, 0, 0,
2044 SCRIPTPROC_HOSTMANAGESSOURCE
|SCRIPTPROC_IMPLICIT_THIS
|SCRIPTPROC_IMPLICIT_PARENTS
, &disp
);
2045 ok(hres
== S_OK
, "ParseProcedureText failed: %08x\n", hres
);
2047 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
2048 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2049 IDispatch_Release(disp
);
2051 V_VT(&res
) = VT_EMPTY
;
2052 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_METHOD
, dp
, &res
, &ei
, NULL
);
2053 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2054 ok(V_VT(&res
) == VT_BOOL
&& V_BOOL(&res
), "InvokeEx returned vt %d (%x)\n", V_VT(&res
), V_I4(&res
));
2055 IDispatchEx_Release(dispex
);
2057 IActiveScriptParseProcedure2_Release(parse_proc
);
2058 IActiveScript_Release(engine
);
2059 IActiveScriptParse_Release(parser
);
2064 static HRESULT
parse_htmlscript(const WCHAR
*script_str
)
2066 IActiveScriptParse
*parser
;
2067 IActiveScript
*engine
;
2070 engine
= create_script();
2074 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2075 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2078 IActiveScript_Release(engine
);
2082 hres
= IActiveScriptParse_InitNew(parser
);
2083 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2085 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2086 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2088 hres
= IActiveScript_AddNamedItem(engine
, L
"test",
2089 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
2090 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2092 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2093 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2095 hres
= IActiveScriptParse_ParseScriptText(parser
, script_str
, NULL
, NULL
, L
"</SCRIPT>", 0, 0, 0, NULL
, NULL
);
2097 IActiveScript_Release(engine
);
2098 IActiveScriptParse_Release(parser
);
2102 #define ERROR_TODO_PARSE 0x0001
2103 #define ERROR_TODO_SCODE 0x0002
2104 #define ERROR_TODO_DESCRIPTION 0x0004
2106 static void test_error_reports(void)
2108 IActiveScriptParse
*parser
;
2109 IActiveScript
*engine
;
2113 static const struct {
2114 const WCHAR
*script
;
2118 const WCHAR
*error_source
;
2119 const WCHAR
*description
;
2120 const WCHAR
*line_text
;
2127 L
"Microsoft JScript compilation error",
2132 L
"var a=1;\nif(a\n-->0) a=5;\n",
2133 JS_E_MISSING_RBRACKET
, 2, 0,
2134 L
"Microsoft JScript compilation error",
2141 JS_E_INVALID_ACTION
, 0, 0,
2142 L
"Microsoft JScript runtime error",
2143 L
"Object doesn't support this action"
2147 JS_E_OBJECT_EXPECTED
, 0, 0,
2148 L
"Microsoft JScript runtime error",
2152 L
"var a;\nnew null;",
2153 JS_E_OBJECT_EXPECTED
, 1, 0,
2154 L
"Microsoft JScript runtime error",
2158 L
"var a; new null;",
2159 JS_E_OBJECT_EXPECTED
, 0, 7,
2160 L
"Microsoft JScript runtime error",
2164 L
"var a;\na=\n new null;",
2165 JS_E_OBJECT_EXPECTED
, 1, 0,
2166 L
"Microsoft JScript runtime error",
2170 L
"var a;\nif(na=\n new null) {}",
2171 JS_E_OBJECT_EXPECTED
, 1, 0,
2172 L
"Microsoft JScript runtime error",
2176 L
"not_existing_variable.something();",
2177 JS_E_UNDEFINED_VARIABLE
, 0, 0,
2178 L
"Microsoft JScript runtime error",
2179 L
"'not_existing_variable' is undefined"
2183 JS_E_EXCEPTION_THROWN
, 0, 1,
2184 L
"Microsoft JScript runtime error",
2185 L
"Exception thrown and not caught"
2188 L
"var f = function() { throw 1; };\n"
2190 JS_E_EXCEPTION_THROWN
, 0, 21,
2191 L
"Microsoft JScript runtime error",
2192 L
"Exception thrown and not caught"
2195 L
"var f = function() { throw 1; };\n"
2196 L
"try { f(); } finally { 2; }\n",
2197 JS_E_EXCEPTION_THROWN
, 1, 21,
2198 L
"Microsoft JScript runtime error",
2199 L
"Exception thrown and not caught"
2202 L
" throwInt(-2146827270);",
2203 JS_E_MISPLACED_RETURN
, 0, 1,
2204 L
"Microsoft JScript runtime error",
2205 L
"'return' statement outside of function"
2208 L
" throwEI(-2146827270);",
2209 JS_E_MISPLACED_RETURN
, 0, 1,
2214 L
" throwEI(-2146827270, false);",
2215 JS_E_MISPLACED_RETURN
, 0, 1,
2216 L
"Microsoft JScript runtime error",
2217 L
"'return' statement outside of function"
2220 L
" throwEI(-2147467259 /* E_FAIL */, false);",
2224 L
" throwInt(-2147467259 /* E_FAIL */);",
2233 L
" throwEI(-2147467259 /* E_FAIL */);",
2240 L
" case 1: break;\n"
2241 L
" case 0: break;\n"
2242 L
" case new null: break;\n"
2243 L
" default: throw 1;\n"
2245 JS_E_OBJECT_EXPECTED
, 3, 4,
2246 L
"Microsoft JScript runtime error",
2252 L
"} while ( new null );\n",
2253 JS_E_OBJECT_EXPECTED
, 2, 2,
2254 L
"Microsoft JScript runtime error",
2258 L
"for (var i = 0; i < 100; new null) { i++ }",
2259 JS_E_OBJECT_EXPECTED
, 0, 25,
2260 L
"Microsoft JScript runtime error",
2264 L
"for (var i = 0; new null; i++) { i++ }",
2265 JS_E_OBJECT_EXPECTED
, 0, 16,
2266 L
"Microsoft JScript runtime error",
2270 L
"for (new null; i < 100; i++) { i++ }",
2271 JS_E_OBJECT_EXPECTED
, 0, 5,
2272 L
"Microsoft JScript runtime error",
2276 L
"var e = new Error();\n"
2277 L
"e.number = -2146828279;\n"
2278 L
"e.description = 'test';\n"
2280 JS_E_SUBSCRIPT_OUT_OF_RANGE
, 3, 0,
2281 L
"Microsoft JScript runtime error",
2288 L
"var e = new Error();\n"
2289 L
"e.number = -2146828279;\n"
2290 L
"e.message = 'test';\n"
2292 JS_E_SUBSCRIPT_OUT_OF_RANGE
, 3, 0,
2293 L
"Microsoft JScript runtime error",
2300 L
"var e = new Error();\n"
2310 L
"var e = new Object();\n"
2311 L
"e.number = -2146828279;\n"
2312 L
"e.description = 'test';\n"
2314 JS_E_EXCEPTION_THROWN
, 3, 0,
2315 L
"Microsoft JScript runtime error",
2316 L
"Exception thrown and not caught",
2318 ERROR_TODO_SCODE
| ERROR_TODO_DESCRIPTION
2321 L
"f(1\n,\n2,\n ,,3\n);\n",
2323 L
"Microsoft JScript compilation error",
2329 if (!is_lang_english())
2330 skip("Non-english UI (test with hardcoded strings)\n");
2332 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++)
2334 engine
= create_script();
2336 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2337 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2339 hres
= IActiveScriptParse_InitNew(parser
);
2340 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2342 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite_CheckError
);
2343 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2345 hres
= IActiveScript_AddNamedItem(engine
, L
"test",
2346 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
2347 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2349 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2350 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2352 hres
= IActiveScript_GetScriptDispatch(engine
, NULL
, &script_disp
);
2353 ok(hres
== S_OK
, "GetScriptDispatch failed: %08x\n", hres
);
2354 ok(script_disp
!= NULL
, "script_disp == NULL\n");
2355 ok(script_disp
!= (IDispatch
*)&Global
, "script_disp == Global\n");
2357 script_error
= NULL
;
2358 SET_EXPECT(ActiveScriptSite_OnScriptError
);
2359 hres
= IActiveScriptParse_ParseScriptText(parser
, tests
[i
].script
, NULL
, NULL
, NULL
, 10, 0, 0, NULL
, NULL
);
2360 todo_wine_if(tests
[i
].todo_flags
& ERROR_TODO_PARSE
)
2361 ok(hres
== SCRIPT_E_REPORTED
|| (tests
[i
].error
== JS_E_EXCEPTION_THROWN
&& hres
== SCRIPT_E_PROPAGATE
),
2362 "[%u] got: 0x%08x for %s\n", i
, hres
, wine_dbgstr_w(tests
[i
].script
));
2363 todo_wine_if(tests
[i
].todo_flags
& ERROR_TODO_PARSE
)
2364 CHECK_CALLED(ActiveScriptSite_OnScriptError
);
2368 DWORD source_context
;
2374 hres
= IActiveScriptError_GetSourcePosition(script_error
, NULL
, NULL
, NULL
);
2375 ok(hres
== S_OK
, "GetSourcePosition failed %08x\n", hres
);
2377 source_context
= 0xdeadbeef;
2378 hres
= IActiveScriptError_GetSourcePosition(script_error
, &source_context
, NULL
, NULL
);
2379 ok(hres
== S_OK
, "GetSourcePosition failed0x%08x\n", hres
);
2380 ok(source_context
== 10, "source_context = %x\n", source_context
);
2382 line_number
= 0xdeadbeef;
2383 hres
= IActiveScriptError_GetSourcePosition(script_error
, NULL
, &line_number
, NULL
);
2384 ok(hres
== S_OK
, "GetSourcePosition failed%08x\n", hres
);
2385 ok(line_number
== tests
[i
].line
, "[%u] line = %u expected %u\n", i
, line_number
, tests
[i
].line
);
2387 character
= 0xdeadbeef;
2388 hres
= IActiveScriptError_GetSourcePosition(script_error
, NULL
, NULL
, &character
);
2389 ok(hres
== S_OK
, "GetSourcePosition failed: %08x\n", hres
);
2390 ok(character
== tests
[i
].character
, "[%u] character = %u expected %u\n", i
, character
, tests
[i
].character
);
2392 hres
= IActiveScriptError_GetSourceLineText(script_error
, NULL
);
2393 ok(hres
== E_POINTER
, "GetSourceLineText returned %08x\n", hres
);
2395 line_text
= (BSTR
)0xdeadbeef;
2396 hres
= IActiveScriptError_GetSourceLineText(script_error
, &line_text
);
2397 if (tests
[i
].line_text
)
2399 ok(hres
== S_OK
, "GetSourceLineText failed: %08x\n", hres
);
2400 ok(line_text
!= NULL
&& !lstrcmpW(line_text
, tests
[i
].line_text
), "[%u] GetSourceLineText returned %s expected %s\n",
2401 i
, wine_dbgstr_w(line_text
), wine_dbgstr_w(tests
[i
].line_text
));
2405 ok(hres
== E_FAIL
, "GetSourceLineText failed: %08x\n", hres
);
2407 if (SUCCEEDED(hres
))
2408 SysFreeString(line_text
);
2410 hres
= IActiveScriptError_GetExceptionInfo(script_error
, NULL
);
2411 ok(hres
== E_POINTER
, "GetExceptionInfo failed: %08x\n", hres
);
2414 ei
.wReserved
= 0xdead;
2415 ei
.bstrSource
= (BSTR
)0xdeadbeef;
2416 ei
.bstrDescription
= (BSTR
)0xdeadbeef;
2417 ei
.bstrHelpFile
= (BSTR
)0xdeadbeef;
2418 ei
.dwHelpContext
= 0xdeadbeef;
2419 ei
.pvReserved
= (void *)0xdeadbeef;
2420 ei
.pfnDeferredFillIn
= (void *)0xdeadbeef;
2421 ei
.scode
= 0xdeadbeef;
2423 hres
= IActiveScriptError_GetExceptionInfo(script_error
, &ei
);
2424 ok(hres
== S_OK
, "GetExceptionInfo failed: %08x\n", hres
);
2426 todo_wine_if(tests
[i
].todo_flags
& ERROR_TODO_SCODE
)
2427 ok(ei
.scode
== tests
[i
].error
, "[%u] scode = %08x, expected %08x\n", i
, ei
.scode
, tests
[i
].error
);
2428 ok(ei
.wCode
== 0, "wCode = %x\n", ei
.wCode
);
2429 todo_wine_if(tests
[i
].reserved_lcid
)
2430 ok(ei
.wReserved
== (tests
[i
].reserved_lcid
? GetUserDefaultLCID() : 0), "[%u] wReserved = %x expected %x\n",
2431 i
, ei
.wReserved
, (tests
[i
].reserved_lcid
? GetUserDefaultLCID() : 0));
2432 if (is_lang_english())
2434 if(tests
[i
].error_source
)
2435 ok(ei
.bstrSource
&& !lstrcmpW(ei
.bstrSource
, tests
[i
].error_source
), "[%u] bstrSource = %s expected %s\n",
2436 i
, wine_dbgstr_w(ei
.bstrSource
), wine_dbgstr_w(tests
[i
].error_source
));
2438 ok(!ei
.bstrSource
, "[%u] bstrSource = %s expected NULL\n", i
, wine_dbgstr_w(ei
.bstrSource
));
2439 if(tests
[i
].description
)
2440 todo_wine_if(tests
[i
].todo_flags
& ERROR_TODO_DESCRIPTION
)
2441 ok(ei
.bstrDescription
&& !lstrcmpW(ei
.bstrDescription
, tests
[i
].description
),
2442 "[%u] bstrDescription = %s expected %s\n", i
, wine_dbgstr_w(ei
.bstrDescription
), wine_dbgstr_w(tests
[i
].description
));
2444 ok(!ei
.bstrDescription
, "[%u] bstrDescription = %s expected NULL\n", i
, wine_dbgstr_w(ei
.bstrDescription
));
2446 ok(!ei
.bstrHelpFile
, "bstrHelpFile = %s\n", wine_dbgstr_w(ei
.bstrHelpFile
));
2447 ok(!ei
.dwHelpContext
, "dwHelpContext = %d\n", ei
.dwHelpContext
);
2448 ok(!ei
.pvReserved
, "pvReserved = %p\n", ei
.pvReserved
);
2449 ok(!ei
.pfnDeferredFillIn
, "pfnDeferredFillIn = %p\n", ei
.pfnDeferredFillIn
);
2451 SysFreeString(ei
.bstrSource
);
2452 SysFreeString(ei
.bstrDescription
);
2453 SysFreeString(ei
.bstrHelpFile
);
2455 IActiveScriptError_Release(script_error
);
2458 IDispatch_Release(script_disp
);
2459 IActiveScript_Release(engine
);
2460 IActiveScriptParse_Release(parser
);
2464 #define run_script(a) _run_script(__LINE__,a)
2465 static void _run_script(unsigned line
, const WCHAR
*src
)
2469 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
2470 ok_(__FILE__
,line
)(hres
== S_OK
, "script %s failed: %08x\n", wine_dbgstr_w(src
), hres
);
2473 static BSTR
get_script_from_file(const char *filename
)
2477 const char *file_map
;
2480 file
= CreateFileA(filename
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_READONLY
, NULL
);
2481 if(file
== INVALID_HANDLE_VALUE
) {
2482 trace("Could not open file: %u\n", GetLastError());
2486 size
= GetFileSize(file
, NULL
);
2488 map
= CreateFileMappingW(file
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
2490 if(map
== INVALID_HANDLE_VALUE
) {
2491 trace("Could not create file mapping: %u\n", GetLastError());
2495 file_map
= MapViewOfFile(map
, FILE_MAP_READ
, 0, 0, 0);
2498 trace("MapViewOfFile failed: %u\n", GetLastError());
2502 len
= MultiByteToWideChar(CP_ACP
, 0, file_map
, size
, NULL
, 0);
2503 ret
= SysAllocStringLen(NULL
, len
);
2504 MultiByteToWideChar(CP_ACP
, 0, file_map
, size
, ret
, len
);
2506 UnmapViewOfFile(file_map
);
2511 static void run_from_file(const char *filename
)
2516 script_str
= get_script_from_file(filename
);
2520 strict_dispid_check
= FALSE
;
2521 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, script_str
);
2522 SysFreeString(script_str
);
2523 ok(hres
== S_OK
, "parse_script failed: %08x\n", hres
);
2526 static BSTR
load_res(const char *name
)
2533 strict_dispid_check
= FALSE
;
2536 src
= FindResourceA(NULL
, name
, (LPCSTR
)40);
2537 ok(src
!= NULL
, "Could not find resource %s\n", name
);
2539 size
= SizeofResource(NULL
, src
);
2540 data
= LoadResource(NULL
, src
);
2542 len
= MultiByteToWideChar(CP_ACP
, 0, data
, size
, NULL
, 0);
2543 str
= SysAllocStringLen(NULL
, len
);
2544 MultiByteToWideChar(CP_ACP
, 0, data
, size
, str
, len
);
2549 static void run_from_res(const char *name
)
2554 str
= load_res(name
);
2556 SET_EXPECT(global_success_d
);
2557 SET_EXPECT(global_success_i
);
2558 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, str
);
2559 CHECK_CALLED(global_success_d
);
2560 CHECK_CALLED(global_success_i
);
2562 ok(hres
== S_OK
, "parse_script failed: %08x\n", hres
);
2566 static void test_isvisible(BOOL global_members
)
2568 IActiveScriptParse
*parser
;
2569 IActiveScript
*engine
;
2572 engine
= create_script();
2576 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2577 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2580 IActiveScript_Release(engine
);
2584 hres
= IActiveScriptParse_InitNew(parser
);
2585 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2587 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2588 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2591 SET_EXPECT(GetItemInfo_testVal
);
2592 hres
= IActiveScript_AddNamedItem(engine
, L
"testVal",
2593 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|
2594 (global_members
? SCRIPTITEM_GLOBALMEMBERS
: 0));
2595 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2597 CHECK_CALLED(GetItemInfo_testVal
);
2599 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2600 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2603 SET_EXPECT(GetItemInfo_testVal
);
2604 hres
= IActiveScriptParse_ParseScriptText(parser
, L
"var v = testVal;", NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
2605 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
2607 CHECK_CALLED(GetItemInfo_testVal
);
2609 hres
= IActiveScriptParse_ParseScriptText(parser
, L
"var v = testVal;", NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
2610 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
2612 IActiveScript_Release(engine
);
2613 IActiveScriptParse_Release(parser
);
2616 static void test_start(void)
2618 IActiveScriptParse
*parser
;
2619 IActiveScript
*engine
;
2623 script_engine
= engine
= create_script();
2627 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2628 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2630 hres
= IActiveScriptParse_InitNew(parser
);
2631 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2633 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2634 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2636 hres
= IActiveScript_AddNamedItem(engine
, L
"test", SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
2637 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2639 str
= SysAllocString(L
"ok(getScriptState() === 5, \"getScriptState = \" + getScriptState());\n"
2640 L
"reportSuccess();");
2641 hres
= IActiveScriptParse_ParseScriptText(parser
, str
, NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
2642 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
2645 SET_EXPECT(global_success_d
);
2646 SET_EXPECT(global_success_i
);
2647 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2648 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2649 CHECK_CALLED(global_success_d
);
2650 CHECK_CALLED(global_success_i
);
2652 IActiveScript_Release(engine
);
2653 IActiveScriptParse_Release(parser
);
2654 script_engine
= NULL
;
2657 static void test_automagic(void)
2659 IActiveScriptParse
*parser
;
2660 IActiveScript
*engine
;
2664 script_engine
= engine
= create_script();
2668 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2669 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2671 hres
= IActiveScriptParse_InitNew(parser
);
2672 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2674 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2675 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2677 hres
= IActiveScript_AddNamedItem(engine
, L
"test", SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
2678 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2680 str
= SysAllocString(L
"function bindEventHandler::eventName() {}\n"
2681 L
"reportSuccess();");
2682 hres
= IActiveScriptParse_ParseScriptText(parser
, str
, NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
2683 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
2686 SET_EXPECT(BindHandler
);
2687 SET_EXPECT(global_success_d
);
2688 SET_EXPECT(global_success_i
);
2689 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2690 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2691 CHECK_CALLED(BindHandler
);
2692 CHECK_CALLED(global_success_d
);
2693 CHECK_CALLED(global_success_i
);
2695 IActiveScript_Release(engine
);
2696 IActiveScriptParse_Release(parser
);
2697 script_engine
= NULL
;
2700 static HRESULT
parse_script_expr(const WCHAR
*expr
, VARIANT
*res
, IActiveScript
**engine_ret
)
2702 IActiveScriptParse
*parser
;
2703 IActiveScript
*engine
;
2706 engine
= create_script();
2710 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2711 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2713 hres
= IActiveScriptParse_InitNew(parser
);
2714 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2716 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2717 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2719 SET_EXPECT(GetItemInfo_testVal
);
2720 hres
= IActiveScript_AddNamedItem(engine
, L
"testVal",
2721 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
2722 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2723 CHECK_CALLED(GetItemInfo_testVal
);
2725 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2726 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2728 hres
= IActiveScriptParse_ParseScriptText(parser
, expr
, NULL
, NULL
, NULL
, 0, 0, SCRIPTTEXT_ISEXPRESSION
, res
, NULL
);
2729 IActiveScriptParse_Release(parser
);
2732 *engine_ret
= engine
;
2734 close_script(engine
);
2739 static void test_retval(void)
2741 IActiveScriptParse
*parser
;
2742 IActiveScript
*engine
;
2748 engine
= create_script();
2752 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
2753 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
2755 hres
= IActiveScriptParse_InitNew(parser
);
2756 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
2758 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
2759 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
2761 SET_EXPECT(GetItemInfo_testVal
);
2762 hres
= IActiveScript_AddNamedItem(engine
, L
"testVal",
2763 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
2764 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
2765 CHECK_CALLED(GetItemInfo_testVal
);
2767 str
= SysAllocString(L
"reportSuccess(), true");
2768 V_VT(&res
) = VT_NULL
;
2769 SET_EXPECT(global_success_d
);
2770 SET_EXPECT(global_success_i
);
2771 hres
= IActiveScriptParse_ParseScriptText(parser
, str
, NULL
, NULL
, NULL
, 0, 0, 0, &res
, NULL
);
2772 CHECK_CALLED(global_success_d
);
2773 CHECK_CALLED(global_success_i
);
2774 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
2775 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(&res) = %d\n", V_VT(&res
));
2778 hres
= IActiveScript_GetScriptState(engine
, &state
);
2779 ok(hres
== S_OK
, "GetScriptState failed: %08x\n", hres
);
2780 ok(state
== SCRIPTSTATE_INITIALIZED
, "state = %d\n", state
);
2782 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
2783 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2785 IActiveScriptParse_Release(parser
);
2787 close_script(engine
);
2790 static void test_default_value(void)
2792 DISPPARAMS dp
= {0};
2797 hres
= parse_script_expr(L
"new Date()", &v
, NULL
);
2798 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2799 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
2800 disp
= V_DISPATCH(&v
);
2802 V_VT(&v
) = VT_EMPTY
;
2803 hres
= IDispatch_Invoke(disp
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dp
, &v
, NULL
, NULL
);
2804 ok(hres
== S_OK
|| broken(hres
== 0x8000ffff), "Invoke failed: %08x\n", hres
);
2807 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
2811 IDispatch_Release(disp
);
2814 static void test_script_exprs(void)
2819 testing_expr
= TRUE
;
2821 hres
= parse_script_expr(L
"true", &v
, NULL
);
2822 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2823 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2824 ok(V_BOOL(&v
) == VARIANT_TRUE
, "V_BOOL(v) = %x\n", V_BOOL(&v
));
2826 hres
= parse_script_expr(L
"false, true", &v
, NULL
);
2827 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2828 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2829 ok(V_BOOL(&v
) == VARIANT_TRUE
, "V_BOOL(v) = %x\n", V_BOOL(&v
));
2831 SET_EXPECT(global_success_d
);
2832 SET_EXPECT(global_success_i
);
2833 hres
= parse_script_expr(L
"reportSuccess(); true", &v
, NULL
);
2834 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2835 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2836 ok(V_BOOL(&v
) == VARIANT_TRUE
, "V_BOOL(v) = %x\n", V_BOOL(&v
));
2837 CHECK_CALLED(global_success_d
);
2838 CHECK_CALLED(global_success_i
);
2840 hres
= parse_script_expr(L
"if(false) true", &v
, NULL
);
2841 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2842 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(v) = %d\n", V_VT(&v
));
2844 hres
= parse_script_expr(L
"return testPropGet", &v
, NULL
);
2845 ok(hres
== 0x800a03fa, "parse_script_expr failed: %08x\n", hres
);
2847 hres
= parse_script_expr(L
"reportSuccess(); return true", &v
, NULL
);
2848 ok(hres
== 0x800a03fa, "parse_script_expr failed: %08x\n", hres
);
2850 SET_EXPECT(global_success_d
);
2851 SET_EXPECT(global_success_i
);
2852 hres
= parse_script_expr(L
"reportSuccess(); true", NULL
, NULL
);
2853 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2854 CHECK_CALLED(global_success_d
);
2855 CHECK_CALLED(global_success_i
);
2857 test_default_value();
2860 testing_expr
= FALSE
;
2863 static void test_invokeex(void)
2865 DISPID func_id
, prop_id
;
2866 DISPPARAMS dp
= {NULL
};
2867 IActiveScript
*script
;
2868 IDispatchEx
*dispex
;
2873 hres
= parse_script_expr(L
"var o = {func: function() {return 3;}, prop: 6}; o", &v
, &script
);
2874 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2875 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
2877 hres
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IDispatchEx
, (void**)&dispex
);
2878 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2881 str
= SysAllocString(L
"func");
2882 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &func_id
);
2884 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2886 str
= SysAllocString(L
"prop");
2887 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &prop_id
);
2889 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2891 hres
= IDispatchEx_InvokeEx(dispex
, func_id
, 0, DISPATCH_METHOD
, &dp
, &v
, NULL
, NULL
);
2892 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2893 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
2894 ok(V_I4(&v
) == 3, "V_I4(v) = %d\n", V_I4(&v
));
2896 hres
= IDispatchEx_InvokeEx(dispex
, prop_id
, 0, DISPATCH_PROPERTYGET
, &dp
, &v
, NULL
, NULL
);
2897 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2898 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
2899 ok(V_I4(&v
) == 6, "V_I4(v) = %d\n", V_I4(&v
));
2901 hres
= IActiveScript_SetScriptState(script
, SCRIPTSTATE_UNINITIALIZED
);
2902 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
2904 str
= SysAllocString(L
"func");
2905 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &func_id
);
2907 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2909 hres
= IDispatchEx_InvokeEx(dispex
, func_id
, 0, DISPATCH_METHOD
, &dp
, &v
, NULL
, NULL
);
2910 ok(hres
== E_UNEXPECTED
|| broken(hres
== 0x800a1393), "InvokeEx failed: %08x\n", hres
);
2912 hres
= IDispatchEx_InvokeEx(dispex
, prop_id
, 0, DISPATCH_PROPERTYGET
, &dp
, &v
, NULL
, NULL
);
2913 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2914 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
2915 ok(V_I4(&v
) == 6, "V_I4(v) = %d\n", V_I4(&v
));
2917 IDispatchEx_Release(dispex
);
2918 IActiveScript_Release(script
);
2920 /* test InvokeEx following prototype chain of builtin object (PROP_PROTREF) */
2921 hres
= parse_script_expr(L
"o = new Array(); o.push(\"foo\"); o", &v
, &script
);
2922 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2923 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
2925 hres
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IDispatchEx
, (void**)&dispex
);
2926 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2929 str
= SysAllocString(L
"push");
2930 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &func_id
);
2932 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2936 V_VT(&arg
) = VT_BSTR
;
2937 V_BSTR(&arg
) = SysAllocString(L
"bar");
2939 hres
= IDispatchEx_InvokeEx(dispex
, func_id
, 0, DISPATCH_METHOD
, &dp
, &v
, NULL
, NULL
);
2940 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2941 SysFreeString(V_BSTR(&arg
));
2943 str
= SysAllocString(L
"join");
2944 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &func_id
);
2946 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2948 V_BSTR(&arg
) = SysAllocString(L
";");
2949 hres
= IDispatchEx_InvokeEx(dispex
, func_id
, 0, DISPATCH_METHOD
, &dp
, &v
, NULL
, NULL
);
2950 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2951 SysFreeString(V_BSTR(&arg
));
2952 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
2953 ok(!lstrcmpW(V_BSTR(&v
), L
"foo;bar"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
2960 IDispatchEx_Release(dispex
);
2961 IActiveScript_Release(script
);
2963 /* test InvokeEx following prototype chain of JScript objects (PROP_JSVAL) */
2964 hres
= parse_script_expr(L
"function c() { this.func = function() { return this.prop1 * this.prop2 };"
2965 L
"this.prop1 = 6; this.prop2 = 9; }; var o = new c(); o.prop2 = 7; o",
2967 ok(hres
== S_OK
, "parse_script_expr failed: %08x\n", hres
);
2968 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
2970 hres
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IDispatchEx
, (void**)&dispex
);
2971 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2974 str
= SysAllocString(L
"prop1");
2975 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &prop_id
);
2977 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2979 hres
= IDispatchEx_InvokeEx(dispex
, prop_id
, 0, DISPATCH_PROPERTYGET
, &dp
, &v
, NULL
, NULL
);
2980 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2981 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
2982 ok(V_I4(&v
) == 6, "V_I4(v) = %d\n", V_I4(&v
));
2984 str
= SysAllocString(L
"prop2");
2985 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &prop_id
);
2987 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2989 hres
= IDispatchEx_InvokeEx(dispex
, prop_id
, 0, DISPATCH_PROPERTYGET
, &dp
, &v
, NULL
, NULL
);
2990 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2991 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
2992 ok(V_I4(&v
) == 7, "V_I4(v) = %d\n", V_I4(&v
));
2994 str
= SysAllocString(L
"func");
2995 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &func_id
);
2997 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2999 hres
= IDispatchEx_InvokeEx(dispex
, func_id
, 0, DISPATCH_METHOD
, &dp
, &v
, NULL
, NULL
);
3000 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3001 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3002 ok(V_I4(&v
) == 42, "V_I4(v) = %s\n", wine_dbgstr_variant(&v
));
3004 IDispatchEx_Release(dispex
);
3005 IActiveScript_Release(script
);
3008 static void test_eval(void)
3010 IActiveScriptParse
*parser
;
3011 IDispatchEx
*script_dispex
;
3012 IDispatch
*script_disp
;
3013 IActiveScript
*engine
;
3020 engine
= create_script();
3022 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
3023 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
3025 hres
= IActiveScriptParse_InitNew(parser
);
3026 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
3028 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
3029 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
3031 SET_EXPECT(GetItemInfo_testVal
);
3032 hres
= IActiveScript_AddNamedItem(engine
, L
"testVal",
3033 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
);
3034 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
3035 CHECK_CALLED(GetItemInfo_testVal
);
3037 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
3038 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
3040 hres
= IActiveScript_GetScriptDispatch(engine
, NULL
, &script_disp
);
3041 ok(hres
== S_OK
, "GetScriptDispatch failed: %08x\n", hres
);
3042 ok(script_disp
!= NULL
, "script_disp == NULL\n");
3044 hres
= IDispatch_QueryInterface(script_disp
, &IID_IDispatchEx
, (void**)&script_dispex
);
3045 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
3046 IDispatch_Release(script_disp
);
3048 str
= SysAllocString(L
"eval");
3049 hres
= IDispatchEx_GetDispID(script_dispex
, str
, 0, &id
);
3050 ok(hres
== S_OK
, "Could not get eval dispid: %08x\n", hres
);
3053 params
.rgvarg
= &arg
;
3054 params
.rgdispidNamedArgs
= NULL
;
3056 params
.cNamedArgs
= 0;
3057 V_VT(&arg
) = VT_BSTR
;
3059 V_BSTR(&arg
) = SysAllocString(L
"var v = 1;");
3060 V_VT(&res
) = VT_ERROR
;
3061 hres
= IDispatchEx_InvokeEx(script_dispex
, id
, 0, DISPATCH_METHOD
, ¶ms
, &res
, NULL
, NULL
);
3062 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3063 ok(V_VT(&res
) == VT_EMPTY
, "eval returned type %u\n", V_VT(&res
));
3064 SysFreeString(V_BSTR(&arg
));
3066 V_BSTR(&arg
) = SysAllocString(L
"v");
3067 V_VT(&res
) = VT_ERROR
;
3068 hres
= IDispatchEx_InvokeEx(script_dispex
, id
, 0, DISPATCH_METHOD
, ¶ms
, &res
, NULL
, NULL
);
3069 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3070 ok(V_VT(&res
) == VT_I4
, "eval returned type %u\n", V_VT(&res
));
3071 ok(V_I4(&res
) == 1, "eval returned %d\n", V_I4(&res
));
3072 SysFreeString(V_BSTR(&arg
));
3074 str
= SysAllocString(L
"v");
3075 hres
= IDispatchEx_GetDispID(script_dispex
, str
, 0, &v_id
);
3076 ok(hres
== S_OK
, "Could not get v dispid: %08x\n", hres
);
3079 params
.rgvarg
= NULL
;
3081 V_VT(&res
) = VT_ERROR
;
3082 hres
= IDispatchEx_InvokeEx(script_dispex
, v_id
, 0, DISPATCH_PROPERTYGET
, ¶ms
, &res
, NULL
, NULL
);
3083 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3084 ok(V_VT(&res
) == VT_I4
, "eval returned type %u\n", V_VT(&res
));
3085 ok(V_I4(&res
) == 1, "eval returned %d\n", V_I4(&res
));
3087 SET_EXPECT(global_calleval_i
);
3088 hres
= IActiveScriptParse_ParseScriptText(parser
,
3092 L
" ok(x === 5, 'x = ' + x);"
3094 NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
3095 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
3096 CHECK_CALLED(global_calleval_i
);
3098 str
= SysAllocString(L
"x");
3099 hres
= IDispatchEx_GetDispID(script_dispex
, str
, 0, &id
);
3100 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(x) returned %08x\n", hres
);
3103 IDispatchEx_Release(script_dispex
);
3104 IActiveScriptParse_Release(parser
);
3105 close_script(engine
);
3114 static void run_bom_tests(void)
3119 struct bom_test bom_tests
[] = {
3120 {L
"var a = 1; reportSuccess();", S_OK
},
3121 {L
"\xfeffvar a = 1; reportSuccess();", S_OK
},
3122 {L
"v\xfeff" "ar a = 1; reportSuccess();", JS_E_OUT_OF_MEMORY
},
3123 {L
"var\xfeff a = 1; reportSuccess();", S_OK
},
3124 {L
"var a = 1; \xfeffreportSuccess();", S_OK
},
3125 {L
"var a = 1; report\xfeffSuccess();", JS_E_OUT_OF_MEMORY
},
3126 {L
"var a = 1; reportSuccess\xfeff();", S_OK
},
3127 {L
"var a = 1; reportSuccess(\xfeff);", S_OK
},
3128 {L
"var a =\xfeff 1; reportSuccess(\xfeff);", S_OK
},
3129 {L
"\xfeffvar a =\xfeff\xfeff 1; reportSuccess(\xfeff);", S_OK
},
3133 engine_clsid
= &CLSID_JScript
;
3135 for (i
= 0; bom_tests
[i
].str
[0]; i
++)
3137 if(bom_tests
[i
].hres
== S_OK
)
3139 SET_EXPECT(global_success_d
);
3140 SET_EXPECT(global_success_i
);
3141 src
= SysAllocString(bom_tests
[i
].str
);
3142 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3143 ok(hres
== S_OK
, "test %s failed with %08x\n", wine_dbgstr_w(src
), hres
);
3145 CHECK_CALLED(global_success_d
);
3146 CHECK_CALLED(global_success_i
);
3150 src
= SysAllocString(bom_tests
[i
].str
);
3151 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3152 todo_wine
ok(hres
== bom_tests
[i
].hres
, "test %s returned with %08x\n", wine_dbgstr_w(src
), hres
);
3158 static BOOL
run_tests(void)
3162 if(invoke_version
) {
3163 IActiveScript
*script
;
3165 script
= create_script();
3167 win_skip("Could not create script\n");
3170 IActiveScript_Release(script
);
3173 strict_dispid_check
= TRUE
;
3176 run_script(L
"/* empty */ ;");
3178 SET_EXPECT(global_propget_d
);
3179 SET_EXPECT(global_propget_i
);
3180 run_script(L
"testPropGet;");
3181 CHECK_CALLED(global_propget_d
);
3182 CHECK_CALLED(global_propget_i
);
3184 SET_EXPECT(global_propput_d
);
3185 SET_EXPECT(global_propput_i
);
3186 run_script(L
"testPropPut = 1;");
3187 CHECK_CALLED(global_propput_d
);
3188 CHECK_CALLED(global_propput_i
);
3190 SET_EXPECT(global_propputref_d
);
3191 SET_EXPECT(global_propputref_i
);
3192 run_script(L
"testPropPutRef = new Object();");
3193 CHECK_CALLED(global_propputref_d
);
3194 CHECK_CALLED(global_propputref_i
);
3196 SET_EXPECT(global_propputref_d
);
3197 SET_EXPECT(global_propputref_i
);
3198 run_script(L
"testPropPutRef = testObj;");
3199 CHECK_CALLED(global_propputref_d
);
3200 CHECK_CALLED(global_propputref_i
);
3202 SET_EXPECT(global_success_d
);
3203 SET_EXPECT(global_success_i
);
3204 run_script(L
"reportSuccess();");
3205 CHECK_CALLED(global_success_d
);
3206 CHECK_CALLED(global_success_i
);
3208 SET_EXPECT(testobj_delete_test
);
3209 run_script(L
"ok((delete testObj.deleteTest) === true, 'delete testObj.deleteTest did not return true');");
3210 CHECK_CALLED(testobj_delete_test
);
3212 SET_EXPECT(testobj_delete_nodelete
);
3213 run_script(L
"ok((delete testObj.noDeleteTest) === false, 'delete testObj.noDeleteTest did not return false');");
3214 CHECK_CALLED(testobj_delete_nodelete
);
3216 SET_EXPECT(global_propdelete_d
);
3217 SET_EXPECT(DeleteMemberByDispID
);
3218 run_script(L
"ok((delete testPropDelete) === true, 'delete testPropDelete did not return true');");
3219 CHECK_CALLED(global_propdelete_d
);
3220 CHECK_CALLED(DeleteMemberByDispID
);
3222 SET_EXPECT(global_nopropdelete_d
);
3223 SET_EXPECT(DeleteMemberByDispID_false
);
3224 run_script(L
"ok((delete testNoPropDelete) === false, 'delete testPropDelete did not return false');");
3225 CHECK_CALLED(global_nopropdelete_d
);
3226 CHECK_CALLED(DeleteMemberByDispID_false
);
3228 SET_EXPECT(global_propdeleteerror_d
);
3229 SET_EXPECT(DeleteMemberByDispID_error
);
3230 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, L
"delete testPropDeleteError;");
3231 ok(hres
== E_FAIL
, "unexpected result %08x\n", hres
);
3232 CHECK_CALLED(global_propdeleteerror_d
);
3233 CHECK_CALLED(DeleteMemberByDispID_error
);
3235 SET_EXPECT(puredisp_prop_d
);
3236 run_script(L
"ok((delete pureDisp.prop) === false, 'delete pureDisp.prop did not return true');");
3237 CHECK_CALLED(puredisp_prop_d
);
3239 SET_EXPECT(puredisp_noprop_d
);
3240 run_script(L
"ok((delete pureDisp.noprop) === true, 'delete pureDisp.noprop did not return false');");
3241 CHECK_CALLED(puredisp_noprop_d
);
3243 SET_EXPECT(puredisp_value
);
3244 run_script(L
"var t=pureDisp; t=t(false);");
3245 CHECK_CALLED(puredisp_value
);
3247 SET_EXPECT(puredisp_value
);
3248 run_script(L
"var t = {func: pureDisp}; t = t.func(false);");
3249 CHECK_CALLED(puredisp_value
);
3251 SET_EXPECT(dispexfunc_value
);
3252 run_script(L
"var t = dispexFunc; t = t(false);");
3253 CHECK_CALLED(dispexfunc_value
);
3255 SET_EXPECT(dispexfunc_value
);
3256 run_script(L
"var t = {func: dispexFunc}; t = t.func(false);");
3257 CHECK_CALLED(dispexfunc_value
);
3259 SET_EXPECT(dispexfunc_value
);
3260 run_script(L
"Function.prototype.apply.call(dispexFunc, testObj, [true]);");
3261 CHECK_CALLED(dispexfunc_value
);
3263 SET_EXPECT(puredisp_value
);
3264 run_script(L
"Function.prototype.apply.call(pureDisp, testObj, [true]);");
3265 CHECK_CALLED(puredisp_value
);
3267 run_script(L
"(function reportSuccess() {})()");
3269 run_script(L
"ok(typeof(test) === 'object', \"typeof(test) != 'object'\");");
3271 run_script(L
"function reportSuccess() {}; reportSuccess();");
3273 SET_EXPECT(global_propget_d
);
3274 run_script(L
"var testPropGet");
3275 CHECK_CALLED(global_propget_d
);
3277 SET_EXPECT(global_propget_d
);
3278 run_script(L
"eval('var testPropGet;');");
3279 CHECK_CALLED(global_propget_d
);
3281 run_script(L
"var testPropGet; function testPropGet() {}");
3283 SET_EXPECT(global_notexists_d
);
3284 run_script(L
"var notExists; notExists = 1;");
3285 CHECK_CALLED(global_notexists_d
);
3287 SET_EXPECT(testobj_notexists_d
);
3288 run_script(L
"testObj.notExists;");
3289 CHECK_CALLED(testobj_notexists_d
);
3291 run_script(L
"function f() { var testPropGet; }");
3292 run_script(L
"(function () { var testPropGet; })();");
3293 run_script(L
"(function () { eval('var testPropGet;'); })();");
3295 SET_EXPECT(invoke_func
);
3296 run_script(L
"ok(propGetFunc() == 0, \"Incorrect propGetFunc value\");");
3297 CHECK_CALLED(invoke_func
);
3298 run_script(L
"ok(propGetFunc(1) == 1, \"Incorrect propGetFunc value\");");
3299 run_script(L
"ok(propGetFunc(1, 2) == 2, \"Incorrect propGetFunc value\");");
3300 SET_EXPECT(invoke_func
);
3301 run_script(L
"ok(propGetFunc().toString() == 0, \"Incorrect propGetFunc value\");");
3302 CHECK_CALLED(invoke_func
);
3303 run_script(L
"ok(propGetFunc(1).toString() == 1, \"Incorrect propGetFunc value\");");
3304 SET_EXPECT(invoke_func
);
3305 run_script(L
"propGetFunc(1);");
3306 CHECK_CALLED(invoke_func
);
3308 run_script(L
"objectFlag(1).toString();");
3310 run_script(L
"(function() { var tmp = (function () { return testObj; })()(1);})();");
3311 run_script(L
"(function() { var tmp = (function () { return testObj; })()();})();");
3313 run_script(L
"ok((testObj instanceof Object) === false, 'testObj is instance of Object');");
3315 SET_EXPECT(testobj_prop_d
);
3316 run_script(L
"ok(('prop' in testObj) === true, 'prop is not in testObj');");
3317 CHECK_CALLED(testobj_prop_d
);
3319 SET_EXPECT(testobj_noprop_d
);
3320 run_script(L
"ok(('noprop' in testObj) === false, 'noprop is in testObj');");
3321 CHECK_CALLED(testobj_noprop_d
);
3323 SET_EXPECT(testobj_prop_d
);
3324 run_script(L
"ok(Object.prototype.hasOwnProperty.call(testObj, 'prop') === true, 'hasOwnProperty(\\\"prop\\\") returned false');");
3325 CHECK_CALLED(testobj_prop_d
);
3327 SET_EXPECT(testobj_noprop_d
);
3328 run_script(L
"ok(Object.prototype.hasOwnProperty.call(testObj, 'noprop') === false, 'hasOwnProperty(\\\"noprop\\\") returned true');");
3329 CHECK_CALLED(testobj_noprop_d
);
3331 SET_EXPECT(puredisp_prop_d
);
3332 run_script(L
"ok(Object.prototype.hasOwnProperty.call(pureDisp, 'prop') === true, 'hasOwnProperty(\\\"noprop\\\") returned false');");
3333 CHECK_CALLED(puredisp_prop_d
);
3335 SET_EXPECT(puredisp_noprop_d
);
3336 run_script(L
"ok(Object.prototype.hasOwnProperty.call(pureDisp, 'noprop') === false, 'hasOwnProperty(\\\"noprop\\\") returned true');");
3337 CHECK_CALLED(puredisp_noprop_d
);
3339 SET_EXPECT(testobj_value
);
3340 run_script(L
"ok(String(testObj) === '1', 'wrong testObj value');");
3341 CHECK_CALLED(testobj_value
);
3343 SET_EXPECT(testobj_value
);
3344 run_script(L
"ok(String.prototype.concat.call(testObj, ' OK') === '1 OK', 'wrong concat result');");
3345 CHECK_CALLED(testobj_value
);
3347 SET_EXPECT(testobj_construct
);
3348 run_script(L
"var t = new testObj(1);");
3349 CHECK_CALLED(testobj_construct
);
3351 SET_EXPECT(global_propget_d
);
3352 SET_EXPECT(global_propget_i
);
3353 run_script(L
"this.testPropGet;");
3354 CHECK_CALLED(global_propget_d
);
3355 CHECK_CALLED(global_propget_i
);
3357 SET_EXPECT(global_propputref_d
);
3358 SET_EXPECT(global_propputref_i
);
3359 run_script(L
"testPropPutRef = nullDisp;");
3360 CHECK_CALLED(global_propputref_d
);
3361 CHECK_CALLED(global_propputref_i
);
3363 SET_EXPECT(global_propget_d
);
3364 SET_EXPECT(global_propget_i
);
3365 run_script(L
"(function () { this.testPropGet; })();");
3366 CHECK_CALLED(global_propget_d
);
3367 CHECK_CALLED(global_propget_i
);
3369 run_script(L
"testThis(this);");
3370 run_script(L
"(function () { testThis(this); })();");
3371 run_script(L
"function x() { testThis(this); }; x();");
3372 run_script(L
"var t = {func: function () { ok(this === t, 'this !== t'); }}; with(t) { func(); }");
3373 run_script(L
"function x() { testThis(this); }; with({y: 1}) { x(); }");
3374 run_script(L
"(function () { function x() { testThis(this);} x(); })();");
3376 SET_EXPECT(testobj_onlydispid_d
);
3377 SET_EXPECT(testobj_onlydispid_i
);
3378 run_script(L
"ok(typeof(testObj.onlyDispID) === 'unknown', 'unexpected typeof(testObj.onlyDispID)');");
3379 CHECK_CALLED(testobj_onlydispid_d
);
3380 CHECK_CALLED(testobj_onlydispid_i
);
3382 SET_EXPECT(testobj_getidfail_d
);
3383 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, L
"testObj.notExists = testObj.getIDFail;");
3384 ok(hres
== E_FAIL
, "parse_script returned %08x\n", hres
);
3385 CHECK_CALLED(testobj_getidfail_d
);
3387 SET_EXPECT(global_propget_d
);
3388 SET_EXPECT(global_propget_i
);
3389 SET_EXPECT(testobj_getidfail_d
);
3390 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, L
"testObj.getIDFail = testPropGet;");
3391 ok(hres
== E_FAIL
, "parse_script returned %08x\n", hres
);
3392 CHECK_CALLED(global_propget_d
);
3393 CHECK_CALLED(global_propget_i
);
3394 CHECK_CALLED(testobj_getidfail_d
);
3396 SET_EXPECT(global_propargput_d
);
3397 SET_EXPECT(global_propargput_i
);
3398 run_script(L
"var t=0; propArgPutG(t++, t++) = t++;");
3399 CHECK_CALLED(global_propargput_d
);
3400 CHECK_CALLED(global_propargput_i
);
3402 SET_EXPECT(global_propargput_d
);
3403 SET_EXPECT(global_propargput_i
);
3404 run_script(L
"var t=0; test.propArgPutO(t++, t++) = t++;");
3405 CHECK_CALLED(global_propargput_d
);
3406 CHECK_CALLED(global_propargput_i
);
3408 SET_EXPECT(global_propargputop_d
);
3409 SET_EXPECT(global_propargputop_get_i
);
3410 SET_EXPECT(global_propargputop_put_i
);
3411 run_script(L
"var t=0; propArgPutOp(t++, t++) += t++;");
3412 CHECK_CALLED(global_propargputop_d
);
3413 CHECK_CALLED(global_propargputop_get_i
);
3414 CHECK_CALLED(global_propargputop_put_i
);
3416 SET_EXPECT(global_propargputop_d
);
3417 SET_EXPECT(global_propargputop_get_i
);
3418 SET_EXPECT(global_propargputop_put_i
);
3419 run_script(L
"var t=0; propArgPutOp(t++, t++) ^= 14;");
3420 CHECK_CALLED(global_propargputop_d
);
3421 CHECK_CALLED(global_propargputop_get_i
);
3422 CHECK_CALLED(global_propargputop_put_i
);
3424 SET_EXPECT(global_testargtypes_i
);
3425 run_script(L
"testArgTypes(dispUnk, intProp(), intProp, getShort(), shortProp,"
3426 L
"function(i1,ui1,ui2,r4,i4ref,ui4,nullunk,d,i,s) {"
3427 L
" ok(getVT(i) === 'VT_I4', 'getVT(i) = ' + getVT(i));"
3428 L
" ok(getVT(s) === 'VT_I4', 'getVT(s) = ' + getVT(s));"
3429 L
" ok(getVT(d) === 'VT_DISPATCH', 'getVT(d) = ' + getVT(d));"
3430 L
" ok(getVT(nullunk) === 'VT_DISPATCH', 'getVT(nullunk) = ' + getVT(nullunk));"
3431 L
" ok(nullunk === null, 'nullunk !== null');"
3432 L
" ok(getVT(ui4) === 'VT_R8', 'getVT(ui4) = ' + getVT(ui4));"
3433 L
" ok(ui4 > 0, 'ui4 = ' + ui4);"
3434 L
" ok(getVT(i4ref) === 'VT_I4', 'getVT(i4ref) = ' + getVT(i4ref));"
3435 L
" ok(i4ref === 2, 'i4ref = ' + i4ref);"
3436 L
" ok(r4 === 0.5, 'r4 = ' + r4);"
3437 L
" ok(getVT(r4) === 'VT_R8', 'getVT(r4) = ' + getVT(r4));"
3438 L
" ok(getVT(ui2) === 'VT_I4', 'getVT(ui2) = ' + getVT(ui2));"
3439 L
" ok(getVT(ui1) === 'VT_I4', 'getVT(ui1) = ' + getVT(ui1));"
3440 L
" ok(ui1 === 4, 'ui1 = ' + ui1);"
3441 L
" ok(getVT(i1) === 'VT_I4', 'getVT(i1) = ' + getVT(i1));"
3442 L
" ok(i1 === 5, 'i1 = ' + i1);"
3444 CHECK_CALLED(global_testargtypes_i
);
3446 SET_EXPECT(testobj_withprop_d
);
3447 SET_EXPECT(testobj_withprop_i
);
3448 run_script(L
"var t = (function () { with(testObj) { return withProp; }})(); ok(t === 1, 't = ' + t);");
3449 CHECK_CALLED(testobj_withprop_d
);
3450 CHECK_CALLED(testobj_withprop_i
);
3452 run_script(L
"@set @t=2\nok(@t === 2, '@t = ' + @t);");
3454 SET_EXPECT(global_success_d
);
3455 SET_EXPECT(global_success_i
);
3456 run_script(L
"@if(true)\nif(@_jscript) reportSuccess();\n@end");
3457 CHECK_CALLED(global_success_d
);
3458 CHECK_CALLED(global_success_i
);
3460 EnumVARIANT_index
= 0;
3461 EnumVARIANT_next_0_count
= 1;
3462 SET_EXPECT(testobj_newenum
);
3463 SET_EXPECT(enumvariant_next_0
);
3464 run_script(L
"new Enumerator(testObj);");
3465 CHECK_CALLED(testobj_newenum
);
3466 CHECK_CALLED(enumvariant_next_0
);
3468 EnumVARIANT_index
= 0;
3469 EnumVARIANT_next_0_count
= 2;
3470 SET_EXPECT(testobj_newenum
);
3471 SET_EXPECT(enumvariant_next_0
);
3472 SET_EXPECT(enumvariant_reset
);
3473 run_script(L
"(function () {"
3474 L
" var testEnumObj = new Enumerator(testObj);"
3475 L
" var tmp = testEnumObj.moveFirst();"
3476 L
" ok(tmp == undefined, \"testEnumObj.moveFirst() = \" + tmp);"
3478 CHECK_CALLED(testobj_newenum
);
3479 CHECK_CALLED(enumvariant_next_0
);
3480 CHECK_CALLED(enumvariant_reset
);
3482 EnumVARIANT_index
= 0;
3483 EnumVARIANT_next_0_count
= 1;
3484 SET_EXPECT(testobj_newenum
);
3485 SET_EXPECT(enumvariant_next_0
);
3486 SET_EXPECT(enumvariant_next_1
);
3487 run_script(L
"(function () {"
3488 L
" var testEnumObj = new Enumerator(testObj);"
3489 L
" while (!testEnumObj.atEnd())"
3491 L
" ok(testEnumObj.item() == 123, "
3492 L
" \"testEnumObj.item() = \"+testEnumObj.item());"
3493 L
" testEnumObj.moveNext();"
3496 CHECK_CALLED(testobj_newenum
);
3497 CHECK_CALLED(enumvariant_next_0
);
3498 CHECK_CALLED(enumvariant_next_1
);
3500 run_from_res("lang.js");
3501 run_from_res("api.js");
3502 run_from_res("regexp.js");
3503 run_from_res("cc.js");
3505 test_isvisible(FALSE
);
3506 test_isvisible(TRUE
);
3510 hres
= parse_script(0, L
"test.testThis2(this);");
3511 ok(hres
== S_OK
, "unexpected result %08x\n", hres
);
3512 hres
= parse_script(0, L
"(function () { test.testThis2(this); })();");
3513 ok(hres
== S_OK
, "unexpected result %08x\n", hres
);
3515 hres
= parse_htmlscript(L
"<!--");
3516 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
3517 hres
= parse_htmlscript(L
"-->");
3518 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
3519 hres
= parse_htmlscript(L
"<!--\nvar a=1;\n-->\n");
3520 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
3521 hres
= parse_htmlscript(L
"<!--\n<!-- ignore this\n-->\n");
3522 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
3523 hres
= parse_htmlscript(L
"var a=1;\nif(a-->0) a=5;\n");
3524 ok(hres
== S_OK
, "ParseScriptText failed: %08x\n", hres
);
3525 hres
= parse_htmlscript(L
"var a=1;\nif(a\n-->0) a=5;\n");
3526 ok(hres
!= S_OK
, "ParseScriptText have not failed\n");
3528 test_script_exprs();
3531 test_error_reports();
3538 static void test_parse_proc(void)
3541 DISPPARAMS dp
= {args
};
3544 invoke_procedure(NULL
, L
"return true;", &dp
);
3547 V_VT(args
) = VT_EMPTY
;
3548 invoke_procedure(NULL
, L
"return arguments.length == 1;", &dp
);
3550 V_VT(args
) = VT_BOOL
;
3551 V_BOOL(args
) = VARIANT_TRUE
;
3552 invoke_procedure(L
" x ", L
"return x;", &dp
);
3557 V_VT(args
+1) = VT_I4
;
3559 invoke_procedure(L
" _x1 , y_2", L
"return _x1 === 1 && y_2 === 2;", &dp
);
3562 static void run_encoded_tests(void)
3567 engine_clsid
= &CLSID_JScriptEncode
;
3569 SET_EXPECT(global_success_d
);
3570 SET_EXPECT(global_success_i
);
3571 /* |reportSuccess(); | */
3572 run_script(L
"#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3573 CHECK_CALLED(global_success_d
);
3574 CHECK_CALLED(global_success_i
);
3576 SET_EXPECT(global_success_d
);
3577 SET_EXPECT(global_success_i
);
3578 run_script(L
"reportSuccess();");
3579 CHECK_CALLED(global_success_d
);
3580 CHECK_CALLED(global_success_i
);
3582 SET_EXPECT(global_success_d
);
3583 SET_EXPECT(global_success_i
);
3585 run_script(L
"report#@~^BwAAAA==j!m^\x7f/k2QIAAA==^#~@();");
3586 CHECK_CALLED(global_success_d
);
3587 CHECK_CALLED(global_success_i
);
3589 SET_EXPECT(global_success_d
);
3590 SET_EXPECT(global_success_i
);
3591 /* |\r\n\treportSuccess();\r\n | */
3592 run_script(L
"#@~^GQAAAA==@#@&d.\x7fwKDYUE1^+k/c#p@#@&OAYAAA==^#~@");
3593 CHECK_CALLED(global_success_d
);
3594 CHECK_CALLED(global_success_i
);
3597 src
= SysAllocString(L
"#@~^EAA*AA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3598 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3600 ok(hres
== JS_E_INVALID_CHAR
, "parse_script failed %08x\n", hres
);
3603 src
= SysAllocString(L
"#@~^EAAAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3604 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3606 ok(hres
== JS_E_INVALID_CHAR
, "parse_script failed %08x\n", hres
);
3609 src
= SysAllocString(L
"#@~^EAAAAA^=.\x7fwGMYUEm1+kd`*iAQYAAA==^#~@");
3610 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3612 ok(hres
== JS_E_INVALID_CHAR
, "parse_script failed %08x\n", hres
);
3615 src
= SysAllocString(L
"#@~^EAAAAA==.\x7fwGMYUEm1ekd`*iAQYAAA==^#~@");
3616 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3618 ok(hres
== JS_E_INVALID_CHAR
, "parse_script failed %08x\n", hres
);
3621 src
= SysAllocString(L
"#@~^EAAAAA==.\x7fwGMYUEm1+kd`*iAQYAAA==^~#@");
3622 hres
= parse_script(SCRIPTITEM_GLOBALMEMBERS
, src
);
3624 ok(hres
== JS_E_INVALID_CHAR
, "parse_script failed %08x\n", hres
);
3627 static void run_benchmark(const char *script_name
)
3629 IActiveScriptParse
*parser
;
3630 IActiveScript
*engine
;
3635 engine
= create_script();
3639 hres
= IActiveScript_QueryInterface(engine
, &IID_IActiveScriptParse
, (void**)&parser
);
3640 ok(hres
== S_OK
, "Could not get IActiveScriptParse: %08x\n", hres
);
3642 IActiveScript_Release(engine
);
3646 hres
= IActiveScriptParse_InitNew(parser
);
3647 ok(hres
== S_OK
, "InitNew failed: %08x\n", hres
);
3649 hres
= IActiveScript_SetScriptSite(engine
, &ActiveScriptSite
);
3650 ok(hres
== S_OK
, "SetScriptSite failed: %08x\n", hres
);
3652 hres
= IActiveScript_AddNamedItem(engine
, L
"test",
3653 SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
);
3654 ok(hres
== S_OK
, "AddNamedItem failed: %08x\n", hres
);
3656 hres
= IActiveScript_SetScriptState(engine
, SCRIPTSTATE_STARTED
);
3657 ok(hres
== S_OK
, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres
);
3659 src
= load_res(script_name
);
3661 start
= GetTickCount();
3662 hres
= IActiveScriptParse_ParseScriptText(parser
, src
, NULL
, NULL
, NULL
, 0, 0, 0, NULL
, NULL
);
3663 end
= GetTickCount();
3664 ok(hres
== S_OK
, "%s: ParseScriptText failed: %08x\n", script_name
, hres
);
3666 trace("%s ran in %u ms\n", script_name
, end
-start
);
3668 IActiveScript_Release(engine
);
3669 IActiveScriptParse_Release(parser
);
3673 static void run_benchmarks(void)
3675 trace("Running benchmarks...\n");
3677 run_benchmark("dna.js");
3678 run_benchmark("base64.js");
3679 run_benchmark("validateinput.js");
3682 static BOOL
check_jscript(void)
3684 IActiveScriptProperty
*script_prop
;
3687 hres
= CoCreateInstance(&CLSID_JScript
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
3688 &IID_IActiveScriptProperty
, (void**)&script_prop
);
3691 IActiveScriptProperty_Release(script_prop
);
3693 return parse_script(0, L
"if(!('localeCompare' in String.prototype)) throw 1;") == S_OK
;
3701 argc
= winetest_get_mainargs(&argv
);
3705 if(!check_jscript()) {
3706 win_skip("Broken engine, probably too old\n");
3707 }else if(argc
> 2) {
3709 run_from_file(argv
[2]);
3711 trace("invoke version 0\n");
3715 trace("invoke version 2\n");
3718 trace("JSctipt.Encode tests...\n");
3719 run_encoded_tests();
3720 trace("ParseProcedureText tests...\n");
3724 if(winetest_interactive
)