1 /*
2  * Copyright 2010 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "precomp.h"
20 
21 #include <test_tlb.h>
22 
23 #define DEFINE_EXPECT(func) \
24     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
25 
26 #define SET_EXPECT(func) \
27     do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
28 
29 #define CHECK_EXPECT2(func) \
30     do { \
31         ok(expect_ ##func, "unexpected call " #func "\n"); \
32         called_ ## func = TRUE; \
33     }while(0)
34 
35 #define CHECK_EXPECT(func) \
36     do { \
37         CHECK_EXPECT2(func); \
38         expect_ ## func = FALSE; \
39     }while(0)
40 
41 #define CHECK_CALLED(func) \
42     do { \
43         ok(called_ ## func, "expected " #func "\n"); \
44         expect_ ## func = called_ ## func = FALSE; \
45     }while(0)
46 
47 #define CLEAR_CALLED(func) \
48     expect_ ## func = called_ ## func = FALSE
49 
50 #undef GetClassInfo
51 
52 DEFINE_EXPECT(CreateInstance);
53 DEFINE_EXPECT(FreezeEvents_TRUE);
54 DEFINE_EXPECT(FreezeEvents_FALSE);
55 DEFINE_EXPECT(QuickActivate);
56 DEFINE_EXPECT(IPersistPropertyBag_InitNew);
57 DEFINE_EXPECT(IPersistPropertyBag_Load);
58 DEFINE_EXPECT(Invoke_READYSTATE);
59 DEFINE_EXPECT(Invoke_ENABLED);
60 DEFINE_EXPECT(Invoke_VALID);
61 DEFINE_EXPECT(Invoke_SECURITYCTX);
62 DEFINE_EXPECT(Invoke_SCRIPTPROP);
63 DEFINE_EXPECT(Invoke_SCRIPTCALL);
64 DEFINE_EXPECT(GetIDsOfNames_scriptprop);
65 DEFINE_EXPECT(DoVerb);
66 DEFINE_EXPECT(SetExtent);
67 DEFINE_EXPECT(GetExtent);
68 DEFINE_EXPECT(SetClientSite);
69 DEFINE_EXPECT(SetClientSite_NULL);
70 DEFINE_EXPECT(Close);
71 DEFINE_EXPECT(InPlaceObject_GetWindow);
72 DEFINE_EXPECT(SetObjectRects);
73 DEFINE_EXPECT(InPlaceDeactivate);
74 DEFINE_EXPECT(UIDeactivate);
75 DEFINE_EXPECT(QueryService_TestActiveX);
76 DEFINE_EXPECT(GetMiscStatus);
77 DEFINE_EXPECT(SetAdvise);
78 DEFINE_EXPECT(GetViewStatus);
79 DEFINE_EXPECT(QI_ITestActiveX);
80 DEFINE_EXPECT(wrapped_AddRef);
81 DEFINE_EXPECT(wrapped_Release);
82 DEFINE_EXPECT(wrapped_func);
83 DEFINE_EXPECT(OnAmbientPropertyChange_UNKNOWN);
84 DEFINE_EXPECT(GetTypeInfo);
85 DEFINE_EXPECT(GetClassInfo);
86 DEFINE_EXPECT(FindConnectionPoint);
87 DEFINE_EXPECT(Advise);
88 DEFINE_EXPECT(Unadvise);
89 
90 #define DISPID_SCRIPTPROP 1000
91 #define DISPID_SCRIPTCALL 1001
92 
93 enum {
94     TEST_FLASH,
95     TEST_NOQUICKACT,
96     TEST_DISPONLY
97 };
98 
99 static ITypeInfo *actxtest_typeinfo, *class_typeinfo;
100 static HWND container_hwnd, plugin_hwnd;
101 static int plugin_behavior;
102 static BOOL no_quickact;
103 static LONG activex_refcnt;
104 
105 #define TESTACTIVEX_CLSID "{178fc163-f585-4e24-9c13-4bb7f6680746}"
106 
107 static const GUID CLSID_TestActiveX =
108     {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xf6,0x68,0x07,0x46}};
109 
110 static const GUID IID_ITestActiveX =
111     {0x178fc663,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xf6,0x68,0x07,0x46}};
112 
113 static const char object_ax_str[] =
114     "<html><head></head><body>"
115     "<object classid=\"clsid:" TESTACTIVEX_CLSID "\" width=\"300\" height=\"200\" id=\"objid\">"
116     "<param name=\"param_name\" value=\"param_value\">"
117     "<param name=\"num_param\" value=\"3\">"
118     "</object>"
119     "<script>"
120     "objid.scriptCall();"
121     "</script>"
122     "</body></html>";
123 
124 static const char event_binding_str[] =
125     "<html><head></head><body>"
126     "<object classid=\"clsid:" TESTACTIVEX_CLSID "\" width=\"300\" height=\"200\" id=\"objid\">"
127     "<param name=\"param_name\" value=\"param_value\">"
128     "<param name=\"num_param\" value=\"3\">"
129     "</object>"
130     "<script for=\"objid\" event=\"testfunc\">return 6;</script>"
131     "<script for=\"objid\" event=\"testfunc2(x,y)\">return x+2*y;</script>"
132     "</body></html>";
133 
134 static REFIID pluginhost_iids[] = {
135     &IID_IOleClientSite,
136     &IID_IAdviseSink,
137     &IID_IAdviseSinkEx,
138     &IID_IPropertyNotifySink,
139     &IID_IDispatch,
140     &IID_IOleWindow,
141     &IID_IOleInPlaceSite,
142     &IID_IOleInPlaceSiteEx,
143     &IID_IOleControlSite,
144     &IID_IBindHost,
145     &IID_IServiceProvider,
146     NULL
147 };
148 
149 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
150 {
151     IUnknown *unk1, *unk2;
152 
153     if(iface1 == iface2)
154         return TRUE;
155 
156     IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
157     IUnknown_Release(unk1);
158     IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
159     IUnknown_Release(unk2);
160 
161     return unk1 == unk2;
162 }
163 
164 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
165 static void _test_ifaces(unsigned line, IUnknown *iface, REFIID *iids)
166 {
167     const IID * const *piid;
168     IUnknown *unk;
169     HRESULT hres;
170 
171      for(piid = iids; *piid; piid++) {
172         hres = IUnknown_QueryInterface(iface, *piid, (void**)&unk);
173         ok_(__FILE__,line) (hres == S_OK, "Could not get %s interface: %08x\n", wine_dbgstr_guid(*piid), hres);
174         if(SUCCEEDED(hres))
175             IUnknown_Release(unk);
176     }
177 }
178 
179 static int strcmp_wa(LPCWSTR strw, const char *stra)
180 {
181     CHAR buf[512];
182     WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
183     return lstrcmpA(stra, buf);
184 }
185 
186 static BSTR a2bstr(const char *str)
187 {
188     BSTR ret;
189     int len;
190 
191     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
192     ret = SysAllocStringLen(NULL, len);
193     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
194 
195     return ret;
196 }
197 
198 static IOleClientSite *client_site;
199 static IDispatch *sink_disp;
200 static READYSTATE plugin_readystate = READYSTATE_UNINITIALIZED;
201 static BOOL have_container;
202 
203 static void set_plugin_readystate(READYSTATE state)
204 {
205     IPropertyNotifySink *prop_notif;
206     HRESULT hres;
207 
208     plugin_readystate = state;
209 
210     hres = IOleClientSite_QueryInterface(client_site, &IID_IPropertyNotifySink, (void**)&prop_notif);
211     ok(hres == S_OK, "Could not get IPropertyNotifySink iface: %08x\n", hres);
212 
213     hres = IPropertyNotifySink_OnChanged(prop_notif, DISPID_READYSTATE);
214     ok(hres == S_OK, "OnChanged(DISPID_READYSTATE) failed: %08x\n", hres);
215 
216     IPropertyNotifySink_Release(prop_notif);
217 }
218 
219 static void test_mon_displayname(IMoniker *mon, const char *exname, const char *broken_name)
220 {
221     LPOLESTR display_name;
222     DWORD mksys;
223     HRESULT hres;
224 
225     hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
226     ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
227     ok(!strcmp_wa(display_name, exname) || broken(broken_name && !strcmp_wa(display_name, broken_name)),
228         "display_name = %s\n", wine_dbgstr_w(display_name));
229     CoTaskMemFree(display_name);
230 
231     hres = IMoniker_IsSystemMoniker(mon, &mksys);
232     ok(hres == S_OK, "IsSystemMoniker failed: %08x\n", hres);
233     ok(mksys == MKSYS_URLMONIKER, "mksys = %d\n", mksys);
234 }
235 
236 static LRESULT WINAPI plugin_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
237 {
238     switch(msg) {
239     case WM_PAINT: {
240         PAINTSTRUCT ps;
241         HBRUSH brush;
242         RECT rect;
243         HDC dc;
244 
245         GetClientRect(hwnd, &rect);
246 
247         dc = BeginPaint(hwnd, &ps);
248         brush = CreateSolidBrush(RGB(255,0,0));
249         SelectObject(dc, brush);
250         Rectangle(dc, rect.left, rect.top, rect.right, rect.bottom);
251         DeleteObject(brush);
252         EndPaint(hwnd, &ps);
253         break;
254     }
255     }
256 
257     return DefWindowProcW(hwnd, msg, wParam, lParam);
258 }
259 
260 static void create_plugin_window(HWND parent, const RECT *rect)
261 {
262     static const WCHAR plugin_testW[] =
263         {'p','l','u','g','i','n',' ','t','e','s','t',0};
264     static WNDCLASSEXW wndclass = {
265         sizeof(WNDCLASSEXW),
266         0,
267         plugin_proc,
268         0, 0, NULL, NULL, NULL, NULL, NULL,
269         plugin_testW,
270         NULL
271     };
272 
273     RegisterClassExW(&wndclass);
274     plugin_hwnd = CreateWindowW(plugin_testW, plugin_testW,
275             WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, rect->left, rect->top,
276             rect->right-rect->left, rect->bottom-rect->top, parent, NULL, NULL, NULL);
277 }
278 
279 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, void **ppv)
280 {
281     ok(0, "unexpected QI call %s\n", wine_dbgstr_guid(riid));
282     return E_NOINTERFACE;
283 }
284 
285 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
286 {
287     return 2;
288 }
289 
290 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
291 {
292     return 1;
293 }
294 
295 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
296 {
297     ok(0, "unexpected call\n");
298     return E_NOTIMPL;
299 }
300 
301 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
302         IConnectionPointContainer **ppCPC)
303 {
304     ok(0, "unexpected call\n");
305     return E_NOTIMPL;
306 }
307 
308 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink, DWORD *pdwCookie)
309 {
310     DispActiveXTest *ax_test;
311     IDispatchEx *dispex;
312     HRESULT hres;
313 
314     CHECK_EXPECT(Advise);
315 
316     hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatch, (void**)&sink_disp);
317     ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres);
318 
319     hres = IUnknown_QueryInterface(pUnkSink, &IID_IDispatchEx, (void**)&dispex);
320     ok(hres == E_NOINTERFACE, "QueryInterface(IID_IDispatchEx) returned: %08x\n", hres);
321 
322     hres = IUnknown_QueryInterface(pUnkSink, &DIID_DispActiveXTest, (void**)&ax_test);
323     ok(hres == S_OK, "Could not get DispActiveXTest iface: %08x\n", hres);
324     DispActiveXTest_Release(ax_test);
325 
326     *pdwCookie = 0xdeadbeef;
327     return S_OK;
328 }
329 
330 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
331 {
332     CHECK_EXPECT(Unadvise);
333 
334     ok(dwCookie == 0xdeadbeef, "dwCookie = %x\n", dwCookie);
335 
336     if(sink_disp) {
337         IDispatch_Release(sink_disp);
338         sink_disp = NULL;
339     }
340 
341     return S_OK;
342 }
343 
344 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface, IEnumConnections **ppEnum)
345 {
346     ok(0, "unexpected call\n");
347     return E_NOTIMPL;
348 }
349 
350 static const IConnectionPointVtbl ConnectionPointVtbl = {
351     ConnectionPoint_QueryInterface,
352     ConnectionPoint_AddRef,
353     ConnectionPoint_Release,
354     ConnectionPoint_GetConnectionInterface,
355     ConnectionPoint_GetConnectionPointContainer,
356     ConnectionPoint_Advise,
357     ConnectionPoint_Unadvise,
358     ConnectionPoint_EnumConnections
359 };
360 
361 static IConnectionPoint ConnectionPoint = { &ConnectionPointVtbl };
362 
363 static HRESULT ax_qi(REFIID,void**);
364 
365 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
366 {
367     return ax_qi(riid, ppv);
368 }
369 
370 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
371 {
372     return ++activex_refcnt;
373 }
374 
375 static ULONG WINAPI OleControl_Release(IOleControl *iface)
376 {
377     return --activex_refcnt;
378 }
379 
380 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
381 {
382     ok(0, "unexpected call\n");
383     return E_NOTIMPL;
384 }
385 
386 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *mMsg)
387 {
388     ok(0, "unexpected call\n");
389     return E_NOTIMPL;
390 }
391 
392 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
393 {
394     switch(dispID) {
395     case DISPID_UNKNOWN:
396         CHECK_EXPECT2(OnAmbientPropertyChange_UNKNOWN);
397         break;
398     default:
399         ok(0, "unexpected call %d\n", dispID);
400     }
401 
402     return S_OK;
403 }
404 
405 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
406 {
407     if(bFreeze)
408         CHECK_EXPECT2(FreezeEvents_TRUE);
409     else
410         CHECK_EXPECT2(FreezeEvents_FALSE);
411     return S_OK;
412 }
413 
414 static const IOleControlVtbl OleControlVtbl = {
415     OleControl_QueryInterface,
416     OleControl_AddRef,
417     OleControl_Release,
418     OleControl_GetControlInfo,
419     OleControl_OnMnemonic,
420     OleControl_OnAmbientPropertyChange,
421     OleControl_FreezeEvents
422 };
423 
424 static IOleControl OleControl = { &OleControlVtbl };
425 
426 static HRESULT WINAPI QuickActivate_QueryInterface(IQuickActivate *iface, REFIID riid, void **ppv)
427 {
428     return ax_qi(riid, ppv);
429 }
430 
431 static ULONG WINAPI QuickActivate_AddRef(IQuickActivate *iface)
432 {
433     return ++activex_refcnt;
434 }
435 
436 static ULONG WINAPI QuickActivate_Release(IQuickActivate *iface)
437 {
438     return --activex_refcnt;
439 }
440 
441 static HRESULT WINAPI QuickActivate_QuickActivate(IQuickActivate *iface, QACONTAINER *container, QACONTROL *control)
442 {
443     CHECK_EXPECT(QuickActivate);
444 
445     ok(container != NULL, "container == NULL\n");
446     ok(container->cbSize == sizeof(*container), "container->cbSize = %d\n", container->cbSize);
447     ok(container->pClientSite != NULL, "container->pClientSite == NULL\n");
448     ok(container->pAdviseSink != NULL, "container->pAdviseSink == NULL\n");
449     ok(container->pPropertyNotifySink != NULL, "container->pPropertyNotifySink == NULL\n");
450     ok(!container->pUnkEventSink, "container->pUnkEventSink != NULL\n");
451     ok(container->dwAmbientFlags == (QACONTAINER_SUPPORTSMNEMONICS|QACONTAINER_MESSAGEREFLECT|QACONTAINER_USERMODE),
452        "container->dwAmbientFlags = %x\n", container->dwAmbientFlags);
453     if(have_container)
454         ok(!container->colorFore, "container->colorFore = %d\n", container->colorFore); /* FIXME */
455     todo_wine
456     ok(container->colorBack, "container->colorBack == 0\n"); /* FIXME */
457     if(have_container)
458         todo_wine ok(container->pFont != NULL, "container->pFont == NULL\n");
459     else
460         ok(!container->pFont, "container->pFont = %p\n", container->pFont);
461     todo_wine
462     ok(container->pUndoMgr != NULL, "container->pUndoMgr == NULL\n");
463     ok(!container->dwAppearance, "container->dwAppearance = %x\n", container->dwAppearance);
464     if(have_container)
465         ok(!container->lcid, "container->lcid = %x\n", container->lcid);
466     ok(!container->hpal, "container->hpal = %p\n", container->hpal);
467     ok(!container->pBindHost, "container->pBindHost != NULL\n");
468     ok(!container->pOleControlSite, "container->pOleControlSite != NULL\n");
469     ok(!container->pServiceProvider, "container->pServiceProvider != NULL\n");
470 
471     ok(control->cbSize == sizeof(*control), "control->cbSize = %d\n", control->cbSize);
472     ok(!control->dwMiscStatus, "control->dwMiscStatus = %x\n", control->dwMiscStatus);
473     ok(!control->dwViewStatus, "control->dwViewStatus = %x\n", control->dwViewStatus);
474     ok(!control->dwEventCookie, "control->dwEventCookie = %x\n", control->dwEventCookie);
475     ok(!control->dwPropNotifyCookie, "control->dwPropNotifyCookie = %x\n", control->dwPropNotifyCookie);
476     ok(!control->dwPointerActivationPolicy, "control->dwPointerActivationPolicy = %x\n", control->dwPointerActivationPolicy);
477 
478     ok(iface_cmp((IUnknown*)container->pClientSite, (IUnknown*)container->pAdviseSink),
479        "container->pClientSite != container->pAdviseSink\n");
480     ok(iface_cmp((IUnknown*)container->pClientSite, (IUnknown*)container->pPropertyNotifySink),
481        "container->pClientSite != container->pPropertyNotifySink\n");
482     test_ifaces((IUnknown*)container->pClientSite, pluginhost_iids);
483 
484     IOleClientSite_AddRef(container->pClientSite);
485     client_site = container->pClientSite;
486 
487     control->dwMiscStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
488         |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
489     control->dwViewStatus = 0x18;
490     control->dwPropNotifyCookie = 1;
491 
492     return S_OK;
493 }
494 
495 static HRESULT WINAPI QuickActivate_SetContentExtent(IQuickActivate *iface, LPSIZEL pSizel)
496 {
497     ok(0, "unexpected call\n");
498     return E_NOTIMPL;
499 }
500 
501 static HRESULT WINAPI QuickActivate_GetContentExtent(IQuickActivate *iface, LPSIZEL pSizel)
502 {
503     ok(0, "unexpected call\n");
504     return E_NOTIMPL;
505 }
506 
507 static const IQuickActivateVtbl QuickActivateVtbl = {
508     QuickActivate_QueryInterface,
509     QuickActivate_AddRef,
510     QuickActivate_Release,
511     QuickActivate_QuickActivate,
512     QuickActivate_GetContentExtent,
513     QuickActivate_SetContentExtent
514 };
515 
516 static IQuickActivate QuickActivate = { &QuickActivateVtbl };
517 
518 static HRESULT WINAPI PersistPropertyBag_QueryInterface(IPersistPropertyBag *iface, REFIID riid, void **ppv)
519 {
520     return ax_qi(riid, ppv);
521 }
522 
523 static ULONG WINAPI PersistPropertyBag_AddRef(IPersistPropertyBag *iface)
524 {
525     return ++activex_refcnt;
526 }
527 
528 static ULONG WINAPI PersistPropertyBag_Release(IPersistPropertyBag *iface)
529 {
530     return --activex_refcnt;
531 }
532 
533 static HRESULT WINAPI PersistPropertyBag_GetClassID(IPersistPropertyBag *face, CLSID *pClassID)
534 {
535     ok(0, "unexpected call\n");
536     return E_NOTIMPL;
537 }
538 
539 static HRESULT WINAPI PersistPropertyBag_InitNew(IPersistPropertyBag *face)
540 {
541     CHECK_EXPECT(IPersistPropertyBag_InitNew);
542     return S_OK;
543 }
544 
545 static HRESULT WINAPI PersistPropertyBag_Load(IPersistPropertyBag *face, IPropertyBag *pPropBag, IErrorLog *pErrorLog)
546 {
547     IBindHost *bind_host, *bind_host2;
548     IServiceProvider *sp;
549     IMoniker *mon;
550     VARIANT v;
551     HRESULT hres;
552 
553     static const WCHAR param_nameW[] = {'p','a','r','a','m','_','n','a','m','e',0};
554     static const WCHAR num_paramW[] = {'n','u','m','_','p','a','r','a','m',0};
555     static const WCHAR no_paramW[] = {'n','o','_','p','a','r','a','m',0};
556     static WCHAR test_swfW[] = {'t','e','s','t','.','s','w','f',0};
557 
558     static const IID *propbag_ifaces[] = {
559         &IID_IPropertyBag,
560         &IID_IPropertyBag2,
561         NULL
562     };
563 
564     CHECK_EXPECT(IPersistPropertyBag_Load);
565 
566     ok(pPropBag != NULL, "pPropBag == NULL\n");
567     ok(!pErrorLog, "pErrorLog != NULL\n");
568 
569     test_ifaces((IUnknown*)pPropBag, propbag_ifaces);
570 
571     V_VT(&v) = VT_BSTR;
572     hres = IPropertyBag_Read(pPropBag, param_nameW, &v, NULL);
573     ok(hres == S_OK, "Read failed: %08x\n", hres);
574     ok(V_VT(&v) == VT_BSTR, "V_VT(&v) = %d\n", V_VT(&v));
575     ok(!strcmp_wa(V_BSTR(&v), "param_value"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
576 
577     V_VT(&v) = VT_I4;
578     V_I4(&v) = 0xdeadbeef;
579     hres = IPropertyBag_Read(pPropBag, param_nameW, &v, NULL);
580     ok(hres == DISP_E_TYPEMISMATCH, "Read failed: %08x, expected DISP_E_TYPEMISMATCH\n", hres);
581     ok(V_VT(&v) == VT_I4, "V_VT(&v) = %d\n", V_VT(&v));
582     ok(V_I4(&v) == 0xdeadbeef, "V_I4(v) = %x\n", V_I4(&v));
583 
584     V_VT(&v) = VT_BSTR;
585     hres = IPropertyBag_Read(pPropBag, num_paramW, &v, NULL);
586     ok(hres == S_OK, "Read failed: %08x\n", hres);
587     ok(V_VT(&v) == VT_BSTR, "V_VT(&v) = %d\n", V_VT(&v));
588     ok(!strcmp_wa(V_BSTR(&v), "3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
589     SysFreeString(V_BSTR(&v));
590 
591     V_VT(&v) = VT_I4;
592     V_I4(&v) = 0xdeadbeef;
593     hres = IPropertyBag_Read(pPropBag, num_paramW, &v, NULL);
594     ok(hres == S_OK, "Read failed: %08x\n", hres);
595     ok(V_VT(&v) == VT_I4, "V_VT(&v) = %d\n", V_VT(&v));
596     ok(V_I4(&v) == 3, "V_I4(v) = %x\n", V_I4(&v));
597 
598     V_VT(&v) = VT_BSTR;
599     V_BSTR(&v) = (BSTR)0xdeadbeef;
600     hres = IPropertyBag_Read(pPropBag, no_paramW, &v, NULL);
601     ok(hres == E_INVALIDARG, "Read failed: %08x\n", hres);
602     ok(V_VT(&v) == VT_BSTR, "V_VT(&v) = %d\n", V_VT(&v));
603     ok(V_BSTR(&v) == (BSTR)0xdeadbeef, "V_BSTR(v) = %p\n", V_BSTR(&v));
604 
605     set_plugin_readystate(READYSTATE_INTERACTIVE);
606 
607     hres = IOleClientSite_QueryInterface(client_site, &IID_IBindHost, (void**)&bind_host);
608     ok(hres == S_OK, "Could not get IBindHost iface: %08x\n", hres);
609 
610     hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&sp);
611     ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
612 
613     hres = IServiceProvider_QueryService(sp, &SID_SBindHost, &IID_IBindHost, (void**)&bind_host2);
614     ok(hres == S_OK, "QueryService(SID_SBindHost) failed: %08x\n", hres);
615     IServiceProvider_Release(sp);
616 
617     ok(iface_cmp((IUnknown*)bind_host, (IUnknown*)bind_host2), "bind_host != bind_host2\n");
618     IBindHost_Release(bind_host2);
619 
620     mon = NULL;
621     hres = IBindHost_CreateMoniker(bind_host, test_swfW, NULL, &mon, 0);
622     ok(hres == S_OK, "CreateMoniker failed: %08x\n", hres);
623     ok(mon != NULL, "mon == NULL\n");
624     test_mon_displayname(mon, "about:test.swf", "about:blanktest.swf");
625     IMoniker_Release(mon);
626 
627     IBindHost_Release(bind_host);
628 
629     mon = NULL;
630     hres = IOleClientSite_GetMoniker(client_site, OLEGETMONIKER_ONLYIFTHERE, OLEWHICHMK_CONTAINER, &mon);
631     ok(hres == S_OK, "GetMoniker failed: %08x\n", hres);
632     ok(mon != NULL, "mon == NULL\n");
633     test_mon_displayname(mon, "about:blank", NULL);
634     IMoniker_Release(mon);
635 
636     set_plugin_readystate(READYSTATE_COMPLETE);
637 
638     return S_OK;
639 }
640 
641 static HRESULT WINAPI PersistPropertyBag_Save(IPersistPropertyBag *face, IPropertyBag *pPropBag, BOOL fClearDisrty, BOOL fSaveAllProperties)
642 {
643     ok(0, "unexpected call\n");
644     return E_NOTIMPL;
645 }
646 
647 static const IPersistPropertyBagVtbl PersistPropertyBagVtbl = {
648     PersistPropertyBag_QueryInterface,
649     PersistPropertyBag_AddRef,
650     PersistPropertyBag_Release,
651     PersistPropertyBag_GetClassID,
652     PersistPropertyBag_InitNew,
653     PersistPropertyBag_Load,
654     PersistPropertyBag_Save
655 
656 };
657 
658 static IPersistPropertyBag PersistPropertyBag = { &PersistPropertyBagVtbl };
659 
660 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
661 {
662     return ax_qi(riid, ppv);
663 }
664 
665 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
666 {
667     return ++activex_refcnt;
668 }
669 
670 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
671 {
672     return --activex_refcnt;
673 }
674 
675 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
676 {
677     ok(0, "unexpected call\n");
678     return E_NOTIMPL;
679 }
680 
681 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
682         ITypeInfo **ppTInfo)
683 {
684     CHECK_EXPECT(GetTypeInfo);
685 
686     ITypeInfo_AddRef(actxtest_typeinfo);
687     *ppTInfo = actxtest_typeinfo;
688     return S_OK;
689 }
690 
691 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
692         UINT cNames, LCID lcid, DISPID *rgDispId)
693 {
694     ok(IsEqualGUID(riid, &IID_NULL), "riid = %s\n", wine_dbgstr_guid(riid));
695     ok(cNames == 1, "cNames = %d\n", cNames);
696     ok(rgszNames != NULL, "rgszNames == NULL\n");
697     ok(rgDispId != NULL, "rgDispId == NULL\n");
698 
699     if(!strcmp_wa(rgszNames[0], "scriptprop")) {
700         CHECK_EXPECT(GetIDsOfNames_scriptprop);
701         *rgDispId = DISPID_SCRIPTPROP;
702     }else if(!strcmp_wa(rgszNames[0], "scriptCall")) {
703         *rgDispId = DISPID_SCRIPTCALL;
704     }else {
705         ok(0, "rgszNames[0] = %s\n", wine_dbgstr_w(rgszNames[0]));
706     }
707 
708     return S_OK;
709 }
710 
711 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
712         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
713         EXCEPINFO *pExcepInfo, UINT *puArgErr)
714 {
715     ok(IsEqualGUID(riid, &IID_NULL), "riid = %s\n", wine_dbgstr_guid(riid));
716     ok(pDispParams != NULL, "pDispParams == NULL\n");
717     ok(!pDispParams->cNamedArgs, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
718     ok(!pDispParams->rgdispidNamedArgs, "pDispParams->rgdispidNamedArgs != NULL\n");
719 
720     switch(dispIdMember) {
721     case DISPID_READYSTATE:
722         CHECK_EXPECT2(Invoke_READYSTATE);
723         ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
724         ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
725         ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
726         ok(!pExcepInfo, "pExcepInfo != NULL\n");
727         ok(puArgErr != NULL, "puArgErr == NULL\n");
728         ok(pVarResult != NULL, "pVarResult == NULL\n");
729 
730         V_VT(pVarResult) = VT_I4;
731         V_I4(pVarResult) = plugin_readystate;
732         return S_OK;
733      case DISPID_ENABLED:
734         CHECK_EXPECT2(Invoke_ENABLED);
735         ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
736         ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
737         ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
738         ok(!pExcepInfo, "pExcepInfo != NULL\n");
739         ok(puArgErr != NULL, "puArgErr == NULL\n");
740         ok(pVarResult != NULL, "pVarResult == NULL\n");
741         return DISP_E_MEMBERNOTFOUND;
742     case DISPID_VALID:
743         CHECK_EXPECT(Invoke_VALID);
744         ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
745         ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
746         ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
747         ok(!pExcepInfo, "pExcepInfo != NULL\n");
748         ok(puArgErr != NULL, "puArgErr == NULL\n");
749         ok(pVarResult != NULL, "pVarResult == NULL\n");
750         return DISP_E_MEMBERNOTFOUND;
751     case DISPID_SECURITYCTX:
752         CHECK_EXPECT(Invoke_SECURITYCTX);
753         ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
754         ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
755         ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
756         ok(!pExcepInfo, "pExcepInfo != NULL\n");
757         ok(puArgErr != NULL, "puArgErr == NULL\n");
758         ok(pVarResult != NULL, "pVarResult == NULL\n");
759         return DISP_E_MEMBERNOTFOUND;
760     case DISPID_SCRIPTPROP:
761         CHECK_EXPECT(Invoke_SCRIPTPROP);
762         ok(wFlags == DISPATCH_PROPERTYGET, "wFlags = %x\n", wFlags);
763         ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
764         ok(!pDispParams->rgvarg, "pDispParams->rgvarg != NULL\n");
765         ok(pExcepInfo != NULL, "pExcepInfo == NULL\n");
766         ok(!puArgErr, "puArgErr != NULL\n");
767         ok(pVarResult != NULL, "pVarResult == NULL\n");
768 
769         V_VT(pVarResult) = VT_I4;
770         V_I4(pVarResult) = 4;
771         return S_OK;
772     case DISPID_SCRIPTCALL:
773         CHECK_EXPECT(Invoke_SCRIPTCALL);
774         ok(wFlags == DISPATCH_METHOD, "wFlags = %x\n", wFlags);
775         ok(!pDispParams->cArgs, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
776         ok(pExcepInfo != NULL, "pExcepInfo == NULL\n");
777         ok(!puArgErr, "puArgErr != NULL\n");
778         ok(!pVarResult, "pVarResult != NULL\n");
779         /*
780         V_VT(pVarResult) = VT_I4;
781         V_I4(pVarResult) = 4;
782         */
783         return S_OK;
784     default:
785         ok(0, "unexpected call %d\n", dispIdMember);
786     }
787 
788     return E_NOTIMPL;
789 }
790 
791 static const IDispatchVtbl DispatchVtbl = {
792     Dispatch_QueryInterface,
793     Dispatch_AddRef,
794     Dispatch_Release,
795     Dispatch_GetTypeInfoCount,
796     Dispatch_GetTypeInfo,
797     Dispatch_GetIDsOfNames,
798     Dispatch_Invoke
799 };
800 
801 static IDispatch Dispatch = { &DispatchVtbl };
802 
803 static HRESULT WINAPI ProvideClassInfo_QueryInterface(IProvideClassInfo *iface, REFIID riid, void **ppv)
804 {
805     return ax_qi(riid, ppv);
806 }
807 
808 static ULONG WINAPI ProvideClassInfo_AddRef(IProvideClassInfo *iface)
809 {
810     return ++activex_refcnt;
811 }
812 
813 static ULONG WINAPI ProvideClassInfo_Release(IProvideClassInfo *iface)
814 {
815     return --activex_refcnt;
816 }
817 
818 static HRESULT WINAPI ProvideClassInfo_GetClassInfo(IProvideClassInfo *iface, ITypeInfo **ppTI)
819 {
820     CHECK_EXPECT(GetClassInfo);
821 
822     ITypeInfo_AddRef(class_typeinfo);
823     *ppTI = class_typeinfo;
824     return S_OK;
825 }
826 
827 static const IProvideClassInfoVtbl ProvideClassInfoVtbl = {
828     ProvideClassInfo_QueryInterface,
829     ProvideClassInfo_AddRef,
830     ProvideClassInfo_Release,
831     ProvideClassInfo_GetClassInfo
832 };
833 
834 static IProvideClassInfo ProvideClassInfo = { &ProvideClassInfoVtbl };
835 
836 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, void **ppv)
837 {
838     return ax_qi(riid, ppv);
839 }
840 
841 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
842 {
843     return ++activex_refcnt;
844 }
845 
846 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
847 {
848     return --activex_refcnt;
849 }
850 
851 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
852         IEnumConnectionPoints **ppEnum)
853 {
854     ok(0, "unexpected call\n");
855     return E_NOTIMPL;
856 }
857 
858 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
859         REFIID riid, IConnectionPoint **ppCP)
860 {
861     if(IsEqualGUID(riid, &IID_IPropertyNotifySink)) {
862         /* TODO */
863         trace("FindConnectionPoint(IID_IPropertyNotifySink)\n");
864         return CONNECT_E_NOCONNECTION;
865     }
866 
867     CHECK_EXPECT(FindConnectionPoint);
868     ok(IsEqualGUID(riid, &DIID_DispActiveXTest), "riid = %s\n", wine_dbgstr_guid(riid));
869 
870     IConnectionPoint_AddRef(&ConnectionPoint);
871     *ppCP = &ConnectionPoint;
872     return S_OK;
873 }
874 
875 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
876     ConnectionPointContainer_QueryInterface,
877     ConnectionPointContainer_AddRef,
878     ConnectionPointContainer_Release,
879     ConnectionPointContainer_EnumConnectionPoints,
880     ConnectionPointContainer_FindConnectionPoint
881 };
882 
883 static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
884 
885 static HRESULT WINAPI ViewObjectEx_QueryInterface(IViewObjectEx *iface, REFIID riid, void **ppv)
886 {
887     return ax_qi(riid, ppv);
888 }
889 
890 static ULONG WINAPI ViewObjectEx_AddRef(IViewObjectEx *iface)
891 {
892     return ++activex_refcnt;
893 }
894 
895 static ULONG WINAPI ViewObjectEx_Release(IViewObjectEx *iface)
896 {
897     return --activex_refcnt;
898 }
899 
900 static HRESULT WINAPI ViewObjectEx_Draw(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd,
901         HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBoungs, BOOL (WINAPI*pfnContinue)(ULONG_PTR), ULONG_PTR dwContinue)
902 {
903     ok(0, "unexpected call\n");
904     return E_NOTIMPL;
905 }
906 
907 static HRESULT WINAPI ViewObjectEx_GetColorSet(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd,
908         HDC hicTargetDev, LOGPALETTE **ppColorSet)
909 {
910     ok(0, "unexpected call\n");
911     return E_NOTIMPL;
912 }
913 
914 static HRESULT WINAPI ViewObjectEx_Freeze(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze)
915 {
916     ok(0, "unexpected call\n");
917     return E_NOTIMPL;
918 }
919 
920 static HRESULT WINAPI ViewObjectEx_Unfreeze(IViewObjectEx *iface, DWORD dwFreeze)
921 {
922     ok(0, "unexpected call\n");
923     return E_NOTIMPL;
924 }
925 
926 static HRESULT WINAPI ViewObjectEx_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
927 {
928     CHECK_EXPECT(SetAdvise);
929 
930     ok(aspects == DVASPECT_CONTENT, "aspects = %x\n", aspects);
931     ok(!advf, "advf = %x\n", advf);
932     ok(pAdvSink != NULL, "pAdvSink = NULL\n");
933 
934     return S_OK;
935 }
936 
937 static HRESULT WINAPI ViewObjectEx_GetAdvise(IViewObjectEx *iface, DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
938 {
939     ok(0, "unexpected call\n");
940     return E_NOTIMPL;
941 }
942 
943 static HRESULT WINAPI ViewObjectEx_GetExtent(IViewObjectEx *iface, DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE *ptd, LPSIZEL lpsizel)
944 {
945     ok(0, "unexpected call\n");
946     return E_NOTIMPL;
947 }
948 
949 static HRESULT WINAPI ViewObjectEx_GetRect(IViewObjectEx *iface, DWORD dwAspect, LPRECTL pRect)
950 {
951     ok(0, "unexpected call\n");
952     return E_NOTIMPL;
953 }
954 
955 static HRESULT WINAPI ViewObjectEx_GetViewStatus(IViewObjectEx *iface, DWORD *pdwStatus)
956 {
957     CHECK_EXPECT(GetViewStatus);
958 
959     *pdwStatus = VIEWSTATUS_OPAQUE|VIEWSTATUS_SOLIDBKGND;
960     return S_OK;
961 }
962 
963 static HRESULT WINAPI ViewObjectEx_QueryHitPoint(IViewObjectEx *iface, DWORD dwAspect, LPCRECT pRectBounds, POINT ptlLoc,
964         LONG lCloseHint, DWORD *pHitResult)
965 {
966     trace("QueryHitPoint call ignored\n");
967     return E_NOTIMPL;
968 }
969 
970 static HRESULT WINAPI ViewObjectEx_QueryHitRect(IViewObjectEx *iface, DWORD dwAspect, LPCRECT pRectBounds, LPCRECT pRectLoc,
971         LONG lCloseHint, DWORD *pHitResult)
972 {
973     ok(0, "unexpected call\n");
974     return E_NOTIMPL;
975 }
976 
977 static HRESULT WINAPI ViewObjectEx_GetNaturalExtent(IViewObjectEx *iface, DWORD dwAspect, LONG lindex, DVTARGETDEVICE *ptd,
978         HDC hicTargetDev, DVEXTENTINFO *pExtentIngo, LPSIZEL pSizel)
979 {
980     ok(0, "unexpected call\n");
981     return E_NOTIMPL;
982 }
983 
984 static const IViewObjectExVtbl ViewObjectExVtbl = {
985     ViewObjectEx_QueryInterface,
986     ViewObjectEx_AddRef,
987     ViewObjectEx_Release,
988     ViewObjectEx_Draw,
989     ViewObjectEx_GetColorSet,
990     ViewObjectEx_Freeze,
991     ViewObjectEx_Unfreeze,
992     ViewObjectEx_SetAdvise,
993     ViewObjectEx_GetAdvise,
994     ViewObjectEx_GetExtent,
995     ViewObjectEx_GetRect,
996     ViewObjectEx_GetViewStatus,
997     ViewObjectEx_QueryHitPoint,
998     ViewObjectEx_QueryHitRect,
999     ViewObjectEx_GetNaturalExtent
1000 };
1001 
1002 static IViewObjectEx ViewObjectEx = { &ViewObjectExVtbl };
1003 
1004 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
1005 {
1006     return ax_qi(riid, ppv);
1007 }
1008 
1009 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
1010 {
1011     return ++activex_refcnt;
1012 }
1013 
1014 static ULONG WINAPI OleObject_Release(IOleObject *iface)
1015 {
1016     return --activex_refcnt;
1017 }
1018 
1019 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
1020 {
1021     if(!pClientSite) {
1022         CHECK_EXPECT(SetClientSite_NULL);
1023         return S_OK;
1024     }
1025 
1026     CHECK_EXPECT(SetClientSite);
1027 
1028     IOleClientSite_AddRef(pClientSite);
1029     client_site = pClientSite;
1030     return S_OK;
1031 }
1032 
1033 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
1034 {
1035     ok(0, "unexpected call\n");
1036     return E_NOTIMPL;
1037 }
1038 
1039 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
1040 {
1041     ok(0, "unexpected call\n");
1042     return E_NOTIMPL;
1043 }
1044 
1045 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
1046 {
1047     CHECK_EXPECT(Close);
1048 
1049     ok(dwSaveOption == OLECLOSE_NOSAVE, "dwSaveOption = %d\n", dwSaveOption);
1050     return S_OK;
1051 }
1052 
1053 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
1054 {
1055     ok(0, "unexpected call\n");
1056     return E_NOTIMPL;
1057 }
1058 
1059 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
1060 {
1061     ok(0, "unexpected call\n");
1062     return E_NOTIMPL;
1063 }
1064 
1065 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
1066         DWORD dwReserved)
1067 {
1068     ok(0, "unexpected call\n");
1069     return E_NOTIMPL;
1070 }
1071 
1072 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
1073 {
1074     ok(0, "unexpected call\n");
1075     return E_NOTIMPL;
1076 }
1077 
1078 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
1079         LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
1080 {
1081     OLEINPLACEFRAMEINFO frame_info = {0xdeadbeef};
1082     IOleInPlaceUIWindow *ip_uiwindow;
1083     IOleInPlaceFrame *ip_frame;
1084     IOleInPlaceSiteEx *ip_site;
1085     RECT pos_rect, clip_rect;
1086     BOOL no_redraw;
1087     HWND hwnd;
1088     HRESULT hres;
1089 
1090     CHECK_EXPECT(DoVerb);
1091 
1092     ok(iVerb == OLEIVERB_INPLACEACTIVATE, "iVerb = %d\n", iVerb);
1093     ok(!lpmsg, "lpmsg != NULL\n");
1094     ok(pActiveSite != NULL, "pActiveSite == NULL\n");
1095     ok(!lindex, "lindex = %d\n", lindex);
1096     ok(hwndParent != NULL, "hwndParent == NULL\n");
1097     ok(lprcPosRect != NULL, "lprcPosRect == NULL\n");
1098 
1099     hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleInPlaceSiteEx, (void**)&ip_site);
1100     ok(hres == S_OK, "Could not get IOleInPlaceSiteEx iface: %08x\n", hres);
1101 
1102     hres = IOleInPlaceSiteEx_CanInPlaceActivate(ip_site);
1103     ok(hres == S_OK, "CanInPlaceActivate failed: %08x\n", hres);
1104 
1105     SET_EXPECT(InPlaceObject_GetWindow);
1106     no_redraw = 0xdeadbeef;
1107     hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ip_site, &no_redraw, 0);
1108     ok(hres == S_OK, "InPlaceActivateEx failed: %08x\n", hres);
1109     ok(!no_redraw, "no_redraw = %x\n", no_redraw);
1110     CHECK_CALLED(InPlaceObject_GetWindow);
1111 
1112     no_redraw = 0xdeadbeef;
1113     hres = IOleInPlaceSiteEx_OnInPlaceActivateEx(ip_site, &no_redraw, 0);
1114     ok(hres == S_OK, "InPlaceActivateEx failed: %08x\n", hres);
1115     ok(no_redraw == 0xdeadbeef, "no_redraw = %x\n", no_redraw);
1116 
1117     hwnd = NULL;
1118     hres = IOleInPlaceSiteEx_GetWindow(ip_site, &hwnd);
1119     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1120     ok(hwnd != NULL, "hwnd == NULL\n");
1121     ok(hwnd == hwndParent, "hwnd != hwndParent\n");
1122 
1123     create_plugin_window(hwnd, lprcPosRect);
1124 
1125     ip_frame = NULL;
1126     ip_uiwindow = NULL;
1127     frame_info.cb = sizeof(OLEINPLACEFRAMEINFO);
1128     hres = IOleInPlaceSiteEx_GetWindowContext(ip_site, &ip_frame, &ip_uiwindow, &pos_rect, &clip_rect, &frame_info);
1129     ok(hres == S_OK, "GetWindowContext failed: %08x\n", hres);
1130     ok(ip_frame != NULL, "ip_frame == NULL\n");
1131     ok(ip_uiwindow != NULL, "ip_uiwindow == NULL\n");
1132     ok((IOleInPlaceUIWindow*)ip_frame != ip_uiwindow, "ip_frame == ip_uiwindow\n");
1133     ok(!memcmp(&pos_rect, lprcPosRect, sizeof(RECT)), "pos_rect != lpecPosRect\n");
1134     ok(!memcmp(&clip_rect, lprcPosRect, sizeof(RECT)), "clip_rect != lpecPosRect\n");
1135     ok(frame_info.cb == sizeof(frame_info), "frame_info.cb = %d\n", frame_info.cb);
1136     ok(!frame_info.fMDIApp, "frame_info.fMDIApp = %x\n", frame_info.fMDIApp);
1137     ok(frame_info.hwndFrame != NULL, "frame_info.hwnd == NULL\n");
1138     ok(frame_info.hwndFrame == container_hwnd, "frame_info.hwnd != container_hwnd\n");
1139     ok(!frame_info.haccel, "frame_info.haccel != 0\n");
1140     ok(!frame_info.cAccelEntries, "frame_info.cAccelEntried != 0\n");
1141 
1142     IOleInPlaceFrame_Release(ip_frame);
1143     IOleInPlaceUIWindow_Release(ip_uiwindow);
1144 
1145 
1146     IOleInPlaceSiteEx_Release(ip_site);
1147 
1148     hres = IOleClientSite_ShowObject(client_site);
1149     ok(hres == S_OK, "ShowObject failed: %08x\n", hres);
1150 
1151     SET_EXPECT(InPlaceObject_GetWindow);
1152     SET_EXPECT(SetObjectRects);
1153 
1154     return S_OK;
1155 }
1156 
1157 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
1158 {
1159     ok(0, "unexpected call\n");
1160     return E_NOTIMPL;
1161 }
1162 
1163 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
1164 {
1165     ok(0, "unexpected call\n");
1166     return E_NOTIMPL;
1167 }
1168 
1169 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
1170 {
1171     ok(0, "unexpected call\n");
1172     return E_NOTIMPL;
1173 }
1174 
1175 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
1176 {
1177     ok(0, "unexpected call\n");
1178     return E_NOTIMPL;
1179 }
1180 
1181 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
1182 {
1183     ok(0, "unexpected call\n");
1184     return E_NOTIMPL;
1185 }
1186 
1187 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
1188 {
1189     CHECK_EXPECT(SetExtent);
1190     return E_NOTIMPL;
1191 }
1192 
1193 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
1194 {
1195     CHECK_EXPECT(GetExtent);
1196     return E_NOTIMPL;
1197 }
1198 
1199 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
1200 {
1201     ok(0, "unexpected call\n");
1202     return E_NOTIMPL;
1203 }
1204 
1205 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
1206 {
1207     ok(0, "unexpected call\n");
1208     return E_NOTIMPL;
1209 }
1210 
1211 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
1212 {
1213     ok(0, "unexpected call\n");
1214     return E_NOTIMPL;
1215 }
1216 
1217 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
1218 {
1219     CHECK_EXPECT(GetMiscStatus);
1220     ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %d\n", dwAspect);
1221     ok(pdwStatus != NULL, "pdwStatus == NULL\n");
1222     *pdwStatus = OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE
1223         |OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE;
1224     return S_OK;
1225 }
1226 
1227 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
1228 {
1229     ok(0, "unexpected call\n");
1230     return E_NOTIMPL;
1231 }
1232 
1233 static const IOleObjectVtbl OleObjectVtbl = {
1234     OleObject_QueryInterface,
1235     OleObject_AddRef,
1236     OleObject_Release,
1237     OleObject_SetClientSite,
1238     OleObject_GetClientSite,
1239     OleObject_SetHostNames,
1240     OleObject_Close,
1241     OleObject_SetMoniker,
1242     OleObject_GetMoniker,
1243     OleObject_InitFromData,
1244     OleObject_GetClipboardData,
1245     OleObject_DoVerb,
1246     OleObject_EnumVerbs,
1247     OleObject_Update,
1248     OleObject_IsUpToDate,
1249     OleObject_GetUserClassID,
1250     OleObject_GetUserType,
1251     OleObject_SetExtent,
1252     OleObject_GetExtent,
1253     OleObject_Advise,
1254     OleObject_Unadvise,
1255     OleObject_EnumAdvise,
1256     OleObject_GetMiscStatus,
1257     OleObject_SetColorScheme
1258 };
1259 
1260 static IOleObject OleObject = { &OleObjectVtbl };
1261 
1262 static HRESULT WINAPI OleInPlaceObject_QueryInterface(IOleInPlaceObjectWindowless *iface,
1263         REFIID riid, void **ppv)
1264 {
1265     return ax_qi(riid, ppv);
1266 }
1267 
1268 static ULONG WINAPI OleInPlaceObject_AddRef(IOleInPlaceObjectWindowless *iface)
1269 {
1270     return ++activex_refcnt;
1271 }
1272 
1273 static ULONG WINAPI OleInPlaceObject_Release(IOleInPlaceObjectWindowless *iface)
1274 {
1275     return --activex_refcnt;
1276 }
1277 
1278 static HRESULT WINAPI OleInPlaceObject_GetWindow(IOleInPlaceObjectWindowless *iface,
1279         HWND *phwnd)
1280 {
1281     CHECK_EXPECT2(InPlaceObject_GetWindow);
1282 
1283     ok(phwnd != NULL, "phwnd == NULL\n");
1284 
1285     *phwnd = plugin_hwnd;
1286     return *phwnd ? S_OK : E_UNEXPECTED;
1287 }
1288 
1289 static HRESULT WINAPI OleInPlaceObject_ContextSensitiveHelp(IOleInPlaceObjectWindowless *iface,
1290         BOOL fEnterMode)
1291 {
1292     ok(0, "unexpected call\n");
1293     return E_NOTIMPL;
1294 }
1295 
1296 static HRESULT WINAPI OleInPlaceObject_InPlaceDeactivate(IOleInPlaceObjectWindowless *iface)
1297 {
1298     IOleInPlaceSite *ip_site;
1299     HRESULT hres;
1300 
1301     CHECK_EXPECT(InPlaceDeactivate);
1302 
1303     hres = IOleClientSite_QueryInterface(client_site, &IID_IOleInPlaceSite, (void**)&ip_site);
1304     ok(hres == S_OK, "Could not get IOleInPlaceSite iface: %08x\n", hres);
1305 
1306     hres = IOleInPlaceSite_OnInPlaceDeactivate(ip_site);
1307     ok(hres == S_OK, "OnInPlaceDeactivate failed: %08x\n", hres);
1308 
1309     IOleInPlaceSite_Release(ip_site);
1310     return S_OK;
1311 }
1312 
1313 static HRESULT WINAPI OleInPlaceObject_UIDeactivate(IOleInPlaceObjectWindowless *iface)
1314 {
1315     CHECK_EXPECT2(UIDeactivate);
1316     return S_OK;
1317 }
1318 
1319 static HRESULT WINAPI OleInPlaceObject_SetObjectRects(IOleInPlaceObjectWindowless *iface,
1320         LPCRECT lprcPosRect, LPCRECT lprcClipRect)
1321 {
1322     CHECK_EXPECT2(SetObjectRects);
1323     return S_OK;
1324 }
1325 
1326 static HRESULT WINAPI OleInPlaceObjectWindowless_ReactivateAndUndo(IOleInPlaceObjectWindowless *iface)
1327 {
1328     ok(0, "unexpected call\n");
1329     return E_NOTIMPL;
1330 }
1331 
1332 static HRESULT WINAPI OleInPlaceObjectWindowless_OnWindowMessage(IOleInPlaceObjectWindowless *iface,
1333         UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *lpResult)
1334 {
1335     ok(0, "unexpected call\n");
1336     return E_NOTIMPL;
1337 }
1338 
1339 static HRESULT WINAPI OleInPlaceObjectWindowless_GetDropTarget(IOleInPlaceObjectWindowless *iface,
1340         IDropTarget **ppDropTarget)
1341 {
1342     ok(0, "unexpected call\n");
1343     return E_NOTIMPL;
1344 }
1345 
1346 static const IOleInPlaceObjectWindowlessVtbl OleInPlaceObjectWindowlessVtbl = {
1347     OleInPlaceObject_QueryInterface,
1348     OleInPlaceObject_AddRef,
1349     OleInPlaceObject_Release,
1350     OleInPlaceObject_GetWindow,
1351     OleInPlaceObject_ContextSensitiveHelp,
1352     OleInPlaceObject_InPlaceDeactivate,
1353     OleInPlaceObject_UIDeactivate,
1354     OleInPlaceObject_SetObjectRects,
1355     OleInPlaceObjectWindowless_ReactivateAndUndo,
1356     OleInPlaceObjectWindowless_OnWindowMessage,
1357     OleInPlaceObjectWindowless_GetDropTarget
1358 };
1359 
1360 static IOleInPlaceObjectWindowless OleInPlaceObjectWindowless = { &OleInPlaceObjectWindowlessVtbl };
1361 
1362 static void *wrapped_iface_vtbl[100];
1363 static IUnknown wrapped_iface = { (IUnknownVtbl*)wrapped_iface_vtbl };
1364 
1365 static HRESULT WINAPI wrapped_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
1366 {
1367     ok(0, "unexpected wrapped_QueryInterface call\n");
1368     *ppv = NULL;
1369     return E_NOINTERFACE;
1370 }
1371 
1372 static ULONG WINAPI wrapped_AddRef(IUnknown *iface)
1373 {
1374     CHECK_EXPECT(wrapped_AddRef);
1375     return 2;
1376 }
1377 
1378 static ULONG WINAPI wrapped_Release(IUnknown *iface)
1379 {
1380     CHECK_EXPECT(wrapped_Release);
1381     return 1;
1382 }
1383 
1384 static HRESULT WINAPI wrapped_func_nocall(IUnknown *iface, int i, double d)
1385 {
1386     ok(0, "unexpected call\n");
1387     return E_FAIL;
1388 }
1389 
1390 static HRESULT WINAPI wrapped_func(IUnknown *iface, int i, double d)
1391 {
1392     CHECK_EXPECT(wrapped_func);
1393     ok(iface == &wrapped_iface, "iface != wrapped_iface\n");
1394     ok(i == 10, "i = %d\n", i);
1395     ok(d == 32.0, "d = %lf\n", d);
1396     return S_OK;
1397 }
1398 
1399 static void init_wrapped_iface(void)
1400 {
1401     unsigned i;
1402 
1403     wrapped_iface_vtbl[0] = wrapped_QueryInterface;
1404     wrapped_iface_vtbl[1] = wrapped_AddRef;
1405     wrapped_iface_vtbl[2] = wrapped_Release;
1406 
1407     for(i=3; i<100; i++)
1408         wrapped_iface_vtbl[i] = wrapped_func_nocall;
1409 
1410     wrapped_iface_vtbl[63] = wrapped_func;
1411 }
1412 
1413 static HRESULT ax_qi(REFIID riid, void **ppv)
1414 {
1415     if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IOleControl)) {
1416         *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &OleControl;
1417     }else if(IsEqualGUID(riid, &IID_IQuickActivate)) {
1418         *ppv = no_quickact ? NULL : &QuickActivate;
1419     }else if(IsEqualGUID(riid, &IID_IPersistPropertyBag)) {
1420         *ppv = no_quickact ? NULL : &PersistPropertyBag;
1421     }else if(IsEqualGUID(riid, &IID_IDispatch)) {
1422         *ppv = &Dispatch;
1423     }else if(IsEqualGUID(riid, &IID_IProvideClassInfo)) {
1424         *ppv = &ProvideClassInfo;
1425     }else if(IsEqualGUID(riid, &IID_IConnectionPointContainer)) {
1426         *ppv = plugin_behavior != TEST_DISPONLY ? &ConnectionPointContainer : NULL;
1427     }else if(IsEqualGUID(riid, &IID_IViewObject) || IsEqualGUID(riid, &IID_IViewObject2)
1428             || IsEqualGUID(riid, &IID_IViewObjectEx)) {
1429         *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &ViewObjectEx;
1430     }else if(IsEqualGUID(riid, &IID_IOleObject)) {
1431         *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &OleObject;
1432     }else if(IsEqualGUID(riid, &IID_ITestActiveX)) {
1433         CHECK_EXPECT(QI_ITestActiveX);
1434         *ppv = &wrapped_iface;
1435         return S_OK;
1436     }else  if(IsEqualGUID(riid, &IID_IOleWindow) || IsEqualGUID(riid, &IID_IOleInPlaceObject)
1437        || IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
1438         *ppv = plugin_behavior == TEST_DISPONLY ? NULL : &OleInPlaceObjectWindowless;
1439     }else {
1440         trace("QI %s\n", wine_dbgstr_guid(riid));
1441         *ppv = NULL;
1442     }
1443 
1444     if(!*ppv)
1445         return E_NOINTERFACE;
1446 
1447     IUnknown_AddRef((IUnknown*)*ppv);
1448     return S_OK;
1449 }
1450 
1451 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1452 {
1453     *ppv = NULL;
1454 
1455     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1456         *ppv = iface;
1457         return S_OK;
1458     }
1459 
1460     if(IsEqualGUID(&IID_IMarshal, riid))
1461         return E_NOINTERFACE;
1462     if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1463         return E_NOINTERFACE;
1464     if(IsEqualGUID(&IID_IClassFactoryEx, riid))
1465         return E_NOINTERFACE; /* TODO */
1466 
1467     ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
1468     return E_NOTIMPL;
1469 }
1470 
1471 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1472 {
1473     return 2;
1474 }
1475 
1476 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1477 {
1478     return 1;
1479 }
1480 
1481 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1482 {
1483     CHECK_EXPECT(CreateInstance);
1484 
1485     ok(!outer, "outer = %p\n", outer);
1486     ok(IsEqualGUID(riid, &IID_IUnknown), "riid = %s\n", wine_dbgstr_guid(riid));
1487 
1488     activex_refcnt++;
1489     *ppv = &OleControl;
1490     return S_OK;
1491 }
1492 
1493 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1494 {
1495     ok(0, "unexpected call\n");
1496     return S_OK;
1497 }
1498 
1499 static const IClassFactoryVtbl ClassFactoryVtbl = {
1500     ClassFactory_QueryInterface,
1501     ClassFactory_AddRef,
1502     ClassFactory_Release,
1503     ClassFactory_CreateInstance,
1504     ClassFactory_LockServer
1505 };
1506 
1507 static IClassFactory activex_cf = { &ClassFactoryVtbl };
1508 
1509 static void test_elem_dispex(IDispatchEx *dispex)
1510 {
1511     DISPPARAMS dp;
1512     EXCEPINFO ei;
1513     VARIANT v;
1514     DISPID id;
1515     BSTR str;
1516     HRESULT hres;
1517 
1518     str = a2bstr("scriptprop");
1519     SET_EXPECT(GetIDsOfNames_scriptprop);
1520     hres = IDispatchEx_GetDispID(dispex, str, 0, &id);
1521     CHECK_CALLED(GetIDsOfNames_scriptprop);
1522     SysFreeString(str);
1523     ok(hres == S_OK, "GetDispID failed: %08x\n", hres);
1524     todo_wine
1525     ok(id == DISPID_SCRIPTPROP, "id = %d\n", id);
1526 
1527     SET_EXPECT(Invoke_SECURITYCTX);
1528     SET_EXPECT(Invoke_SCRIPTPROP);
1529     memset(&dp, 0, sizeof(dp));
1530     memset(&ei, 0, sizeof(ei));
1531     V_VT(&v) = VT_EMPTY;
1532     hres = IDispatchEx_InvokeEx(dispex, id, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL);
1533     ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
1534     ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
1535     ok(V_I4(&v) == 4, "V_I4(v) = %d\n", V_I4(&v));
1536     CHECK_CALLED(Invoke_SECURITYCTX);
1537     CHECK_CALLED(Invoke_SCRIPTPROP);
1538 }
1539 
1540 static void test_iface_wrapping(IHTMLObjectElement *elem)
1541 {
1542     IHTMLObjectElement *elem2;
1543     IUnknown *unk, *unk2;
1544     ULONG ref;
1545     void **vtbl;
1546     HRESULT hres;
1547 
1548     SET_EXPECT(QI_ITestActiveX);
1549     SET_EXPECT(wrapped_AddRef);
1550     SET_EXPECT(wrapped_Release);
1551     unk = (void*)0xdeadbeef;
1552     hres = IHTMLObjectElement_QueryInterface(elem, &IID_ITestActiveX, (void**)&unk);
1553     ok(hres == S_OK, "QueryInerface(IID_ITestActiveX failed: %08x\n", hres);
1554     CHECK_CALLED(QI_ITestActiveX);
1555     CHECK_CALLED(wrapped_AddRef);
1556     CHECK_CALLED(wrapped_Release);
1557 
1558     /* See dlls/mshtml/ifacewrap.c */
1559     ok(unk != &wrapped_iface, "Unexpected unk %p, expected %p (%p, %p)\n", unk, &ViewObjectEx, unk->lpVtbl, &ViewObjectExVtbl);
1560     ok(unk->lpVtbl != wrapped_iface.lpVtbl, "unk->lpVtbl == wrapped_iface->lpVtbl\n");
1561     ok(unk->lpVtbl->QueryInterface != wrapped_QueryInterface, "QueryInterface not wrapped\n");
1562     ok(unk->lpVtbl->AddRef != wrapped_AddRef, "AddRef not wrapped\n");
1563     ok(unk->lpVtbl->Release != wrapped_Release, "Release not wrapped\n");
1564 
1565     vtbl = (void**)unk->lpVtbl;
1566     ok(vtbl[4] != wrapped_func_nocall, "func not wrapped\n");
1567     ok(vtbl[63] != wrapped_func, "func not wrapped\n");
1568 
1569     SET_EXPECT(wrapped_func);
1570     hres = ((HRESULT (WINAPI*)(IUnknown*,int,double))vtbl[63])(unk, 10, 32.0);
1571     ok(hres == S_OK, "wrapped_func returned %08x\n", hres);
1572     CHECK_CALLED(wrapped_func);
1573 
1574     hres = IUnknown_QueryInterface(unk, &IID_IHTMLObjectElement, (void**)&elem2);
1575     ok(hres == S_OK, "Could not get IHTMLObjectElement from wrapped iface: %08x\n", hres);
1576     ok(iface_cmp((IUnknown*)elem2, (IUnknown*)elem), "elem2 != elem\n");
1577     IHTMLObjectElement_Release(elem2);
1578 
1579     SET_EXPECT(wrapped_Release);
1580     ref = IUnknown_Release(unk);
1581     ok(!ref, "ref=%d\n", ref);
1582     CHECK_CALLED(wrapped_Release);
1583 
1584     SET_EXPECT(QI_ITestActiveX);
1585     SET_EXPECT(wrapped_AddRef);
1586     SET_EXPECT(wrapped_Release);
1587     unk = (void*)0xdeadbeef;
1588     hres = IHTMLObjectElement_QueryInterface(elem, &IID_ITestActiveX, (void**)&unk2);
1589     ok(hres == S_OK, "QueryInerface(IID_ITestActiveX failed: %08x\n", hres);
1590     CHECK_CALLED(QI_ITestActiveX);
1591     CHECK_CALLED(wrapped_AddRef);
1592     CHECK_CALLED(wrapped_Release);
1593 
1594     ok(unk != unk2, "unk == unk2\n");
1595 
1596     SET_EXPECT(wrapped_Release);
1597     ref = IUnknown_Release(unk2);
1598     ok(!ref, "ref=%d\n", ref);
1599     CHECK_CALLED(wrapped_Release);
1600 }
1601 
1602 static void test_object_elem(IHTMLDocument2 *doc)
1603 {
1604     IHTMLObjectElement *objelem;
1605     IHTMLDocument3 *doc3;
1606     IDispatchEx *dispex;
1607     IHTMLElement *elem;
1608     IDispatch *disp;
1609     VARIANT v;
1610     BSTR str;
1611     HRESULT hres;
1612 
1613     hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
1614     ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
1615 
1616     str = a2bstr("objid");
1617     elem = (void*)0xdeadbeef;
1618     hres = IHTMLDocument3_getElementById(doc3, str, &elem);
1619     IHTMLDocument3_Release(doc3);
1620     SysFreeString(str);
1621     ok(hres == S_OK, "getElementById failed: %08x\n", hres);
1622     ok(elem != NULL, "elem == NULL\n");
1623 
1624     hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLObjectElement, (void**)&objelem);
1625     IHTMLElement_Release(elem);
1626     ok(hres == S_OK, "Could not get IHTMLObjectElement iface: %08x\n", hres);
1627 
1628     SET_EXPECT(Invoke_SECURITYCTX);
1629     hres = IHTMLObjectElement_get_object(objelem, &disp);
1630     ok(hres == S_OK, "get_object failed: %08x\n", hres);
1631     ok(disp == &Dispatch, "disp != Dispatch\n");
1632     CHECK_CALLED(Invoke_SECURITYCTX);
1633 
1634     hres = IHTMLObjectElement_QueryInterface(objelem, &IID_IDispatchEx, (void**)&dispex);
1635     ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
1636     test_elem_dispex(dispex);
1637     IDispatchEx_Release(dispex);
1638 
1639     test_iface_wrapping(objelem);
1640 
1641     hres = IHTMLObjectElement_get_width(objelem, &v);
1642     ok(hres == S_OK, "get_width failed: %08x\n", hres);
1643     ok(V_VT(&v) == VT_BSTR, "V_VT(width) = %d\n", V_VT(&v));
1644     ok(!strcmp_wa(V_BSTR(&v), "300"), "V_BSTR(width) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
1645     VariantClear(&v);
1646 
1647     hres = IHTMLObjectElement_get_height(objelem, &v);
1648     ok(hres == S_OK, "get_height failed: %08x\n", hres);
1649     ok(V_VT(&v) == VT_BSTR, "V_VT(height) = %d\n", V_VT(&v));
1650     ok(!strcmp_wa(V_BSTR(&v), "200"), "V_BSTR(height) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
1651     VariantClear(&v);
1652 
1653     V_VT(&v) = VT_I4;
1654     V_I4(&v) = 400;
1655     SET_EXPECT(OnAmbientPropertyChange_UNKNOWN);
1656     SET_EXPECT(Invoke_ENABLED);
1657     hres = IHTMLObjectElement_put_width(objelem, v);
1658     ok(hres == S_OK, "put_width failed: %08x\n", hres);
1659     CHECK_CALLED(OnAmbientPropertyChange_UNKNOWN);
1660     CLEAR_CALLED(Invoke_ENABLED); /* Not called on IE10 */
1661 
1662     hres = IHTMLObjectElement_get_width(objelem, &v);
1663     ok(hres == S_OK, "get_width failed: %08x\n", hres);
1664     ok(V_VT(&v) == VT_BSTR, "V_VT(width) = %d\n", V_VT(&v));
1665     ok(!strcmp_wa(V_BSTR(&v), "400"), "V_BSTR(width) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
1666     VariantClear(&v);
1667 
1668     V_VT(&v) = VT_I4;
1669     V_I4(&v) = 250;
1670     SET_EXPECT(OnAmbientPropertyChange_UNKNOWN);
1671     SET_EXPECT(Invoke_ENABLED);
1672     hres = IHTMLObjectElement_put_height(objelem, v);
1673     ok(hres == S_OK, "put_height failed: %08x\n", hres);
1674     CHECK_CALLED(OnAmbientPropertyChange_UNKNOWN);
1675     CLEAR_CALLED(Invoke_ENABLED); /* Not called on IE10 */
1676 
1677     hres = IHTMLObjectElement_get_height(objelem, &v);
1678     ok(hres == S_OK, "get_height failed: %08x\n", hres);
1679     ok(V_VT(&v) == VT_BSTR, "V_VT(height) = %d\n", V_VT(&v));
1680     ok(!strcmp_wa(V_BSTR(&v), "250"), "V_BSTR(height) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
1681     VariantClear(&v);
1682 
1683     IHTMLObjectElement_Release(objelem);
1684 }
1685 
1686 static void test_container(IHTMLDocument2 *doc_obj)
1687 {
1688     IHTMLWindow2 *parent_window, *html_window;
1689     IServiceProvider *serv_prov;
1690     IOleContainer *container;
1691     IHTMLDocument2 *doc;
1692     IUnknown *unk;
1693     HRESULT hres;
1694 
1695     container = NULL;
1696     hres = IOleClientSite_GetContainer(client_site, &container);
1697     ok(hres == S_OK, "GetContainer failed: %08x\n", hres);
1698     ok(container != NULL, "container == NULL\n");
1699 
1700     hres = IHTMLDocument2_get_parentWindow(doc_obj, &parent_window);
1701     ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
1702     ok(parent_window != NULL, "parentWindow == NULL\n");
1703 
1704     hres = IHTMLWindow2_get_document(parent_window, &doc);
1705     ok(hres == S_OK, "get_document failed: %08x\n", hres);
1706     ok(doc != NULL, "doc == NULL\n");
1707     ok(iface_cmp((IUnknown*)doc, (IUnknown*)container), "container != doc\n");
1708     IHTMLDocument2_Release(doc);
1709 
1710     hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
1711     ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
1712 
1713     hres = IServiceProvider_QueryService(serv_prov, &IID_IHTMLWindow2, &IID_IHTMLWindow2, (void**)&html_window);
1714     ok(hres == S_OK, "Could not get IHTMLWindow2 service: %08x\n", hres);
1715     todo_wine
1716     ok(!iface_cmp((IUnknown*)html_window, (IUnknown*)parent_window), "html_window != parent_window\n");
1717     IHTMLWindow2_Release(html_window);
1718 
1719     SET_EXPECT(QueryService_TestActiveX);
1720     hres = IServiceProvider_QueryService(serv_prov, &CLSID_TestActiveX, &IID_IUnknown, (void**)&unk);
1721     ok(hres == S_OK, "QueryService(CLSID_TestActiveX) failed: %08x\n", hres);
1722     ok(unk == (IUnknown*)&OleObject, "unexpected unk %p\n", unk);
1723     CHECK_CALLED(QueryService_TestActiveX);
1724     IUnknown_Release(unk);
1725 
1726     IServiceProvider_Release(serv_prov);
1727 
1728     IHTMLWindow2_Release(parent_window);
1729     IOleContainer_Release(container);
1730 }
1731 
1732 static void test_ui_activate(void)
1733 {
1734     IOleInPlaceSite *ip_site;
1735     HRESULT hres;
1736 
1737     hres = IOleClientSite_QueryInterface(client_site, &IID_IOleInPlaceSite, (void**)&ip_site);
1738     ok(hres == S_OK, "Could not get IOleInPlaceSite iface: %08x\n", hres);
1739 
1740     SET_EXPECT(Invoke_ENABLED);
1741     hres = IOleInPlaceSite_OnUIActivate(ip_site);
1742     ok(hres == S_OK, "OnUIActivate failed: %08x\n", hres);
1743     CLEAR_CALLED(Invoke_ENABLED); /* Not called on IE10 */
1744 
1745     IOleInPlaceSite_Release(ip_site);
1746 }
1747 
1748 static HRESULT cs_qi(REFIID,void **);
1749 static IOleDocumentView *view;
1750 
1751 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1752 {
1753     static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1754 
1755     if(!IsEqualGUID(&undocumented_frame_iid, riid))
1756         ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
1757 
1758     *ppv = NULL;
1759     return E_NOINTERFACE;
1760 }
1761 
1762 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1763 {
1764     return 2;
1765 }
1766 
1767 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1768 {
1769     return 1;
1770 }
1771 
1772 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1773 {
1774     return E_NOTIMPL;
1775 }
1776 
1777 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1778 {
1779     return E_NOTIMPL;
1780 }
1781 
1782 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1783 {
1784     return E_NOTIMPL;
1785 }
1786 
1787 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1788         LPCBORDERWIDTHS pborderwidths)
1789 {
1790     return E_NOTIMPL;
1791 }
1792 
1793 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1794         LPCBORDERWIDTHS pborderwidths)
1795 {
1796     return S_OK;
1797 }
1798 
1799 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1800         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1801 {
1802     return S_OK;
1803 }
1804 
1805 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1806         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1807 {
1808     return S_OK;
1809 }
1810 
1811 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1812         LPOLEMENUGROUPWIDTHS lpMenuWidths)
1813 {
1814     return E_NOTIMPL;
1815 }
1816 
1817 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1818         HOLEMENU holemenu, HWND hwndActiveObject)
1819 {
1820     ok(0, "unexpected call\n");
1821     return E_NOTIMPL;
1822 }
1823 
1824 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1825 {
1826     ok(0, "unexpected call\n");
1827     return E_NOTIMPL;
1828 }
1829 
1830 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1831 {
1832     return S_OK;
1833 }
1834 
1835 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1836 {
1837     return E_NOTIMPL;
1838 }
1839 
1840 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1841 {
1842     ok(0, "unexpected call\n");
1843     return E_NOTIMPL;
1844 }
1845 
1846 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1847     InPlaceFrame_QueryInterface,
1848     InPlaceFrame_AddRef,
1849     InPlaceFrame_Release,
1850     InPlaceFrame_GetWindow,
1851     InPlaceFrame_ContextSensitiveHelp,
1852     InPlaceFrame_GetBorder,
1853     InPlaceFrame_RequestBorderSpace,
1854     InPlaceFrame_SetBorderSpace,
1855     InPlaceFrame_SetActiveObject,
1856     InPlaceFrame_InsertMenus,
1857     InPlaceFrame_SetMenu,
1858     InPlaceFrame_RemoveMenus,
1859     InPlaceFrame_SetStatusText,
1860     InPlaceFrame_EnableModeless,
1861     InPlaceFrame_TranslateAccelerator
1862 };
1863 
1864 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1865 
1866 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1867     InPlaceFrame_QueryInterface,
1868     InPlaceFrame_AddRef,
1869     InPlaceFrame_Release,
1870     InPlaceFrame_GetWindow,
1871     InPlaceFrame_ContextSensitiveHelp,
1872     InPlaceFrame_GetBorder,
1873     InPlaceFrame_RequestBorderSpace,
1874     InPlaceFrame_SetBorderSpace,
1875     InPlaceUIWindow_SetActiveObject,
1876 };
1877 
1878 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1879 
1880 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
1881 {
1882     return cs_qi(riid, ppv);
1883 }
1884 
1885 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
1886 {
1887     return 2;
1888 }
1889 
1890 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
1891 {
1892     return 1;
1893 }
1894 
1895 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
1896 {
1897     *phwnd = container_hwnd;
1898     return S_OK;
1899 }
1900 
1901 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
1902 {
1903     ok(0, "unexpected call\n");
1904     return E_NOTIMPL;
1905 }
1906 
1907 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
1908 {
1909     return S_OK;
1910 }
1911 
1912 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
1913 {
1914     return S_OK;
1915 }
1916 
1917 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
1918 {
1919     return S_OK;
1920 }
1921 
1922 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
1923         IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1924         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1925 {
1926     static const RECT rect = {0,0,500,500};
1927 
1928     *ppFrame = &InPlaceFrame;
1929     *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1930     *lprcPosRect = rect;
1931     *lprcClipRect = rect;
1932 
1933     lpFrameInfo->fMDIApp = FALSE;
1934     lpFrameInfo->hwndFrame = container_hwnd;
1935     lpFrameInfo->haccel = NULL;
1936     lpFrameInfo->cAccelEntries = 0;
1937 
1938     return S_OK;
1939 }
1940 
1941 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
1942 {
1943     return E_NOTIMPL;
1944 }
1945 
1946 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
1947 {
1948     return S_OK;
1949 }
1950 
1951 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
1952 {
1953     return S_OK;
1954 }
1955 
1956 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
1957 {
1958     return E_NOTIMPL;
1959 }
1960 
1961 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
1962 {
1963     return E_NOTIMPL;
1964 }
1965 
1966 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
1967 {
1968     return E_NOTIMPL;
1969 }
1970 
1971 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
1972     InPlaceSite_QueryInterface,
1973     InPlaceSite_AddRef,
1974     InPlaceSite_Release,
1975     InPlaceSite_GetWindow,
1976     InPlaceSite_ContextSensitiveHelp,
1977     InPlaceSite_CanInPlaceActivate,
1978     InPlaceSite_OnInPlaceActivate,
1979     InPlaceSite_OnUIActivate,
1980     InPlaceSite_GetWindowContext,
1981     InPlaceSite_Scroll,
1982     InPlaceSite_OnUIDeactivate,
1983     InPlaceSite_OnInPlaceDeactivate,
1984     InPlaceSite_DiscardUndoState,
1985     InPlaceSite_DeactivateAndUndo,
1986     InPlaceSite_OnPosRectChange,
1987 };
1988 
1989 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
1990 
1991 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1992 {
1993     return cs_qi(riid, ppv);
1994 }
1995 
1996 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1997 {
1998     return 2;
1999 }
2000 
2001 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
2002 {
2003     return 1;
2004 }
2005 
2006 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
2007 {
2008     ok(0, "unexpected call\n");
2009     return E_NOTIMPL;
2010 }
2011 
2012 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
2013         IMoniker **ppmon)
2014 {
2015     ok(0, "unexpected call\n");
2016     return E_NOTIMPL;
2017 }
2018 
2019 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
2020 {
2021     return E_NOTIMPL;
2022 }
2023 
2024 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
2025 {
2026     ok(0, "unexpected call\n");
2027     return E_NOTIMPL;
2028 }
2029 
2030 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
2031 {
2032     ok(0, "unexpected call\n");
2033     return E_NOTIMPL;
2034 }
2035 
2036 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
2037 {
2038     ok(0, "unexpected call\n");
2039     return E_NOTIMPL;
2040 }
2041 
2042 static const IOleClientSiteVtbl ClientSiteVtbl = {
2043     ClientSite_QueryInterface,
2044     ClientSite_AddRef,
2045     ClientSite_Release,
2046     ClientSite_SaveObject,
2047     ClientSite_GetMoniker,
2048     ClientSite_GetContainer,
2049     ClientSite_ShowObject,
2050     ClientSite_OnShowWindow,
2051     ClientSite_RequestNewObjectLayout
2052 };
2053 
2054 static IOleClientSite ClientSite = { &ClientSiteVtbl };
2055 
2056 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
2057 {
2058     return cs_qi(riid, ppv);
2059 }
2060 
2061 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
2062 {
2063     return 2;
2064 }
2065 
2066 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
2067 {
2068     return 1;
2069 }
2070 
2071 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
2072 {
2073     RECT rect = {0,0,400,500};
2074     IOleDocument *document;
2075     HRESULT hres;
2076 
2077     hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
2078     ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
2079 
2080     hres = IOleDocument_CreateView(document, &InPlaceSite, NULL, 0, &view);
2081     IOleDocument_Release(document);
2082     ok(hres == S_OK, "CreateView failed: %08x\n", hres);
2083 
2084     hres = IOleDocumentView_SetInPlaceSite(view, &InPlaceSite);
2085     ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
2086 
2087     hres = IOleDocumentView_UIActivate(view, TRUE);
2088     ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
2089 
2090     hres = IOleDocumentView_SetRect(view, &rect);
2091     ok(hres == S_OK, "SetRect failed: %08x\n", hres);
2092 
2093     hres = IOleDocumentView_Show(view, TRUE);
2094     ok(hres == S_OK, "Show failed: %08x\n", hres);
2095 
2096     return S_OK;
2097 }
2098 
2099 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
2100     DocumentSite_QueryInterface,
2101     DocumentSite_AddRef,
2102     DocumentSite_Release,
2103     DocumentSite_ActivateMe
2104 };
2105 
2106 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
2107 
2108 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2109                                                      REFIID riid, void **ppv)
2110 {
2111     return cs_qi(riid, ppv);
2112 }
2113 
2114 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2115 {
2116     return 2;
2117 }
2118 
2119 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2120 {
2121     return 1;
2122 }
2123 
2124 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2125         REFIID riid, void **ppv)
2126 {
2127     if(IsEqualGUID(&CLSID_TestActiveX, guidService)) {
2128         CHECK_EXPECT(QueryService_TestActiveX);
2129         ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
2130         *ppv = &OleObject;
2131         return S_OK;
2132     }
2133 
2134     *ppv = NULL;
2135     return E_NOINTERFACE;
2136 }
2137 
2138 static const IServiceProviderVtbl ServiceProviderVtbl = {
2139     ServiceProvider_QueryInterface,
2140     ServiceProvider_AddRef,
2141     ServiceProvider_Release,
2142     ServiceProvider_QueryService
2143 };
2144 
2145 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2146 
2147 static HRESULT cs_qi(REFIID riid, void **ppv)
2148 {
2149     *ppv = NULL;
2150 
2151     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2152         *ppv = &ClientSite;
2153     else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2154         *ppv = &DocumentSite;
2155     else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2156         *ppv = &InPlaceSite;
2157     else if(IsEqualGUID(riid, &IID_IServiceProvider))
2158         *ppv = &ServiceProvider;
2159 
2160     return *ppv ? S_OK : E_NOINTERFACE;
2161 }
2162 
2163 static IHTMLDocument2 *notif_doc;
2164 static BOOL doc_complete;
2165 
2166 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
2167         REFIID riid, void**ppv)
2168 {
2169     if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2170         *ppv = iface;
2171         return S_OK;
2172     }
2173 
2174     ok(0, "unexpected call\n");
2175     return E_NOINTERFACE;
2176 }
2177 
2178 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
2179 {
2180     return 2;
2181 }
2182 
2183 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
2184 {
2185     return 1;
2186 }
2187 
2188 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
2189 {
2190     if(dispID == DISPID_READYSTATE){
2191         BSTR state;
2192         HRESULT hres;
2193 
2194         static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
2195 
2196         hres = IHTMLDocument2_get_readyState(notif_doc, &state);
2197         ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
2198 
2199         if(!lstrcmpW(state, completeW))
2200             doc_complete = TRUE;
2201 
2202         SysFreeString(state);
2203     }
2204 
2205     return S_OK;
2206 }
2207 
2208 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
2209 {
2210     ok(0, "unexpected call\n");
2211     return E_NOTIMPL;
2212 }
2213 
2214 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
2215     PropertyNotifySink_QueryInterface,
2216     PropertyNotifySink_AddRef,
2217     PropertyNotifySink_Release,
2218     PropertyNotifySink_OnChanged,
2219     PropertyNotifySink_OnRequestEdit
2220 };
2221 
2222 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
2223 
2224 static void doc_load_string(IHTMLDocument2 *doc, const char *str)
2225 {
2226     IPersistStreamInit *init;
2227     IStream *stream;
2228     HGLOBAL mem;
2229     SIZE_T len;
2230 
2231     notif_doc = doc;
2232 
2233     doc_complete = FALSE;
2234     len = strlen(str);
2235     mem = GlobalAlloc(0, len);
2236     memcpy(mem, str, len);
2237     CreateStreamOnHGlobal(mem, TRUE, &stream);
2238 
2239     IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
2240 
2241     IPersistStreamInit_Load(init, stream);
2242     IPersistStreamInit_Release(init);
2243     IStream_Release(stream);
2244 }
2245 
2246 static void do_advise(IUnknown *unk, REFIID riid, IUnknown *unk_advise)
2247 {
2248     IConnectionPointContainer *container;
2249     IConnectionPoint *cp;
2250     DWORD cookie;
2251     HRESULT hres;
2252 
2253     hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2254     ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2255 
2256     hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2257     IConnectionPointContainer_Release(container);
2258     ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2259 
2260     hres = IConnectionPoint_Advise(cp, unk_advise, &cookie);
2261     IConnectionPoint_Release(cp);
2262     ok(hres == S_OK, "Advise failed: %08x\n", hres);
2263 }
2264 
2265 static void set_client_site(IHTMLDocument2 *doc, BOOL set)
2266 {
2267     IOleObject *oleobj;
2268     HRESULT hres;
2269 
2270     if(!set && view) {
2271         IOleDocumentView_Show(view, FALSE);
2272         IOleDocumentView_CloseView(view, 0);
2273         IOleDocumentView_SetInPlaceSite(view, NULL);
2274         IOleDocumentView_Release(view);
2275         view = NULL;
2276     }
2277 
2278     hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
2279     ok(hres == S_OK, "Could not et IOleObject: %08x\n", hres);
2280 
2281     hres = IOleObject_SetClientSite(oleobj, set ? &ClientSite : NULL);
2282     ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2283 
2284     if(set) {
2285         IHlinkTarget *hlink;
2286 
2287         hres = IOleObject_QueryInterface(oleobj, &IID_IHlinkTarget, (void**)&hlink);
2288         ok(hres == S_OK, "Could not get IHlinkTarget iface: %08x\n", hres);
2289 
2290         hres = IHlinkTarget_Navigate(hlink, 0, NULL);
2291         ok(hres == S_OK, "Navgate failed: %08x\n", hres);
2292 
2293         IHlinkTarget_Release(hlink);
2294     }
2295 
2296     IOleObject_Release(oleobj);
2297 }
2298 static IHTMLDocument2 *create_document(void)
2299 {
2300     IHTMLDocument2 *doc;
2301     HRESULT hres;
2302 
2303     hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2304             &IID_IHTMLDocument2, (void**)&doc);
2305     ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
2306 
2307     return doc;
2308 }
2309 
2310 static IHTMLDocument2 *create_doc(const char *str)
2311 {
2312     IHTMLDocument2 *doc;
2313     MSG msg;
2314 
2315     doc = create_document();
2316     set_client_site(doc, TRUE);
2317     doc_load_string(doc, str);
2318     do_advise((IUnknown*)doc, &IID_IPropertyNotifySink, (IUnknown*)&PropertyNotifySink);
2319 
2320     while(!doc_complete && GetMessageW(&msg, NULL, 0, 0)) {
2321         TranslateMessage(&msg);
2322         DispatchMessageW(&msg);
2323     }
2324 
2325     return doc;
2326 }
2327 
2328 static void release_doc(IHTMLDocument2 *doc)
2329 {
2330     ULONG ref;
2331 
2332     set_client_site(doc, FALSE);
2333     ref = IHTMLDocument2_Release(doc);
2334     ok(!ref || broken(ref == 1) /* Vista */, "ref = %d\n", ref);
2335 
2336     if(client_site) {
2337         IOleClientSite_Release(client_site);
2338         client_site = NULL;
2339     }
2340 
2341     if(plugin_hwnd) {
2342         DestroyWindow(plugin_hwnd);
2343         plugin_hwnd = NULL;
2344     }
2345 
2346     ok(!activex_refcnt, "activex_refcnt = %d\n", activex_refcnt);
2347 }
2348 
2349 static void init_test(int behavior)
2350 {
2351     plugin_behavior = behavior;
2352 
2353     activex_refcnt = 0;
2354     no_quickact = behavior == TEST_NOQUICKACT || behavior == TEST_DISPONLY;
2355     have_container = TRUE;
2356 }
2357 
2358 static void test_event_call(void)
2359 {
2360     VARIANT res, args[2];
2361     DISPPARAMS dp = {args};
2362     EXCEPINFO ei = {0};
2363     HRESULT hres;
2364 
2365     V_VT(&res) = VT_EMPTY;
2366     hres = IDispatch_Invoke(sink_disp, 1, &IID_NULL, 0, DISPATCH_METHOD, &dp, &res, &ei, NULL);
2367     ok(hres == S_OK, "Invoke failed: %08x\n", hres);
2368     ok(V_VT(&res) == VT_I4 && V_I4(&res) == 6, "unexpected result\n");
2369 
2370     V_VT(args) = VT_I4;
2371     V_I4(args) = 2;
2372     V_VT(args+1) = VT_I4;
2373     V_I4(args+1) = 3;
2374     dp.cArgs = 2;
2375     V_VT(&res) = VT_EMPTY;
2376     hres = IDispatch_Invoke(sink_disp, 2, &IID_NULL, 0, DISPATCH_METHOD, &dp, &res, &ei, NULL);
2377     ok(hres == S_OK, "Invoke failed: %08x\n", hres);
2378     ok(V_VT(&res) == VT_I4 && V_I4(&res) == 7, "unexpected result: %d\n", V_I4(&res));
2379 
2380     V_VT(&res) = VT_ERROR;
2381     hres = IDispatch_Invoke(sink_disp, 10, &IID_NULL, 0, DISPATCH_METHOD, &dp, &res, &ei, NULL);
2382     ok(hres == S_OK, "Invoke failed: %08x\n", hres);
2383     ok(V_VT(&res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(&res));
2384 }
2385 
2386 static void test_flash_ax(void)
2387 {
2388     IHTMLDocument2 *doc;
2389     IOleClientSite *cs;
2390 
2391     init_test(TEST_FLASH);
2392 
2393     SET_EXPECT(CreateInstance);
2394     SET_EXPECT(FreezeEvents_TRUE);
2395     SET_EXPECT(QuickActivate);
2396     SET_EXPECT(FreezeEvents_FALSE);
2397     SET_EXPECT(IPersistPropertyBag_Load);
2398     SET_EXPECT(Invoke_READYSTATE);
2399     SET_EXPECT(Invoke_SECURITYCTX);
2400     SET_EXPECT(Invoke_SCRIPTCALL);
2401     SET_EXPECT(SetExtent);
2402     SET_EXPECT(GetExtent);
2403     SET_EXPECT(DoVerb);
2404 
2405     doc = create_doc(object_ax_str);
2406 
2407     CHECK_CALLED(CreateInstance);
2408     todo_wine
2409     CHECK_CALLED(FreezeEvents_TRUE);
2410     CHECK_CALLED(QuickActivate);
2411     todo_wine
2412     CHECK_CALLED(FreezeEvents_FALSE);
2413     CHECK_CALLED(IPersistPropertyBag_Load);
2414     CHECK_CALLED(Invoke_READYSTATE);
2415     CHECK_CALLED(Invoke_SECURITYCTX);
2416     CHECK_CALLED(Invoke_SCRIPTCALL);
2417     todo_wine
2418     CHECK_CALLED(SetExtent);
2419     todo_wine
2420     CHECK_CALLED(GetExtent);
2421     CHECK_CALLED(DoVerb);
2422 
2423     /* Set in DoVerb */
2424     CHECK_CALLED(InPlaceObject_GetWindow);
2425     CHECK_CALLED(SetObjectRects);
2426     if (winetest_interactive)
2427     {
2428         test_ui_activate();
2429         test_container(notif_doc);
2430         test_object_elem(notif_doc);
2431     }
2432     else
2433     {
2434         skip("Skipping test_ui_activate(). ROSTESTS-114.\n");
2435         skip("Skipping test_container(notif_doc). ROSTESTS-114.\n");
2436         skip("Skipping test_object_elem(notif_doc). ROSTESTS-114.\n");
2437     }
2438 
2439     IOleClientSite_AddRef(client_site);
2440     cs = client_site;
2441 
2442     SET_EXPECT(UIDeactivate);
2443     SET_EXPECT(Invoke_ENABLED);
2444     SET_EXPECT(Invoke_VALID);
2445     SET_EXPECT(InPlaceDeactivate);
2446     SET_EXPECT(Close);
2447     SET_EXPECT(SetClientSite_NULL);
2448     release_doc(doc);
2449     CHECK_CALLED(UIDeactivate);
2450     CLEAR_CALLED(Invoke_ENABLED); /* Not called on IE10 */
2451     todo_wine
2452     CHECK_CALLED(Invoke_VALID);
2453     CHECK_CALLED(InPlaceDeactivate);
2454     CHECK_CALLED(Close);
2455     CHECK_CALLED(SetClientSite_NULL);
2456 
2457     IOleClientSite_Release(cs);
2458 }
2459 
2460 static void test_noquickact_ax(void)
2461 {
2462     IHTMLDocument2 *doc;
2463 
2464     init_test(TEST_NOQUICKACT);
2465 
2466     SET_EXPECT(CreateInstance);
2467     SET_EXPECT(FreezeEvents_TRUE);
2468     SET_EXPECT(GetMiscStatus);
2469     SET_EXPECT(SetClientSite);
2470     SET_EXPECT(SetAdvise);
2471     SET_EXPECT(GetViewStatus);
2472     SET_EXPECT(FreezeEvents_FALSE);
2473     SET_EXPECT(Invoke_READYSTATE);
2474     SET_EXPECT(Invoke_SECURITYCTX);
2475     SET_EXPECT(Invoke_SCRIPTCALL);
2476     SET_EXPECT(SetExtent);
2477     SET_EXPECT(GetExtent);
2478     SET_EXPECT(DoVerb);
2479 
2480     doc = create_doc(object_ax_str);
2481 
2482     CHECK_CALLED(CreateInstance);
2483     todo_wine CHECK_CALLED(FreezeEvents_TRUE);
2484     CHECK_CALLED(GetMiscStatus);
2485     CHECK_CALLED(SetClientSite);
2486     CHECK_CALLED(SetAdvise);
2487     CHECK_CALLED(GetViewStatus);
2488     todo_wine CHECK_CALLED(FreezeEvents_FALSE);
2489     CHECK_CALLED(Invoke_READYSTATE);
2490     CHECK_CALLED(Invoke_SECURITYCTX);
2491     CHECK_CALLED(Invoke_SCRIPTCALL);
2492     todo_wine CHECK_CALLED(SetExtent);
2493     todo_wine CHECK_CALLED(GetExtent);
2494     CHECK_CALLED(DoVerb);
2495 
2496     /* Set in DoVerb */
2497     CHECK_CALLED(InPlaceObject_GetWindow);
2498     CHECK_CALLED(SetObjectRects);
2499 
2500     SET_EXPECT(InPlaceDeactivate);
2501     SET_EXPECT(Close);
2502     SET_EXPECT(SetClientSite_NULL);
2503     release_doc(doc);
2504     CHECK_CALLED(InPlaceDeactivate);
2505     CHECK_CALLED(Close);
2506     CHECK_CALLED(SetClientSite_NULL);
2507 }
2508 
2509 static void test_event_binding(void)
2510 {
2511     IHTMLDocument2 *doc;
2512 
2513     init_test(TEST_FLASH);
2514 
2515     SET_EXPECT(CreateInstance);
2516     SET_EXPECT(FreezeEvents_TRUE);
2517     SET_EXPECT(QuickActivate);
2518     SET_EXPECT(FreezeEvents_FALSE);
2519     SET_EXPECT(IPersistPropertyBag_Load);
2520     SET_EXPECT(Invoke_READYSTATE);
2521     SET_EXPECT(SetExtent);
2522     SET_EXPECT(GetExtent);
2523     SET_EXPECT(DoVerb);
2524 
2525     SET_EXPECT(GetClassInfo);
2526     SET_EXPECT(OnAmbientPropertyChange_UNKNOWN);
2527     SET_EXPECT(FindConnectionPoint);
2528     SET_EXPECT(Advise);
2529 
2530     doc = create_doc(event_binding_str);
2531 
2532     CHECK_CALLED(CreateInstance);
2533     todo_wine
2534     CHECK_CALLED(FreezeEvents_TRUE);
2535     CHECK_CALLED(QuickActivate);
2536     todo_wine
2537     CHECK_CALLED(FreezeEvents_FALSE);
2538     CHECK_CALLED(IPersistPropertyBag_Load);
2539     CHECK_CALLED(Invoke_READYSTATE);
2540     todo_wine
2541     CHECK_CALLED(SetExtent);
2542     todo_wine
2543     CHECK_CALLED(GetExtent);
2544     CHECK_CALLED(DoVerb);
2545 
2546     /* Set in DoVerb */
2547     CHECK_CALLED(InPlaceObject_GetWindow);
2548     CHECK_CALLED(SetObjectRects);
2549 
2550     CHECK_CALLED(GetClassInfo);
2551     todo_wine
2552     CHECK_CALLED(OnAmbientPropertyChange_UNKNOWN);
2553     CHECK_CALLED(FindConnectionPoint);
2554     CHECK_CALLED(Advise);
2555 
2556     if (winetest_interactive)
2557         test_event_call();
2558     else
2559         skip("Skipping test_event_call(). ROSTESTS-114.\n");
2560 
2561     SET_EXPECT(InPlaceDeactivate);
2562     SET_EXPECT(Close);
2563     SET_EXPECT(SetClientSite_NULL);
2564     SET_EXPECT(FindConnectionPoint);
2565     SET_EXPECT(Unadvise);
2566     release_doc(doc);
2567     CHECK_CALLED(InPlaceDeactivate);
2568     CHECK_CALLED(Close);
2569     CHECK_CALLED(SetClientSite_NULL);
2570     CHECK_CALLED(FindConnectionPoint);
2571     CHECK_CALLED(Unadvise);
2572 }
2573 
2574 static void test_nooleobj_ax(void)
2575 {
2576     IHTMLDocument2 *doc;
2577 
2578     init_test(TEST_DISPONLY);
2579 
2580     SET_EXPECT(CreateInstance);
2581     SET_EXPECT(Invoke_READYSTATE);
2582     SET_EXPECT(Invoke_SECURITYCTX);
2583     SET_EXPECT(Invoke_SCRIPTCALL);
2584 
2585     doc = create_doc(object_ax_str);
2586 
2587     CHECK_CALLED(CreateInstance);
2588     CHECK_CALLED(Invoke_READYSTATE);
2589     CHECK_CALLED(Invoke_SECURITYCTX);
2590     CHECK_CALLED(Invoke_SCRIPTCALL);
2591 
2592     release_doc(doc);
2593 }
2594 
2595 static void test_exec_script(IHTMLDocument2 *doc, const char *codea, const char *langa)
2596 {
2597     IHTMLWindow2 *window;
2598     BSTR code, lang;
2599     VARIANT v;
2600     HRESULT hres;
2601 
2602     hres = IHTMLDocument2_get_parentWindow(doc, &window);
2603     ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
2604 
2605     code = a2bstr(codea);
2606     lang = a2bstr(langa);
2607 
2608     hres = IHTMLWindow2_execScript(window, code, lang, &v);
2609     ok(hres == S_OK, "execScript failed: %08x\n", hres);
2610     SysFreeString(lang);
2611     VariantClear(&v);
2612 
2613     IHTMLWindow2_Release(window);
2614 }
2615 
2616 static void test_create_element(void)
2617 {
2618     IHTMLDocument2 *doc;
2619 
2620     init_test(TEST_FLASH);
2621 
2622     doc = create_doc("<html></html>");
2623 
2624     have_container = FALSE;
2625 
2626     SET_EXPECT(CreateInstance);
2627     SET_EXPECT(FreezeEvents_TRUE);
2628     SET_EXPECT(QuickActivate);
2629     SET_EXPECT(IPersistPropertyBag_InitNew);
2630     SET_EXPECT(Invoke_READYSTATE);
2631     SET_EXPECT(FreezeEvents_FALSE);
2632 
2633     test_exec_script(doc,
2634                      "var test_elem = document.createElement('object');"
2635                      "test_elem.classid = 'CLSID:178fc163-f585-4e24-9c13-4bb7f6680746';",
2636                      "javascript");
2637 
2638     CHECK_CALLED(CreateInstance);
2639     todo_wine CHECK_CALLED(FreezeEvents_TRUE);
2640     CHECK_CALLED(QuickActivate);
2641     CHECK_CALLED(IPersistPropertyBag_InitNew);
2642     CHECK_CALLED(Invoke_READYSTATE);
2643     todo_wine CHECK_CALLED(FreezeEvents_FALSE);
2644 
2645     have_container = TRUE;
2646 
2647     SET_EXPECT(DoVerb);
2648     test_exec_script(doc,
2649                      "document.body.appendChild(test_elem);",
2650                      "javascript");
2651     todo_wine CHECK_CALLED(DoVerb);
2652 
2653     SET_EXPECT(InPlaceDeactivate);
2654     SET_EXPECT(Close);
2655     SET_EXPECT(SetClientSite_NULL);
2656     release_doc(doc);
2657     todo_wine CHECK_CALLED(InPlaceDeactivate);
2658     CHECK_CALLED(Close);
2659     CHECK_CALLED(SetClientSite_NULL);
2660 }
2661 
2662 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2663 {
2664     return DefWindowProcW(hwnd, msg, wParam, lParam);
2665 }
2666 
2667 static HWND create_container_window(void)
2668 {
2669     static const WCHAR html_document_testW[] =
2670         {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
2671     static WNDCLASSEXW wndclass = {
2672         sizeof(WNDCLASSEXW),
2673         0,
2674         wnd_proc,
2675         0, 0, NULL, NULL, NULL, NULL, NULL,
2676         html_document_testW,
2677         NULL
2678     };
2679 
2680     RegisterClassExW(&wndclass);
2681     return CreateWindowW(html_document_testW, html_document_testW,
2682             WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
2683             515, 530, NULL, NULL, NULL, NULL);
2684 }
2685 
2686 static void load_typelib(void)
2687 {
2688     WCHAR path[MAX_PATH];
2689     ITypeLib *typelib;
2690     HRESULT hres;
2691 
2692     GetModuleFileNameW(NULL, path, MAX_PATH);
2693 
2694     hres = LoadTypeLib(path, &typelib);
2695     ok(hres == S_OK, "LoadTypeLib failed: %08x\n", hres);
2696 
2697     hres = ITypeLib_GetTypeInfoOfGuid(typelib, &DIID_DispActiveXTest, &actxtest_typeinfo);
2698     ok(hres == S_OK, "GetTypeInfoOfGuid(DIID_DispActiveXTest) failed: %08x\n", hres);
2699 
2700     hres = ITypeLib_GetTypeInfoOfGuid(typelib, &CLSID_ActiveXTest, &class_typeinfo);
2701     ok(hres == S_OK, "GetTypeInfoOfGuid(CLSID_ActiveXTest) failed: %08x\n", hres);
2702 
2703     ITypeLib_Release(typelib);
2704 }
2705 
2706 static BOOL init_key(const char *key_name, const char *def_value, BOOL init)
2707 {
2708     HKEY hkey;
2709     DWORD res;
2710 
2711     if(!init) {
2712         RegDeleteKeyA(HKEY_CLASSES_ROOT, key_name);
2713         return TRUE;
2714     }
2715 
2716     res = RegCreateKeyA(HKEY_CLASSES_ROOT, key_name, &hkey);
2717     if(res != ERROR_SUCCESS)
2718         return FALSE;
2719 
2720     if(def_value)
2721         res = RegSetValueA(hkey, NULL, REG_SZ, def_value, strlen(def_value));
2722 
2723     RegCloseKey(hkey);
2724 
2725     return res == ERROR_SUCCESS;
2726 }
2727 
2728 static BOOL init_registry(BOOL init)
2729 {
2730     return init_key("TestActiveX\\CLSID", TESTACTIVEX_CLSID, init)
2731         && init_key("CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95801-9882-11cf-9fa9-00aa006c42c4}",
2732                     NULL, init)
2733         && init_key("CLSID\\"TESTACTIVEX_CLSID"\\Implemented Categories\\{7dd95802-9882-11cf-9fa9-00aa006c42c4}",
2734                     NULL, init);
2735 }
2736 
2737 static BOOL register_activex(void)
2738 {
2739     DWORD regid;
2740     HRESULT hres;
2741 
2742     if(!init_registry(TRUE)) {
2743         init_registry(FALSE);
2744         return FALSE;
2745     }
2746 
2747     hres = CoRegisterClassObject(&CLSID_TestActiveX, (IUnknown*)&activex_cf,
2748             CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
2749     ok(hres == S_OK, "Could not register control: %08x\n", hres);
2750 
2751     return TRUE;
2752 }
2753 
2754 static BOOL check_ie(void)
2755 {
2756     IHTMLDocument5 *doc;
2757     HRESULT hres;
2758 
2759     hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2760             &IID_IHTMLDocument5, (void**)&doc);
2761     if(FAILED(hres))
2762         return FALSE;
2763 
2764     IHTMLDocument5_Release(doc);
2765     return TRUE;
2766 }
2767 
2768 START_TEST(activex)
2769 {
2770     CoInitialize(NULL);
2771 
2772     if(!check_ie()) {
2773         CoUninitialize();
2774         win_skip("Too old IE\n");
2775         return;
2776     }
2777 
2778     if(is_ie_hardened()) {
2779         CoUninitialize();
2780         win_skip("IE running in Enhanced Security Configuration\n");
2781         return;
2782     }
2783 
2784     init_wrapped_iface();
2785     load_typelib();
2786     container_hwnd = create_container_window();
2787     ShowWindow(container_hwnd, SW_SHOW);
2788 
2789     if(register_activex()) {
2790         trace("Testing emulated flash embedding...\n");
2791         test_flash_ax();
2792         trace("Testing plugin without IQuickActivate iface...\n");
2793         test_noquickact_ax();
2794         trace("Testing plugin with IDispatch iface only...\n");
2795         test_nooleobj_ax();
2796         trace("Testing event object binding...\n");
2797         test_event_binding();
2798         trace("Testing createElement(object)...\n");
2799         test_create_element();
2800         init_registry(FALSE);
2801     }else {
2802         skip("Could not register ActiveX\n");
2803     }
2804 
2805     if(actxtest_typeinfo)
2806         ITypeInfo_Release(actxtest_typeinfo);
2807     if(class_typeinfo)
2808         ITypeInfo_Release(class_typeinfo);
2809     DestroyWindow(container_hwnd);
2810     CoUninitialize();
2811 }
2812