2 * Copyright 2008-2009 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
22 #include <wine/test.h>
40 #include "mshtml_test.h"
42 DEFINE_GUID(CLSID_IdentityUnmarshal
,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
44 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
45 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
46 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
50 #define CTXARG_T DWORDLONG
51 #define IActiveScriptParseVtbl IActiveScriptParse64Vtbl
52 #define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_64Vtbl
53 #define IActiveScriptSiteDebug_Release IActiveScriptSiteDebug64_Release
57 #define CTXARG_T DWORD
58 #define IActiveScriptParseVtbl IActiveScriptParse32Vtbl
59 #define IActiveScriptParseProcedure2Vtbl IActiveScriptParseProcedure2_32Vtbl
60 #define IActiveScriptSiteDebug_Release IActiveScriptSiteDebug32_Release
64 #define DEFINE_EXPECT(func) \
65 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
67 #define SET_EXPECT(func) \
68 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
70 #define CHECK_EXPECT2(func) \
72 ok(expect_ ##func, "unexpected call " #func "\n"); \
73 called_ ## func = TRUE; \
76 #define CHECK_EXPECT(func) \
78 CHECK_EXPECT2(func); \
79 expect_ ## func = FALSE; \
82 #define CHECK_CALLED(func) \
84 ok(called_ ## func, "expected " #func "\n"); \
85 expect_ ## func = called_ ## func = FALSE; \
88 #define CHECK_CALLED_BROKEN(func) \
90 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
91 expect_ ## func = called_ ## func = FALSE; \
94 #define CHECK_NOT_CALLED(func) \
96 ok(!called_ ## func, "unexpected " #func "\n"); \
97 expect_ ## func = called_ ## func = FALSE; \
100 #define CLEAR_CALLED(func) \
101 expect_ ## func = called_ ## func = FALSE
104 DEFINE_EXPECT(CreateInstance
);
105 DEFINE_EXPECT(GetInterfaceSafetyOptions
);
106 DEFINE_EXPECT(SetInterfaceSafetyOptions
);
107 DEFINE_EXPECT(InitNew
);
108 DEFINE_EXPECT(Close
);
109 DEFINE_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
110 DEFINE_EXPECT(SetProperty_INVOKEVERSIONING
);
111 DEFINE_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
);
112 DEFINE_EXPECT(SetScriptSite
);
113 DEFINE_EXPECT(GetScriptState
);
114 DEFINE_EXPECT(SetScriptState_STARTED
);
115 DEFINE_EXPECT(SetScriptState_CONNECTED
);
116 DEFINE_EXPECT(SetScriptState_DISCONNECTED
);
117 DEFINE_EXPECT(AddNamedItem
);
118 DEFINE_EXPECT(ParseScriptText_script
);
119 DEFINE_EXPECT(ParseScriptText_execScript
);
120 DEFINE_EXPECT(GetScriptDispatch
);
121 DEFINE_EXPECT(funcDisp
);
122 DEFINE_EXPECT(script_divid_d
);
123 DEFINE_EXPECT(script_testprop_d
);
124 DEFINE_EXPECT(script_testprop_i
);
125 DEFINE_EXPECT(script_testprop2_d
);
126 DEFINE_EXPECT(AXQueryInterface_IActiveScript
);
127 DEFINE_EXPECT(AXQueryInterface_IObjectSafety
);
128 DEFINE_EXPECT(AXGetInterfaceSafetyOptions
);
129 DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
130 DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
131 DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
132 DEFINE_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
133 DEFINE_EXPECT(external_success
);
134 DEFINE_EXPECT(QS_VariantConversion
);
135 DEFINE_EXPECT(QS_IActiveScriptSite
);
136 DEFINE_EXPECT(QS_GetCaller
);
137 DEFINE_EXPECT(ChangeType
);
139 #define TESTSCRIPT_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80746}"
140 #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7faf80646}"
142 #define DISPID_SCRIPT_TESTPROP 0x100000
143 #define DISPID_SCRIPT_TESTPROP2 0x100001
145 #define DISPID_EXTERNAL_OK 0x300000
146 #define DISPID_EXTERNAL_TRACE 0x300001
147 #define DISPID_EXTERNAL_REPORTSUCCESS 0x300002
148 #define DISPID_EXTERNAL_TODO_WINE_OK 0x300003
150 static const GUID CLSID_TestScript
=
151 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}};
152 static const GUID CLSID_TestActiveX
=
153 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
155 static BOOL is_ie9plus
;
156 static IHTMLDocument2
*notif_doc
;
157 static IOleDocumentView
*view
;
158 static IDispatchEx
*window_dispex
;
159 static BOOL doc_complete
;
160 static IDispatch
*script_disp
;
161 static BOOL ax_objsafe
;
162 static HWND container_hwnd
;
163 static HRESULT ax_getopt_hres
= S_OK
, ax_setopt_dispex_hres
= S_OK
;
164 static HRESULT ax_setopt_disp_caller_hres
= S_OK
, ax_setopt_disp_data_hres
= S_OK
;
165 static BOOL skip_loadobject_tests
;
167 static IActiveScriptSite
*site
;
168 static SCRIPTSTATE state
;
170 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
173 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
174 return lstrcmpA(stra
, buf
);
177 static BSTR
a2bstr(const char *str
)
185 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
186 ret
= SysAllocStringLen(NULL
, len
);
187 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
192 static BOOL
init_key(const char *key_name
, const char *def_value
, BOOL init
)
198 RegDeleteKeyA(HKEY_CLASSES_ROOT
, key_name
);
202 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, key_name
, &hkey
);
203 if(res
!= ERROR_SUCCESS
)
207 res
= RegSetValueA(hkey
, NULL
, REG_SZ
, def_value
, strlen(def_value
));
211 return res
== ERROR_SUCCESS
;
214 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
215 REFIID riid
, void**ppv
)
217 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
222 return E_NOINTERFACE
;
225 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
230 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
235 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
237 if(dispID
== DISPID_READYSTATE
){
241 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
243 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
244 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
246 if(!lstrcmpW(state
, completeW
))
249 SysFreeString(state
);
255 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
257 ok(0, "unexpected call\n");
261 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
262 PropertyNotifySink_QueryInterface
,
263 PropertyNotifySink_AddRef
,
264 PropertyNotifySink_Release
,
265 PropertyNotifySink_OnChanged
,
266 PropertyNotifySink_OnRequestEdit
269 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
271 static HRESULT WINAPI
VariantChangeType_QueryInterface(IVariantChangeType
*iface
, REFIID riid
, void **ppv
)
273 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid
));
275 return E_NOINTERFACE
;
278 static ULONG WINAPI
VariantChangeType_AddRef(IVariantChangeType
*iface
)
283 static ULONG WINAPI
VariantChangeType_Release(IVariantChangeType
*iface
)
288 static HRESULT WINAPI
VariantChangeType_ChangeType(IVariantChangeType
*iface
, VARIANT
*dst
, VARIANT
*src
, LCID lcid
, VARTYPE vt
)
290 CHECK_EXPECT(ChangeType
);
292 ok(dst
!= NULL
, "dst = NULL\n");
293 ok(V_VT(dst
) == VT_EMPTY
, "V_VT(dst) = %d\n", V_VT(dst
));
294 ok(src
!= NULL
, "src = NULL\n");
295 ok(V_VT(src
) == VT_I4
, "V_VT(src) = %d\n", V_VT(src
));
296 ok(V_I4(src
) == 0xf0f0f0, "V_I4(src) = %x\n", V_I4(src
));
297 ok(lcid
== LOCALE_NEUTRAL
, "lcid = %d\n", lcid
);
298 ok(vt
== VT_BSTR
, "vt = %d\n", vt
);
301 V_BSTR(dst
) = a2bstr("red");
305 static const IVariantChangeTypeVtbl VariantChangeTypeVtbl
= {
306 VariantChangeType_QueryInterface
,
307 VariantChangeType_AddRef
,
308 VariantChangeType_Release
,
309 VariantChangeType_ChangeType
312 static IVariantChangeType VChangeType
= { &VariantChangeTypeVtbl
};
314 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
316 ok(0, "unexpected call\n");
317 return E_NOINTERFACE
;
320 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
325 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
330 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
331 REFIID riid
, void **ppv
)
333 if(IsEqualGUID(guidService
, &SID_VariantConversion
)) {
334 CHECK_EXPECT(QS_VariantConversion
);
335 ok(IsEqualGUID(riid
, &IID_IVariantChangeType
), "uenxpected riid %s\n", wine_dbgstr_guid(riid
));
340 if(IsEqualGUID(guidService
, &IID_IActiveScriptSite
)) {
341 CHECK_EXPECT(QS_IActiveScriptSite
);
342 ok(IsEqualGUID(riid
, &IID_IOleCommandTarget
), "uenxpected riid %s\n", wine_dbgstr_guid(riid
));
343 return IActiveScriptSite_QueryInterface(site
, riid
, ppv
);
346 if(IsEqualGUID(guidService
, &SID_GetCaller
)) {
347 CHECK_EXPECT(QS_GetCaller
);
348 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "uenxpected riid %s\n", wine_dbgstr_guid(riid
));
350 return E_NOINTERFACE
;
353 ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService
));
354 return E_NOINTERFACE
;
357 static const IServiceProviderVtbl ServiceProviderVtbl
= {
358 ServiceProvider_QueryInterface
,
359 ServiceProvider_AddRef
,
360 ServiceProvider_Release
,
361 ServiceProvider_QueryService
364 static IServiceProvider caller_sp
= { &ServiceProviderVtbl
};
366 static HRESULT WINAPI
DispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
370 if(IsEqualGUID(riid
, &IID_IUnknown
)
371 || IsEqualGUID(riid
, &IID_IDispatch
)
372 || IsEqualGUID(riid
, &IID_IDispatchEx
))
375 return E_NOINTERFACE
;
380 static ULONG WINAPI
DispatchEx_AddRef(IDispatchEx
*iface
)
385 static ULONG WINAPI
DispatchEx_Release(IDispatchEx
*iface
)
390 static HRESULT WINAPI
DispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
392 ok(0, "unexpected call\n");
396 static HRESULT WINAPI
DispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
397 LCID lcid
, ITypeInfo
**ppTInfo
)
399 ok(0, "unexpected call\n");
403 static HRESULT WINAPI
DispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
404 LPOLESTR
*rgszNames
, UINT cNames
,
405 LCID lcid
, DISPID
*rgDispId
)
407 ok(0, "unexpected call\n");
411 static HRESULT WINAPI
DispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
412 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
413 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
415 ok(0, "unexpected call\n");
419 static HRESULT WINAPI
DispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
421 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName
), grfdex
);
425 static HRESULT WINAPI
DispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
427 ok(0, "unexpected call\n");
431 static HRESULT WINAPI
DispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
433 ok(0, "unexpected call\n");
437 static HRESULT WINAPI
DispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
439 ok(0, "unexpected call\n");
443 static HRESULT WINAPI
DispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
445 ok(0, "unexpected call\n");
449 static HRESULT WINAPI
DispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
451 ok(0, "unexpected call\n");
455 static HRESULT WINAPI
DispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
457 ok(0, "unexpected call\n");
461 static HRESULT WINAPI
funcDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
462 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
464 CHECK_EXPECT(funcDisp
);
466 ok(id
== DISPID_VALUE
, "id = %d\n", id
);
467 ok(lcid
== 0, "lcid = %x\n", lcid
);
468 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
469 ok(pdp
!= NULL
, "pdp == NULL\n");
470 ok(pdp
->cArgs
== 2, "pdp->cArgs = %d\n", pdp
->cArgs
);
471 ok(pdp
->cNamedArgs
== 1, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
472 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_THIS
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
473 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
474 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(rgvarg[1]) = %d\n", V_VT(pdp
->rgvarg
));
475 ok(V_BOOL(pdp
->rgvarg
+1) == VARIANT_TRUE
, "V_BOOL(rgvarg[1]) = %x\n", V_BOOL(pdp
->rgvarg
));
476 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
477 ok(pei
!= NULL
, "pei == NULL\n");
478 ok(!pspCaller
, "pspCaller != NULL\n");
480 V_VT(pvarRes
) = VT_I4
;
485 static IDispatchExVtbl testObjVtbl
= {
486 DispatchEx_QueryInterface
,
489 DispatchEx_GetTypeInfoCount
,
490 DispatchEx_GetTypeInfo
,
491 DispatchEx_GetIDsOfNames
,
493 DispatchEx_GetDispID
,
495 DispatchEx_DeleteMemberByName
,
496 DispatchEx_DeleteMemberByDispID
,
497 DispatchEx_GetMemberProperties
,
498 DispatchEx_GetMemberName
,
499 DispatchEx_GetNextDispID
,
500 DispatchEx_GetNameSpaceParent
503 static IDispatchEx funcDisp
= { &testObjVtbl
};
505 static HRESULT WINAPI
scriptDisp_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
507 if(!strcmp_wa(bstrName
, "testProp")) {
508 CHECK_EXPECT(script_testprop_d
);
509 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
510 *pid
= DISPID_SCRIPT_TESTPROP
;
514 if(!strcmp_wa(bstrName
, "testProp2")) {
515 CHECK_EXPECT(script_testprop2_d
);
516 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
517 *pid
= DISPID_SCRIPT_TESTPROP2
;
521 if(!strcmp_wa(bstrName
, "divid")) {
522 CHECK_EXPECT(script_divid_d
);
523 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
527 ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName
));
531 static HRESULT WINAPI
scriptDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
532 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
535 case DISPID_SCRIPT_TESTPROP
:
536 CHECK_EXPECT(script_testprop_i
);
538 ok(lcid
== 0, "lcid = %x\n", lcid
);
539 ok(wFlags
== DISPATCH_PROPERTYGET
, "wFlags = %x\n", wFlags
);
540 ok(pdp
!= NULL
, "pdp == NULL\n");
541 ok(pdp
->cArgs
== 0, "pdp->cArgs = %d\n", pdp
->cArgs
);
542 ok(pdp
->cNamedArgs
== 0, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
543 ok(!pdp
->rgdispidNamedArgs
, "pdp->rgdispidNamedArgs != NULL\n");
544 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
545 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
546 ok(pei
!= NULL
, "pei == NULL\n");
547 ok(!pspCaller
, "pspCaller != NULL\n");
549 V_VT(pvarRes
) = VT_NULL
;
552 ok(0, "unexpected call\n");
559 static IDispatchExVtbl scriptDispVtbl
= {
560 DispatchEx_QueryInterface
,
563 DispatchEx_GetTypeInfoCount
,
564 DispatchEx_GetTypeInfo
,
565 DispatchEx_GetIDsOfNames
,
567 scriptDisp_GetDispID
,
569 DispatchEx_DeleteMemberByName
,
570 DispatchEx_DeleteMemberByDispID
,
571 DispatchEx_GetMemberProperties
,
572 DispatchEx_GetMemberName
,
573 DispatchEx_GetNextDispID
,
574 DispatchEx_GetNameSpaceParent
577 static IDispatchEx scriptDisp
= { &scriptDispVtbl
};
579 static HRESULT WINAPI
externalDisp_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
581 if(!strcmp_wa(bstrName
, "ok")) {
582 *pid
= DISPID_EXTERNAL_OK
;
585 if(!strcmp_wa(bstrName
, "trace")) {
586 *pid
= DISPID_EXTERNAL_TRACE
;
589 if(!strcmp_wa(bstrName
, "reportSuccess")) {
590 *pid
= DISPID_EXTERNAL_REPORTSUCCESS
;
593 if(!strcmp_wa(bstrName
, "todo_wine_ok")) {
594 *pid
= DISPID_EXTERNAL_TODO_WINE_OK
;
598 ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName
));
599 return DISP_E_UNKNOWNNAME
;
602 static HRESULT WINAPI
externalDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
603 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
606 case DISPID_EXTERNAL_OK
: {
609 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
610 ok(pdp
!= NULL
, "pdp == NULL\n");
611 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
612 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
613 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
614 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
615 ok(pei
!= NULL
, "pei == NULL\n");
618 if(V_VT(m
) == (VT_BYREF
|VT_VARIANT
))
620 ok(V_VT(m
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
623 if(V_VT(b
) == (VT_BYREF
|VT_VARIANT
))
625 ok(V_VT(b
) == VT_BOOL
, "V_VT(b) = %d\n", V_VT(b
));
627 ok(V_BOOL(b
), "%s\n", wine_dbgstr_w(V_BSTR(m
)));
631 case DISPID_EXTERNAL_TRACE
:
632 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
633 ok(pdp
!= NULL
, "pdp == NULL\n");
634 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
635 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
636 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
637 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
638 ok(!pvarRes
, "pvarRes != NULL\n");
639 ok(pei
!= NULL
, "pei == NULL\n");
641 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
642 if(V_VT(pdp
->rgvarg
) == VT_BSTR
)
643 trace("%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
647 case DISPID_EXTERNAL_REPORTSUCCESS
:
648 CHECK_EXPECT(external_success
);
650 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
651 ok(pdp
!= NULL
, "pdp == NULL\n");
652 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
653 ok(pdp
->cArgs
== 0, "cArgs = %d\n", pdp
->cArgs
);
654 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
655 ok(!pvarRes
, "pvarRes != NULL\n");
656 ok(pei
!= NULL
, "pei == NULL\n");
660 case DISPID_EXTERNAL_TODO_WINE_OK
:
661 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
662 ok(pdp
!= NULL
, "pdp == NULL\n");
663 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
664 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
665 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
666 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
667 ok(pei
!= NULL
, "pei == NULL\n");
669 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
670 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp
->rgvarg
));
672 ok(V_BOOL(pdp
->rgvarg
+1), "%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
677 ok(0, "unexpected call\n");
684 static IDispatchExVtbl externalDispVtbl
= {
685 DispatchEx_QueryInterface
,
688 DispatchEx_GetTypeInfoCount
,
689 DispatchEx_GetTypeInfo
,
690 DispatchEx_GetIDsOfNames
,
692 externalDisp_GetDispID
,
693 externalDisp_InvokeEx
,
694 DispatchEx_DeleteMemberByName
,
695 DispatchEx_DeleteMemberByDispID
,
696 DispatchEx_GetMemberProperties
,
697 DispatchEx_GetMemberName
,
698 DispatchEx_GetNextDispID
,
699 DispatchEx_GetNameSpaceParent
702 static IDispatchEx externalDisp
= { &externalDispVtbl
};
704 static HRESULT
QueryInterface(REFIID
,void**);
706 static HRESULT WINAPI
DocHostUIHandler_QueryInterface(IDocHostUIHandler2
*iface
, REFIID riid
, void **ppv
)
708 return QueryInterface(riid
, ppv
);
711 static ULONG WINAPI
DocHostUIHandler_AddRef(IDocHostUIHandler2
*iface
)
716 static ULONG WINAPI
DocHostUIHandler_Release(IDocHostUIHandler2
*iface
)
721 static HRESULT WINAPI
DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2
*iface
, DWORD dwID
, POINT
*ppt
,
722 IUnknown
*pcmdtReserved
, IDispatch
*pdicpReserved
)
727 static HRESULT WINAPI
DocHostUIHandler_GetHostInfo(IDocHostUIHandler2
*iface
, DOCHOSTUIINFO
*pInfo
)
732 static HRESULT WINAPI
DocHostUIHandler_ShowUI(IDocHostUIHandler2
*iface
, DWORD dwID
,
733 IOleInPlaceActiveObject
*pActiveObject
, IOleCommandTarget
*pCommandTarget
,
734 IOleInPlaceFrame
*pFrame
, IOleInPlaceUIWindow
*pDoc
)
739 static HRESULT WINAPI
DocHostUIHandler_HideUI(IDocHostUIHandler2
*iface
)
744 static HRESULT WINAPI
DocHostUIHandler_UpdateUI(IDocHostUIHandler2
*iface
)
749 static HRESULT WINAPI
DocHostUIHandler_EnableModeless(IDocHostUIHandler2
*iface
, BOOL fEnable
)
754 static HRESULT WINAPI
DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
759 static HRESULT WINAPI
DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
764 static HRESULT WINAPI
DocHostUIHandler_ResizeBorder(IDocHostUIHandler2
*iface
, LPCRECT prcBorder
,
765 IOleInPlaceUIWindow
*pUIWindow
, BOOL fRameWindow
)
770 static HRESULT WINAPI
DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2
*iface
, LPMSG lpMsg
,
771 const GUID
*pguidCmdGroup
, DWORD nCmdID
)
776 static HRESULT WINAPI
DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2
*iface
,
777 LPOLESTR
*pchKey
, DWORD dw
)
782 static HRESULT WINAPI
DocHostUIHandler_GetDropTarget(IDocHostUIHandler2
*iface
,
783 IDropTarget
*pDropTarget
, IDropTarget
**ppDropTarget
)
788 static HRESULT WINAPI
DocHostUIHandler_GetExternal(IDocHostUIHandler2
*iface
, IDispatch
**ppDispatch
)
790 *ppDispatch
= (IDispatch
*)&externalDisp
;
794 static HRESULT WINAPI
DocHostUIHandler_TranslateUrl(IDocHostUIHandler2
*iface
, DWORD dwTranslate
,
795 OLECHAR
*pchURLIn
, OLECHAR
**ppchURLOut
)
800 static HRESULT WINAPI
DocHostUIHandler_FilterDataObject(IDocHostUIHandler2
*iface
, IDataObject
*pDO
,
801 IDataObject
**ppPORet
)
806 static HRESULT WINAPI
DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2
*iface
,
807 LPOLESTR
*pchKey
, DWORD dw
)
812 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl
= {
813 DocHostUIHandler_QueryInterface
,
814 DocHostUIHandler_AddRef
,
815 DocHostUIHandler_Release
,
816 DocHostUIHandler_ShowContextMenu
,
817 DocHostUIHandler_GetHostInfo
,
818 DocHostUIHandler_ShowUI
,
819 DocHostUIHandler_HideUI
,
820 DocHostUIHandler_UpdateUI
,
821 DocHostUIHandler_EnableModeless
,
822 DocHostUIHandler_OnDocWindowActivate
,
823 DocHostUIHandler_OnFrameWindowActivate
,
824 DocHostUIHandler_ResizeBorder
,
825 DocHostUIHandler_TranslateAccelerator
,
826 DocHostUIHandler_GetOptionKeyPath
,
827 DocHostUIHandler_GetDropTarget
,
828 DocHostUIHandler_GetExternal
,
829 DocHostUIHandler_TranslateUrl
,
830 DocHostUIHandler_FilterDataObject
,
831 DocHostUIHandler_GetOverrideKeyPath
834 static IDocHostUIHandler2 DocHostUIHandler
= { &DocHostUIHandlerVtbl
};
836 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
838 return E_NOINTERFACE
;
841 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
846 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
851 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
856 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
861 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
866 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
867 LPCBORDERWIDTHS pborderwidths
)
872 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
873 LPCBORDERWIDTHS pborderwidths
)
878 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
879 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
884 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
885 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
890 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
891 HOLEMENU holemenu
, HWND hwndActiveObject
)
893 ok(0, "unexpected call\n");
897 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
899 ok(0, "unexpected call\n");
903 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
908 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
913 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
915 ok(0, "unexpected call\n");
919 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
920 InPlaceFrame_QueryInterface
,
922 InPlaceFrame_Release
,
923 InPlaceFrame_GetWindow
,
924 InPlaceFrame_ContextSensitiveHelp
,
925 InPlaceFrame_GetBorder
,
926 InPlaceFrame_RequestBorderSpace
,
927 InPlaceFrame_SetBorderSpace
,
928 InPlaceFrame_SetActiveObject
,
929 InPlaceFrame_InsertMenus
,
930 InPlaceFrame_SetMenu
,
931 InPlaceFrame_RemoveMenus
,
932 InPlaceFrame_SetStatusText
,
933 InPlaceFrame_EnableModeless
,
934 InPlaceFrame_TranslateAccelerator
937 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
939 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
941 return QueryInterface(riid
, ppv
);
944 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
949 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
954 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
956 *phwnd
= container_hwnd
;
960 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
962 ok(0, "unexpected call\n");
966 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
971 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
976 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
981 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
982 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
983 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
985 static const RECT rect
= {0,0,300,300};
987 *ppFrame
= &InPlaceFrame
;
988 *ppDoc
= (IOleInPlaceUIWindow
*)&InPlaceFrame
;
990 *lprcClipRect
= rect
;
992 ok(lpFrameInfo
->cb
== sizeof(*lpFrameInfo
), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo
->cb
, (unsigned)sizeof(*lpFrameInfo
));
993 lpFrameInfo
->fMDIApp
= FALSE
;
994 lpFrameInfo
->hwndFrame
= container_hwnd
;
995 lpFrameInfo
->haccel
= NULL
;
996 lpFrameInfo
->cAccelEntries
= 0;
1001 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
1006 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
1011 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
1016 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
1021 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
1026 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
1031 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
1032 InPlaceSite_QueryInterface
,
1034 InPlaceSite_Release
,
1035 InPlaceSite_GetWindow
,
1036 InPlaceSite_ContextSensitiveHelp
,
1037 InPlaceSite_CanInPlaceActivate
,
1038 InPlaceSite_OnInPlaceActivate
,
1039 InPlaceSite_OnUIActivate
,
1040 InPlaceSite_GetWindowContext
,
1042 InPlaceSite_OnUIDeactivate
,
1043 InPlaceSite_OnInPlaceDeactivate
,
1044 InPlaceSite_DiscardUndoState
,
1045 InPlaceSite_DeactivateAndUndo
,
1046 InPlaceSite_OnPosRectChange
,
1049 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
1051 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
1053 return QueryInterface(riid
, ppv
);
1056 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
1061 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
1066 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
1068 ok(0, "unexpected call\n");
1072 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
1075 ok(0, "unexpected call\n");
1079 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
1084 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
1086 ok(0, "unexpected call\n");
1090 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
1092 ok(0, "unexpected call\n");
1096 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
1098 ok(0, "unexpected call\n");
1102 static const IOleClientSiteVtbl ClientSiteVtbl
= {
1103 ClientSite_QueryInterface
,
1106 ClientSite_SaveObject
,
1107 ClientSite_GetMoniker
,
1108 ClientSite_GetContainer
,
1109 ClientSite_ShowObject
,
1110 ClientSite_OnShowWindow
,
1111 ClientSite_RequestNewObjectLayout
1114 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
1116 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
1118 return QueryInterface(riid
, ppv
);
1121 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
1126 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
1131 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
1133 RECT rect
= {0,0,300,300};
1134 IOleDocument
*document
;
1137 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
1138 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
1140 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
1141 IOleDocument_Release(document
);
1142 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
1144 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
1145 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
1147 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
1148 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
1150 hres
= IOleDocumentView_SetRect(view
, &rect
);
1151 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
1153 hres
= IOleDocumentView_Show(view
, TRUE
);
1154 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
1159 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
1160 DocumentSite_QueryInterface
,
1161 DocumentSite_AddRef
,
1162 DocumentSite_Release
,
1163 DocumentSite_ActivateMe
1166 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
1168 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
1172 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
1174 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
1175 *ppv
= &DocumentSite
;
1176 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
1177 *ppv
= &InPlaceSite
;
1178 else if(IsEqualGUID(&IID_IDocHostUIHandler
, riid
) || IsEqualGUID(&IID_IDocHostUIHandler2
, riid
))
1179 *ppv
= &DocHostUIHandler
;
1181 return *ppv
? S_OK
: E_NOINTERFACE
;
1184 static IHTMLDocument2
*create_document(void)
1186 IHTMLDocument2
*doc
;
1189 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1190 &IID_IHTMLDocument2
, (void**)&doc
);
1191 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1192 return SUCCEEDED(hres
) ? doc
: NULL
;
1195 static void load_string(IHTMLDocument2
*doc
, const char *str
)
1197 IPersistStreamInit
*init
;
1202 doc_complete
= FALSE
;
1204 mem
= GlobalAlloc(0, len
);
1205 memcpy(mem
, str
, len
);
1206 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
1208 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
1210 IPersistStreamInit_Load(init
, stream
);
1211 IPersistStreamInit_Release(init
);
1212 IStream_Release(stream
);
1215 static void do_advise(IHTMLDocument2
*doc
, REFIID riid
, IUnknown
*unk_advise
)
1217 IConnectionPointContainer
*container
;
1218 IConnectionPoint
*cp
;
1222 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IConnectionPointContainer
, (void**)&container
);
1223 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
1225 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
1226 IConnectionPointContainer_Release(container
);
1227 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1231 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
1232 IConnectionPoint_Release(cp
);
1233 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1236 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
1242 IOleDocumentView_Show(view
, FALSE
);
1243 IOleDocumentView_CloseView(view
, 0);
1244 IOleDocumentView_SetInPlaceSite(view
, NULL
);
1245 IOleDocumentView_Release(view
);
1249 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
1250 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
1252 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
1253 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
1256 IHlinkTarget
*hlink
;
1258 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
1259 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
1261 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
1262 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
1264 IHlinkTarget_Release(hlink
);
1267 IOleObject_Release(oleobj
);
1270 typedef void (*domtest_t
)(IHTMLDocument2
*);
1272 static void load_doc(IHTMLDocument2
*doc
, const char *str
)
1274 IHTMLElement
*body
= NULL
;
1277 static const WCHAR ucPtr
[] = {'b','a','c','k','g','r','o','u','n','d',0};
1281 load_string(doc
, str
);
1282 do_advise(doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
1284 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
1285 TranslateMessage(&msg
);
1286 DispatchMessageW(&msg
);
1289 hres
= IHTMLDocument2_get_body(doc
, &body
);
1290 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1292 /* Check we can query for function on the IHTMLElementBody interface */
1293 name
= (WCHAR
*)ucPtr
;
1294 hres
= IHTMLElement_GetIDsOfNames(body
, &IID_NULL
, &name
, 1, LOCALE_USER_DEFAULT
, &dispID
);
1295 ok(hres
== S_OK
, "GetIDsOfNames(background) failed %08x\n", hres
);
1296 ok(dispID
== DISPID_IHTMLBODYELEMENT_BACKGROUND
, "Incorrect dispID got (%d)\n", dispID
);
1298 IHTMLElement_Release(body
);
1301 static HRESULT WINAPI
ObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1304 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid
));
1305 return E_NOINTERFACE
;
1308 static ULONG WINAPI
ObjectSafety_AddRef(IObjectSafety
*iface
)
1313 static ULONG WINAPI
ObjectSafety_Release(IObjectSafety
*iface
)
1318 static HRESULT WINAPI
ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1319 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1321 CHECK_EXPECT(GetInterfaceSafetyOptions
);
1323 ok(IsEqualGUID(&IID_IActiveScriptParse
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1324 ok(pdwSupportedOptions
!= NULL
, "pdwSupportedOptions == NULL\n");
1325 ok(pdwEnabledOptions
!= NULL
, "pdwEnabledOptions == NULL\n");
1327 *pdwSupportedOptions
= INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
;
1328 *pdwEnabledOptions
= INTERFACE_USES_DISPEX
;
1333 static HRESULT WINAPI
ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1334 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1336 CHECK_EXPECT(SetInterfaceSafetyOptions
);
1338 ok(IsEqualGUID(&IID_IActiveScriptParse
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1340 ok(dwOptionSetMask
== (INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
),
1341 "dwOptionSetMask=%x\n", dwOptionSetMask
);
1342 ok(dwEnabledOptions
== (INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
),
1343 "dwEnabledOptions=%x\n", dwOptionSetMask
);
1348 static const IObjectSafetyVtbl ObjectSafetyVtbl
= {
1349 ObjectSafety_QueryInterface
,
1350 ObjectSafety_AddRef
,
1351 ObjectSafety_Release
,
1352 ObjectSafety_GetInterfaceSafetyOptions
,
1353 ObjectSafety_SetInterfaceSafetyOptions
1356 static IObjectSafety ObjectSafety
= { &ObjectSafetyVtbl
};
1358 static HRESULT WINAPI
AXObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1362 if(IsEqualGUID(&IID_IActiveScript
, riid
)) {
1363 CHECK_EXPECT(AXQueryInterface_IActiveScript
);
1364 return E_NOINTERFACE
;
1367 if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
1368 CHECK_EXPECT2(AXQueryInterface_IObjectSafety
);
1370 return E_NOINTERFACE
;
1375 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid
));
1376 return E_NOINTERFACE
;
1379 static HRESULT WINAPI
AXObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1380 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1382 CHECK_EXPECT(AXGetInterfaceSafetyOptions
);
1384 ok(IsEqualGUID(&IID_IDispatchEx
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1385 ok(pdwSupportedOptions
!= NULL
, "pdwSupportedOptions == NULL\n");
1386 ok(pdwEnabledOptions
!= NULL
, "pdwEnabledOptions == NULL\n");
1388 if(SUCCEEDED(ax_getopt_hres
)) {
1389 *pdwSupportedOptions
= INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
;
1390 *pdwEnabledOptions
= INTERFACE_USES_DISPEX
;
1393 return ax_getopt_hres
;
1396 static HRESULT WINAPI
AXObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1397 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1399 if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
1400 switch(dwEnabledOptions
) {
1401 case INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACE_USES_SECURITY_MANAGER
:
1402 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1404 case INTERFACESAFE_FOR_UNTRUSTED_CALLER
:
1405 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1408 ok(0, "unexpected dwEnabledOptions %x\n", dwEnabledOptions
);
1411 ok(dwOptionSetMask
== dwEnabledOptions
, "dwOptionSetMask=%x, expected %x\n", dwOptionSetMask
, dwEnabledOptions
);
1412 return ax_setopt_dispex_hres
;
1415 if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1418 switch(dwEnabledOptions
) {
1419 case INTERFACESAFE_FOR_UNTRUSTED_CALLER
:
1420 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1421 hres
= ax_setopt_disp_caller_hres
;
1423 case INTERFACESAFE_FOR_UNTRUSTED_DATA
:
1424 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1425 hres
= ax_setopt_disp_data_hres
;
1428 ok(0, "unexpected dwEnabledOptions %x\n", dwEnabledOptions
);
1431 ok(dwOptionSetMask
== dwEnabledOptions
, "dwOptionSetMask=%x, expected %x\n", dwOptionSetMask
, dwEnabledOptions
);
1435 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1436 return E_NOINTERFACE
;
1439 static const IObjectSafetyVtbl AXObjectSafetyVtbl
= {
1440 AXObjectSafety_QueryInterface
,
1441 ObjectSafety_AddRef
,
1442 ObjectSafety_Release
,
1443 AXObjectSafety_GetInterfaceSafetyOptions
,
1444 AXObjectSafety_SetInterfaceSafetyOptions
1447 static IObjectSafety AXObjectSafety
= { &AXObjectSafetyVtbl
};
1449 static BOOL
set_safe_reg(BOOL safe_call
, BOOL safe_data
)
1451 return init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
1453 && init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95802-9882-11cf-9fa9-00aa006c42c4}",
1457 #define check_custom_policy(a,b,c,d) _check_custom_policy(__LINE__,a,b,c,d)
1458 static void _check_custom_policy(unsigned line
, HRESULT hres
, BYTE
*ppolicy
, DWORD policy_size
, DWORD expolicy
)
1460 ok_(__FILE__
,line
)(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1461 ok_(__FILE__
,line
)(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1462 ok_(__FILE__
,line
)(*(DWORD
*)ppolicy
== expolicy
, "policy = %x, expected %x\n", *(DWORD
*)ppolicy
, expolicy
);
1463 CoTaskMemFree(ppolicy
);
1466 static void test_security_reg(IInternetHostSecurityManager
*sec_mgr
, DWORD policy_caller
, DWORD policy_load
)
1468 struct CONFIRMSAFETY cs
;
1473 cs
.clsid
= CLSID_TestActiveX
;
1474 cs
.pUnk
= (IUnknown
*)&AXObjectSafety
;
1478 SET_EXPECT(AXQueryInterface_IActiveScript
);
1479 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1480 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1481 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1482 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1483 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1484 check_custom_policy(hres
, ppolicy
, policy_size
, policy_caller
);
1487 SET_EXPECT(AXQueryInterface_IActiveScript
);
1488 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1489 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1490 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1491 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1492 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1493 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1494 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1495 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1496 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1497 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1499 if(skip_loadobject_tests
)
1502 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1504 SET_EXPECT(AXQueryInterface_IActiveScript
);
1505 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1506 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1507 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1508 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1509 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1510 check_custom_policy(hres
, ppolicy
, policy_size
, policy_load
);
1513 SET_EXPECT(AXQueryInterface_IActiveScript
);
1514 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1515 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1516 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1517 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1518 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1519 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1520 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1521 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1522 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1523 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1524 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1525 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1528 static void test_security(void)
1530 IInternetHostSecurityManager
*sec_mgr
;
1531 IServiceProvider
*sp
;
1532 DWORD policy
, policy_size
;
1533 struct CONFIRMSAFETY cs
;
1537 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IServiceProvider
, (void**)&sp
);
1538 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
1540 hres
= IServiceProvider_QueryService(sp
, &SID_SInternetHostSecurityManager
,
1541 &IID_IInternetHostSecurityManager
, (void**)&sec_mgr
);
1542 IServiceProvider_Release(sp
);
1543 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1545 hres
= IInternetHostSecurityManager_ProcessUrlAction(sec_mgr
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
, sizeof(policy
),
1546 (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
1547 ok(hres
== S_OK
, "ProcessUrlAction failed: %08x\n", hres
);
1548 ok(policy
== URLPOLICY_ALLOW
, "policy = %x\n", policy
);
1550 cs
.clsid
= CLSID_TestActiveX
;
1551 cs
.pUnk
= (IUnknown
*)&AXObjectSafety
;
1555 SET_EXPECT(AXQueryInterface_IActiveScript
);
1556 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1557 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1558 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1559 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1560 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1561 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1562 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1563 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1564 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1565 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1567 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1568 SET_EXPECT(AXQueryInterface_IActiveScript
);
1569 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1570 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1571 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1572 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1573 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1574 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1575 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1576 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1577 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1578 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1579 if(called_AXSetInterfaceSafetyOptions_IDispatch_data
) {
1580 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1582 win_skip("CONFIRMSAFETYACTION_LOADOBJECT flag not supported\n");
1583 skip_loadobject_tests
= TRUE
;
1584 CLEAR_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1586 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1590 SET_EXPECT(AXQueryInterface_IActiveScript
);
1591 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1592 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1593 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1594 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1595 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1596 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1598 if(!skip_loadobject_tests
) {
1599 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1601 SET_EXPECT(AXQueryInterface_IActiveScript
);
1602 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1603 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1604 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1605 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1606 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1607 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1610 if(set_safe_reg(TRUE
, FALSE
)) {
1611 test_security_reg(sec_mgr
, URLPOLICY_ALLOW
, URLPOLICY_DISALLOW
);
1613 set_safe_reg(FALSE
, TRUE
);
1614 test_security_reg(sec_mgr
, URLPOLICY_DISALLOW
, URLPOLICY_DISALLOW
);
1616 set_safe_reg(TRUE
, TRUE
);
1617 test_security_reg(sec_mgr
, URLPOLICY_ALLOW
, URLPOLICY_ALLOW
);
1619 set_safe_reg(FALSE
, FALSE
);
1621 skip("Could not set safety registry\n");
1627 ax_setopt_dispex_hres
= E_NOINTERFACE
;
1628 SET_EXPECT(AXQueryInterface_IActiveScript
);
1629 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1630 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1631 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1632 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1633 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1634 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1635 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1636 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1637 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1638 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1639 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1640 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1642 ax_setopt_dispex_hres
= E_FAIL
;
1643 ax_setopt_disp_caller_hres
= E_NOINTERFACE
;
1644 SET_EXPECT(AXQueryInterface_IActiveScript
);
1645 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1646 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1647 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1648 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1649 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1650 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1651 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1652 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1653 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1654 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1655 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1656 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1658 if(!skip_loadobject_tests
) {
1659 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1660 ax_setopt_dispex_hres
= E_FAIL
;
1661 ax_setopt_disp_caller_hres
= E_NOINTERFACE
;
1662 SET_EXPECT(AXQueryInterface_IActiveScript
);
1663 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1664 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1665 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1666 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1667 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1668 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1669 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1670 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1671 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1672 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1673 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1674 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1678 ax_setopt_dispex_hres
= E_FAIL
;
1679 ax_setopt_disp_caller_hres
= S_OK
;
1680 ax_getopt_hres
= E_NOINTERFACE
;
1681 SET_EXPECT(AXQueryInterface_IActiveScript
);
1682 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1683 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1684 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1685 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1686 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1687 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1688 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1689 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1690 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1691 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1692 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1693 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1695 if(!skip_loadobject_tests
) {
1696 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1697 ax_setopt_dispex_hres
= E_FAIL
;
1698 ax_setopt_disp_caller_hres
= S_OK
;
1699 ax_setopt_disp_data_hres
= E_FAIL
;
1700 ax_getopt_hres
= E_NOINTERFACE
;
1701 SET_EXPECT(AXQueryInterface_IActiveScript
);
1702 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1703 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1704 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1705 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1706 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1707 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1708 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1709 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1710 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1711 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1712 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1713 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1714 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1715 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1718 IInternetHostSecurityManager_Release(sec_mgr
);
1721 static HRESULT WINAPI
ActiveScriptProperty_QueryInterface(IActiveScriptProperty
*iface
, REFIID riid
, void **ppv
)
1724 ok(0, "unexpected call\n");
1725 return E_NOINTERFACE
;
1728 static ULONG WINAPI
ActiveScriptProperty_AddRef(IActiveScriptProperty
*iface
)
1733 static ULONG WINAPI
ActiveScriptProperty_Release(IActiveScriptProperty
*iface
)
1738 static HRESULT WINAPI
ActiveScriptProperty_GetProperty(IActiveScriptProperty
*iface
, DWORD dwProperty
,
1739 VARIANT
*pvarIndex
, VARIANT
*pvarValue
)
1741 ok(0, "unexpected call\n");
1745 static HRESULT WINAPI
ActiveScriptProperty_SetProperty(IActiveScriptProperty
*iface
, DWORD dwProperty
,
1746 VARIANT
*pvarIndex
, VARIANT
*pvarValue
)
1748 switch(dwProperty
) {
1749 case SCRIPTPROP_HACK_TRIDENTEVENTSINK
:
1750 CHECK_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
1751 ok(V_VT(pvarValue
) == VT_BOOL
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1752 ok(V_BOOL(pvarValue
) == VARIANT_TRUE
, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue
));
1754 case SCRIPTPROP_INVOKEVERSIONING
:
1755 CHECK_EXPECT(SetProperty_INVOKEVERSIONING
);
1756 ok(V_VT(pvarValue
) == VT_I4
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1757 ok(V_I4(pvarValue
) == 1, "V_I4(pvarValue)=%d\n", V_I4(pvarValue
));
1759 case SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION
:
1760 CHECK_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
);
1761 ok(V_VT(pvarValue
) == VT_BOOL
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1762 ok(V_BOOL(pvarValue
) == VARIANT_TRUE
, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue
));
1764 case 0x70000003: /* Undocumented property set by IE10 */
1767 ok(0, "unexpected property %x\n", dwProperty
);
1771 ok(!pvarIndex
, "pvarIndex != NULL\n");
1772 ok(pvarValue
!= NULL
, "pvarValue == NULL\n");
1777 static const IActiveScriptPropertyVtbl ActiveScriptPropertyVtbl
= {
1778 ActiveScriptProperty_QueryInterface
,
1779 ActiveScriptProperty_AddRef
,
1780 ActiveScriptProperty_Release
,
1781 ActiveScriptProperty_GetProperty
,
1782 ActiveScriptProperty_SetProperty
1785 static IActiveScriptProperty ActiveScriptProperty
= { &ActiveScriptPropertyVtbl
};
1787 static HRESULT WINAPI
ActiveScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2
*iface
, REFIID riid
, void **ppv
)
1790 ok(0, "unexpected call\n");
1791 return E_NOINTERFACE
;
1794 static ULONG WINAPI
ActiveScriptParseProcedure_AddRef(IActiveScriptParseProcedure2
*iface
)
1799 static ULONG WINAPI
ActiveScriptParseProcedure_Release(IActiveScriptParseProcedure2
*iface
)
1804 static HRESULT WINAPI
ActiveScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2
*iface
,
1805 LPCOLESTR pstrCode
, LPCOLESTR pstrFormalParams
, LPCOLESTR pstrProcedureName
,
1806 LPCOLESTR pstrItemName
, IUnknown
*punkContext
, LPCOLESTR pstrDelimiter
,
1807 CTXARG_T dwSourceContextCookie
, ULONG ulStartingLineNumber
, DWORD dwFlags
, IDispatch
**ppdisp
)
1809 ok(0, "unexpected call\n");
1813 static const IActiveScriptParseProcedure2Vtbl ActiveScriptParseProcedureVtbl
= {
1814 ActiveScriptParseProcedure_QueryInterface
,
1815 ActiveScriptParseProcedure_AddRef
,
1816 ActiveScriptParseProcedure_Release
,
1817 ActiveScriptParseProcedure_ParseProcedureText
1820 static IActiveScriptParseProcedure2 ActiveScriptParseProcedure
= { &ActiveScriptParseProcedureVtbl
};
1822 static HRESULT WINAPI
ActiveScriptParse_QueryInterface(IActiveScriptParse
*iface
, REFIID riid
, void **ppv
)
1825 ok(0, "unexpected call\n");
1826 return E_NOINTERFACE
;
1829 static ULONG WINAPI
ActiveScriptParse_AddRef(IActiveScriptParse
*iface
)
1834 static ULONG WINAPI
ActiveScriptParse_Release(IActiveScriptParse
*iface
)
1839 static HRESULT WINAPI
ActiveScriptParse_InitNew(IActiveScriptParse
*iface
)
1841 CHECK_EXPECT(InitNew
);
1845 static HRESULT WINAPI
ActiveScriptParse_AddScriptlet(IActiveScriptParse
*iface
,
1846 LPCOLESTR pstrDefaultName
, LPCOLESTR pstrCode
, LPCOLESTR pstrItemName
,
1847 LPCOLESTR pstrSubItemName
, LPCOLESTR pstrEventName
, LPCOLESTR pstrDelimiter
,
1848 CTXARG_T dwSourceContextCookie
, ULONG ulStartingLineNumber
, DWORD dwFlags
,
1849 BSTR
*pbstrName
, EXCEPINFO
*pexcepinfo
)
1851 ok(0, "unexpected call\n");
1855 static HRESULT
dispex_propput(IDispatchEx
*obj
, DISPID id
, DWORD flags
, VARIANT
*var
, IServiceProvider
*caller_sp
)
1857 DISPID propput_arg
= DISPID_PROPERTYPUT
;
1858 DISPPARAMS dp
= {var
, &propput_arg
, 1, 1};
1861 return IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYPUT
|flags
, &dp
, NULL
, &ei
, caller_sp
);
1864 static HRESULT
dispex_propget(IDispatchEx
*obj
, DISPID id
, VARIANT
*res
, IServiceProvider
*caller_sp
)
1866 DISPPARAMS dp
= {NULL
};
1869 return IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYGET
, &dp
, res
, &ei
, caller_sp
);
1872 static void test_func(IDispatchEx
*obj
)
1875 IDispatchEx
*dispex
;
1883 str
= a2bstr("toString");
1884 hres
= IDispatchEx_GetDispID(obj
, str
, fdexNameCaseSensitive
, &id
);
1886 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1887 ok(id
== DISPID_IOMNAVIGATOR_TOSTRING
, "id = %x\n", id
);
1889 memset(&dp
, 0, sizeof(dp
));
1890 memset(&ei
, 0, sizeof(ei
));
1892 hres
= IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1893 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1894 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
1895 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
1896 disp
= V_DISPATCH(&var
);
1898 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
1899 IDispatch_Release(disp
);
1900 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
1902 /* FIXME: Test InvokeEx(DISPATCH_METHOD) */
1904 memset(&dp
, 0, sizeof(dp
));
1905 memset(&ei
, 0, sizeof(ei
));
1907 hres
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, LOCALE_NEUTRAL
, DISPATCH_METHOD
, &dp
, &var
, &ei
, NULL
);
1908 ok(hres
== S_OK
|| broken(E_ACCESSDENIED
), "InvokeEx failed: %08x\n", hres
);
1909 if(SUCCEEDED(hres
)) {
1910 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&var
));
1911 ok(!strcmp_wa(V_BSTR(&var
), "[object]"), "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
1917 hres
= dispex_propput(obj
, id
, 0, &var
, NULL
);
1918 ok(hres
== E_NOTIMPL
, "InvokeEx failed: %08x\n", hres
);
1920 hres
= dispex_propget(dispex
, DISPID_VALUE
, &var
, NULL
);
1921 ok(hres
== E_ACCESSDENIED
, "InvokeEx returned: %08x, expected E_ACCESSDENIED\n", hres
);
1925 SET_EXPECT(QS_IActiveScriptSite
);
1926 SET_EXPECT(QS_GetCaller
);
1927 hres
= dispex_propget(dispex
, DISPID_VALUE
, &var
, &caller_sp
);
1928 ok(hres
== S_OK
, "InvokeEx returned: %08x, expected S_OK\n", hres
);
1929 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var) = %d\n", V_VT(&var
));
1930 ok(!strcmp_wa(V_BSTR(&var
), "\nfunction toString() {\n [native code]\n}\n"),
1931 "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
1933 todo_wine
CHECK_CALLED(QS_IActiveScriptSite
);
1934 todo_wine
CHECK_CALLED(QS_GetCaller
);
1936 IDispatchEx_Release(dispex
);
1939 static void test_nextdispid(IDispatchEx
*dispex
)
1941 DISPID last_id
= DISPID_STARTENUM
, id
, dyn_id
;
1946 name
= a2bstr("dynVal");
1947 hres
= IDispatchEx_GetDispID(dispex
, name
, fdexNameCaseSensitive
|fdexNameEnsure
, &dyn_id
);
1948 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1949 SysFreeString(name
);
1951 V_VT(&var
) = VT_EMPTY
;
1952 hres
= dispex_propput(dispex
, dyn_id
, 0, &var
, NULL
);
1953 ok(hres
== S_OK
, "dispex_propput failed: %08x\n", hres
);
1955 while(last_id
!= dyn_id
) {
1956 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, last_id
, &id
);
1957 ok(hres
== S_OK
, "GetNextDispID returned: %08x\n", hres
);
1958 ok(id
!= DISPID_STARTENUM
, "id == DISPID_STARTENUM\n");
1959 ok(id
!= DISPID_IOMNAVIGATOR_TOSTRING
, "id == DISPID_IOMNAVIGATOR_TOSTRING\n");
1961 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
1962 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
1965 ok(!strcmp_wa(name
, "dynVal"), "name = %s\n", wine_dbgstr_w(name
));
1966 else if(id
== DISPID_IOMNAVIGATOR_PLATFORM
)
1967 ok(!strcmp_wa(name
, "platform"), "name = %s\n", wine_dbgstr_w(name
));
1969 SysFreeString(name
);
1973 hres
= IDispatchEx_GetNextDispID(dispex
, 0, id
, &id
);
1974 ok(hres
== S_FALSE
, "GetNextDispID returned: %08x\n", hres
);
1975 ok(id
== DISPID_STARTENUM
, "id != DISPID_STARTENUM\n");
1978 static void test_global_id(void)
1987 SET_EXPECT(GetScriptDispatch
);
1988 SET_EXPECT(script_divid_d
);
1989 tmp
= a2bstr("divid");
1990 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
1991 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1993 CHECK_CALLED(GetScriptDispatch
);
1994 CHECK_CALLED(script_divid_d
);
1997 memset(&ei
, 0, sizeof(ei
));
1998 memset(&dp
, 0, sizeof(dp
));
1999 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2000 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2001 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var) = %d\n", V_VT(&var
));
2005 static void test_arg_conv(IHTMLWindow2
*window
)
2007 IHTMLDocument2
*doc
;
2008 IDispatchEx
*dispex
;
2013 hres
= IHTMLWindow2_get_document(window
, &doc
);
2014 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2016 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2017 IHTMLDocument2_Release(doc
);
2018 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2020 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2021 IHTMLElement_Release(elem
);
2022 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2024 SET_EXPECT(QS_VariantConversion
);
2025 SET_EXPECT(ChangeType
);
2027 V_I4(&v
) = 0xf0f0f0;
2028 hres
= dispex_propput(dispex
, DISPID_IHTMLBODYELEMENT_BACKGROUND
, 0, &v
, &caller_sp
);
2029 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2030 CHECK_CALLED(QS_VariantConversion
);
2031 CHECK_CALLED(ChangeType
);
2033 V_VT(&v
) = VT_EMPTY
;
2034 hres
= dispex_propget(dispex
, DISPID_IHTMLBODYELEMENT_BGCOLOR
, &v
, &caller_sp
);
2035 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2036 ok(V_VT(&v
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&v
));
2037 ok(!V_BSTR(&v
), "V_BSTR(&var) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
2039 IDispatchEx_Release(dispex
);
2042 #define test_elem_disabled(a,b) _test_elem_disabled(__LINE__,a,b)
2043 static void _test_elem_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
2045 IHTMLElement3
*elem3
;
2046 VARIANT_BOOL b
= 100;
2049 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLElement3
, (void**)&elem3
);
2050 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLElement3 iface: %08x\n", hres
);
2052 hres
= IHTMLElement3_get_disabled(elem3
, &b
);
2053 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2054 ok_(__FILE__
,line
)(b
== exb
, "disabled = %x, expected %x\n", b
, exb
);
2056 IHTMLElement3_Release(elem3
);
2059 static void test_default_arg_conv(IHTMLWindow2
*window
)
2061 IHTMLDocument2
*doc
;
2062 IDispatchEx
*dispex
;
2067 hres
= IHTMLWindow2_get_document(window
, &doc
);
2068 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2070 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2071 IHTMLDocument2_Release(doc
);
2072 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2074 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2075 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2077 test_elem_disabled(elem
, VARIANT_FALSE
);
2080 V_BSTR(&v
) = a2bstr("test");
2081 hres
= dispex_propput(dispex
, DISPID_IHTMLELEMENT3_DISABLED
, 0, &v
, NULL
);
2082 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2083 SysFreeString(V_BSTR(&v
));
2085 test_elem_disabled(elem
, VARIANT_TRUE
);
2089 hres
= dispex_propput(dispex
, DISPID_IHTMLELEMENT3_DISABLED
, 0, &v
, NULL
);
2090 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2092 test_elem_disabled(elem
, VARIANT_FALSE
);
2094 IHTMLElement_Release(elem
);
2095 IDispatchEx_Release(dispex
);
2098 static void test_ui(void)
2100 IActiveScriptSiteUIControl
*ui_control
;
2101 SCRIPTUICHANDLING uic_handling
= 10;
2104 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IActiveScriptSiteUIControl
, (void**)&ui_control
);
2105 if(hres
== E_NOINTERFACE
) {
2106 win_skip("IActiveScriptSiteUIControl not supported\n");
2109 ok(hres
== S_OK
, "Could not get IActiveScriptSiteUIControl: %08x\n", hres
);
2111 hres
= IActiveScriptSiteUIControl_GetUIBehavior(ui_control
, SCRIPTUICITEM_MSGBOX
, &uic_handling
);
2112 ok(hres
== S_OK
, "GetUIBehavior failed: %08x\n", hres
);
2113 ok(uic_handling
== SCRIPTUICHANDLING_ALLOW
, "uic_handling = %d\n", uic_handling
);
2115 IActiveScriptSiteUIControl_Release(ui_control
);
2118 static void test_sp(void)
2120 IServiceProvider
*sp
;
2124 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IServiceProvider
, (void**)&sp
);
2125 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
2127 hres
= IServiceProvider_QueryService(sp
, &SID_SContainerDispatch
, &IID_IHTMLDocument
, (void**)&unk
);
2128 ok(hres
== S_OK
, "Could not get SID_SContainerDispatch service: %08x\n", hres
);
2129 IUnknown_Release(unk
);
2131 IServiceProvider_Release(sp
);
2134 static void test_script_run(void)
2136 IDispatchEx
*document
, *dispex
;
2137 IHTMLWindow2
*window
;
2138 IOmNavigator
*navigator
;
2147 static const WCHAR documentW
[] = {'d','o','c','u','m','e','n','t',0};
2148 static const WCHAR testW
[] = {'t','e','s','t',0};
2149 static const WCHAR funcW
[] = {'f','u','n','c',0};
2151 SET_EXPECT(GetScriptDispatch
);
2153 tmp
= SysAllocString(documentW
);
2154 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2156 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
2157 ok(id
== DISPID_IHTMLWINDOW2_DOCUMENT
, "id=%x\n", id
);
2159 CHECK_CALLED(GetScriptDispatch
);
2162 memset(&dp
, 0, sizeof(dp
));
2163 memset(&ei
, 0, sizeof(ei
));
2165 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2166 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2167 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2168 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(&var) == NULL\n");
2170 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IDispatchEx
, (void**)&document
);
2172 ok(hres
== S_OK
, "Could not get DispatchEx: %08x\n", hres
);
2174 tmp
= SysAllocString(testW
);
2175 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
, &id
);
2176 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
2177 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
| fdexNameImplicit
, &id
);
2178 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
2182 tmp
= SysAllocString(testW
);
2183 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
2185 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
2186 ok(id
, "id == 0\n");
2190 hres
= dispex_propput(document
, id
, 0, &var
, NULL
);
2191 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2193 tmp
= SysAllocString(testW
);
2194 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
, &id
);
2196 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
2198 hres
= IDispatchEx_DeleteMemberByDispID(document
, id
);
2199 ok(hres
== E_NOTIMPL
, "DeleteMemberByDispID failed = %08x\n", hres
);
2202 memset(&dp
, 0, sizeof(dp
));
2203 memset(&ei
, 0, sizeof(ei
));
2204 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2205 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2206 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2207 ok(V_I4(&var
) == 100, "V_I4(&var) = %d\n", V_I4(&var
));
2211 hres
= dispex_propput(document
, id
, DISPATCH_PROPERTYPUTREF
, &var
, NULL
);
2212 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2215 memset(&dp
, 0, sizeof(dp
));
2216 memset(&ei
, 0, sizeof(ei
));
2217 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2218 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2219 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2220 ok(V_I4(&var
) == 200, "V_I4(&var) = %d\n", V_I4(&var
));
2222 memset(&dp
, 0, sizeof(dp
));
2223 memset(&ei
, 0, sizeof(ei
));
2228 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
2229 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2232 memset(&dp
, 0, sizeof(dp
));
2233 memset(&ei
, 0, sizeof(ei
));
2234 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2235 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2236 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2237 ok(V_I4(&var
) == 300, "V_I4(&var) = %d\n", V_I4(&var
));
2239 V_VT(&var
) = VT_BSTR
;
2240 V_BSTR(&var
) = NULL
;
2241 dispex_propput(document
, id
, 0, &var
, NULL
);
2244 memset(&dp
, 0, sizeof(dp
));
2245 memset(&ei
, 0, sizeof(ei
));
2246 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2247 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2248 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&var
));
2249 ok(!V_BSTR(&var
), "V_BSTR(&var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2251 unk
= (void*)0xdeadbeef;
2252 hres
= IDispatchEx_GetNameSpaceParent(window_dispex
, &unk
);
2253 ok(hres
== S_OK
, "GetNameSpaceParent failed: %08x\n", hres
);
2254 ok(!unk
, "unk=%p, expected NULL\n", unk
);
2257 tmp
= SysAllocString(funcW
);
2258 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
2260 ok(hres
== S_OK
, "GetDispID(func) failed: %08x\n", hres
);
2261 ok(id
, "id == 0\n");
2266 dp
.rgdispidNamedArgs
= NULL
;
2267 V_VT(&var
) = VT_DISPATCH
;
2268 V_DISPATCH(&var
) = (IDispatch
*)&funcDisp
;
2269 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
2270 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2273 memset(&dp
, 0, sizeof(dp
));
2274 memset(&ei
, 0, sizeof(ei
));
2275 V_VT(&arg
) = VT_BOOL
;
2276 V_BOOL(&arg
) = VARIANT_TRUE
;
2280 SET_EXPECT(funcDisp
);
2281 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_FUNC
, &dp
, &var
, &ei
, NULL
);
2282 CHECK_CALLED(funcDisp
);
2284 ok(hres
== S_OK
, "InvokeEx(INVOKE_FUNC) failed: %08x\n", hres
);
2285 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2286 ok(V_I4(&var
) == 100, "V_I4(&var) == NULL\n");
2288 IDispatchEx_Release(document
);
2290 hres
= IDispatchEx_QueryInterface(window_dispex
, &IID_IHTMLWindow2
, (void**)&window
);
2291 ok(hres
== S_OK
, "Could not get IHTMLWindow2 iface: %08x\n", hres
);
2293 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
2294 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
2296 hres
= IOmNavigator_QueryInterface(navigator
, &IID_IDispatchEx
, (void**)&dispex
);
2297 IOmNavigator_Release(navigator
);
2298 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2301 test_nextdispid(dispex
);
2303 test_arg_conv(window
);
2304 test_default_arg_conv(window
);
2305 IHTMLWindow2_Release(window
);
2307 tmp
= a2bstr("test");
2308 hres
= IDispatchEx_DeleteMemberByName(dispex
, tmp
, fdexNameCaseSensitive
);
2309 ok(hres
== E_NOTIMPL
, "DeleteMemberByName failed: %08x\n", hres
);
2311 IDispatchEx_Release(dispex
);
2313 script_disp
= (IDispatch
*)&scriptDisp
;
2315 SET_EXPECT(GetScriptDispatch
);
2316 SET_EXPECT(script_testprop_d
);
2317 tmp
= a2bstr("testProp");
2318 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2319 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2320 ok(id
!= DISPID_SCRIPT_TESTPROP
, "id == DISPID_SCRIPT_TESTPROP\n");
2321 CHECK_CALLED(GetScriptDispatch
);
2322 CHECK_CALLED(script_testprop_d
);
2325 tmp
= a2bstr("testProp");
2326 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2327 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2328 ok(id
!= DISPID_SCRIPT_TESTPROP
, "id == DISPID_SCRIPT_TESTPROP\n");
2331 SET_EXPECT(GetScriptDispatch
);
2332 SET_EXPECT(script_testprop_i
);
2333 memset(&ei
, 0, sizeof(ei
));
2334 memset(&dp
, 0, sizeof(dp
));
2335 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2336 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2337 ok(V_VT(&var
) == VT_NULL
, "V_VT(var) = %d\n", V_VT(&var
));
2338 CHECK_CALLED(GetScriptDispatch
);
2339 CHECK_CALLED(script_testprop_i
);
2341 SET_EXPECT(GetScriptDispatch
);
2342 SET_EXPECT(script_testprop2_d
);
2343 tmp
= a2bstr("testProp2");
2344 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
2345 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2346 ok(id
!= DISPID_SCRIPT_TESTPROP2
, "id == DISPID_SCRIPT_TESTPROP2\n");
2347 CHECK_CALLED(GetScriptDispatch
);
2348 CHECK_CALLED(script_testprop2_d
);
2351 tmp
= a2bstr("test");
2352 hres
= IDispatchEx_DeleteMemberByName(window_dispex
, tmp
, fdexNameCaseSensitive
);
2353 ok(hres
== E_NOTIMPL
, "DeleteMemberByName failed: %08x\n", hres
);
2362 static HRESULT WINAPI
ActiveScriptParse_ParseScriptText(IActiveScriptParse
*iface
,
2363 LPCOLESTR pstrCode
, LPCOLESTR pstrItemName
, IUnknown
*punkContext
,
2364 LPCOLESTR pstrDelimiter
, CTXARG_T dwSourceContextCookie
, ULONG ulStartingLine
,
2365 DWORD dwFlags
, VARIANT
*pvarResult
, EXCEPINFO
*pexcepinfo
)
2367 ok(pvarResult
!= NULL
, "pvarResult == NULL\n");
2368 ok(pexcepinfo
!= NULL
, "pexcepinfo == NULL\n");
2370 if(!strcmp_wa(pstrCode
, "execScript call")) {
2371 CHECK_EXPECT(ParseScriptText_execScript
);
2372 ok(!pstrItemName
, "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2373 ok(!strcmp_wa(pstrDelimiter
, "\""), "pstrDelimiter = %s\n", wine_dbgstr_w(pstrDelimiter
));
2374 ok(dwFlags
== SCRIPTTEXT_ISVISIBLE
, "dwFlags = %x\n", dwFlags
);
2376 V_VT(pvarResult
) = VT_I4
;
2377 V_I4(pvarResult
) = 10;
2379 }else if(!strcmp_wa(pstrCode
, "simple script")) {
2380 CHECK_EXPECT(ParseScriptText_script
);
2381 ok(!strcmp_wa(pstrItemName
, "window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2382 ok(!strcmp_wa(pstrDelimiter
, "</SCRIPT>"), "pstrDelimiter = %s\n", wine_dbgstr_w(pstrDelimiter
));
2383 ok(dwFlags
== (SCRIPTTEXT_ISVISIBLE
|SCRIPTTEXT_HOSTMANAGESSOURCE
), "dwFlags = %x\n", dwFlags
);
2389 ok(0, "unexpected script %s\n", wine_dbgstr_w(pstrCode
));
2393 static const IActiveScriptParseVtbl ActiveScriptParseVtbl
= {
2394 ActiveScriptParse_QueryInterface
,
2395 ActiveScriptParse_AddRef
,
2396 ActiveScriptParse_Release
,
2397 ActiveScriptParse_InitNew
,
2398 ActiveScriptParse_AddScriptlet
,
2399 ActiveScriptParse_ParseScriptText
2402 static IActiveScriptParse ActiveScriptParse
= { &ActiveScriptParseVtbl
};
2404 static HRESULT WINAPI
ActiveScript_QueryInterface(IActiveScript
*iface
, REFIID riid
, void **ppv
)
2408 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IActiveScript
, riid
)) {
2413 if(IsEqualGUID(&IID_IActiveScriptParse
, riid
)) {
2414 *ppv
= &ActiveScriptParse
;
2418 if(IsEqualGUID(&IID_IActiveScriptParseProcedure2
, riid
)) {
2419 *ppv
= &ActiveScriptParseProcedure
;
2423 if(IsEqualGUID(&IID_IActiveScriptProperty
, riid
)) {
2424 *ppv
= &ActiveScriptProperty
;
2428 if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
2429 *ppv
= &ObjectSafety
;
2433 if(IsEqualGUID(&IID_IActiveScriptDebug
, riid
))
2434 return E_NOINTERFACE
;
2436 trace("QI(%s)\n", wine_dbgstr_guid(riid
));
2437 return E_NOINTERFACE
;
2440 static ULONG WINAPI
ActiveScript_AddRef(IActiveScript
*iface
)
2445 static ULONG WINAPI
ActiveScript_Release(IActiveScript
*iface
)
2450 static HRESULT WINAPI
ActiveScript_SetScriptSite(IActiveScript
*iface
, IActiveScriptSite
*pass
)
2452 IActiveScriptSiteInterruptPoll
*poll
;
2453 IActiveScriptSiteDebug
*debug
;
2454 IServiceProvider
*service
;
2455 ICanHandleException
*canexpection
;
2459 CHECK_EXPECT(SetScriptSite
);
2461 ok(pass
!= NULL
, "pass == NULL\n");
2463 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IActiveScriptSiteInterruptPoll
, (void**)&poll
);
2464 ok(hres
== S_OK
, "Could not get IActiveScriptSiteInterruptPoll interface: %08x\n", hres
);
2466 IActiveScriptSiteInterruptPoll_Release(poll
);
2468 hres
= IActiveScriptSite_GetLCID(pass
, &lcid
);
2469 ok(hres
== S_OK
, "GetLCID failed: %08x\n", hres
);
2471 hres
= IActiveScriptSite_OnStateChange(pass
, (state
= SCRIPTSTATE_INITIALIZED
));
2472 ok(hres
== S_OK
, "OnStateChange failed: %08x\n", hres
);
2474 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IActiveScriptSiteDebug
, (void**)&debug
);
2475 ok(hres
== S_OK
, "Could not get IActiveScriptSiteDebug interface: %08x\n", hres
);
2477 IActiveScriptSiteDebug_Release(debug
);
2479 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_ICanHandleException
, (void**)&canexpection
);
2480 ok(hres
== E_NOINTERFACE
, "Could not get IID_ICanHandleException interface: %08x\n", hres
);
2482 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IServiceProvider
, (void**)&service
);
2483 ok(hres
== S_OK
, "Could not get IServiceProvider interface: %08x\n", hres
);
2485 IServiceProvider_Release(service
);
2488 IActiveScriptSite_AddRef(site
);
2492 static HRESULT WINAPI
ActiveScript_GetScriptSite(IActiveScript
*iface
, REFIID riid
,
2495 ok(0, "unexpected call\n");
2499 static HRESULT WINAPI
ActiveScript_SetScriptState(IActiveScript
*iface
, SCRIPTSTATE ss
)
2504 case SCRIPTSTATE_STARTED
:
2505 CHECK_EXPECT(SetScriptState_STARTED
);
2507 case SCRIPTSTATE_CONNECTED
:
2508 CHECK_EXPECT(SetScriptState_CONNECTED
);
2510 case SCRIPTSTATE_DISCONNECTED
:
2511 CHECK_EXPECT(SetScriptState_DISCONNECTED
);
2514 ok(0, "unexpected state %d\n", ss
);
2518 hres
= IActiveScriptSite_OnStateChange(site
, (state
= ss
));
2519 ok(hres
== S_OK
, "OnStateChange failed: %08x\n", hres
);
2524 static HRESULT WINAPI
ActiveScript_GetScriptState(IActiveScript
*iface
, SCRIPTSTATE
*pssState
)
2526 CHECK_EXPECT(GetScriptState
);
2532 static HRESULT WINAPI
ActiveScript_Close(IActiveScript
*iface
)
2534 CHECK_EXPECT(Close
);
2538 static HRESULT WINAPI
ActiveScript_AddNamedItem(IActiveScript
*iface
,
2539 LPCOLESTR pstrName
, DWORD dwFlags
)
2542 IUnknown
*unk
= NULL
, *unk2
;
2545 static const WCHAR windowW
[] = {'w','i','n','d','o','w',0};
2547 static const IID unknown_iid
= {0x719C3050,0xF9D3,0x11CF,{0xA4,0x93,0x00,0x40,0x05,0x23,0xA8,0xA0}};
2549 CHECK_EXPECT(AddNamedItem
);
2551 ok(!lstrcmpW(pstrName
, windowW
), "pstrName=%s\n", wine_dbgstr_w(pstrName
));
2552 ok(dwFlags
== (SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
), "dwFlags=%x\n", dwFlags
);
2554 hres
= IActiveScriptSite_GetItemInfo(site
, windowW
, SCRIPTINFO_IUNKNOWN
, &unk
, NULL
);
2555 ok(hres
== S_OK
, "GetItemInfo failed: %08x\n", hres
);
2556 ok(unk
!= NULL
, "unk == NULL\n");
2558 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
2559 ok(hres
== S_OK
, "Could not get IDispatch interface: %08x\n", hres
);
2561 IDispatch_Release(disp
);
2563 hres
= IUnknown_QueryInterface(unk
, &unknown_iid
, (void**)&unk2
);
2564 ok(hres
== E_NOINTERFACE
, "Got ?? interface: %p\n", unk2
);
2566 IUnknown_Release(unk2
);
2568 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&window_dispex
);
2569 ok(hres
== S_OK
, "Could not get IDispatchEx interface: %08x\n", hres
);
2571 IUnknown_Release(unk
);
2575 static HRESULT WINAPI
ActiveScript_AddTypeLib(IActiveScript
*iface
, REFGUID rguidTypeLib
,
2576 DWORD dwMajor
, DWORD dwMinor
, DWORD dwFlags
)
2578 ok(0, "unexpected call\n");
2582 static HRESULT WINAPI
ActiveScript_GetScriptDispatch(IActiveScript
*iface
, LPCOLESTR pstrItemName
,
2585 CHECK_EXPECT(GetScriptDispatch
);
2587 ok(!strcmp_wa(pstrItemName
, "window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2592 *ppdisp
= script_disp
;
2596 static HRESULT WINAPI
ActiveScript_GetCurrentScriptThreadID(IActiveScript
*iface
,
2597 SCRIPTTHREADID
*pstridThread
)
2599 ok(0, "unexpected call\n");
2603 static HRESULT WINAPI
ActiveScript_GetScriptThreadID(IActiveScript
*iface
,
2604 DWORD dwWin32ThreadId
, SCRIPTTHREADID
*pstidThread
)
2606 ok(0, "unexpected call\n");
2610 static HRESULT WINAPI
ActiveScript_GetScriptThreadState(IActiveScript
*iface
,
2611 SCRIPTTHREADID stidThread
, SCRIPTTHREADSTATE
*pstsState
)
2613 ok(0, "unexpected call\n");
2617 static HRESULT WINAPI
ActiveScript_InterruptScriptThread(IActiveScript
*iface
,
2618 SCRIPTTHREADID stidThread
, const EXCEPINFO
*pexcepinfo
, DWORD dwFlags
)
2620 ok(0, "unexpected call\n");
2624 static HRESULT WINAPI
ActiveScript_Clone(IActiveScript
*iface
, IActiveScript
**ppscript
)
2626 ok(0, "unexpected call\n");
2630 static const IActiveScriptVtbl ActiveScriptVtbl
= {
2631 ActiveScript_QueryInterface
,
2632 ActiveScript_AddRef
,
2633 ActiveScript_Release
,
2634 ActiveScript_SetScriptSite
,
2635 ActiveScript_GetScriptSite
,
2636 ActiveScript_SetScriptState
,
2637 ActiveScript_GetScriptState
,
2639 ActiveScript_AddNamedItem
,
2640 ActiveScript_AddTypeLib
,
2641 ActiveScript_GetScriptDispatch
,
2642 ActiveScript_GetCurrentScriptThreadID
,
2643 ActiveScript_GetScriptThreadID
,
2644 ActiveScript_GetScriptThreadState
,
2645 ActiveScript_InterruptScriptThread
,
2649 static IActiveScript ActiveScript
= { &ActiveScriptVtbl
};
2651 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
2655 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
2660 if(IsEqualGUID(&IID_IMarshal
, riid
))
2661 return E_NOINTERFACE
;
2662 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
2663 return E_NOINTERFACE
;
2665 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2669 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
2674 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
2679 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
2681 CHECK_EXPECT(CreateInstance
);
2683 ok(!outer
, "outer = %p\n", outer
);
2684 ok(IsEqualGUID(&IID_IActiveScript
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2685 *ppv
= &ActiveScript
;
2689 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
2691 ok(0, "unexpected call\n");
2695 static const IClassFactoryVtbl ClassFactoryVtbl
= {
2696 ClassFactory_QueryInterface
,
2697 ClassFactory_AddRef
,
2698 ClassFactory_Release
,
2699 ClassFactory_CreateInstance
,
2700 ClassFactory_LockServer
2703 static IClassFactory script_cf
= { &ClassFactoryVtbl
};
2705 static const char simple_script_str
[] =
2706 "<html><head></head><body>"
2707 "<div id=\"divid\"></div>"
2708 "<script language=\"TestScript\">simple script</script>"
2711 static void test_exec_script(IHTMLDocument2
*doc
, const char *codea
, const char *langa
)
2713 IHTMLWindow2
*window
;
2718 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2719 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
2721 code
= a2bstr(codea
);
2722 lang
= a2bstr(langa
);
2724 SET_EXPECT(ParseScriptText_execScript
);
2725 hres
= IHTMLWindow2_execScript(window
, code
, lang
, &v
);
2726 ok(hres
== S_OK
, "execScript failed: %08x\n", hres
);
2727 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
2728 ok(V_I4(&v
) == 10, "V_I4(v) = %d\n", V_I4(&v
));
2729 CHECK_CALLED(ParseScriptText_execScript
);
2730 SysFreeString(lang
);
2732 lang
= a2bstr("invalid");
2734 hres
= IHTMLWindow2_execScript(window
, code
, lang
, &v
);
2735 ok(hres
== CO_E_CLASSSTRING
, "execScript failed: %08x, expected CO_E_CLASSSTRING\n", hres
);
2736 ok(V_VT(&v
) == 100, "V_VT(v) = %d\n", V_VT(&v
));
2737 SysFreeString(lang
);
2738 SysFreeString(code
);
2740 IHTMLWindow2_Release(window
);
2743 static void test_simple_script(void)
2745 IHTMLDocument2
*doc
;
2747 doc
= create_document();
2751 SET_EXPECT(CreateInstance
);
2752 SET_EXPECT(GetInterfaceSafetyOptions
);
2753 SET_EXPECT(SetInterfaceSafetyOptions
);
2754 SET_EXPECT(SetProperty_INVOKEVERSIONING
); /* IE8 */
2755 SET_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
2756 SET_EXPECT(InitNew
);
2757 SET_EXPECT(SetScriptSite
);
2758 SET_EXPECT(GetScriptState
);
2759 SET_EXPECT(SetScriptState_STARTED
);
2760 SET_EXPECT(AddNamedItem
);
2761 SET_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
); /* IE8 */
2762 SET_EXPECT(ParseScriptText_script
);
2763 SET_EXPECT(SetScriptState_CONNECTED
);
2765 load_doc(doc
, simple_script_str
);
2767 CHECK_CALLED(CreateInstance
);
2768 CHECK_CALLED(GetInterfaceSafetyOptions
);
2769 CHECK_CALLED(SetInterfaceSafetyOptions
);
2770 CHECK_CALLED_BROKEN(SetProperty_INVOKEVERSIONING
); /* IE8 */
2771 CHECK_CALLED(SetProperty_HACK_TRIDENTEVENTSINK
);
2772 CHECK_CALLED(InitNew
);
2773 CHECK_CALLED(SetScriptSite
);
2774 CHECK_CALLED(GetScriptState
);
2775 CHECK_CALLED(SetScriptState_STARTED
);
2776 CHECK_CALLED(AddNamedItem
);
2777 CHECK_CALLED_BROKEN(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
); /* IE8 */
2778 CHECK_CALLED(ParseScriptText_script
);
2779 CHECK_CALLED(SetScriptState_CONNECTED
);
2781 test_exec_script(doc
, "execScript call", "TestScript");
2784 IActiveScriptSite_Release(site
);
2786 IDispatchEx_Release(window_dispex
);
2788 SET_EXPECT(SetScriptState_DISCONNECTED
);
2791 IHTMLDocument2_Release(doc
);
2793 CHECK_CALLED(SetScriptState_DISCONNECTED
);
2794 CHECK_CALLED(Close
);
2797 static void run_js_script(const char *test_name
)
2799 WCHAR url
[INTERNET_MAX_URL_LENGTH
];
2800 char urlA
[INTERNET_MAX_URL_LENGTH
];
2801 IPersistMoniker
*persist
;
2802 IHTMLDocument2
*doc
;
2807 static const char res
[] = "res://";
2809 trace("running %s...\n", test_name
);
2811 doc
= create_document();
2815 set_client_site(doc
, TRUE
);
2816 do_advise(doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
2818 lstrcpyA(urlA
, res
);
2819 GetModuleFileNameA(NULL
, urlA
+ lstrlenA(res
), sizeof(urlA
) - lstrlenA(res
));
2820 lstrcatA(urlA
, "/");
2821 lstrcatA(urlA
, test_name
);
2822 MultiByteToWideChar(CP_ACP
, 0, urlA
, -1, url
, sizeof(url
)/sizeof(WCHAR
));
2824 hres
= CreateURLMoniker(NULL
, url
, &mon
);
2825 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
2827 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistMoniker
, (void**)&persist
);
2828 ok(hres
== S_OK
, "Could not get IPersistMoniker iface: %08x\n", hres
);
2830 hres
= IPersistMoniker_Load(persist
, FALSE
, mon
, NULL
, 0);
2831 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
2833 IMoniker_Release(mon
);
2834 IPersistMoniker_Release(persist
);
2836 SET_EXPECT(external_success
);
2838 while(!called_external_success
&& GetMessageW(&msg
, NULL
, 0, 0)) {
2839 TranslateMessage(&msg
);
2840 DispatchMessageW(&msg
);
2843 CHECK_CALLED(external_success
);
2845 set_client_site(doc
, FALSE
);
2846 IHTMLDocument2_Release(doc
);
2849 static void run_js_tests(void)
2851 run_js_script("jstest.html");
2852 run_js_script("exectest.html");
2853 run_js_script("vbtest.html");
2854 run_js_script("events.html");
2856 run_js_script("nav_test.html");
2858 win_skip("Skipping nav_test.html on IE older than 9 (for broken ieframe onload).\n");
2861 static BOOL
init_registry(BOOL init
)
2863 return init_key("TestScript\\CLSID", TESTSCRIPT_CLSID
, init
)
2864 && init_key("CLSID\\"TESTSCRIPT_CLSID
"\\Implemented Categories\\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}",
2866 && init_key("CLSID\\"TESTSCRIPT_CLSID
"\\Implemented Categories\\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}",
2870 static BOOL
register_script_engine(void)
2875 if(!init_registry(TRUE
)) {
2876 init_registry(FALSE
);
2880 hres
= CoRegisterClassObject(&CLSID_TestScript
, (IUnknown
*)&script_cf
,
2881 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
2882 ok(hres
== S_OK
, "Could not register script engine: %08x\n", hres
);
2887 static LRESULT WINAPI
wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2889 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
2892 static HWND
create_container_window(void)
2894 static const CHAR szHTMLDocumentTest
[] = "HTMLDocumentTest";
2895 static WNDCLASSEXA wndclass
= {
2896 sizeof(WNDCLASSEXA
),
2899 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
2904 RegisterClassExA(&wndclass
);
2905 return CreateWindowA(szHTMLDocumentTest
, szHTMLDocumentTest
,
2906 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
,
2907 300, 300, NULL
, NULL
, NULL
, NULL
);
2910 static BOOL
check_ie(void)
2912 IHTMLDocument2
*doc
;
2913 IHTMLDocument5
*doc5
;
2914 IHTMLDocument7
*doc7
;
2917 doc
= create_document();
2921 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument7
, (void**)&doc7
);
2922 if(SUCCEEDED(hres
)) {
2924 IHTMLDocument7_Release(doc7
);
2927 trace("is_ie9plus %x\n", is_ie9plus
);
2929 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
2931 IHTMLDocument5_Release(doc5
);
2933 IHTMLDocument2_Release(doc
);
2934 return SUCCEEDED(hres
);
2940 container_hwnd
= create_container_window();
2943 if(winetest_interactive
|| ! is_ie_hardened()) {
2944 if(register_script_engine()) {
2945 test_simple_script();
2946 init_registry(FALSE
);
2948 skip("Could not register TestScript engine\n");
2952 skip("IE running in Enhanced Security Configuration\n");
2955 win_skip("Too old IE.\n");
2958 DestroyWindow(container_hwnd
);