2 * Copyright 2010 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>
33 #include "mshtml_test.h"
35 #define DEFINE_EXPECT(func) \
36 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
38 #define SET_EXPECT(func) \
39 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
41 #define CHECK_EXPECT2(func) \
43 ok(expect_ ##func, "unexpected call " #func "\n"); \
44 called_ ## func = TRUE; \
47 #define CHECK_EXPECT(func) \
49 CHECK_EXPECT2(func); \
50 expect_ ## func = FALSE; \
53 #define CHECK_CALLED(func) \
55 ok(called_ ## func, "expected " #func "\n"); \
56 expect_ ## func = called_ ## func = FALSE; \
59 DEFINE_EXPECT(CreateInstance
);
60 DEFINE_EXPECT(FreezeEvents_TRUE
);
61 DEFINE_EXPECT(FreezeEvents_FALSE
);
62 DEFINE_EXPECT(QuickActivate
);
63 DEFINE_EXPECT(IPersistPropertyBag_InitNew
);
64 DEFINE_EXPECT(IPersistPropertyBag_Load
);
65 DEFINE_EXPECT(Invoke_READYSTATE
);
67 static HWND container_hwnd
;
69 #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7f6680746}"
71 static const GUID CLSID_TestActiveX
=
72 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xf6,0x68,0x07,0x46}};
74 static const char object_ax_str
[] =
75 "<html><head></head><body>"
76 "<object classid=\"clsid:" TESTACTIVEX_CLSID
"\" width=\"300\" height=\"200\" id=\"objid\">"
77 "<param name=\"param_name\" value=\"param_value\">"
78 "<param name=\"num_param\" value=\"3\">"
82 static const REFIID pluginhost_iids
[] = {
86 &IID_IPropertyNotifySink
,
90 &IID_IOleInPlaceSiteEx
,
93 &IID_IServiceProvider
,
97 static const char *debugstr_guid(REFIID riid
)
101 sprintf(buf
, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
102 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
103 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
104 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
109 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
111 IUnknown
*unk1
, *unk2
;
116 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
117 IUnknown_Release(unk1
);
118 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
119 IUnknown_Release(unk2
);
124 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
125 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
127 const IID
* const *piid
;
131 for(piid
= iids
; *piid
; piid
++) {
132 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
133 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", debugstr_guid(*piid
), hres
);
135 IUnknown_Release(unk
);
139 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
142 WideCharToMultiByte(CP_ACP
, 0, strw
, -1, buf
, sizeof(buf
), NULL
, NULL
);
143 return lstrcmpA(stra
, buf
);
146 static IOleClientSite
*client_site
;
147 static READYSTATE plugin_readystate
= READYSTATE_UNINITIALIZED
;
149 static void set_plugin_readystate(READYSTATE state
)
151 IPropertyNotifySink
*prop_notif
;
154 plugin_readystate
= state
;
156 hres
= IOleClientSite_QueryInterface(client_site
, &IID_IPropertyNotifySink
, (void**)&prop_notif
);
157 ok(hres
== S_OK
, "Could not get IPropertyNotifySink iface: %08x\n", hres
);
159 hres
= IPropertyNotifySink_OnChanged(prop_notif
, DISPID_READYSTATE
);
160 ok(hres
== S_OK
, "OnChanged(DISPID_READYSTATE) failed: %08x\n", hres
);
162 IPropertyNotifySink_Release(prop_notif
);
165 static void test_mon_displayname(IMoniker
*mon
, const char *exname
)
167 LPOLESTR display_name
;
171 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &display_name
);
172 ok(hres
== S_OK
, "GetDisplayName failed: %08x\n", hres
);
173 ok(!strcmp_wa(display_name
, exname
), "display_name = %s\n", wine_dbgstr_w(display_name
));
174 CoTaskMemFree(display_name
);
176 hres
= IMoniker_IsSystemMoniker(mon
, &mksys
);
177 ok(hres
== S_OK
, "IsSystemMoniker failed: %08x\n", hres
);
178 ok(mksys
== MKSYS_URLMONIKER
, "mksys = %d\n", mksys
);
181 static HRESULT
ax_qi(REFIID
,void**);
183 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
, REFIID riid
, void **ppv
)
185 return ax_qi(riid
, ppv
);
188 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
193 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
198 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, CONTROLINFO
*pCI
)
200 ok(0, "unexpected call\n");
204 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, MSG
*mMsg
)
206 ok(0, "unexpected call\n");
210 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
212 ok(0, "unexpected call\n");
216 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
219 CHECK_EXPECT2(FreezeEvents_TRUE
);
221 CHECK_EXPECT2(FreezeEvents_FALSE
);
225 static const IOleControlVtbl OleControlVtbl
= {
226 OleControl_QueryInterface
,
229 OleControl_GetControlInfo
,
230 OleControl_OnMnemonic
,
231 OleControl_OnAmbientPropertyChange
,
232 OleControl_FreezeEvents
235 static IOleControl OleControl
= { &OleControlVtbl
};
237 static HRESULT WINAPI
QuickActivate_QueryInterface(IQuickActivate
*iface
, REFIID riid
, void **ppv
)
239 return ax_qi(riid
, ppv
);
242 static ULONG WINAPI
QuickActivate_AddRef(IQuickActivate
*iface
)
247 static ULONG WINAPI
QuickActivate_Release(IQuickActivate
*iface
)
252 static HRESULT WINAPI
QuickActivate_QuickActivate(IQuickActivate
*iface
, QACONTAINER
*container
, QACONTROL
*control
)
254 CHECK_EXPECT(QuickActivate
);
256 ok(container
!= NULL
, "container == NULL\n");
257 ok(container
->cbSize
== sizeof(*container
), "container->cbSize = %d\n", container
->cbSize
);
258 ok(container
->pClientSite
!= NULL
, "container->pClientSite == NULL\n");
259 ok(container
->pAdviseSink
!= NULL
, "container->pAdviseSink == NULL\n");
260 ok(container
->pPropertyNotifySink
!= NULL
, "container->pPropertyNotifySink == NULL\n");
261 ok(!container
->pUnkEventSink
, "container->pUnkEventSink != NULL\n");
262 ok(container
->dwAmbientFlags
== (QACONTAINER_SUPPORTSMNEMONICS
|QACONTAINER_MESSAGEREFLECT
|QACONTAINER_USERMODE
),
263 "container->dwAmbientFlags = %x\n", container
->dwAmbientFlags
);
264 ok(!container
->colorFore
, "container->colorFore == 0\n"); /* FIXME */
266 ok(container
->colorBack
, "container->colorBack == 0\n"); /* FIXME */
268 ok(container
->pFont
!= NULL
, "container->pFont == NULL\n");
270 ok(container
->pUndoMgr
!= NULL
, "container->pUndoMgr == NULL\n");
271 ok(!container
->dwAppearance
, "container->dwAppearance = %x\n", container
->dwAppearance
);
272 ok(!container
->lcid
, "container->lcid = %x\n", container
->lcid
);
273 ok(!container
->hpal
, "container->hpal = %p\n", container
->hpal
);
274 ok(!container
->pBindHost
, "container->pBindHost != NULL\n");
275 ok(!container
->pOleControlSite
, "container->pOleControlSite != NULL\n");
276 ok(!container
->pServiceProvider
, "container->pServiceProvider != NULL\n");
278 ok(control
->cbSize
== sizeof(*control
), "control->cbSize = %d\n", control
->cbSize
);
279 ok(!control
->dwMiscStatus
, "control->dwMiscStatus = %x\n", control
->dwMiscStatus
);
280 ok(!control
->dwViewStatus
, "control->dwViewStatus = %x\n", control
->dwViewStatus
);
281 ok(!control
->dwEventCookie
, "control->dwEventCookie = %x\n", control
->dwEventCookie
);
282 ok(!control
->dwPropNotifyCookie
, "control->dwPropNotifyCookie = %x\n", control
->dwPropNotifyCookie
);
283 ok(!control
->dwPointerActivationPolicy
, "control->dwPointerActivationPolicy = %x\n", control
->dwPointerActivationPolicy
);
285 ok(iface_cmp((IUnknown
*)container
->pClientSite
, (IUnknown
*)container
->pAdviseSink
),
286 "container->pClientSite != container->pAdviseSink\n");
287 ok(iface_cmp((IUnknown
*)container
->pClientSite
, (IUnknown
*)container
->pPropertyNotifySink
),
288 "container->pClientSite != container->pPropertyNotifySink\n");
289 test_ifaces((IUnknown
*)container
->pClientSite
, pluginhost_iids
);
291 IOleClientSite_AddRef(container
->pClientSite
);
292 client_site
= container
->pClientSite
;
297 static HRESULT WINAPI
QuickActivate_SetContentExtent(IQuickActivate
*iface
, LPSIZEL pSizel
)
299 ok(0, "unexpected call\n");
303 static HRESULT WINAPI
QuickActivate_GetContentExtent(IQuickActivate
*iface
, LPSIZEL pSizel
)
305 ok(0, "unexpected call\n");
309 static const IQuickActivateVtbl QuickActivateVtbl
= {
310 QuickActivate_QueryInterface
,
311 QuickActivate_AddRef
,
312 QuickActivate_Release
,
313 QuickActivate_QuickActivate
,
314 QuickActivate_GetContentExtent
,
315 QuickActivate_SetContentExtent
318 static IQuickActivate QuickActivate
= { &QuickActivateVtbl
};
320 static HRESULT WINAPI
PersistPropertyBag_QueryInterface(IPersistPropertyBag
*iface
, REFIID riid
, void **ppv
)
322 return ax_qi(riid
, ppv
);
325 static ULONG WINAPI
PersistPropertyBag_AddRef(IPersistPropertyBag
*iface
)
330 static ULONG WINAPI
PersistPropertyBag_Release(IPersistPropertyBag
*iface
)
335 static HRESULT WINAPI
PersistPropertyBag_GetClassID(IPersistPropertyBag
*face
, CLSID
*pClassID
)
337 ok(0, "unexpected call\n");
341 static HRESULT WINAPI
PersistPropertyBag_InitNew(IPersistPropertyBag
*face
)
343 CHECK_EXPECT(IPersistPropertyBag_InitNew
);
347 static HRESULT WINAPI
PersistPropertyBag_Load(IPersistPropertyBag
*face
, IPropertyBag
*pPropBag
, IErrorLog
*pErrorLog
)
349 IBindHost
*bind_host
, *bind_host2
;
350 IServiceProvider
*sp
;
355 static const WCHAR param_nameW
[] = {'p','a','r','a','m','_','n','a','m','e',0};
356 static const WCHAR num_paramW
[] = {'n','u','m','_','p','a','r','a','m',0};
357 static const WCHAR no_paramW
[] = {'n','o','_','p','a','r','a','m',0};
359 static const IID
*propbag_ifaces
[] = {
365 CHECK_EXPECT(IPersistPropertyBag_Load
);
367 ok(pPropBag
!= NULL
, "pPropBag == NULL\n");
368 ok(!pErrorLog
, "pErrorLog != NULL\n");
370 test_ifaces((IUnknown
*)pPropBag
, propbag_ifaces
);
373 hres
= IPropertyBag_Read(pPropBag
, param_nameW
, &v
, NULL
);
374 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
375 ok(V_VT(&v
) == VT_BSTR
, "V_VT(&v) = %d\n", V_VT(&v
));
376 ok(!strcmp_wa(V_BSTR(&v
), "param_value"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
379 V_I4(&v
) = 0xdeadbeef;
380 hres
= IPropertyBag_Read(pPropBag
, param_nameW
, &v
, NULL
);
381 ok(hres
== DISP_E_TYPEMISMATCH
, "Read failed: %08x, expected DISP_E_TYPEMISMATCH\n", hres
);
382 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
383 ok(V_I4(&v
) == 0xdeadbeef, "V_I4(v) = %x\n", V_I4(&v
));
386 hres
= IPropertyBag_Read(pPropBag
, num_paramW
, &v
, NULL
);
387 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
388 ok(V_VT(&v
) == VT_BSTR
, "V_VT(&v) = %d\n", V_VT(&v
));
389 ok(!strcmp_wa(V_BSTR(&v
), "3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
392 V_I4(&v
) = 0xdeadbeef;
393 hres
= IPropertyBag_Read(pPropBag
, num_paramW
, &v
, NULL
);
394 ok(hres
== S_OK
, "Read failed: %08x\n", hres
);
395 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
396 ok(V_I4(&v
) == 3, "V_I4(v) = %x\n", V_I4(&v
));
399 V_BSTR(&v
) = (BSTR
)0xdeadbeef;
400 hres
= IPropertyBag_Read(pPropBag
, no_paramW
, &v
, NULL
);
401 ok(hres
== E_INVALIDARG
, "Read failed: %08x\n", hres
);
402 ok(V_VT(&v
) == VT_BSTR
, "V_VT(&v) = %d\n", V_VT(&v
));
403 ok(V_BSTR(&v
) == (BSTR
)0xdeadbeef, "V_BSTR(v) = %p\n", V_BSTR(&v
));
405 set_plugin_readystate(READYSTATE_INTERACTIVE
);
407 hres
= IOleClientSite_QueryInterface(client_site
, &IID_IBindHost
, (void**)&bind_host
);
408 ok(hres
== S_OK
, "Could not get IBindHost iface: %08x\n", hres
);
410 hres
= IOleClientSite_QueryInterface(client_site
, &IID_IServiceProvider
, (void**)&sp
);
411 ok(hres
== S_OK
, "Could not get IServiceProvider iface: %08x\n", hres
);
413 hres
= IServiceProvider_QueryService(sp
, &IID_IBindHost
, &SID_SBindHost
, (void**)&bind_host2
);
414 ok(hres
== S_OK
, "QueryService(SID_SBindHost) failed: %08x\n", hres
);
415 IServiceProvider_Release(sp
);
417 ok(iface_cmp((IUnknown
*)bind_host
, (IUnknown
*)bind_host2
), "bind_host != bind_host2\n");
418 IBindHost_Release(bind_host2
);
421 hres
= IOleClientSite_GetMoniker(client_site
, OLEGETMONIKER_ONLYIFTHERE
, OLEWHICHMK_CONTAINER
, &mon
);
422 ok(hres
== S_OK
, "GetMoniker failed: %08x\n", hres
);
423 ok(mon
!= NULL
, "mon == NULL\n");
424 test_mon_displayname(mon
, "about:blank");
425 IMoniker_Release(mon
);
427 IBindHost_Release(bind_host
);
429 set_plugin_readystate(READYSTATE_COMPLETE
);
434 static HRESULT WINAPI
PersistPropertyBag_Save(IPersistPropertyBag
*face
, IPropertyBag
*pPropBag
, BOOL fClearDisrty
, BOOL fSaveAllProperties
)
436 ok(0, "unexpected call\n");
440 static const IPersistPropertyBagVtbl PersistPropertyBagVtbl
= {
441 PersistPropertyBag_QueryInterface
,
442 PersistPropertyBag_AddRef
,
443 PersistPropertyBag_Release
,
444 PersistPropertyBag_GetClassID
,
445 PersistPropertyBag_InitNew
,
446 PersistPropertyBag_Load
,
447 PersistPropertyBag_Save
451 static IPersistPropertyBag PersistPropertyBag
= { &PersistPropertyBagVtbl
};
453 static HRESULT WINAPI
Dispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
455 return ax_qi(riid
, ppv
);
458 static ULONG WINAPI
Dispatch_AddRef(IDispatch
*iface
)
463 static ULONG WINAPI
Dispatch_Release(IDispatch
*iface
)
468 static HRESULT WINAPI
Dispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
470 ok(0, "unexpected call\n");
474 static HRESULT WINAPI
Dispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
, LCID lcid
,
477 ok(0, "unexpected call\n");
481 static HRESULT WINAPI
Dispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
482 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
484 ok(0, "unexpected call\n");
488 static HRESULT WINAPI
Dispatch_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
,
489 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
490 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
492 ok(IsEqualGUID(riid
, &IID_NULL
), "riid = %s\n", debugstr_guid(riid
));
493 ok(pDispParams
!= NULL
, "pDispParams == NULL\n");
494 ok(!pDispParams
->cNamedArgs
, "pDispParams->cNamedArgs = %d\n", pDispParams
->cNamedArgs
);
495 ok(!pDispParams
->rgdispidNamedArgs
, "pDispParams->rgdispidNamedArgs != NULL\n");
496 ok(pVarResult
!= NULL
, "pVarResult == NULL\n");
497 ok(!pExcepInfo
, "pExcepInfo != NULL\n");
498 ok(puArgErr
!= NULL
, "puArgErr == NULL\n");
500 switch(dispIdMember
) {
501 case DISPID_READYSTATE
:
502 CHECK_EXPECT2(Invoke_READYSTATE
);
503 ok(wFlags
== DISPATCH_PROPERTYGET
, "wFlags = %x\n", wFlags
);
504 ok(!pDispParams
->cArgs
, "pDispParams->cArgs = %d\n", pDispParams
->cArgs
);
505 ok(!pDispParams
->rgvarg
, "pDispParams->rgvarg != NULL\n");
507 V_VT(pVarResult
) = VT_I4
;
508 V_I4(pVarResult
) = plugin_readystate
;
511 ok(0, "unexpected call %d\n", dispIdMember
);
517 static const IDispatchVtbl DispatchVtbl
= {
518 Dispatch_QueryInterface
,
521 Dispatch_GetTypeInfoCount
,
522 Dispatch_GetTypeInfo
,
523 Dispatch_GetIDsOfNames
,
527 static IDispatch Dispatch
= { &DispatchVtbl
};
529 static HRESULT
ax_qi(REFIID riid
, void **ppv
)
531 if(IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_IOleControl
)) {
536 if(IsEqualGUID(riid
, &IID_IQuickActivate
)) {
537 *ppv
= &QuickActivate
;
541 if(IsEqualGUID(riid
, &IID_IPersistPropertyBag
)) {
542 *ppv
= &PersistPropertyBag
;
546 if(IsEqualGUID(riid
, &IID_IDispatch
)) {
552 return E_NOINTERFACE
;
555 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
559 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
564 if(IsEqualGUID(&IID_IMarshal
, riid
))
565 return E_NOINTERFACE
;
566 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
567 return E_NOINTERFACE
;
568 if(IsEqualGUID(&IID_IClassFactoryEx
, riid
))
569 return E_NOINTERFACE
; /* TODO */
571 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
575 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
580 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
585 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
587 CHECK_EXPECT(CreateInstance
);
589 ok(!outer
, "outer = %p\n", outer
);
590 ok(IsEqualGUID(riid
, &IID_IUnknown
), "riid = %s\n", debugstr_guid(riid
));
596 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
598 ok(0, "unexpected call\n");
602 static const IClassFactoryVtbl ClassFactoryVtbl
= {
603 ClassFactory_QueryInterface
,
605 ClassFactory_Release
,
606 ClassFactory_CreateInstance
,
607 ClassFactory_LockServer
610 static IClassFactory activex_cf
= { &ClassFactoryVtbl
};
612 static HRESULT
cs_qi(REFIID
,void **);
613 static IOleDocumentView
*view
;
615 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
617 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
619 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
620 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
623 return E_NOINTERFACE
;
626 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
631 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
636 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
641 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
646 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
651 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
652 LPCBORDERWIDTHS pborderwidths
)
657 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
658 LPCBORDERWIDTHS pborderwidths
)
663 static HRESULT WINAPI
InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame
*iface
,
664 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
669 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
670 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
675 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
676 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
681 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
682 HOLEMENU holemenu
, HWND hwndActiveObject
)
684 ok(0, "unexpected call\n");
688 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
690 ok(0, "unexpected call\n");
694 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
699 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
704 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
706 ok(0, "unexpected call\n");
710 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
711 InPlaceFrame_QueryInterface
,
713 InPlaceFrame_Release
,
714 InPlaceFrame_GetWindow
,
715 InPlaceFrame_ContextSensitiveHelp
,
716 InPlaceFrame_GetBorder
,
717 InPlaceFrame_RequestBorderSpace
,
718 InPlaceFrame_SetBorderSpace
,
719 InPlaceFrame_SetActiveObject
,
720 InPlaceFrame_InsertMenus
,
721 InPlaceFrame_SetMenu
,
722 InPlaceFrame_RemoveMenus
,
723 InPlaceFrame_SetStatusText
,
724 InPlaceFrame_EnableModeless
,
725 InPlaceFrame_TranslateAccelerator
728 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
730 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl
= {
731 InPlaceFrame_QueryInterface
,
733 InPlaceFrame_Release
,
734 InPlaceFrame_GetWindow
,
735 InPlaceFrame_ContextSensitiveHelp
,
736 InPlaceFrame_GetBorder
,
737 InPlaceFrame_RequestBorderSpace
,
738 InPlaceFrame_SetBorderSpace
,
739 InPlaceUIWindow_SetActiveObject
,
742 static IOleInPlaceFrame InPlaceUIWindow
= { &InPlaceUIWindowVtbl
};
744 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
746 return cs_qi(riid
, ppv
);
749 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
754 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
759 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
761 *phwnd
= container_hwnd
;
765 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
767 ok(0, "unexpected call\n");
771 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
776 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
781 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
786 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
787 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
788 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
790 static const RECT rect
= {0,0,500,500};
792 *ppFrame
= &InPlaceFrame
;
793 *ppDoc
= (IOleInPlaceUIWindow
*)&InPlaceUIWindow
;
795 *lprcClipRect
= rect
;
797 lpFrameInfo
->cb
= sizeof(*lpFrameInfo
);
798 lpFrameInfo
->fMDIApp
= FALSE
;
799 lpFrameInfo
->hwndFrame
= container_hwnd
;
800 lpFrameInfo
->haccel
= NULL
;
801 lpFrameInfo
->cAccelEntries
= 0;
806 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
811 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
816 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
821 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
826 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
831 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
836 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
837 InPlaceSite_QueryInterface
,
840 InPlaceSite_GetWindow
,
841 InPlaceSite_ContextSensitiveHelp
,
842 InPlaceSite_CanInPlaceActivate
,
843 InPlaceSite_OnInPlaceActivate
,
844 InPlaceSite_OnUIActivate
,
845 InPlaceSite_GetWindowContext
,
847 InPlaceSite_OnUIDeactivate
,
848 InPlaceSite_OnInPlaceDeactivate
,
849 InPlaceSite_DiscardUndoState
,
850 InPlaceSite_DeactivateAndUndo
,
851 InPlaceSite_OnPosRectChange
,
854 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
856 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
858 return cs_qi(riid
, ppv
);
861 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
866 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
871 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
873 ok(0, "unexpected call\n");
877 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
880 ok(0, "unexpected call\n");
884 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
889 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
891 ok(0, "unexpected call\n");
895 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
897 ok(0, "unexpected call\n");
901 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
903 ok(0, "unexpected call\n");
907 static const IOleClientSiteVtbl ClientSiteVtbl
= {
908 ClientSite_QueryInterface
,
911 ClientSite_SaveObject
,
912 ClientSite_GetMoniker
,
913 ClientSite_GetContainer
,
914 ClientSite_ShowObject
,
915 ClientSite_OnShowWindow
,
916 ClientSite_RequestNewObjectLayout
919 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
921 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
923 return cs_qi(riid
, ppv
);
926 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
931 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
936 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
938 RECT rect
= {0,0,400,500};
939 IOleDocument
*document
;
942 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
943 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
945 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
946 IOleDocument_Release(document
);
947 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
949 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
950 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
952 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
953 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
955 hres
= IOleDocumentView_SetRect(view
, &rect
);
956 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
958 hres
= IOleDocumentView_Show(view
, TRUE
);
959 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
964 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
965 DocumentSite_QueryInterface
,
967 DocumentSite_Release
,
968 DocumentSite_ActivateMe
971 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
973 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
977 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
979 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
980 *ppv
= &DocumentSite
;
981 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
984 return *ppv
? S_OK
: E_NOINTERFACE
;
987 static IHTMLDocument2
*notif_doc
;
988 static BOOL doc_complete
;
990 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
991 REFIID riid
, void**ppv
)
993 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
998 ok(0, "unexpected call\n");
999 return E_NOINTERFACE
;
1002 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
1007 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
1012 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
1014 if(dispID
== DISPID_READYSTATE
){
1018 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
1020 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
1021 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
1023 if(!lstrcmpW(state
, completeW
))
1024 doc_complete
= TRUE
;
1026 SysFreeString(state
);
1032 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
1034 ok(0, "unexpected call\n");
1038 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
1039 PropertyNotifySink_QueryInterface
,
1040 PropertyNotifySink_AddRef
,
1041 PropertyNotifySink_Release
,
1042 PropertyNotifySink_OnChanged
,
1043 PropertyNotifySink_OnRequestEdit
1046 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
1048 static void doc_load_string(IHTMLDocument2
*doc
, const char *str
)
1050 IPersistStreamInit
*init
;
1057 doc_complete
= FALSE
;
1059 mem
= GlobalAlloc(0, len
);
1060 memcpy(mem
, str
, len
);
1061 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
1063 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
1065 IPersistStreamInit_Load(init
, stream
);
1066 IPersistStreamInit_Release(init
);
1067 IStream_Release(stream
);
1070 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
1072 IConnectionPointContainer
*container
;
1073 IConnectionPoint
*cp
;
1077 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
1078 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
1080 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
1081 IConnectionPointContainer_Release(container
);
1082 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1084 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
1085 IConnectionPoint_Release(cp
);
1086 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1089 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
1095 IOleDocumentView_Show(view
, FALSE
);
1096 IOleDocumentView_CloseView(view
, 0);
1097 IOleDocumentView_SetInPlaceSite(view
, NULL
);
1098 IOleDocumentView_Release(view
);
1102 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
1103 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
1105 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
1106 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
1109 IHlinkTarget
*hlink
;
1111 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
1112 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
1114 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
1115 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
1117 IHlinkTarget_Release(hlink
);
1120 IOleObject_Release(oleobj
);
1122 static IHTMLDocument2
*create_document(void)
1124 IHTMLDocument2
*doc
;
1127 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1128 &IID_IHTMLDocument2
, (void**)&doc
);
1129 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
1134 static IHTMLDocument2
*create_doc(const char *str
, BOOL
*b
)
1136 IHTMLDocument2
*doc
;
1139 doc
= create_document();
1140 set_client_site(doc
, TRUE
);
1141 doc_load_string(doc
, str
);
1142 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
1144 while((!doc_complete
|| (b
&& !*b
)) && GetMessage(&msg
, NULL
, 0, 0)) {
1145 TranslateMessage(&msg
);
1146 DispatchMessage(&msg
);
1152 static void release_doc(IHTMLDocument2
*doc
)
1157 IOleClientSite_Release(client_site
);
1161 set_client_site(doc
, FALSE
);
1162 ref
= IHTMLDocument2_Release(doc
);
1163 ok(!ref
, "ref = %d\n", ref
);
1166 static void test_object_ax(void)
1168 IHTMLDocument2
*doc
;
1171 * We pump messages until both document is loaded and plugin instance is created.
1172 * Pumping until document is loaded should be enough, but Gecko loads plugins
1173 * asynchronously and until we'll work around it, we need this hack.
1175 SET_EXPECT(CreateInstance
);
1176 SET_EXPECT(FreezeEvents_TRUE
);
1177 SET_EXPECT(QuickActivate
);
1178 SET_EXPECT(FreezeEvents_FALSE
);
1179 SET_EXPECT(IPersistPropertyBag_Load
);
1180 SET_EXPECT(Invoke_READYSTATE
);
1182 doc
= create_doc(object_ax_str
, &called_CreateInstance
);
1184 CHECK_CALLED(CreateInstance
);
1186 CHECK_CALLED(FreezeEvents_TRUE
);
1187 CHECK_CALLED(QuickActivate
);
1189 CHECK_CALLED(FreezeEvents_FALSE
);
1190 CHECK_CALLED(IPersistPropertyBag_Load
);
1191 CHECK_CALLED(Invoke_READYSTATE
);
1196 static LRESULT WINAPI
wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1198 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
1201 static HWND
create_container_window(void)
1203 static const WCHAR html_document_testW
[] =
1204 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
1205 static WNDCLASSEXW wndclass
= {
1206 sizeof(WNDCLASSEXW
),
1209 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
1210 html_document_testW
,
1214 RegisterClassExW(&wndclass
);
1215 return CreateWindowW(html_document_testW
, html_document_testW
,
1216 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1217 515, 530, NULL
, NULL
, NULL
, NULL
);
1220 static BOOL
init_key(const char *key_name
, const char *def_value
, BOOL init
)
1226 RegDeleteKey(HKEY_CLASSES_ROOT
, key_name
);
1230 res
= RegCreateKeyA(HKEY_CLASSES_ROOT
, key_name
, &hkey
);
1231 if(res
!= ERROR_SUCCESS
)
1235 res
= RegSetValueA(hkey
, NULL
, REG_SZ
, def_value
, strlen(def_value
));
1239 return res
== ERROR_SUCCESS
;
1242 static BOOL
init_registry(BOOL init
)
1244 return init_key("TestActiveX\\CLSID", TESTACTIVEX_CLSID
, init
)
1245 && init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
1247 && init_key("CLSID\\"TESTACTIVEX_CLSID
"\\Implemented Categories\\{7dd95802-9882-11cf-9fa9-00aa006c42c4}",
1251 static BOOL
register_activex(void)
1256 if(!init_registry(TRUE
)) {
1257 init_registry(FALSE
);
1261 hres
= CoRegisterClassObject(&CLSID_TestActiveX
, (IUnknown
*)&activex_cf
,
1262 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
1263 ok(hres
== S_OK
, "Could not register control: %08x\n", hres
);
1268 static BOOL
check_ie(void)
1270 IHTMLDocument5
*doc
;
1273 static const WCHAR xW
[] = {'x',0};
1274 static const WCHAR yW
[] = {'y',0};
1276 if(!lstrcmpW(xW
, yW
))
1279 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
1280 &IID_IHTMLDocument5
, (void**)&doc
);
1284 IHTMLDocument5_Release(doc
);
1294 win_skip("Too old IE\n");
1298 if(is_ie_hardened()) {
1300 win_skip("IE running in Enhanced Security Configuration\n");
1304 container_hwnd
= create_container_window();
1305 ShowWindow(container_hwnd
, SW_SHOW
);
1307 if(register_activex()) {
1309 init_registry(FALSE
);
1311 skip("Could not register ActiveX\n");
1314 DestroyWindow(container_hwnd
);