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
149 #define DISPID_EXTERNAL_BROKEN 0x300004
150 #define DISPID_EXTERNAL_WIN_SKIP 0x300005
151 #define DISPID_EXTERNAL_WRITESTREAM 0x300006
153 static const GUID CLSID_TestScript
=
154 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x07,0x46}};
155 static const GUID CLSID_TestActiveX
=
156 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
158 static BOOL is_ie9plus
;
159 static IHTMLDocument2
*notif_doc
;
160 static IOleDocumentView
*view
;
161 static IDispatchEx
*window_dispex
;
162 static BOOL doc_complete
;
163 static IDispatch
*script_disp
;
164 static BOOL ax_objsafe
;
165 static HWND container_hwnd
;
166 static HRESULT ax_getopt_hres
= S_OK
, ax_setopt_dispex_hres
= S_OK
;
167 static HRESULT ax_setopt_disp_caller_hres
= S_OK
, ax_setopt_disp_data_hres
= S_OK
;
168 static BOOL skip_loadobject_tests
;
170 static IActiveScriptSite
*site
;
171 static SCRIPTSTATE state
;
173 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
176 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
177 return lstrcmpA(stra
, buf
);
180 static BSTR
a2bstr(const char *str
)
188 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
189 ret
= SysAllocStringLen(NULL
, len
);
190 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
195 static BOOL
init_key(const char *key_name
, const char *def_value
, BOOL init
)
201 RegDeleteKeyA(HKEY_CLASSES_ROOT
, key_name
);
205 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, key_name
, &hkey
);
206 if(res
!= ERROR_SUCCESS
)
210 res
= RegSetValueA(hkey
, NULL
, REG_SZ
, def_value
, strlen(def_value
));
214 return res
== ERROR_SUCCESS
;
217 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
218 REFIID riid
, void**ppv
)
220 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
225 return E_NOINTERFACE
;
228 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
233 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
238 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
240 if(dispID
== DISPID_READYSTATE
){
244 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
246 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
247 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
249 if(!lstrcmpW(state
, completeW
))
252 SysFreeString(state
);
258 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
260 ok(0, "unexpected call\n");
264 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
265 PropertyNotifySink_QueryInterface
,
266 PropertyNotifySink_AddRef
,
267 PropertyNotifySink_Release
,
268 PropertyNotifySink_OnChanged
,
269 PropertyNotifySink_OnRequestEdit
272 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
274 static HRESULT WINAPI
VariantChangeType_QueryInterface(IVariantChangeType
*iface
, REFIID riid
, void **ppv
)
276 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid
));
278 return E_NOINTERFACE
;
281 static ULONG WINAPI
VariantChangeType_AddRef(IVariantChangeType
*iface
)
286 static ULONG WINAPI
VariantChangeType_Release(IVariantChangeType
*iface
)
291 static HRESULT WINAPI
VariantChangeType_ChangeType(IVariantChangeType
*iface
, VARIANT
*dst
, VARIANT
*src
, LCID lcid
, VARTYPE vt
)
293 CHECK_EXPECT(ChangeType
);
295 ok(dst
!= NULL
, "dst = NULL\n");
296 ok(V_VT(dst
) == VT_EMPTY
, "V_VT(dst) = %d\n", V_VT(dst
));
297 ok(src
!= NULL
, "src = NULL\n");
298 ok(V_VT(src
) == VT_I4
, "V_VT(src) = %d\n", V_VT(src
));
299 ok(V_I4(src
) == 0xf0f0f0, "V_I4(src) = %x\n", V_I4(src
));
300 ok(lcid
== LOCALE_NEUTRAL
, "lcid = %d\n", lcid
);
301 ok(vt
== VT_BSTR
, "vt = %d\n", vt
);
304 V_BSTR(dst
) = a2bstr("red");
308 static const IVariantChangeTypeVtbl VariantChangeTypeVtbl
= {
309 VariantChangeType_QueryInterface
,
310 VariantChangeType_AddRef
,
311 VariantChangeType_Release
,
312 VariantChangeType_ChangeType
315 static IVariantChangeType VChangeType
= { &VariantChangeTypeVtbl
};
317 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
319 ok(0, "unexpected call\n");
320 return E_NOINTERFACE
;
323 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
328 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
333 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
334 REFIID riid
, void **ppv
)
336 if(IsEqualGUID(guidService
, &SID_VariantConversion
)) {
337 CHECK_EXPECT(QS_VariantConversion
);
338 ok(IsEqualGUID(riid
, &IID_IVariantChangeType
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
343 if(IsEqualGUID(guidService
, &IID_IActiveScriptSite
)) {
344 CHECK_EXPECT(QS_IActiveScriptSite
);
345 ok(IsEqualGUID(riid
, &IID_IOleCommandTarget
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
346 return IActiveScriptSite_QueryInterface(site
, riid
, ppv
);
349 if(IsEqualGUID(guidService
, &SID_GetCaller
)) {
350 CHECK_EXPECT(QS_GetCaller
);
351 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
353 return E_NOINTERFACE
;
356 ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService
));
357 return E_NOINTERFACE
;
360 static const IServiceProviderVtbl ServiceProviderVtbl
= {
361 ServiceProvider_QueryInterface
,
362 ServiceProvider_AddRef
,
363 ServiceProvider_Release
,
364 ServiceProvider_QueryService
367 static IServiceProvider caller_sp
= { &ServiceProviderVtbl
};
369 static HRESULT WINAPI
DispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
373 if(IsEqualGUID(riid
, &IID_IUnknown
)
374 || IsEqualGUID(riid
, &IID_IDispatch
)
375 || IsEqualGUID(riid
, &IID_IDispatchEx
))
378 return E_NOINTERFACE
;
383 static ULONG WINAPI
DispatchEx_AddRef(IDispatchEx
*iface
)
388 static ULONG WINAPI
DispatchEx_Release(IDispatchEx
*iface
)
393 static HRESULT WINAPI
DispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
395 ok(0, "unexpected call\n");
399 static HRESULT WINAPI
DispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
400 LCID lcid
, ITypeInfo
**ppTInfo
)
402 ok(0, "unexpected call\n");
406 static HRESULT WINAPI
DispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
407 LPOLESTR
*rgszNames
, UINT cNames
,
408 LCID lcid
, DISPID
*rgDispId
)
410 ok(0, "unexpected call\n");
414 static HRESULT WINAPI
DispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
415 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
416 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
418 ok(0, "unexpected call\n");
422 static HRESULT WINAPI
DispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
424 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName
), grfdex
);
428 static HRESULT WINAPI
DispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
430 ok(0, "unexpected call\n");
434 static HRESULT WINAPI
DispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
436 ok(0, "unexpected call\n");
440 static HRESULT WINAPI
DispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
442 ok(0, "unexpected call\n");
446 static HRESULT WINAPI
DispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
448 ok(0, "unexpected call\n");
452 static HRESULT WINAPI
DispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
454 ok(0, "unexpected call\n");
458 static HRESULT WINAPI
DispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
460 ok(0, "unexpected call\n");
464 static HRESULT WINAPI
funcDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
465 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
467 CHECK_EXPECT(funcDisp
);
469 ok(id
== DISPID_VALUE
, "id = %d\n", id
);
470 ok(lcid
== 0, "lcid = %x\n", lcid
);
471 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
472 ok(pdp
!= NULL
, "pdp == NULL\n");
473 ok(pdp
->cArgs
== 2, "pdp->cArgs = %d\n", pdp
->cArgs
);
474 ok(pdp
->cNamedArgs
== 1, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
475 ok(pdp
->rgdispidNamedArgs
[0] == DISPID_THIS
, "pdp->rgdispidNamedArgs[0] = %d\n", pdp
->rgdispidNamedArgs
[0]);
476 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
477 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(rgvarg[1]) = %d\n", V_VT(pdp
->rgvarg
));
478 ok(V_BOOL(pdp
->rgvarg
+1) == VARIANT_TRUE
, "V_BOOL(rgvarg[1]) = %x\n", V_BOOL(pdp
->rgvarg
));
479 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
480 ok(pei
!= NULL
, "pei == NULL\n");
481 ok(!pspCaller
, "pspCaller != NULL\n");
483 V_VT(pvarRes
) = VT_I4
;
488 static IDispatchExVtbl testObjVtbl
= {
489 DispatchEx_QueryInterface
,
492 DispatchEx_GetTypeInfoCount
,
493 DispatchEx_GetTypeInfo
,
494 DispatchEx_GetIDsOfNames
,
496 DispatchEx_GetDispID
,
498 DispatchEx_DeleteMemberByName
,
499 DispatchEx_DeleteMemberByDispID
,
500 DispatchEx_GetMemberProperties
,
501 DispatchEx_GetMemberName
,
502 DispatchEx_GetNextDispID
,
503 DispatchEx_GetNameSpaceParent
506 static IDispatchEx funcDisp
= { &testObjVtbl
};
508 static HRESULT WINAPI
scriptDisp_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
510 if(!strcmp_wa(bstrName
, "testProp")) {
511 CHECK_EXPECT(script_testprop_d
);
512 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
513 *pid
= DISPID_SCRIPT_TESTPROP
;
517 if(!strcmp_wa(bstrName
, "testProp2")) {
518 CHECK_EXPECT(script_testprop2_d
);
519 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
520 *pid
= DISPID_SCRIPT_TESTPROP2
;
524 if(!strcmp_wa(bstrName
, "divid")) {
525 CHECK_EXPECT(script_divid_d
);
526 ok(grfdex
== fdexNameCaseSensitive
, "grfdex = %x\n", grfdex
);
530 ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName
));
534 static HRESULT WINAPI
scriptDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
535 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
538 case DISPID_SCRIPT_TESTPROP
:
539 CHECK_EXPECT(script_testprop_i
);
541 ok(lcid
== 0, "lcid = %x\n", lcid
);
542 ok(wFlags
== DISPATCH_PROPERTYGET
, "wFlags = %x\n", wFlags
);
543 ok(pdp
!= NULL
, "pdp == NULL\n");
544 ok(pdp
->cArgs
== 0, "pdp->cArgs = %d\n", pdp
->cArgs
);
545 ok(pdp
->cNamedArgs
== 0, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
546 ok(!pdp
->rgdispidNamedArgs
, "pdp->rgdispidNamedArgs != NULL\n");
547 ok(!pdp
->rgvarg
, "rgvarg != NULL\n");
548 ok(pvarRes
!= NULL
, "pvarRes == NULL\n");
549 ok(pei
!= NULL
, "pei == NULL\n");
550 ok(!pspCaller
, "pspCaller != NULL\n");
552 V_VT(pvarRes
) = VT_NULL
;
555 ok(0, "unexpected call\n");
562 static IDispatchExVtbl scriptDispVtbl
= {
563 DispatchEx_QueryInterface
,
566 DispatchEx_GetTypeInfoCount
,
567 DispatchEx_GetTypeInfo
,
568 DispatchEx_GetIDsOfNames
,
570 scriptDisp_GetDispID
,
572 DispatchEx_DeleteMemberByName
,
573 DispatchEx_DeleteMemberByDispID
,
574 DispatchEx_GetMemberProperties
,
575 DispatchEx_GetMemberName
,
576 DispatchEx_GetNextDispID
,
577 DispatchEx_GetNameSpaceParent
580 static IDispatchEx scriptDisp
= { &scriptDispVtbl
};
582 static HRESULT WINAPI
externalDisp_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
584 if(!strcmp_wa(bstrName
, "ok")) {
585 *pid
= DISPID_EXTERNAL_OK
;
588 if(!strcmp_wa(bstrName
, "trace")) {
589 *pid
= DISPID_EXTERNAL_TRACE
;
592 if(!strcmp_wa(bstrName
, "reportSuccess")) {
593 *pid
= DISPID_EXTERNAL_REPORTSUCCESS
;
596 if(!strcmp_wa(bstrName
, "todo_wine_ok")) {
597 *pid
= DISPID_EXTERNAL_TODO_WINE_OK
;
600 if(!strcmp_wa(bstrName
, "broken")) {
601 *pid
= DISPID_EXTERNAL_BROKEN
;
604 if(!strcmp_wa(bstrName
, "win_skip")) {
605 *pid
= DISPID_EXTERNAL_WIN_SKIP
;
608 if(!strcmp_wa(bstrName
, "writeStream")) {
609 *pid
= DISPID_EXTERNAL_WRITESTREAM
;
613 ok(0, "unexpected name %s\n", wine_dbgstr_w(bstrName
));
614 return DISP_E_UNKNOWNNAME
;
617 static void stream_write(const WCHAR
*,const WCHAR
*);
619 static HRESULT WINAPI
externalDisp_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
620 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
623 case DISPID_EXTERNAL_OK
: {
626 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
627 ok(pdp
!= NULL
, "pdp == NULL\n");
628 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
629 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
630 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
631 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
632 ok(pei
!= NULL
, "pei == NULL\n");
635 if(V_VT(m
) == (VT_BYREF
|VT_VARIANT
))
637 ok(V_VT(m
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
640 if(V_VT(b
) == (VT_BYREF
|VT_VARIANT
))
642 ok(V_VT(b
) == VT_BOOL
, "V_VT(b) = %d\n", V_VT(b
));
644 ok(V_BOOL(b
), "%s\n", wine_dbgstr_w(V_BSTR(m
)));
648 case DISPID_EXTERNAL_TRACE
:
649 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
650 ok(pdp
!= NULL
, "pdp == NULL\n");
651 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
652 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
653 ok(pdp
->cArgs
== 1, "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");
658 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
659 if(V_VT(pdp
->rgvarg
) == VT_BSTR
)
660 trace("%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
664 case DISPID_EXTERNAL_REPORTSUCCESS
:
665 CHECK_EXPECT(external_success
);
667 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
668 ok(pdp
!= NULL
, "pdp == NULL\n");
669 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
670 ok(pdp
->cArgs
== 0, "cArgs = %d\n", pdp
->cArgs
);
671 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
672 ok(!pvarRes
, "pvarRes != NULL\n");
673 ok(pei
!= NULL
, "pei == NULL\n");
677 case DISPID_EXTERNAL_TODO_WINE_OK
:
678 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
679 ok(pdp
!= NULL
, "pdp == NULL\n");
680 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
681 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
682 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
683 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
684 ok(pei
!= NULL
, "pei == NULL\n");
686 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
687 ok(V_VT(pdp
->rgvarg
+1) == VT_BOOL
, "V_VT(psp->rgvargs+1) = %d\n", V_VT(pdp
->rgvarg
));
689 ok(V_BOOL(pdp
->rgvarg
+1), "%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
693 case DISPID_EXTERNAL_BROKEN
:
694 ok(wFlags
== INVOKE_FUNC
|| wFlags
== (INVOKE_FUNC
|INVOKE_PROPERTYGET
), "wFlags = %x\n", wFlags
);
695 ok(pdp
!= NULL
, "pdp == NULL\n");
696 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
697 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
698 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
699 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
700 ok(pei
!= NULL
, "pei == NULL\n");
702 ok(V_VT(pdp
->rgvarg
) == VT_BOOL
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
703 V_VT(pvarRes
) = VT_BOOL
;
704 V_BOOL(pvarRes
) = broken(V_BOOL(pdp
->rgvarg
)) ? VARIANT_TRUE
: VARIANT_FALSE
;
707 case DISPID_EXTERNAL_WIN_SKIP
:
708 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
709 ok(pdp
!= NULL
, "pdp == NULL\n");
710 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
711 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
712 ok(pdp
->cArgs
== 1, "cArgs = %d\n", pdp
->cArgs
);
713 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
714 ok(!pvarRes
, "pvarRes != NULL\n");
715 ok(pei
!= NULL
, "pei == NULL\n");
717 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
718 if(V_VT(pdp
->rgvarg
) == VT_BSTR
)
719 win_skip("%s\n", wine_dbgstr_w(V_BSTR(pdp
->rgvarg
)));
723 case DISPID_EXTERNAL_WRITESTREAM
:
724 ok(wFlags
== INVOKE_FUNC
, "wFlags = %x\n", wFlags
);
725 ok(pdp
!= NULL
, "pdp == NULL\n");
726 ok(pdp
->rgvarg
!= NULL
, "rgvarg == NULL\n");
727 ok(!pdp
->rgdispidNamedArgs
, "rgdispidNamedArgs != NULL\n");
728 ok(pdp
->cArgs
== 2, "cArgs = %d\n", pdp
->cArgs
);
729 ok(!pdp
->cNamedArgs
, "cNamedArgs = %d\n", pdp
->cNamedArgs
);
730 ok(!pvarRes
, "pvarRes != NULL\n");
731 ok(pei
!= NULL
, "pei == NULL\n");
733 ok(V_VT(pdp
->rgvarg
) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
734 ok(V_VT(pdp
->rgvarg
+1) == VT_BSTR
, "V_VT(psp->rgvargs) = %d\n", V_VT(pdp
->rgvarg
));
736 stream_write(V_BSTR(pdp
->rgvarg
+1), V_BSTR(pdp
->rgvarg
));
740 ok(0, "unexpected call\n");
747 static IDispatchExVtbl externalDispVtbl
= {
748 DispatchEx_QueryInterface
,
751 DispatchEx_GetTypeInfoCount
,
752 DispatchEx_GetTypeInfo
,
753 DispatchEx_GetIDsOfNames
,
755 externalDisp_GetDispID
,
756 externalDisp_InvokeEx
,
757 DispatchEx_DeleteMemberByName
,
758 DispatchEx_DeleteMemberByDispID
,
759 DispatchEx_GetMemberProperties
,
760 DispatchEx_GetMemberName
,
761 DispatchEx_GetNextDispID
,
762 DispatchEx_GetNameSpaceParent
765 static IDispatchEx externalDisp
= { &externalDispVtbl
};
767 static HRESULT
QueryInterface(REFIID
,void**);
769 static HRESULT WINAPI
DocHostUIHandler_QueryInterface(IDocHostUIHandler2
*iface
, REFIID riid
, void **ppv
)
771 return QueryInterface(riid
, ppv
);
774 static ULONG WINAPI
DocHostUIHandler_AddRef(IDocHostUIHandler2
*iface
)
779 static ULONG WINAPI
DocHostUIHandler_Release(IDocHostUIHandler2
*iface
)
784 static HRESULT WINAPI
DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2
*iface
, DWORD dwID
, POINT
*ppt
,
785 IUnknown
*pcmdtReserved
, IDispatch
*pdicpReserved
)
790 static HRESULT WINAPI
DocHostUIHandler_GetHostInfo(IDocHostUIHandler2
*iface
, DOCHOSTUIINFO
*pInfo
)
795 static HRESULT WINAPI
DocHostUIHandler_ShowUI(IDocHostUIHandler2
*iface
, DWORD dwID
,
796 IOleInPlaceActiveObject
*pActiveObject
, IOleCommandTarget
*pCommandTarget
,
797 IOleInPlaceFrame
*pFrame
, IOleInPlaceUIWindow
*pDoc
)
802 static HRESULT WINAPI
DocHostUIHandler_HideUI(IDocHostUIHandler2
*iface
)
807 static HRESULT WINAPI
DocHostUIHandler_UpdateUI(IDocHostUIHandler2
*iface
)
812 static HRESULT WINAPI
DocHostUIHandler_EnableModeless(IDocHostUIHandler2
*iface
, BOOL fEnable
)
817 static HRESULT WINAPI
DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
822 static HRESULT WINAPI
DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2
*iface
, BOOL fActivate
)
827 static HRESULT WINAPI
DocHostUIHandler_ResizeBorder(IDocHostUIHandler2
*iface
, LPCRECT prcBorder
,
828 IOleInPlaceUIWindow
*pUIWindow
, BOOL fRameWindow
)
833 static HRESULT WINAPI
DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2
*iface
, LPMSG lpMsg
,
834 const GUID
*pguidCmdGroup
, DWORD nCmdID
)
839 static HRESULT WINAPI
DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2
*iface
,
840 LPOLESTR
*pchKey
, DWORD dw
)
845 static HRESULT WINAPI
DocHostUIHandler_GetDropTarget(IDocHostUIHandler2
*iface
,
846 IDropTarget
*pDropTarget
, IDropTarget
**ppDropTarget
)
851 static HRESULT WINAPI
DocHostUIHandler_GetExternal(IDocHostUIHandler2
*iface
, IDispatch
**ppDispatch
)
853 *ppDispatch
= (IDispatch
*)&externalDisp
;
857 static HRESULT WINAPI
DocHostUIHandler_TranslateUrl(IDocHostUIHandler2
*iface
, DWORD dwTranslate
,
858 OLECHAR
*pchURLIn
, OLECHAR
**ppchURLOut
)
863 static HRESULT WINAPI
DocHostUIHandler_FilterDataObject(IDocHostUIHandler2
*iface
, IDataObject
*pDO
,
864 IDataObject
**ppPORet
)
869 static HRESULT WINAPI
DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2
*iface
,
870 LPOLESTR
*pchKey
, DWORD dw
)
875 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl
= {
876 DocHostUIHandler_QueryInterface
,
877 DocHostUIHandler_AddRef
,
878 DocHostUIHandler_Release
,
879 DocHostUIHandler_ShowContextMenu
,
880 DocHostUIHandler_GetHostInfo
,
881 DocHostUIHandler_ShowUI
,
882 DocHostUIHandler_HideUI
,
883 DocHostUIHandler_UpdateUI
,
884 DocHostUIHandler_EnableModeless
,
885 DocHostUIHandler_OnDocWindowActivate
,
886 DocHostUIHandler_OnFrameWindowActivate
,
887 DocHostUIHandler_ResizeBorder
,
888 DocHostUIHandler_TranslateAccelerator
,
889 DocHostUIHandler_GetOptionKeyPath
,
890 DocHostUIHandler_GetDropTarget
,
891 DocHostUIHandler_GetExternal
,
892 DocHostUIHandler_TranslateUrl
,
893 DocHostUIHandler_FilterDataObject
,
894 DocHostUIHandler_GetOverrideKeyPath
897 static IDocHostUIHandler2 DocHostUIHandler
= { &DocHostUIHandlerVtbl
};
899 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
901 return E_NOINTERFACE
;
904 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
909 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
914 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
919 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
924 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
929 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
930 LPCBORDERWIDTHS pborderwidths
)
935 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
936 LPCBORDERWIDTHS pborderwidths
)
941 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
942 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
947 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
948 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
953 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
954 HOLEMENU holemenu
, HWND hwndActiveObject
)
956 ok(0, "unexpected call\n");
960 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
962 ok(0, "unexpected call\n");
966 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
971 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
976 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
978 ok(0, "unexpected call\n");
982 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
983 InPlaceFrame_QueryInterface
,
985 InPlaceFrame_Release
,
986 InPlaceFrame_GetWindow
,
987 InPlaceFrame_ContextSensitiveHelp
,
988 InPlaceFrame_GetBorder
,
989 InPlaceFrame_RequestBorderSpace
,
990 InPlaceFrame_SetBorderSpace
,
991 InPlaceFrame_SetActiveObject
,
992 InPlaceFrame_InsertMenus
,
993 InPlaceFrame_SetMenu
,
994 InPlaceFrame_RemoveMenus
,
995 InPlaceFrame_SetStatusText
,
996 InPlaceFrame_EnableModeless
,
997 InPlaceFrame_TranslateAccelerator
1000 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
1002 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
1004 return QueryInterface(riid
, ppv
);
1007 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
1012 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
1017 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
1019 *phwnd
= container_hwnd
;
1023 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
1025 ok(0, "unexpected call\n");
1029 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
1034 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
1039 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
1044 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
1045 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
1046 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
1048 static const RECT rect
= {0,0,300,300};
1050 *ppFrame
= &InPlaceFrame
;
1051 *ppDoc
= (IOleInPlaceUIWindow
*)&InPlaceFrame
;
1052 *lprcPosRect
= rect
;
1053 *lprcClipRect
= rect
;
1055 ok(lpFrameInfo
->cb
== sizeof(*lpFrameInfo
), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo
->cb
, (unsigned)sizeof(*lpFrameInfo
));
1056 lpFrameInfo
->fMDIApp
= FALSE
;
1057 lpFrameInfo
->hwndFrame
= container_hwnd
;
1058 lpFrameInfo
->haccel
= NULL
;
1059 lpFrameInfo
->cAccelEntries
= 0;
1064 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
1069 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
1074 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
1079 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
1084 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
1089 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
1094 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
1095 InPlaceSite_QueryInterface
,
1097 InPlaceSite_Release
,
1098 InPlaceSite_GetWindow
,
1099 InPlaceSite_ContextSensitiveHelp
,
1100 InPlaceSite_CanInPlaceActivate
,
1101 InPlaceSite_OnInPlaceActivate
,
1102 InPlaceSite_OnUIActivate
,
1103 InPlaceSite_GetWindowContext
,
1105 InPlaceSite_OnUIDeactivate
,
1106 InPlaceSite_OnInPlaceDeactivate
,
1107 InPlaceSite_DiscardUndoState
,
1108 InPlaceSite_DeactivateAndUndo
,
1109 InPlaceSite_OnPosRectChange
,
1112 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
1114 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
1116 return QueryInterface(riid
, ppv
);
1119 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
1124 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
1129 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
1131 ok(0, "unexpected call\n");
1135 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
1138 ok(0, "unexpected call\n");
1142 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
1147 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
1149 ok(0, "unexpected call\n");
1153 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
1155 ok(0, "unexpected call\n");
1159 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
1161 ok(0, "unexpected call\n");
1165 static const IOleClientSiteVtbl ClientSiteVtbl
= {
1166 ClientSite_QueryInterface
,
1169 ClientSite_SaveObject
,
1170 ClientSite_GetMoniker
,
1171 ClientSite_GetContainer
,
1172 ClientSite_ShowObject
,
1173 ClientSite_OnShowWindow
,
1174 ClientSite_RequestNewObjectLayout
1177 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
1179 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
1181 return QueryInterface(riid
, ppv
);
1184 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
1189 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
1194 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
1196 RECT rect
= {0,0,300,300};
1197 IOleDocument
*document
;
1200 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
1201 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
1203 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
1204 IOleDocument_Release(document
);
1205 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
1207 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
1208 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
1210 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
1211 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
1213 hres
= IOleDocumentView_SetRect(view
, &rect
);
1214 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
1216 hres
= IOleDocumentView_Show(view
, TRUE
);
1217 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
1222 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
1223 DocumentSite_QueryInterface
,
1224 DocumentSite_AddRef
,
1225 DocumentSite_Release
,
1226 DocumentSite_ActivateMe
1229 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
1231 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
1235 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
1237 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
1238 *ppv
= &DocumentSite
;
1239 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
1240 *ppv
= &InPlaceSite
;
1241 else if(IsEqualGUID(&IID_IDocHostUIHandler
, riid
) || IsEqualGUID(&IID_IDocHostUIHandler2
, riid
))
1242 *ppv
= &DocHostUIHandler
;
1244 return *ppv
? S_OK
: E_NOINTERFACE
;
1247 static IHTMLDocument2
*create_document(void)
1249 IHTMLDocument2
*doc
;
1252 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1253 &IID_IHTMLDocument2
, (void**)&doc
);
1254 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1255 return SUCCEEDED(hres
) ? doc
: NULL
;
1258 static void load_string(IHTMLDocument2
*doc
, const char *str
)
1260 IPersistStreamInit
*init
;
1265 doc_complete
= FALSE
;
1267 mem
= GlobalAlloc(0, len
);
1268 memcpy(mem
, str
, len
);
1269 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
1271 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
1273 IPersistStreamInit_Load(init
, stream
);
1274 IPersistStreamInit_Release(init
);
1275 IStream_Release(stream
);
1278 static void do_advise(IHTMLDocument2
*doc
, REFIID riid
, IUnknown
*unk_advise
)
1280 IConnectionPointContainer
*container
;
1281 IConnectionPoint
*cp
;
1285 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IConnectionPointContainer
, (void**)&container
);
1286 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
1288 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
1289 IConnectionPointContainer_Release(container
);
1290 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1294 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
1295 IConnectionPoint_Release(cp
);
1296 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1299 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
1305 IOleDocumentView_Show(view
, FALSE
);
1306 IOleDocumentView_CloseView(view
, 0);
1307 IOleDocumentView_SetInPlaceSite(view
, NULL
);
1308 IOleDocumentView_Release(view
);
1312 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
1313 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
1315 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
1316 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
1319 IHlinkTarget
*hlink
;
1321 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
1322 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
1324 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
1325 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
1327 IHlinkTarget_Release(hlink
);
1330 IOleObject_Release(oleobj
);
1333 typedef void (*domtest_t
)(IHTMLDocument2
*);
1335 static void load_doc(IHTMLDocument2
*doc
, const char *str
)
1337 IHTMLElement
*body
= NULL
;
1340 static const WCHAR ucPtr
[] = {'b','a','c','k','g','r','o','u','n','d',0};
1344 load_string(doc
, str
);
1345 do_advise(doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
1347 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
1348 TranslateMessage(&msg
);
1349 DispatchMessageW(&msg
);
1352 hres
= IHTMLDocument2_get_body(doc
, &body
);
1353 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1355 /* Check we can query for function on the IHTMLElementBody interface */
1356 name
= (WCHAR
*)ucPtr
;
1357 hres
= IHTMLElement_GetIDsOfNames(body
, &IID_NULL
, &name
, 1, LOCALE_USER_DEFAULT
, &dispID
);
1358 ok(hres
== S_OK
, "GetIDsOfNames(background) failed %08x\n", hres
);
1359 ok(dispID
== DISPID_IHTMLBODYELEMENT_BACKGROUND
, "Incorrect dispID got (%d)\n", dispID
);
1361 IHTMLElement_Release(body
);
1364 static HRESULT WINAPI
ObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1367 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid
));
1368 return E_NOINTERFACE
;
1371 static ULONG WINAPI
ObjectSafety_AddRef(IObjectSafety
*iface
)
1376 static ULONG WINAPI
ObjectSafety_Release(IObjectSafety
*iface
)
1381 static HRESULT WINAPI
ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1382 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1384 CHECK_EXPECT(GetInterfaceSafetyOptions
);
1386 ok(IsEqualGUID(&IID_IActiveScriptParse
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1387 ok(pdwSupportedOptions
!= NULL
, "pdwSupportedOptions == NULL\n");
1388 ok(pdwEnabledOptions
!= NULL
, "pdwEnabledOptions == NULL\n");
1390 *pdwSupportedOptions
= INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
;
1391 *pdwEnabledOptions
= INTERFACE_USES_DISPEX
;
1396 static HRESULT WINAPI
ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1397 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1399 CHECK_EXPECT(SetInterfaceSafetyOptions
);
1401 ok(IsEqualGUID(&IID_IActiveScriptParse
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1403 ok(dwOptionSetMask
== (INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
),
1404 "dwOptionSetMask=%x\n", dwOptionSetMask
);
1405 ok(dwEnabledOptions
== (INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
),
1406 "dwEnabledOptions=%x\n", dwOptionSetMask
);
1411 static const IObjectSafetyVtbl ObjectSafetyVtbl
= {
1412 ObjectSafety_QueryInterface
,
1413 ObjectSafety_AddRef
,
1414 ObjectSafety_Release
,
1415 ObjectSafety_GetInterfaceSafetyOptions
,
1416 ObjectSafety_SetInterfaceSafetyOptions
1419 static IObjectSafety ObjectSafety
= { &ObjectSafetyVtbl
};
1421 static HRESULT WINAPI
AXObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1425 if(IsEqualGUID(&IID_IActiveScript
, riid
)) {
1426 CHECK_EXPECT(AXQueryInterface_IActiveScript
);
1427 return E_NOINTERFACE
;
1430 if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
1431 CHECK_EXPECT2(AXQueryInterface_IObjectSafety
);
1433 return E_NOINTERFACE
;
1438 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid
));
1439 return E_NOINTERFACE
;
1442 static HRESULT WINAPI
AXObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1443 DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1445 CHECK_EXPECT(AXGetInterfaceSafetyOptions
);
1447 ok(IsEqualGUID(&IID_IDispatchEx
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1448 ok(pdwSupportedOptions
!= NULL
, "pdwSupportedOptions == NULL\n");
1449 ok(pdwEnabledOptions
!= NULL
, "pdwEnabledOptions == NULL\n");
1451 if(SUCCEEDED(ax_getopt_hres
)) {
1452 *pdwSupportedOptions
= INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_DISPEX
|INTERFACE_USES_SECURITY_MANAGER
;
1453 *pdwEnabledOptions
= INTERFACE_USES_DISPEX
;
1456 return ax_getopt_hres
;
1459 static HRESULT WINAPI
AXObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
, REFIID riid
,
1460 DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1462 if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
1463 switch(dwEnabledOptions
) {
1464 case INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACE_USES_SECURITY_MANAGER
:
1465 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1467 case INTERFACESAFE_FOR_UNTRUSTED_CALLER
:
1468 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1471 ok(0, "unexpected dwEnabledOptions %x\n", dwEnabledOptions
);
1474 ok(dwOptionSetMask
== dwEnabledOptions
, "dwOptionSetMask=%x, expected %x\n", dwOptionSetMask
, dwEnabledOptions
);
1475 return ax_setopt_dispex_hres
;
1478 if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1481 switch(dwEnabledOptions
) {
1482 case INTERFACESAFE_FOR_UNTRUSTED_CALLER
:
1483 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1484 hres
= ax_setopt_disp_caller_hres
;
1486 case INTERFACESAFE_FOR_UNTRUSTED_DATA
:
1487 CHECK_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1488 hres
= ax_setopt_disp_data_hres
;
1491 ok(0, "unexpected dwEnabledOptions %x\n", dwEnabledOptions
);
1494 ok(dwOptionSetMask
== dwEnabledOptions
, "dwOptionSetMask=%x, expected %x\n", dwOptionSetMask
, dwEnabledOptions
);
1498 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
1499 return E_NOINTERFACE
;
1502 static const IObjectSafetyVtbl AXObjectSafetyVtbl
= {
1503 AXObjectSafety_QueryInterface
,
1504 ObjectSafety_AddRef
,
1505 ObjectSafety_Release
,
1506 AXObjectSafety_GetInterfaceSafetyOptions
,
1507 AXObjectSafety_SetInterfaceSafetyOptions
1510 static IObjectSafety AXObjectSafety
= { &AXObjectSafetyVtbl
};
1512 static BOOL
set_safe_reg(BOOL safe_call
, BOOL safe_data
)
1514 return init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
1516 && init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95802-9882-11cf-9fa9-00aa006c42c4}",
1520 #define check_custom_policy(a,b,c,d) _check_custom_policy(__LINE__,a,b,c,d)
1521 static void _check_custom_policy(unsigned line
, HRESULT hres
, BYTE
*ppolicy
, DWORD policy_size
, DWORD expolicy
)
1523 ok_(__FILE__
,line
)(hres
== S_OK
, "QueryCusromPolicy failed: %08x\n", hres
);
1524 ok_(__FILE__
,line
)(policy_size
== sizeof(DWORD
), "policy_size = %d\n", policy_size
);
1525 ok_(__FILE__
,line
)(*(DWORD
*)ppolicy
== expolicy
, "policy = %x, expected %x\n", *(DWORD
*)ppolicy
, expolicy
);
1526 CoTaskMemFree(ppolicy
);
1529 static void test_security_reg(IInternetHostSecurityManager
*sec_mgr
, DWORD policy_caller
, DWORD policy_load
)
1531 struct CONFIRMSAFETY cs
;
1536 cs
.clsid
= CLSID_TestActiveX
;
1537 cs
.pUnk
= (IUnknown
*)&AXObjectSafety
;
1541 SET_EXPECT(AXQueryInterface_IActiveScript
);
1542 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1543 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1544 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1545 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1546 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1547 check_custom_policy(hres
, ppolicy
, policy_size
, policy_caller
);
1550 SET_EXPECT(AXQueryInterface_IActiveScript
);
1551 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1552 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1553 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1554 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1555 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1556 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1557 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1558 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1559 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1560 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1562 if(skip_loadobject_tests
)
1565 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1567 SET_EXPECT(AXQueryInterface_IActiveScript
);
1568 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1569 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1570 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1571 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1572 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1573 check_custom_policy(hres
, ppolicy
, policy_size
, policy_load
);
1576 SET_EXPECT(AXQueryInterface_IActiveScript
);
1577 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1578 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1579 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1580 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1581 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1582 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1583 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1584 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1585 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1586 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1587 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1588 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1591 static void test_security(void)
1593 IInternetHostSecurityManager
*sec_mgr
;
1594 IServiceProvider
*sp
;
1595 DWORD policy
, policy_size
;
1596 struct CONFIRMSAFETY cs
;
1600 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IServiceProvider
, (void**)&sp
);
1601 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
1603 hres
= IServiceProvider_QueryService(sp
, &SID_SInternetHostSecurityManager
,
1604 &IID_IInternetHostSecurityManager
, (void**)&sec_mgr
);
1605 IServiceProvider_Release(sp
);
1606 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
1608 hres
= IInternetHostSecurityManager_ProcessUrlAction(sec_mgr
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
, sizeof(policy
),
1609 (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
1610 ok(hres
== S_OK
, "ProcessUrlAction failed: %08x\n", hres
);
1611 ok(policy
== URLPOLICY_ALLOW
, "policy = %x\n", policy
);
1613 cs
.clsid
= CLSID_TestActiveX
;
1614 cs
.pUnk
= (IUnknown
*)&AXObjectSafety
;
1618 SET_EXPECT(AXQueryInterface_IActiveScript
);
1619 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1620 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1621 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1622 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1623 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1624 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1625 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1626 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1627 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1628 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1630 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1631 SET_EXPECT(AXQueryInterface_IActiveScript
);
1632 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1633 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1634 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1635 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1636 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1637 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1638 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1639 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1640 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1641 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1642 if(called_AXSetInterfaceSafetyOptions_IDispatch_data
) {
1643 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1645 win_skip("CONFIRMSAFETYACTION_LOADOBJECT flag not supported\n");
1646 skip_loadobject_tests
= TRUE
;
1647 CLEAR_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1649 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1653 SET_EXPECT(AXQueryInterface_IActiveScript
);
1654 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1655 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1656 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1657 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1658 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1659 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1661 if(!skip_loadobject_tests
) {
1662 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1664 SET_EXPECT(AXQueryInterface_IActiveScript
);
1665 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1666 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1667 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1668 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1669 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1670 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1673 if(set_safe_reg(TRUE
, FALSE
)) {
1674 test_security_reg(sec_mgr
, URLPOLICY_ALLOW
, URLPOLICY_DISALLOW
);
1676 set_safe_reg(FALSE
, TRUE
);
1677 test_security_reg(sec_mgr
, URLPOLICY_DISALLOW
, URLPOLICY_DISALLOW
);
1679 set_safe_reg(TRUE
, TRUE
);
1680 test_security_reg(sec_mgr
, URLPOLICY_ALLOW
, URLPOLICY_ALLOW
);
1682 set_safe_reg(FALSE
, FALSE
);
1684 skip("Could not set safety registry\n");
1690 ax_setopt_dispex_hres
= E_NOINTERFACE
;
1691 SET_EXPECT(AXQueryInterface_IActiveScript
);
1692 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1693 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1694 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1695 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1696 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1697 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1698 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1699 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1700 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1701 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1702 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1703 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1705 ax_setopt_dispex_hres
= E_FAIL
;
1706 ax_setopt_disp_caller_hres
= E_NOINTERFACE
;
1707 SET_EXPECT(AXQueryInterface_IActiveScript
);
1708 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1709 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1710 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1711 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1712 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1713 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1714 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1715 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1716 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1717 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1718 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1719 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1721 if(!skip_loadobject_tests
) {
1722 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1723 ax_setopt_dispex_hres
= E_FAIL
;
1724 ax_setopt_disp_caller_hres
= E_NOINTERFACE
;
1725 SET_EXPECT(AXQueryInterface_IActiveScript
);
1726 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1727 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1728 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1729 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1730 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1731 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1732 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1733 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1734 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1735 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller_secmgr
);
1736 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1737 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1741 ax_setopt_dispex_hres
= E_FAIL
;
1742 ax_setopt_disp_caller_hres
= S_OK
;
1743 ax_getopt_hres
= E_NOINTERFACE
;
1744 SET_EXPECT(AXQueryInterface_IActiveScript
);
1745 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1746 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1747 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1748 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1749 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1750 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1751 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1752 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1753 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1754 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1755 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1756 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_ALLOW
);
1758 if(!skip_loadobject_tests
) {
1759 cs
.dwFlags
= CONFIRMSAFETYACTION_LOADOBJECT
;
1760 ax_setopt_dispex_hres
= E_FAIL
;
1761 ax_setopt_disp_caller_hres
= S_OK
;
1762 ax_setopt_disp_data_hres
= E_FAIL
;
1763 ax_getopt_hres
= E_NOINTERFACE
;
1764 SET_EXPECT(AXQueryInterface_IActiveScript
);
1765 SET_EXPECT(AXQueryInterface_IObjectSafety
);
1766 SET_EXPECT(AXGetInterfaceSafetyOptions
);
1767 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1768 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1769 SET_EXPECT(AXSetInterfaceSafetyOptions_IDispatch_data
);
1770 hres
= IInternetHostSecurityManager_QueryCustomPolicy(sec_mgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
1771 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
1772 CHECK_CALLED(AXQueryInterface_IActiveScript
);
1773 CHECK_CALLED(AXQueryInterface_IObjectSafety
);
1774 CHECK_CALLED(AXGetInterfaceSafetyOptions
);
1775 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatchEx_caller
);
1776 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_caller
);
1777 CHECK_CALLED(AXSetInterfaceSafetyOptions_IDispatch_data
);
1778 check_custom_policy(hres
, ppolicy
, policy_size
, URLPOLICY_DISALLOW
);
1781 IInternetHostSecurityManager_Release(sec_mgr
);
1784 static HRESULT WINAPI
ActiveScriptProperty_QueryInterface(IActiveScriptProperty
*iface
, REFIID riid
, void **ppv
)
1787 ok(0, "unexpected call\n");
1788 return E_NOINTERFACE
;
1791 static ULONG WINAPI
ActiveScriptProperty_AddRef(IActiveScriptProperty
*iface
)
1796 static ULONG WINAPI
ActiveScriptProperty_Release(IActiveScriptProperty
*iface
)
1801 static HRESULT WINAPI
ActiveScriptProperty_GetProperty(IActiveScriptProperty
*iface
, DWORD dwProperty
,
1802 VARIANT
*pvarIndex
, VARIANT
*pvarValue
)
1804 ok(0, "unexpected call\n");
1808 static HRESULT WINAPI
ActiveScriptProperty_SetProperty(IActiveScriptProperty
*iface
, DWORD dwProperty
,
1809 VARIANT
*pvarIndex
, VARIANT
*pvarValue
)
1811 switch(dwProperty
) {
1812 case SCRIPTPROP_HACK_TRIDENTEVENTSINK
:
1813 CHECK_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
1814 ok(V_VT(pvarValue
) == VT_BOOL
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1815 ok(V_BOOL(pvarValue
) == VARIANT_TRUE
, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue
));
1817 case SCRIPTPROP_INVOKEVERSIONING
:
1818 CHECK_EXPECT(SetProperty_INVOKEVERSIONING
);
1819 ok(V_VT(pvarValue
) == VT_I4
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1820 ok(V_I4(pvarValue
) == 1, "V_I4(pvarValue)=%d\n", V_I4(pvarValue
));
1822 case SCRIPTPROP_ABBREVIATE_GLOBALNAME_RESOLUTION
:
1823 CHECK_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
);
1824 ok(V_VT(pvarValue
) == VT_BOOL
, "V_VT(pvarValue)=%d\n", V_VT(pvarValue
));
1825 ok(V_BOOL(pvarValue
) == VARIANT_TRUE
, "V_BOOL(pvarValue)=%x\n", V_BOOL(pvarValue
));
1827 case 0x70000003: /* Undocumented property set by IE10 */
1830 ok(0, "unexpected property %x\n", dwProperty
);
1834 ok(!pvarIndex
, "pvarIndex != NULL\n");
1835 ok(pvarValue
!= NULL
, "pvarValue == NULL\n");
1840 static const IActiveScriptPropertyVtbl ActiveScriptPropertyVtbl
= {
1841 ActiveScriptProperty_QueryInterface
,
1842 ActiveScriptProperty_AddRef
,
1843 ActiveScriptProperty_Release
,
1844 ActiveScriptProperty_GetProperty
,
1845 ActiveScriptProperty_SetProperty
1848 static IActiveScriptProperty ActiveScriptProperty
= { &ActiveScriptPropertyVtbl
};
1850 static HRESULT WINAPI
ActiveScriptParseProcedure_QueryInterface(IActiveScriptParseProcedure2
*iface
, REFIID riid
, void **ppv
)
1853 ok(0, "unexpected call\n");
1854 return E_NOINTERFACE
;
1857 static ULONG WINAPI
ActiveScriptParseProcedure_AddRef(IActiveScriptParseProcedure2
*iface
)
1862 static ULONG WINAPI
ActiveScriptParseProcedure_Release(IActiveScriptParseProcedure2
*iface
)
1867 static HRESULT WINAPI
ActiveScriptParseProcedure_ParseProcedureText(IActiveScriptParseProcedure2
*iface
,
1868 LPCOLESTR pstrCode
, LPCOLESTR pstrFormalParams
, LPCOLESTR pstrProcedureName
,
1869 LPCOLESTR pstrItemName
, IUnknown
*punkContext
, LPCOLESTR pstrDelimiter
,
1870 CTXARG_T dwSourceContextCookie
, ULONG ulStartingLineNumber
, DWORD dwFlags
, IDispatch
**ppdisp
)
1872 ok(0, "unexpected call\n");
1876 static const IActiveScriptParseProcedure2Vtbl ActiveScriptParseProcedureVtbl
= {
1877 ActiveScriptParseProcedure_QueryInterface
,
1878 ActiveScriptParseProcedure_AddRef
,
1879 ActiveScriptParseProcedure_Release
,
1880 ActiveScriptParseProcedure_ParseProcedureText
1883 static IActiveScriptParseProcedure2 ActiveScriptParseProcedure
= { &ActiveScriptParseProcedureVtbl
};
1885 static HRESULT WINAPI
ActiveScriptParse_QueryInterface(IActiveScriptParse
*iface
, REFIID riid
, void **ppv
)
1888 ok(0, "unexpected call\n");
1889 return E_NOINTERFACE
;
1892 static ULONG WINAPI
ActiveScriptParse_AddRef(IActiveScriptParse
*iface
)
1897 static ULONG WINAPI
ActiveScriptParse_Release(IActiveScriptParse
*iface
)
1902 static HRESULT WINAPI
ActiveScriptParse_InitNew(IActiveScriptParse
*iface
)
1904 CHECK_EXPECT(InitNew
);
1908 static HRESULT WINAPI
ActiveScriptParse_AddScriptlet(IActiveScriptParse
*iface
,
1909 LPCOLESTR pstrDefaultName
, LPCOLESTR pstrCode
, LPCOLESTR pstrItemName
,
1910 LPCOLESTR pstrSubItemName
, LPCOLESTR pstrEventName
, LPCOLESTR pstrDelimiter
,
1911 CTXARG_T dwSourceContextCookie
, ULONG ulStartingLineNumber
, DWORD dwFlags
,
1912 BSTR
*pbstrName
, EXCEPINFO
*pexcepinfo
)
1914 ok(0, "unexpected call\n");
1918 static HRESULT
dispex_propput(IDispatchEx
*obj
, DISPID id
, DWORD flags
, VARIANT
*var
, IServiceProvider
*caller_sp
)
1920 DISPID propput_arg
= DISPID_PROPERTYPUT
;
1921 DISPPARAMS dp
= {var
, &propput_arg
, 1, 1};
1924 return IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYPUT
|flags
, &dp
, NULL
, &ei
, caller_sp
);
1927 static HRESULT
dispex_propget(IDispatchEx
*obj
, DISPID id
, VARIANT
*res
, IServiceProvider
*caller_sp
)
1929 DISPPARAMS dp
= {NULL
};
1932 return IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYGET
, &dp
, res
, &ei
, caller_sp
);
1935 static void test_func(IDispatchEx
*obj
)
1938 IDispatchEx
*dispex
;
1946 str
= a2bstr("toString");
1947 hres
= IDispatchEx_GetDispID(obj
, str
, fdexNameCaseSensitive
, &id
);
1949 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
1950 ok(id
== DISPID_IOMNAVIGATOR_TOSTRING
, "id = %x\n", id
);
1952 memset(&dp
, 0, sizeof(dp
));
1953 memset(&ei
, 0, sizeof(ei
));
1955 hres
= IDispatchEx_InvokeEx(obj
, id
, LOCALE_NEUTRAL
, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
1956 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1957 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
1958 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
1959 disp
= V_DISPATCH(&var
);
1961 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
1962 IDispatch_Release(disp
);
1963 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
1965 /* FIXME: Test InvokeEx(DISPATCH_METHOD) */
1967 memset(&dp
, 0, sizeof(dp
));
1968 memset(&ei
, 0, sizeof(ei
));
1970 hres
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, LOCALE_NEUTRAL
, DISPATCH_METHOD
, &dp
, &var
, &ei
, NULL
);
1971 ok(hres
== S_OK
|| broken(hres
== E_ACCESSDENIED
), "InvokeEx failed: %08x\n", hres
);
1972 if(SUCCEEDED(hres
)) {
1973 DISPID named_args
[2] = { DISPID_THIS
, 0xdeadbeef };
1976 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&var
));
1977 ok(!strcmp_wa(V_BSTR(&var
), "[object]"), "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
1980 dp
.rgdispidNamedArgs
= named_args
;
1984 V_VT(args
) = VT_DISPATCH
;
1985 V_DISPATCH(args
) = (IDispatch
*)obj
;
1986 V_VT(args
+1) = VT_I4
;
1988 hres
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, LOCALE_NEUTRAL
, DISPATCH_METHOD
, &dp
, &var
, &ei
, NULL
);
1989 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
1990 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&var
));
1991 ok(!strcmp_wa(V_BSTR(&var
), "[object]"), "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
1997 hres
= dispex_propput(obj
, id
, 0, &var
, NULL
);
1998 todo_wine
ok(hres
== E_NOTIMPL
, "InvokeEx failed: %08x\n", hres
);
2000 hres
= dispex_propget(dispex
, DISPID_VALUE
, &var
, NULL
);
2001 ok(hres
== E_ACCESSDENIED
, "InvokeEx returned: %08x, expected E_ACCESSDENIED\n", hres
);
2005 SET_EXPECT(QS_IActiveScriptSite
);
2006 SET_EXPECT(QS_GetCaller
);
2007 hres
= dispex_propget(dispex
, DISPID_VALUE
, &var
, &caller_sp
);
2008 ok(hres
== S_OK
, "InvokeEx returned: %08x, expected S_OK\n", hres
);
2009 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var) = %d\n", V_VT(&var
));
2010 ok(!strcmp_wa(V_BSTR(&var
), "\nfunction toString() {\n [native code]\n}\n"),
2011 "V_BSTR(var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2013 todo_wine
CHECK_CALLED(QS_IActiveScriptSite
);
2014 todo_wine
CHECK_CALLED(QS_GetCaller
);
2016 IDispatchEx_Release(dispex
);
2019 static void test_nextdispid(IDispatchEx
*dispex
)
2021 DISPID last_id
= DISPID_STARTENUM
, id
, dyn_id
;
2026 name
= a2bstr("dynVal");
2027 hres
= IDispatchEx_GetDispID(dispex
, name
, fdexNameCaseSensitive
|fdexNameEnsure
, &dyn_id
);
2028 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2029 SysFreeString(name
);
2031 V_VT(&var
) = VT_EMPTY
;
2032 hres
= dispex_propput(dispex
, dyn_id
, 0, &var
, NULL
);
2033 ok(hres
== S_OK
, "dispex_propput failed: %08x\n", hres
);
2035 while(last_id
!= dyn_id
) {
2036 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, last_id
, &id
);
2037 ok(hres
== S_OK
, "GetNextDispID returned: %08x\n", hres
);
2038 ok(id
!= DISPID_STARTENUM
, "id == DISPID_STARTENUM\n");
2039 ok(id
!= DISPID_IOMNAVIGATOR_TOSTRING
, "id == DISPID_IOMNAVIGATOR_TOSTRING\n");
2041 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
2042 ok(hres
== S_OK
, "GetMemberName failed: %08x\n", hres
);
2045 ok(!strcmp_wa(name
, "dynVal"), "name = %s\n", wine_dbgstr_w(name
));
2046 else if(id
== DISPID_IOMNAVIGATOR_PLATFORM
)
2047 ok(!strcmp_wa(name
, "platform"), "name = %s\n", wine_dbgstr_w(name
));
2049 SysFreeString(name
);
2053 hres
= IDispatchEx_GetNextDispID(dispex
, 0, id
, &id
);
2054 ok(hres
== S_FALSE
, "GetNextDispID returned: %08x\n", hres
);
2055 ok(id
== DISPID_STARTENUM
, "id != DISPID_STARTENUM\n");
2058 static void test_global_id(void)
2067 SET_EXPECT(GetScriptDispatch
);
2068 SET_EXPECT(script_divid_d
);
2069 tmp
= a2bstr("divid");
2070 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2071 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2073 CHECK_CALLED(GetScriptDispatch
);
2074 CHECK_CALLED(script_divid_d
);
2077 memset(&ei
, 0, sizeof(ei
));
2078 memset(&dp
, 0, sizeof(dp
));
2079 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2080 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2081 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var) = %d\n", V_VT(&var
));
2085 static void test_arg_conv(IHTMLWindow2
*window
)
2087 IHTMLDocument2
*doc
;
2088 IDispatchEx
*dispex
;
2093 hres
= IHTMLWindow2_get_document(window
, &doc
);
2094 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2096 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2097 IHTMLDocument2_Release(doc
);
2098 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2100 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2101 IHTMLElement_Release(elem
);
2102 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2104 SET_EXPECT(QS_VariantConversion
);
2105 SET_EXPECT(ChangeType
);
2107 V_I4(&v
) = 0xf0f0f0;
2108 hres
= dispex_propput(dispex
, DISPID_IHTMLBODYELEMENT_BACKGROUND
, 0, &v
, &caller_sp
);
2109 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2110 CHECK_CALLED(QS_VariantConversion
);
2111 CHECK_CALLED(ChangeType
);
2113 V_VT(&v
) = VT_EMPTY
;
2114 hres
= dispex_propget(dispex
, DISPID_IHTMLBODYELEMENT_BGCOLOR
, &v
, &caller_sp
);
2115 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2116 ok(V_VT(&v
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&v
));
2117 ok(!V_BSTR(&v
), "V_BSTR(&var) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
2119 IDispatchEx_Release(dispex
);
2122 #define test_elem_disabled(a,b) _test_elem_disabled(__LINE__,a,b)
2123 static void _test_elem_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
2125 IHTMLElement3
*elem3
;
2126 VARIANT_BOOL b
= 100;
2129 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLElement3
, (void**)&elem3
);
2130 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLElement3 iface: %08x\n", hres
);
2132 hres
= IHTMLElement3_get_disabled(elem3
, &b
);
2133 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
2134 ok_(__FILE__
,line
)(b
== exb
, "disabled = %x, expected %x\n", b
, exb
);
2136 IHTMLElement3_Release(elem3
);
2139 static void test_default_arg_conv(IHTMLWindow2
*window
)
2141 IHTMLDocument2
*doc
;
2142 IDispatchEx
*dispex
;
2147 hres
= IHTMLWindow2_get_document(window
, &doc
);
2148 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2150 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2151 IHTMLDocument2_Release(doc
);
2152 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2154 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
2155 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2157 test_elem_disabled(elem
, VARIANT_FALSE
);
2160 V_BSTR(&v
) = a2bstr("test");
2161 hres
= dispex_propput(dispex
, DISPID_IHTMLELEMENT3_DISABLED
, 0, &v
, NULL
);
2162 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2163 SysFreeString(V_BSTR(&v
));
2165 test_elem_disabled(elem
, VARIANT_TRUE
);
2169 hres
= dispex_propput(dispex
, DISPID_IHTMLELEMENT3_DISABLED
, 0, &v
, NULL
);
2170 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2172 test_elem_disabled(elem
, VARIANT_FALSE
);
2176 hres
= dispex_propput(dispex
, DISPID_IHTMLELEMENT3_DISABLED
, DISPATCH_PROPERTYPUTREF
, &v
, NULL
);
2177 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2179 test_elem_disabled(elem
, VARIANT_TRUE
);
2181 IHTMLElement_Release(elem
);
2182 IDispatchEx_Release(dispex
);
2185 static void test_ui(void)
2187 IActiveScriptSiteUIControl
*ui_control
;
2188 SCRIPTUICHANDLING uic_handling
= 10;
2191 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IActiveScriptSiteUIControl
, (void**)&ui_control
);
2192 if(hres
== E_NOINTERFACE
) {
2193 win_skip("IActiveScriptSiteUIControl not supported\n");
2196 ok(hres
== S_OK
, "Could not get IActiveScriptSiteUIControl: %08x\n", hres
);
2198 hres
= IActiveScriptSiteUIControl_GetUIBehavior(ui_control
, SCRIPTUICITEM_MSGBOX
, &uic_handling
);
2199 ok(hres
== S_OK
, "GetUIBehavior failed: %08x\n", hres
);
2200 ok(uic_handling
== SCRIPTUICHANDLING_ALLOW
, "uic_handling = %d\n", uic_handling
);
2202 IActiveScriptSiteUIControl_Release(ui_control
);
2205 static void test_sp(void)
2207 IServiceProvider
*sp
;
2211 hres
= IActiveScriptSite_QueryInterface(site
, &IID_IServiceProvider
, (void**)&sp
);
2212 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
2214 hres
= IServiceProvider_QueryService(sp
, &SID_SContainerDispatch
, &IID_IHTMLDocument
, (void**)&unk
);
2215 ok(hres
== S_OK
, "Could not get SID_SContainerDispatch service: %08x\n", hres
);
2216 IUnknown_Release(unk
);
2218 IServiceProvider_Release(sp
);
2221 static void test_script_run(void)
2223 IDispatchEx
*document
, *dispex
;
2224 IHTMLWindow2
*window
;
2225 IOmNavigator
*navigator
;
2234 static const WCHAR documentW
[] = {'d','o','c','u','m','e','n','t',0};
2235 static const WCHAR testW
[] = {'t','e','s','t',0};
2236 static const WCHAR funcW
[] = {'f','u','n','c',0};
2238 SET_EXPECT(GetScriptDispatch
);
2240 tmp
= SysAllocString(documentW
);
2241 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2243 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
2244 ok(id
== DISPID_IHTMLWINDOW2_DOCUMENT
, "id=%x\n", id
);
2246 CHECK_CALLED(GetScriptDispatch
);
2249 memset(&dp
, 0, sizeof(dp
));
2250 memset(&ei
, 0, sizeof(ei
));
2252 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2253 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2254 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
2255 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(&var) == NULL\n");
2257 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IDispatchEx
, (void**)&document
);
2259 ok(hres
== S_OK
, "Could not get DispatchEx: %08x\n", hres
);
2261 tmp
= SysAllocString(testW
);
2262 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
, &id
);
2263 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
2264 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
| fdexNameImplicit
, &id
);
2265 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID(document) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
2269 tmp
= SysAllocString(testW
);
2270 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
2272 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
2273 ok(id
, "id == 0\n");
2277 hres
= dispex_propput(document
, id
, 0, &var
, NULL
);
2278 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2280 tmp
= SysAllocString(testW
);
2281 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
, &id
);
2283 ok(hres
== S_OK
, "GetDispID(document) failed: %08x\n", hres
);
2285 hres
= IDispatchEx_DeleteMemberByDispID(document
, id
);
2286 ok(hres
== E_NOTIMPL
, "DeleteMemberByDispID failed = %08x\n", hres
);
2289 memset(&dp
, 0, sizeof(dp
));
2290 memset(&ei
, 0, sizeof(ei
));
2291 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2292 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2293 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2294 ok(V_I4(&var
) == 100, "V_I4(&var) = %d\n", V_I4(&var
));
2298 hres
= dispex_propput(document
, id
, DISPATCH_PROPERTYPUTREF
, &var
, NULL
);
2299 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2302 memset(&dp
, 0, sizeof(dp
));
2303 memset(&ei
, 0, sizeof(ei
));
2304 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2305 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2306 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2307 ok(V_I4(&var
) == 200, "V_I4(&var) = %d\n", V_I4(&var
));
2309 memset(&dp
, 0, sizeof(dp
));
2310 memset(&ei
, 0, sizeof(ei
));
2315 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
2316 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2319 memset(&dp
, 0, sizeof(dp
));
2320 memset(&ei
, 0, sizeof(ei
));
2321 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2322 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2323 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2324 ok(V_I4(&var
) == 300, "V_I4(&var) = %d\n", V_I4(&var
));
2326 V_VT(&var
) = VT_BSTR
;
2327 V_BSTR(&var
) = NULL
;
2328 dispex_propput(document
, id
, 0, &var
, NULL
);
2331 memset(&dp
, 0, sizeof(dp
));
2332 memset(&ei
, 0, sizeof(ei
));
2333 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2334 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2335 ok(V_VT(&var
) == VT_BSTR
, "V_VT(var)=%d\n", V_VT(&var
));
2336 ok(!V_BSTR(&var
), "V_BSTR(&var) = %s\n", wine_dbgstr_w(V_BSTR(&var
)));
2338 unk
= (void*)0xdeadbeef;
2339 hres
= IDispatchEx_GetNameSpaceParent(window_dispex
, &unk
);
2340 ok(hres
== S_OK
, "GetNameSpaceParent failed: %08x\n", hres
);
2341 ok(!unk
, "unk=%p, expected NULL\n", unk
);
2344 tmp
= SysAllocString(funcW
);
2345 hres
= IDispatchEx_GetDispID(document
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
2347 ok(hres
== S_OK
, "GetDispID(func) failed: %08x\n", hres
);
2348 ok(id
, "id == 0\n");
2353 dp
.rgdispidNamedArgs
= NULL
;
2354 V_VT(&var
) = VT_DISPATCH
;
2355 V_DISPATCH(&var
) = (IDispatch
*)&funcDisp
;
2356 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
2357 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2360 memset(&dp
, 0, sizeof(dp
));
2361 memset(&ei
, 0, sizeof(ei
));
2362 V_VT(&arg
) = VT_BOOL
;
2363 V_BOOL(&arg
) = VARIANT_TRUE
;
2367 SET_EXPECT(funcDisp
);
2368 hres
= IDispatchEx_InvokeEx(document
, id
, LOCALE_NEUTRAL
, INVOKE_FUNC
, &dp
, &var
, &ei
, NULL
);
2369 CHECK_CALLED(funcDisp
);
2371 ok(hres
== S_OK
, "InvokeEx(INVOKE_FUNC) failed: %08x\n", hres
);
2372 ok(V_VT(&var
) == VT_I4
, "V_VT(var)=%d\n", V_VT(&var
));
2373 ok(V_I4(&var
) == 100, "V_I4(&var) == NULL\n");
2375 IDispatchEx_Release(document
);
2377 hres
= IDispatchEx_QueryInterface(window_dispex
, &IID_IHTMLWindow2
, (void**)&window
);
2378 ok(hres
== S_OK
, "Could not get IHTMLWindow2 iface: %08x\n", hres
);
2380 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
2381 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
2383 hres
= IOmNavigator_QueryInterface(navigator
, &IID_IDispatchEx
, (void**)&dispex
);
2384 IOmNavigator_Release(navigator
);
2385 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08x\n", hres
);
2388 test_nextdispid(dispex
);
2390 test_arg_conv(window
);
2391 test_default_arg_conv(window
);
2392 IHTMLWindow2_Release(window
);
2394 tmp
= a2bstr("test");
2395 hres
= IDispatchEx_DeleteMemberByName(dispex
, tmp
, fdexNameCaseSensitive
);
2396 ok(hres
== E_NOTIMPL
, "DeleteMemberByName failed: %08x\n", hres
);
2398 IDispatchEx_Release(dispex
);
2400 script_disp
= (IDispatch
*)&scriptDisp
;
2402 SET_EXPECT(GetScriptDispatch
);
2403 SET_EXPECT(script_testprop_d
);
2404 tmp
= a2bstr("testProp");
2405 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2406 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2407 ok(id
!= DISPID_SCRIPT_TESTPROP
, "id == DISPID_SCRIPT_TESTPROP\n");
2408 CHECK_CALLED(GetScriptDispatch
);
2409 CHECK_CALLED(script_testprop_d
);
2412 tmp
= a2bstr("testProp");
2413 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
, &id
);
2414 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2415 ok(id
!= DISPID_SCRIPT_TESTPROP
, "id == DISPID_SCRIPT_TESTPROP\n");
2418 SET_EXPECT(GetScriptDispatch
);
2419 SET_EXPECT(script_testprop_i
);
2420 memset(&ei
, 0, sizeof(ei
));
2421 memset(&dp
, 0, sizeof(dp
));
2422 hres
= IDispatchEx_InvokeEx(window_dispex
, id
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
2423 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
2424 ok(V_VT(&var
) == VT_NULL
, "V_VT(var) = %d\n", V_VT(&var
));
2425 CHECK_CALLED(GetScriptDispatch
);
2426 CHECK_CALLED(script_testprop_i
);
2428 SET_EXPECT(GetScriptDispatch
);
2429 SET_EXPECT(script_testprop2_d
);
2430 tmp
= a2bstr("testProp2");
2431 hres
= IDispatchEx_GetDispID(window_dispex
, tmp
, fdexNameCaseSensitive
|fdexNameEnsure
, &id
);
2432 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
2433 ok(id
!= DISPID_SCRIPT_TESTPROP2
, "id == DISPID_SCRIPT_TESTPROP2\n");
2434 CHECK_CALLED(GetScriptDispatch
);
2435 CHECK_CALLED(script_testprop2_d
);
2438 tmp
= a2bstr("test");
2439 hres
= IDispatchEx_DeleteMemberByName(window_dispex
, tmp
, fdexNameCaseSensitive
);
2440 ok(hres
== E_NOTIMPL
, "DeleteMemberByName failed: %08x\n", hres
);
2449 static HRESULT WINAPI
ActiveScriptParse_ParseScriptText(IActiveScriptParse
*iface
,
2450 LPCOLESTR pstrCode
, LPCOLESTR pstrItemName
, IUnknown
*punkContext
,
2451 LPCOLESTR pstrDelimiter
, CTXARG_T dwSourceContextCookie
, ULONG ulStartingLine
,
2452 DWORD dwFlags
, VARIANT
*pvarResult
, EXCEPINFO
*pexcepinfo
)
2454 ok(pvarResult
!= NULL
, "pvarResult == NULL\n");
2455 ok(pexcepinfo
!= NULL
, "pexcepinfo == NULL\n");
2457 if(!strcmp_wa(pstrCode
, "execScript call")) {
2458 CHECK_EXPECT(ParseScriptText_execScript
);
2459 ok(!pstrItemName
, "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2460 ok(!strcmp_wa(pstrDelimiter
, "\""), "pstrDelimiter = %s\n", wine_dbgstr_w(pstrDelimiter
));
2461 ok(dwFlags
== SCRIPTTEXT_ISVISIBLE
, "dwFlags = %x\n", dwFlags
);
2463 V_VT(pvarResult
) = VT_I4
;
2464 V_I4(pvarResult
) = 10;
2466 }else if(!strcmp_wa(pstrCode
, "simple script")) {
2467 CHECK_EXPECT(ParseScriptText_script
);
2468 ok(!strcmp_wa(pstrItemName
, "window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2469 ok(!strcmp_wa(pstrDelimiter
, "</SCRIPT>"), "pstrDelimiter = %s\n", wine_dbgstr_w(pstrDelimiter
));
2470 ok(dwFlags
== (SCRIPTTEXT_ISVISIBLE
|SCRIPTTEXT_HOSTMANAGESSOURCE
), "dwFlags = %x\n", dwFlags
);
2476 ok(0, "unexpected script %s\n", wine_dbgstr_w(pstrCode
));
2480 static const IActiveScriptParseVtbl ActiveScriptParseVtbl
= {
2481 ActiveScriptParse_QueryInterface
,
2482 ActiveScriptParse_AddRef
,
2483 ActiveScriptParse_Release
,
2484 ActiveScriptParse_InitNew
,
2485 ActiveScriptParse_AddScriptlet
,
2486 ActiveScriptParse_ParseScriptText
2489 static IActiveScriptParse ActiveScriptParse
= { &ActiveScriptParseVtbl
};
2491 static HRESULT WINAPI
ActiveScript_QueryInterface(IActiveScript
*iface
, REFIID riid
, void **ppv
)
2495 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IActiveScript
, riid
)) {
2500 if(IsEqualGUID(&IID_IActiveScriptParse
, riid
)) {
2501 *ppv
= &ActiveScriptParse
;
2505 if(IsEqualGUID(&IID_IActiveScriptParseProcedure2
, riid
)) {
2506 *ppv
= &ActiveScriptParseProcedure
;
2510 if(IsEqualGUID(&IID_IActiveScriptProperty
, riid
)) {
2511 *ppv
= &ActiveScriptProperty
;
2515 if(IsEqualGUID(&IID_IObjectSafety
, riid
)) {
2516 *ppv
= &ObjectSafety
;
2520 if(IsEqualGUID(&IID_IActiveScriptDebug
, riid
))
2521 return E_NOINTERFACE
;
2523 trace("QI(%s)\n", wine_dbgstr_guid(riid
));
2524 return E_NOINTERFACE
;
2527 static ULONG WINAPI
ActiveScript_AddRef(IActiveScript
*iface
)
2532 static ULONG WINAPI
ActiveScript_Release(IActiveScript
*iface
)
2537 static HRESULT WINAPI
ActiveScript_SetScriptSite(IActiveScript
*iface
, IActiveScriptSite
*pass
)
2539 IActiveScriptSiteInterruptPoll
*poll
;
2540 IActiveScriptSiteDebug
*debug
;
2541 IServiceProvider
*service
;
2542 ICanHandleException
*canexpection
;
2546 CHECK_EXPECT(SetScriptSite
);
2548 ok(pass
!= NULL
, "pass == NULL\n");
2550 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IActiveScriptSiteInterruptPoll
, (void**)&poll
);
2551 ok(hres
== S_OK
, "Could not get IActiveScriptSiteInterruptPoll interface: %08x\n", hres
);
2553 IActiveScriptSiteInterruptPoll_Release(poll
);
2555 hres
= IActiveScriptSite_GetLCID(pass
, &lcid
);
2556 ok(hres
== S_OK
, "GetLCID failed: %08x\n", hres
);
2558 hres
= IActiveScriptSite_OnStateChange(pass
, (state
= SCRIPTSTATE_INITIALIZED
));
2559 ok(hres
== S_OK
, "OnStateChange failed: %08x\n", hres
);
2561 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IActiveScriptSiteDebug
, (void**)&debug
);
2562 ok(hres
== S_OK
, "Could not get IActiveScriptSiteDebug interface: %08x\n", hres
);
2564 IActiveScriptSiteDebug_Release(debug
);
2566 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_ICanHandleException
, (void**)&canexpection
);
2567 ok(hres
== E_NOINTERFACE
, "Could not get IID_ICanHandleException interface: %08x\n", hres
);
2569 hres
= IActiveScriptSite_QueryInterface(pass
, &IID_IServiceProvider
, (void**)&service
);
2570 ok(hres
== S_OK
, "Could not get IServiceProvider interface: %08x\n", hres
);
2572 IServiceProvider_Release(service
);
2575 IActiveScriptSite_AddRef(site
);
2579 static HRESULT WINAPI
ActiveScript_GetScriptSite(IActiveScript
*iface
, REFIID riid
,
2582 ok(0, "unexpected call\n");
2586 static HRESULT WINAPI
ActiveScript_SetScriptState(IActiveScript
*iface
, SCRIPTSTATE ss
)
2591 case SCRIPTSTATE_STARTED
:
2592 CHECK_EXPECT(SetScriptState_STARTED
);
2594 case SCRIPTSTATE_CONNECTED
:
2595 CHECK_EXPECT(SetScriptState_CONNECTED
);
2597 case SCRIPTSTATE_DISCONNECTED
:
2598 CHECK_EXPECT(SetScriptState_DISCONNECTED
);
2601 ok(0, "unexpected state %d\n", ss
);
2605 hres
= IActiveScriptSite_OnStateChange(site
, (state
= ss
));
2606 ok(hres
== S_OK
, "OnStateChange failed: %08x\n", hres
);
2611 static HRESULT WINAPI
ActiveScript_GetScriptState(IActiveScript
*iface
, SCRIPTSTATE
*pssState
)
2613 CHECK_EXPECT(GetScriptState
);
2619 static HRESULT WINAPI
ActiveScript_Close(IActiveScript
*iface
)
2621 CHECK_EXPECT(Close
);
2625 static HRESULT WINAPI
ActiveScript_AddNamedItem(IActiveScript
*iface
,
2626 LPCOLESTR pstrName
, DWORD dwFlags
)
2629 IUnknown
*unk
= NULL
, *unk2
;
2632 static const WCHAR windowW
[] = {'w','i','n','d','o','w',0};
2634 static const IID unknown_iid
= {0x719C3050,0xF9D3,0x11CF,{0xA4,0x93,0x00,0x40,0x05,0x23,0xA8,0xA0}};
2636 CHECK_EXPECT(AddNamedItem
);
2638 ok(!lstrcmpW(pstrName
, windowW
), "pstrName=%s\n", wine_dbgstr_w(pstrName
));
2639 ok(dwFlags
== (SCRIPTITEM_ISVISIBLE
|SCRIPTITEM_ISSOURCE
|SCRIPTITEM_GLOBALMEMBERS
), "dwFlags=%x\n", dwFlags
);
2641 hres
= IActiveScriptSite_GetItemInfo(site
, windowW
, SCRIPTINFO_IUNKNOWN
, &unk
, NULL
);
2642 ok(hres
== S_OK
, "GetItemInfo failed: %08x\n", hres
);
2643 ok(unk
!= NULL
, "unk == NULL\n");
2645 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
2646 ok(hres
== S_OK
, "Could not get IDispatch interface: %08x\n", hres
);
2648 IDispatch_Release(disp
);
2650 hres
= IUnknown_QueryInterface(unk
, &unknown_iid
, (void**)&unk2
);
2651 ok(hres
== E_NOINTERFACE
, "Got ?? interface: %p\n", unk2
);
2653 IUnknown_Release(unk2
);
2655 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&window_dispex
);
2656 ok(hres
== S_OK
, "Could not get IDispatchEx interface: %08x\n", hres
);
2658 IUnknown_Release(unk
);
2662 static HRESULT WINAPI
ActiveScript_AddTypeLib(IActiveScript
*iface
, REFGUID rguidTypeLib
,
2663 DWORD dwMajor
, DWORD dwMinor
, DWORD dwFlags
)
2665 ok(0, "unexpected call\n");
2669 static HRESULT WINAPI
ActiveScript_GetScriptDispatch(IActiveScript
*iface
, LPCOLESTR pstrItemName
,
2672 CHECK_EXPECT(GetScriptDispatch
);
2674 ok(!strcmp_wa(pstrItemName
, "window"), "pstrItemName = %s\n", wine_dbgstr_w(pstrItemName
));
2679 *ppdisp
= script_disp
;
2683 static HRESULT WINAPI
ActiveScript_GetCurrentScriptThreadID(IActiveScript
*iface
,
2684 SCRIPTTHREADID
*pstridThread
)
2686 ok(0, "unexpected call\n");
2690 static HRESULT WINAPI
ActiveScript_GetScriptThreadID(IActiveScript
*iface
,
2691 DWORD dwWin32ThreadId
, SCRIPTTHREADID
*pstidThread
)
2693 ok(0, "unexpected call\n");
2697 static HRESULT WINAPI
ActiveScript_GetScriptThreadState(IActiveScript
*iface
,
2698 SCRIPTTHREADID stidThread
, SCRIPTTHREADSTATE
*pstsState
)
2700 ok(0, "unexpected call\n");
2704 static HRESULT WINAPI
ActiveScript_InterruptScriptThread(IActiveScript
*iface
,
2705 SCRIPTTHREADID stidThread
, const EXCEPINFO
*pexcepinfo
, DWORD dwFlags
)
2707 ok(0, "unexpected call\n");
2711 static HRESULT WINAPI
ActiveScript_Clone(IActiveScript
*iface
, IActiveScript
**ppscript
)
2713 ok(0, "unexpected call\n");
2717 static const IActiveScriptVtbl ActiveScriptVtbl
= {
2718 ActiveScript_QueryInterface
,
2719 ActiveScript_AddRef
,
2720 ActiveScript_Release
,
2721 ActiveScript_SetScriptSite
,
2722 ActiveScript_GetScriptSite
,
2723 ActiveScript_SetScriptState
,
2724 ActiveScript_GetScriptState
,
2726 ActiveScript_AddNamedItem
,
2727 ActiveScript_AddTypeLib
,
2728 ActiveScript_GetScriptDispatch
,
2729 ActiveScript_GetCurrentScriptThreadID
,
2730 ActiveScript_GetScriptThreadID
,
2731 ActiveScript_GetScriptThreadState
,
2732 ActiveScript_InterruptScriptThread
,
2736 static IActiveScript ActiveScript
= { &ActiveScriptVtbl
};
2738 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
2742 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
2747 if(IsEqualGUID(&IID_IMarshal
, riid
))
2748 return E_NOINTERFACE
;
2749 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
2750 return E_NOINTERFACE
;
2752 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2756 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
2761 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
2766 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
2768 CHECK_EXPECT(CreateInstance
);
2770 ok(!outer
, "outer = %p\n", outer
);
2771 ok(IsEqualGUID(&IID_IActiveScript
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2772 *ppv
= &ActiveScript
;
2776 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
2778 ok(0, "unexpected call\n");
2782 static const IClassFactoryVtbl ClassFactoryVtbl
= {
2783 ClassFactory_QueryInterface
,
2784 ClassFactory_AddRef
,
2785 ClassFactory_Release
,
2786 ClassFactory_CreateInstance
,
2787 ClassFactory_LockServer
2790 static IClassFactory script_cf
= { &ClassFactoryVtbl
};
2793 IInternetProtocolEx IInternetProtocolEx_iface
;
2794 IWinInetHttpInfo IWinInetHttpInfo_iface
;
2798 IInternetProtocolSink
*sink
;
2809 static void report_data(ProtocolHandler
*This
)
2811 IServiceProvider
*service_provider
;
2812 IHttpNegotiate
*http_negotiate
;
2813 WCHAR
*addl_headers
= NULL
;
2817 static const WCHAR emptyW
[] = {0};
2819 hres
= IInternetProtocolSink_QueryInterface(This
->sink
, &IID_IServiceProvider
, (void**)&service_provider
);
2820 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
2822 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
, (void**)&http_negotiate
);
2823 IServiceProvider_Release(service_provider
);
2824 ok(hres
== S_OK
, "Could not get IHttpNegotiate interface: %08x\n", hres
);
2826 IUri_GetDisplayUri(This
->uri
, &url
);
2827 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, url
, emptyW
, 0, &addl_headers
);
2828 ok(hres
== S_OK
, "BeginningTransaction failed: %08x\n", hres
);
2831 CoTaskMemFree(addl_headers
);
2833 headers
= a2bstr("HTTP/1.1 200 OK\r\n\r\n");
2834 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, headers
, NULL
, NULL
);
2835 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
2836 SysFreeString(headers
);
2838 IHttpNegotiate_Release(http_negotiate
);
2840 hres
= IInternetProtocolSink_ReportData(This
->sink
, BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
,
2841 This
->size
, This
->size
);
2842 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
2844 hres
= IInternetProtocolSink_ReportResult(This
->sink
, S_OK
, 0, NULL
);
2845 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
2848 typedef struct js_stream_t
{
2849 struct js_stream_t
*next
;
2850 ProtocolHandler
*protocol_handler
;
2854 static js_stream_t
*registered_stream_list
;
2856 static void register_stream(ProtocolHandler
*protocol_handler
, const WCHAR
*name
)
2858 js_stream_t
*stream
;
2861 len
= lstrlenW(name
)+1;
2862 stream
= HeapAlloc(GetProcessHeap(), 0, offsetof(js_stream_t
, name
[len
+1]));
2864 IInternetProtocolEx_AddRef(&protocol_handler
->IInternetProtocolEx_iface
);
2865 stream
->protocol_handler
= protocol_handler
;
2866 memcpy(stream
->name
, name
, len
*sizeof(WCHAR
));
2868 stream
->next
= registered_stream_list
;
2869 registered_stream_list
= stream
;
2872 static void free_registered_streams(void)
2876 while((iter
= registered_stream_list
)) {
2877 ok(!iter
->protocol_handler
, "protocol handler still pending for %s\n", wine_dbgstr_w(iter
->name
));
2878 if(iter
->protocol_handler
)
2879 IInternetProtocolEx_Release(&iter
->protocol_handler
->IInternetProtocolEx_iface
);
2881 registered_stream_list
= iter
->next
;
2882 HeapFree(GetProcessHeap(), 0, iter
);
2886 static DWORD WINAPI
async_switch_proc(void *arg
)
2888 PROTOCOLDATA protocol_data
= {PI_FORCE_ASYNC
};
2889 ProtocolHandler
*protocol_handler
= arg
;
2891 IInternetProtocolSink_Switch(protocol_handler
->sink
, &protocol_data
);
2895 static void async_switch(ProtocolHandler
*protocol_handler
)
2897 IInternetProtocolEx_AddRef(&protocol_handler
->IInternetProtocolEx_iface
);
2898 QueueUserWorkItem(async_switch_proc
, protocol_handler
, 0);
2901 static void stream_write(const WCHAR
*name
, const WCHAR
*data
)
2903 ProtocolHandler
*protocol_handler
;
2904 LARGE_INTEGER large_zero
;
2905 js_stream_t
*stream
;
2908 static const BYTE bom_utf16
[] = {0xff,0xfe};
2910 for(stream
= registered_stream_list
; stream
; stream
= stream
->next
) {
2911 if(!lstrcmpW(stream
->name
, name
))
2914 ok(stream
!= NULL
, "stream %s not found\n", wine_dbgstr_w(name
));
2918 protocol_handler
= stream
->protocol_handler
;
2919 ok(protocol_handler
!= NULL
, "protocol_handler is NULL\n");
2920 if(!protocol_handler
)
2922 stream
->protocol_handler
= NULL
;
2924 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &protocol_handler
->stream
);
2925 ok(hres
== S_OK
, "CreateStreamOnHGlobal failed: %08x\n", hres
);
2927 hres
= IStream_Write(protocol_handler
->stream
, bom_utf16
, sizeof(bom_utf16
), NULL
);
2928 ok(hres
== S_OK
, "Write failed: %08x\n", hres
);
2930 hres
= IStream_Write(protocol_handler
->stream
, data
, lstrlenW(data
)*sizeof(WCHAR
), NULL
);
2931 ok(hres
== S_OK
, "Write failed: %08x\n", hres
);
2933 U(large_zero
).QuadPart
= 0;
2934 hres
= IStream_Seek(protocol_handler
->stream
, large_zero
, STREAM_SEEK_SET
, NULL
);
2935 ok(hres
== S_OK
, "Seek failed: %08x\n", hres
);
2937 async_switch(protocol_handler
);
2938 IInternetProtocolEx_Release(&protocol_handler
->IInternetProtocolEx_iface
);
2941 static char index_html_data
[4096];
2943 static inline ProtocolHandler
*impl_from_IInternetProtocolEx(IInternetProtocolEx
*iface
)
2945 return CONTAINING_RECORD(iface
, ProtocolHandler
, IInternetProtocolEx_iface
);
2948 static HRESULT WINAPI
Protocol_QueryInterface(IInternetProtocolEx
*iface
, REFIID riid
, void **ppv
)
2950 ProtocolHandler
*This
= impl_from_IInternetProtocolEx(iface
);
2952 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
) || IsEqualGUID(&IID_IInternetProtocolEx
, riid
)) {
2953 *ppv
= &This
->IInternetProtocolEx_iface
;
2954 }else if(IsEqualGUID(&IID_IWinInetInfo
, riid
) || IsEqualGUID(&IID_IWinInetHttpInfo
, riid
)) {
2955 *ppv
= &This
->IWinInetHttpInfo_iface
;
2958 return E_NOINTERFACE
;
2961 IUnknown_AddRef((IUnknown
*)*ppv
);
2965 static ULONG WINAPI
Protocol_AddRef(IInternetProtocolEx
*iface
)
2967 ProtocolHandler
*This
= impl_from_IInternetProtocolEx(iface
);
2968 return InterlockedIncrement(&This
->ref
);
2971 static ULONG WINAPI
Protocol_Release(IInternetProtocolEx
*iface
)
2973 ProtocolHandler
*This
= impl_from_IInternetProtocolEx(iface
);
2974 LONG ref
= InterlockedDecrement(&This
->ref
);
2978 IInternetProtocolSink_Release(This
->sink
);
2980 IStream_Release(This
->stream
);
2982 IUri_Release(This
->uri
);
2983 ReleaseBindInfo(&This
->bind_info
);
2984 HeapFree(GetProcessHeap(), 0, This
);
2990 static HRESULT WINAPI
Protocol_Start(IInternetProtocolEx
*iface
, LPCWSTR szUrl
, IInternetProtocolSink
*pOIProtSink
,
2991 IInternetBindInfo
*pOIBindInfo
, DWORD grfPI
, HANDLE_PTR dwReserved
)
2993 ok(0, "unexpected call\n");
2997 static HRESULT WINAPI
Protocol_Continue(IInternetProtocolEx
*iface
, PROTOCOLDATA
*pProtocolData
)
2999 ProtocolHandler
*This
= impl_from_IInternetProtocolEx(iface
);
3001 IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
3005 static HRESULT WINAPI
Protocol_Abort(IInternetProtocolEx
*iface
, HRESULT hrReason
, DWORD dwOptions
)
3007 trace("Abort(%08x %x)\n", hrReason
, dwOptions
);
3011 static HRESULT WINAPI
Protocol_Terminate(IInternetProtocolEx
*iface
, DWORD dwOptions
)
3016 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocolEx
*iface
)
3018 ok(0, "unexpected call\n");
3022 static HRESULT WINAPI
Protocol_Resume(IInternetProtocolEx
*iface
)
3024 ok(0, "unexpected call\n");
3028 static HRESULT WINAPI
Protocol_Read(IInternetProtocolEx
*iface
, void *pv
, ULONG cb
, ULONG
*pcbRead
)
3030 ProtocolHandler
*This
= impl_from_IInternetProtocolEx(iface
);
3035 hres
= IStream_Read(This
->stream
, pv
, cb
, &read
);
3036 ok(SUCCEEDED(hres
), "Read failed: %08x\n", hres
);
3041 return read
? S_OK
: S_FALSE
;
3044 read
= This
->size
- (This
->ptr
- This
->data
);
3049 memcpy(pv
, This
->ptr
, read
);
3054 return This
->ptr
== This
->data
+This
->size
? S_FALSE
: S_OK
;
3057 static HRESULT WINAPI
Protocol_Seek(IInternetProtocolEx
*iface
,
3058 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
3060 ok(0, "unexpected call\n");
3064 static HRESULT WINAPI
Protocol_LockRequest(IInternetProtocolEx
*iface
, DWORD dwOptions
)
3069 static HRESULT WINAPI
Protocol_UnlockRequest(IInternetProtocolEx
*iface
)
3074 static HRESULT WINAPI
ProtocolEx_StartEx(IInternetProtocolEx
*iface
, IUri
*uri
, IInternetProtocolSink
*pOIProtSink
,
3075 IInternetBindInfo
*pOIBindInfo
, DWORD grfPI
, HANDLE
*dwReserved
)
3077 ProtocolHandler
*This
= impl_from_IInternetProtocolEx(iface
);
3084 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &bindf
, &This
->bind_info
);
3085 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
3087 hres
= IUri_GetPath(uri
, &path
);
3091 if(!strcmp_wa(path
, "/index.html")) {
3092 This
->data
= index_html_data
;
3093 This
->size
= strlen(This
->data
);
3094 }else if(!strcmp_wa(path
, "/echo.php")) {
3095 ok(This
->bind_info
.dwBindVerb
== BINDVERB_POST
, "unexpected bind verb %d\n", This
->bind_info
.dwBindVerb
== BINDVERB_POST
);
3096 todo_wine
ok(This
->bind_info
.stgmedData
.tymed
== TYMED_ISTREAM
, "tymed = %x\n", This
->bind_info
.stgmedData
.tymed
);
3097 switch(This
->bind_info
.stgmedData
.tymed
) {
3099 This
->size
= This
->bind_info
.cbstgmedData
;
3100 This
->data
= U(This
->bind_info
.stgmedData
).hGlobal
;
3103 This
->stream
= U(This
->bind_info
.stgmedData
).pstm
;
3104 IStream_AddRef(This
->stream
);
3107 ok(0, "unexpected tymed %d\n", This
->bind_info
.stgmedData
.tymed
);
3109 }else if(!strcmp_wa(path
, "/jsstream.php")) {
3112 hres
= IUri_GetQuery(uri
, &query
);
3113 ok(hres
== S_OK
, "GetQuery failed: %08x\n", hres
);
3114 ok(SysStringLen(query
) > 1 && *query
== '?', "unexpected query %s\n", wine_dbgstr_w(query
));
3115 register_stream(This
, query
+1);
3116 SysFreeString(query
);
3119 src
= FindResourceW(NULL
, *path
== '/' ? path
+1 : path
, (const WCHAR
*)RT_HTML
);
3120 ok(src
!= NULL
, "Could not find resource for path %s\n", wine_dbgstr_w(path
));
3121 SysFreeString(path
);
3123 This
->size
= SizeofResource(NULL
, src
);
3124 This
->data
= LoadResource(NULL
, src
);
3130 SysFreeString(path
);
3134 IInternetProtocolSink_AddRef(This
->sink
= pOIProtSink
);
3135 IUri_AddRef(This
->uri
= uri
);
3137 This
->ptr
= This
->data
;
3143 static const IInternetProtocolExVtbl ProtocolExVtbl
= {
3144 Protocol_QueryInterface
,
3155 Protocol_LockRequest
,
3156 Protocol_UnlockRequest
,
3160 static inline ProtocolHandler
*impl_from_IWinInetHttpInfo(IWinInetHttpInfo
*iface
)
3162 return CONTAINING_RECORD(iface
, ProtocolHandler
, IWinInetHttpInfo_iface
);
3165 static HRESULT WINAPI
HttpInfo_QueryInterface(IWinInetHttpInfo
*iface
, REFIID riid
, void **ppv
)
3167 ProtocolHandler
*This
= impl_from_IWinInetHttpInfo(iface
);
3168 return IInternetProtocolEx_QueryInterface(&This
->IInternetProtocolEx_iface
, riid
, ppv
);
3171 static ULONG WINAPI
HttpInfo_AddRef(IWinInetHttpInfo
*iface
)
3173 ProtocolHandler
*This
= impl_from_IWinInetHttpInfo(iface
);
3174 return IInternetProtocolEx_AddRef(&This
->IInternetProtocolEx_iface
);
3177 static ULONG WINAPI
HttpInfo_Release(IWinInetHttpInfo
*iface
)
3179 ProtocolHandler
*This
= impl_from_IWinInetHttpInfo(iface
);
3180 return IInternetProtocolEx_Release(&This
->IInternetProtocolEx_iface
);
3183 static HRESULT WINAPI
HttpInfo_QueryOption(IWinInetHttpInfo
*iface
, DWORD dwOption
,
3184 void *pBuffer
, DWORD
*pcbBuffer
)
3189 static HRESULT WINAPI
HttpInfo_QueryInfo(IWinInetHttpInfo
*iface
, DWORD dwOption
,
3190 void *pBuffer
, DWORD
*pcbBuffer
, DWORD
*pdwFlags
, DWORD
*pdwReserved
)
3195 static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl
= {
3196 HttpInfo_QueryInterface
,
3199 HttpInfo_QueryOption
,
3203 static HRESULT WINAPI
ProtocolCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
3205 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
3211 return E_NOINTERFACE
;
3214 static HRESULT WINAPI
ProtocolCF_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
3216 ProtocolHandler
*protocol
;
3219 protocol
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*protocol
));
3220 protocol
->IInternetProtocolEx_iface
.lpVtbl
= &ProtocolExVtbl
;
3221 protocol
->IWinInetHttpInfo_iface
.lpVtbl
= &WinInetHttpInfoVtbl
;
3223 protocol
->bind_info
.cbSize
= sizeof(protocol
->bind_info
);
3225 hres
= IInternetProtocolEx_QueryInterface(&protocol
->IInternetProtocolEx_iface
, riid
, ppv
);
3226 IInternetProtocolEx_Release(&protocol
->IInternetProtocolEx_iface
);
3230 static const IClassFactoryVtbl ProtocolCFVtbl
= {
3231 ProtocolCF_QueryInterface
,
3232 ClassFactory_AddRef
,
3233 ClassFactory_Release
,
3234 ProtocolCF_CreateInstance
,
3235 ClassFactory_LockServer
3238 static IClassFactory protocol_cf
= { &ProtocolCFVtbl
};
3240 static const char simple_script_str
[] =
3241 "<html><head></head><body>"
3242 "<div id=\"divid\"></div>"
3243 "<script language=\"TestScript\">simple script</script>"
3246 static void test_exec_script(IHTMLDocument2
*doc
, const char *codea
, const char *langa
)
3248 IHTMLWindow2
*window
;
3253 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3254 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3256 code
= a2bstr(codea
);
3257 lang
= a2bstr(langa
);
3259 SET_EXPECT(ParseScriptText_execScript
);
3260 hres
= IHTMLWindow2_execScript(window
, code
, lang
, &v
);
3261 ok(hres
== S_OK
, "execScript failed: %08x\n", hres
);
3262 ok(V_VT(&v
) == VT_I4
, "V_VT(v) = %d\n", V_VT(&v
));
3263 ok(V_I4(&v
) == 10, "V_I4(v) = %d\n", V_I4(&v
));
3264 CHECK_CALLED(ParseScriptText_execScript
);
3265 SysFreeString(lang
);
3267 lang
= a2bstr("invalid");
3269 hres
= IHTMLWindow2_execScript(window
, code
, lang
, &v
);
3270 ok(hres
== CO_E_CLASSSTRING
, "execScript failed: %08x, expected CO_E_CLASSSTRING\n", hres
);
3271 ok(V_VT(&v
) == 100, "V_VT(v) = %d\n", V_VT(&v
));
3272 SysFreeString(lang
);
3273 SysFreeString(code
);
3275 IHTMLWindow2_Release(window
);
3278 static void test_simple_script(void)
3280 IHTMLDocument2
*doc
;
3282 doc
= create_document();
3286 SET_EXPECT(CreateInstance
);
3287 SET_EXPECT(GetInterfaceSafetyOptions
);
3288 SET_EXPECT(SetInterfaceSafetyOptions
);
3289 SET_EXPECT(SetProperty_INVOKEVERSIONING
); /* IE8 */
3290 SET_EXPECT(SetProperty_HACK_TRIDENTEVENTSINK
);
3291 SET_EXPECT(InitNew
);
3292 SET_EXPECT(SetScriptSite
);
3293 SET_EXPECT(GetScriptState
);
3294 SET_EXPECT(SetScriptState_STARTED
);
3295 SET_EXPECT(AddNamedItem
);
3296 SET_EXPECT(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
); /* IE8 */
3297 SET_EXPECT(ParseScriptText_script
);
3298 SET_EXPECT(SetScriptState_CONNECTED
);
3300 load_doc(doc
, simple_script_str
);
3302 CHECK_CALLED(CreateInstance
);
3303 CHECK_CALLED(GetInterfaceSafetyOptions
);
3304 CHECK_CALLED(SetInterfaceSafetyOptions
);
3305 CHECK_CALLED_BROKEN(SetProperty_INVOKEVERSIONING
); /* IE8 */
3306 CHECK_CALLED(SetProperty_HACK_TRIDENTEVENTSINK
);
3307 CHECK_CALLED(InitNew
);
3308 CHECK_CALLED(SetScriptSite
);
3309 CHECK_CALLED(GetScriptState
);
3310 CHECK_CALLED(SetScriptState_STARTED
);
3311 CHECK_CALLED(AddNamedItem
);
3312 CHECK_CALLED_BROKEN(SetProperty_ABBREVIATE_GLOBALNAME_RESOLUTION
); /* IE8 */
3313 CHECK_CALLED(ParseScriptText_script
);
3314 CHECK_CALLED(SetScriptState_CONNECTED
);
3316 test_exec_script(doc
, "execScript call", "TestScript");
3319 IActiveScriptSite_Release(site
);
3321 IDispatchEx_Release(window_dispex
);
3323 SET_EXPECT(SetScriptState_DISCONNECTED
);
3326 IHTMLDocument2_Release(doc
);
3328 CHECK_CALLED(SetScriptState_DISCONNECTED
);
3329 CHECK_CALLED(Close
);
3332 static void run_from_moniker(IMoniker
*mon
)
3334 IPersistMoniker
*persist
;
3335 IHTMLDocument2
*doc
;
3339 doc
= create_document();
3343 set_client_site(doc
, TRUE
);
3344 do_advise(doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
3346 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistMoniker
, (void**)&persist
);
3347 ok(hres
== S_OK
, "Could not get IPersistMoniker iface: %08x\n", hres
);
3349 hres
= IPersistMoniker_Load(persist
, FALSE
, mon
, NULL
, 0);
3350 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
3352 IPersistMoniker_Release(persist
);
3354 SET_EXPECT(external_success
);
3356 while(!called_external_success
&& GetMessageW(&msg
, NULL
, 0, 0)) {
3357 TranslateMessage(&msg
);
3358 DispatchMessageW(&msg
);
3361 CHECK_CALLED(external_success
);
3363 free_registered_streams();
3364 set_client_site(doc
, FALSE
);
3365 IHTMLDocument2_Release(doc
);
3368 static void run_js_script(const char *test_name
)
3370 WCHAR url
[INTERNET_MAX_URL_LENGTH
] = {'r','e','s',':','/','/'}, *ptr
;
3374 trace("running %s...\n", test_name
);
3376 ptr
= url
+ lstrlenW(url
);
3377 ptr
+= GetModuleFileNameW(NULL
, ptr
, url
+ sizeof(url
)/sizeof(WCHAR
) - ptr
);
3379 MultiByteToWideChar(CP_ACP
, 0, test_name
, -1, ptr
, url
+ sizeof(url
)/sizeof(WCHAR
) - ptr
);
3381 hres
= CreateURLMoniker(NULL
, url
, &mon
);
3382 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
3383 run_from_moniker(mon
);
3385 IMoniker_Release(mon
);
3388 static void run_from_path(const char *path
, const char *opt
)
3390 char buf
[255] = "http://winetest.example.org";
3399 hres
= CreateURLMoniker(NULL
, url
, &mon
);
3401 ok(hres
== S_OK
, "CreateUrlMoniker failed: %08x\n", hres
);
3403 run_from_moniker(mon
);
3405 IMoniker_Release(mon
);
3408 static void run_script_as_http_with_mode(const char *script
, const char *opt
, const char *document_mode
)
3410 trace("Running %s script in %s mode...\n", script
, document_mode
? document_mode
: "quirks");
3412 sprintf(index_html_data
,
3417 " <script src=\"winetest.js\" type=\"text/javascript\"></script>\n"
3418 " <script src=\"%s\" type=\"text/javascript\"></script>\n"
3420 " <body onload=\"run_tests();\">\n"
3423 document_mode
? "<!DOCTYPE html>\n" : "",
3424 document_mode
? "<meta http-equiv=\"x-ua-compatible\" content=\"IE=" : "",
3425 document_mode
? document_mode
: "",
3426 document_mode
? "\">" : "",
3429 run_from_path("/index.html", opt
);
3432 static void init_protocol_handler(void)
3434 IInternetSession
*internet_session
;
3437 static const WCHAR httpW
[] = {'h','t','t','p',0};
3439 hres
= CoInternetGetSession(0, &internet_session
, 0);
3440 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
3442 hres
= IInternetSession_RegisterNameSpace(internet_session
, &protocol_cf
, &CLSID_HttpProtocol
, httpW
, 0, NULL
, 0);
3443 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
3445 IInternetSession_Release(internet_session
);
3448 static void run_js_tests(void)
3450 run_js_script("jstest.html");
3451 run_js_script("exectest.html");
3452 run_js_script("vbtest.html");
3453 run_js_script("events.html");
3456 win_skip("Skipping some script tests on IE older than 9.\n");
3460 init_protocol_handler();
3462 run_script_as_http_with_mode("xhr.js", NULL
, "11");
3463 run_script_as_http_with_mode("navigation.js", NULL
, NULL
);
3464 run_script_as_http_with_mode("navigation.js", NULL
, "11");
3466 run_script_as_http_with_mode("documentmode.js", "?5", NULL
);
3467 run_script_as_http_with_mode("documentmode.js", "?5", "5");
3468 run_script_as_http_with_mode("documentmode.js", "?5", "6");
3469 run_script_as_http_with_mode("documentmode.js", "?7", "7");
3470 run_script_as_http_with_mode("documentmode.js", "?8", "8");
3471 run_script_as_http_with_mode("documentmode.js", "?9", "9");
3472 run_script_as_http_with_mode("documentmode.js", "?10", "10");
3473 run_script_as_http_with_mode("documentmode.js", "?11", "11");
3475 run_script_as_http_with_mode("asyncscriptload.js", NULL
, "9");
3478 static BOOL
init_registry(BOOL init
)
3480 return init_key("TestScript\\CLSID", TESTSCRIPT_CLSID
, init
)
3481 && init_key("CLSID\\"TESTSCRIPT_CLSID
"\\Implemented Categories\\{F0B7A1A1-9847-11CF-8F20-00805F2CD064}",
3483 && init_key("CLSID\\"TESTSCRIPT_CLSID
"\\Implemented Categories\\{F0B7A1A2-9847-11CF-8F20-00805F2CD064}",
3487 static BOOL
register_script_engine(void)
3492 if(!init_registry(TRUE
)) {
3493 init_registry(FALSE
);
3497 hres
= CoRegisterClassObject(&CLSID_TestScript
, (IUnknown
*)&script_cf
,
3498 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
3499 ok(hres
== S_OK
, "Could not register script engine: %08x\n", hres
);
3504 static LRESULT WINAPI
wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3506 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
3509 static HWND
create_container_window(void)
3511 static const CHAR szHTMLDocumentTest
[] = "HTMLDocumentTest";
3512 static WNDCLASSEXA wndclass
= {
3513 sizeof(WNDCLASSEXA
),
3516 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
3521 RegisterClassExA(&wndclass
);
3522 return CreateWindowA(szHTMLDocumentTest
, szHTMLDocumentTest
,
3523 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
,
3524 300, 300, NULL
, NULL
, NULL
, NULL
);
3527 static BOOL
check_ie(void)
3529 IHTMLDocument2
*doc
;
3530 IHTMLDocument5
*doc5
;
3531 IHTMLDocument7
*doc7
;
3534 doc
= create_document();
3538 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument7
, (void**)&doc7
);
3539 if(SUCCEEDED(hres
)) {
3541 IHTMLDocument7_Release(doc7
);
3544 trace("is_ie9plus %x\n", is_ie9plus
);
3546 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3548 IHTMLDocument5_Release(doc5
);
3550 IHTMLDocument2_Release(doc
);
3551 return SUCCEEDED(hres
);
3557 container_hwnd
= create_container_window();
3560 if(winetest_interactive
|| ! is_ie_hardened()) {
3561 if(register_script_engine()) {
3562 test_simple_script();
3563 init_registry(FALSE
);
3565 skip("Could not register TestScript engine\n");
3569 skip("IE running in Enhanced Security Configuration\n");
3572 win_skip("Too old IE.\n");
3575 DestroyWindow(container_hwnd
);