mshtml: Add tests for get_scrollLeft.
[wine] / dlls / shdocvw / tests / webbrowser.c
1 /*
2  * Copyright 2006 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 #define COBJMACROS
20 #define CONST_VTABLE
21
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "exdisp.h"
31 #include "htiframe.h"
32 #include "mshtmhst.h"
33 #include "idispids.h"
34 #include "olectl.h"
35 #include "mshtmdid.h"
36 #include "shobjidl.h"
37 #include "shlguid.h"
38 #include "exdispid.h"
39
40 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
41
42 #define DEFINE_EXPECT(func) \
43     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
44
45 #define SET_EXPECT(func) \
46     expect_ ## func = TRUE
47
48 #define CHECK_EXPECT2(func) \
49     do { \
50         ok(expect_ ##func, "unexpected call " #func "\n"); \
51         called_ ## func = TRUE; \
52     }while(0)
53
54 #define CHECK_EXPECT(func) \
55     do { \
56         CHECK_EXPECT2(func); \
57         expect_ ## func = FALSE; \
58     }while(0)
59
60 #define CHECK_CALLED(func) \
61     do { \
62         ok(called_ ## func, "expected " #func "\n"); \
63         expect_ ## func = called_ ## func = FALSE; \
64     }while(0)
65
66 DEFINE_EXPECT(GetContainer);
67 DEFINE_EXPECT(Site_GetWindow);
68 DEFINE_EXPECT(ShowObject);
69 DEFINE_EXPECT(CanInPlaceActivate);
70 DEFINE_EXPECT(OnInPlaceActivate);
71 DEFINE_EXPECT(OnUIActivate);
72 DEFINE_EXPECT(GetWindowContext);
73 DEFINE_EXPECT(Frame_GetWindow);
74 DEFINE_EXPECT(Frame_SetActiveObject);
75 DEFINE_EXPECT(UIWindow_SetActiveObject);
76 DEFINE_EXPECT(SetMenu);
77 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
78 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
79 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
80 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
81 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
82 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
83 DEFINE_EXPECT(Invoke_STATUSTEXTCHANGE);
84 DEFINE_EXPECT(Invoke_PROPERTYCHANGE);
85 DEFINE_EXPECT(Invoke_DOWNLOADBEGIN);
86 DEFINE_EXPECT(Invoke_BEFORENAVIGATE2);
87 DEFINE_EXPECT(Invoke_SETSECURELOCKICON);
88 DEFINE_EXPECT(Invoke_FILEDOWNLOAD);
89 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE);
90 DEFINE_EXPECT(Invoke_DOWNLOADCOMPLETE);
91 DEFINE_EXPECT(Invoke_ONMENUBAR);
92 DEFINE_EXPECT(Invoke_ONADDRESSBAR);
93 DEFINE_EXPECT(Invoke_ONSTATUSBAR);
94 DEFINE_EXPECT(Invoke_ONTOOLBAR);
95 DEFINE_EXPECT(Invoke_ONFULLSCREEN);
96 DEFINE_EXPECT(Invoke_ONTHEATERMODE);
97 DEFINE_EXPECT(Invoke_WINDOWSETRESIZABLE);
98 DEFINE_EXPECT(EnableModeless_TRUE);
99 DEFINE_EXPECT(EnableModeless_FALSE);
100 DEFINE_EXPECT(GetHostInfo);
101 DEFINE_EXPECT(GetOptionKeyPath);
102 DEFINE_EXPECT(GetOverridesKeyPath);
103 DEFINE_EXPECT(SetStatusText);
104 DEFINE_EXPECT(UpdateUI);
105 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
106 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
107 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
108 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
109 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
110
111 static const WCHAR wszItem[] = {'i','t','e','m',0};
112 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
113 static const WCHAR emptyW[] = {0};
114
115 static VARIANT_BOOL exvb;
116 static IWebBrowser2 *wb;
117
118 static HWND container_hwnd, shell_embedding_hwnd;
119
120 static const char *debugstr_w(LPCWSTR str)
121 {
122     static char buf[1024];
123     if(!str)
124         return "(null)";
125     WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
126     return buf;
127 }
128
129 static const char *debugstr_guid(REFIID riid)
130 {
131     static char buf[50];
132
133     sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
134             riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
135             riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
136             riid->Data4[5], riid->Data4[6], riid->Data4[7]);
137
138     return buf;
139 }
140
141 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
142 static void _test_LocationURL(unsigned line, IUnknown *unk, LPCWSTR exurl)
143 {
144     IWebBrowser2 *wb;
145     BSTR url = (void*)0xdeadbeef;
146     HRESULT hres;
147
148     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
149     ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
150     if(FAILED(hres))
151         return;
152
153     hres = IWebBrowser2_get_LocationURL(wb, &url);
154     ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
155     ok_(__FILE__,line) (!lstrcmpW(url, exurl), "unexpected URL: %s\n", debugstr_w(url));
156
157     SysFreeString(url);
158     IWebBrowser2_Release(wb);
159 }
160
161 static HRESULT QueryInterface(REFIID,void**);
162
163 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
164         REFIID riid, void **ppv)
165 {
166     ok(0, "unexpected call\n");
167     return E_NOINTERFACE;
168 }
169
170 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
171 {
172     return 2;
173 }
174
175 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
176 {
177     return 1;
178 }
179
180 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
181         ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
182 {
183     ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
184     ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
185     ok(!pCmdText, "pCmdText != NULL\n");
186
187     switch(prgCmds[0].cmdID) {
188     case OLECMDID_SETPROGRESSTEXT:
189         CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
190         prgCmds[0].cmdf = OLECMDF_ENABLED;
191         return S_OK;
192     default:
193         ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
194     }
195
196     return E_FAIL;
197 }
198
199 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
200         DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
201 {
202     if(!pguidCmdGroup) {
203         switch(nCmdID) {
204         case OLECMDID_SETPROGRESSMAX:
205             CHECK_EXPECT(Exec_SETPROGRESSMAX);
206             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
207             ok(pvaIn != NULL, "pvaIn == NULL\n");
208             if(pvaIn)
209                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
210             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
211             return S_OK;
212         case OLECMDID_SETPROGRESSPOS:
213             CHECK_EXPECT(Exec_SETPROGRESSPOS);
214             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
215             ok(pvaIn != NULL, "pvaIn == NULL\n");
216             if(pvaIn)
217                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
218             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
219             return S_OK;
220         case OLECMDID_SETDOWNLOADSTATE:
221             ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
222             ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
223             ok(pvaIn != NULL, "pvaIn == NULL\n");
224             ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
225             switch(V_I4(pvaIn)) {
226             case 0:
227                 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
228                 break;
229             case 1:
230                 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
231                 break;
232             default:
233                 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
234             }
235             return S_OK;
236         default:
237             ok(0, "unexpected nsCmdID %d\n", nCmdID);
238         }
239     }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
240         switch(nCmdID) {
241         case 24:
242             return E_FAIL; /* TODO */
243         case 66:
244             return E_FAIL; /* TODO */
245         default:
246             ok(0, "unexpected nCmdID %d\n", nCmdID);
247         }
248     }else {
249         ok(0, "unepected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
250     }
251
252     return E_FAIL;
253 }
254
255 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
256     OleCommandTarget_QueryInterface,
257     OleCommandTarget_AddRef,
258     OleCommandTarget_Release,
259     OleCommandTarget_QueryStatus,
260     OleCommandTarget_Exec
261 };
262
263 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
264
265 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
266 {
267     if(IsEqualGUID(&IID_ITargetContainer, riid))
268         return E_NOINTERFACE; /* TODO */
269
270     if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
271         *ppv = &OleCommandTarget;
272         return S_OK;
273     }
274
275     ok(0, "unexpected call\n");
276     return E_NOINTERFACE;
277 }
278
279 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
280 {
281     return 2;
282 }
283
284 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
285 {
286     return 1;
287 }
288
289 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
290         LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
291 {
292     ok(0, "unexpected call\n");
293     return E_NOTIMPL;
294 }
295
296 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
297         IEnumUnknown **ppenum)
298 {
299     ok(0, "unexpected call\n");
300     return E_NOTIMPL;
301 }
302
303 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
304 {
305     ok(0, "unexpected call\n");
306     return E_NOTIMPL;
307 }
308
309 static const IOleContainerVtbl OleContainerVtbl = {
310     OleContainer_QueryInterface,
311     OleContainer_AddRef,
312     OleContainer_Release,
313     OleContainer_ParseDisplayName,
314     OleContainer_EnumObjects,
315     OleContainer_LockContainer
316 };
317
318 static IOleContainer OleContainer = { &OleContainerVtbl };
319
320 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
321 {
322     return QueryInterface(riid, ppv);
323 }
324
325 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
326 {
327     return 2;
328 }
329
330 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
331 {
332     return 1;
333 }
334
335 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
336 {
337     ok(0, "unexpected call\n");
338     return E_NOTIMPL;
339 }
340
341 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
342         ITypeInfo **ppTInfo)
343 {
344     ok(0, "unexpected call\n");
345     return E_NOTIMPL;
346 }
347
348 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
349         UINT cNames, LCID lcid, DISPID *rgDispId)
350 {
351     ok(0, "unexpected call\n");
352     return E_NOTIMPL;
353 }
354
355 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
356         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
357         EXCEPINFO *pExcepInfo, UINT *puArgErr)
358 {
359     ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
360     ok(pDispParams != NULL, "pDispParams == NULL\n");
361     ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
362     ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
363     ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
364     ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
365     ok(pDispParams->rgdispidNamedArgs == NULL,
366        "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
367     ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
368     ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
369
370     switch(dispIdMember) {
371     case DISPID_AMBIENT_USERMODE:
372         CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
373         return E_FAIL;
374     case DISPID_AMBIENT_DLCONTROL:
375         CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
376         ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
377         return E_FAIL;
378     case DISPID_AMBIENT_USERAGENT:
379        CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
380         ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
381         return E_FAIL;
382     case DISPID_AMBIENT_PALETTE:
383         CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
384         ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
385         return E_FAIL;
386     case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
387         CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
388         ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
389         V_VT(pVarResult) = VT_BOOL;
390         V_BOOL(pVarResult) = VARIANT_FALSE;
391         return S_OK;
392     case DISPID_AMBIENT_SILENT:
393         CHECK_EXPECT(Invoke_AMBIENT_SILENT);
394         ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
395         V_VT(pVarResult) = VT_BOOL;
396         V_BOOL(pVarResult) = VARIANT_FALSE;
397         return S_OK;
398     }
399
400     ok(0, "unexpected dispIdMember %d\n", dispIdMember);
401     return E_NOTIMPL;
402 }
403
404 static IDispatchVtbl DispatchVtbl = {
405     Dispatch_QueryInterface,
406     Dispatch_AddRef,
407     Dispatch_Release,
408     Dispatch_GetTypeInfoCount,
409     Dispatch_GetTypeInfo,
410     Dispatch_GetIDsOfNames,
411     Dispatch_Invoke
412 };
413
414 static IDispatch Dispatch = { &DispatchVtbl };
415
416 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
417 {
418     *ppv = NULL;
419
420     if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
421         *ppv = iface;
422         return S_OK;
423     }
424
425     ok(0, "unexpected riid %s\n", debugstr_guid(riid));
426     return E_NOINTERFACE;
427 }
428
429 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
430 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
431 {
432     ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
433     ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
434     ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
435     if(strict)
436         ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
437                             V_BOOL(params->rgvarg), exvb);
438     else
439         ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
440                             V_BOOL(params->rgvarg), exvb);
441 }
442
443 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
444         const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
445 {
446     ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
447     ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
448     ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
449
450     ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
451     ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
452     if(V_VARIANTREF(url)) {
453         ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
454            V_VT(V_VARIANTREF(url)));
455         ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
456         ok(!lstrcmpW(V_BSTR(V_VARIANTREF(url)), about_blankW), "unexpected url %s\n",
457            debugstr_w(V_BSTR(V_VARIANTREF(url))));
458     }
459
460     ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
461        V_VT(flags));
462     ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
463        V_VT(flags));
464     ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
465     if(V_VARIANTREF(flags)) {
466         ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
467            V_VT(V_VARIANTREF(flags)));
468         ok(V_I4(V_VARIANTREF(flags)) == 0, "V_I4(V_VARIANTREF(flags)) = %d, expected 0\n",
469            V_I4(V_VARIANTREF(flags)));
470     }
471
472     ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
473        V_VT(frame));
474     ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
475        V_VT(frame));
476     ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
477     if(V_VARIANTREF(frame)) {
478         ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
479            V_VT(V_VARIANTREF(frame)));
480         ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
481            V_BSTR(V_VARIANTREF(frame)));
482     }
483
484     ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
485        V_VT(post_data));
486     ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
487        V_VT(post_data));
488     ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
489     if(V_VARIANTREF(post_data)) {
490         ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
491            "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
492            V_VT(V_VARIANTREF(post_data)));
493         ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
494            "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
495         if(V_VARIANTREF(V_VARIANTREF(post_data))) {
496             ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
497                "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
498                V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
499
500             if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
501                 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
502
503                 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
504                 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
505             }
506         }
507     }
508
509     ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
510        V_VT(headers));
511     ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
512     if(V_VARIANTREF(headers)) {
513         ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
514            V_VT(V_VARIANTREF(headers)));
515         ok(V_BSTR(V_VARIANTREF(headers)) == NULL, "V_BSTR(V_VARIANTREF(heders)) = %p, expected NULL\n",
516            V_BSTR(V_VARIANTREF(headers)));
517     }
518
519     ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
520        V_VT(cancel));
521     ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
522     if(V_BOOLREF(cancel))
523         ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(calcel) = %x, expected VARIANT_FALSE\n",
524            *V_BOOLREF(cancel));
525 }
526
527 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
528         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
529         EXCEPINFO *pExcepInfo, UINT *puArgErr)
530 {
531     ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
532     ok(pDispParams != NULL, "pDispParams == NULL\n");
533     ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
534     ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
535     ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
536     ok(pDispParams->rgdispidNamedArgs == NULL,
537        "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
538     ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
539
540     switch(dispIdMember) {
541     case DISPID_STATUSTEXTCHANGE:
542         CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
543
544         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
545         ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
546         ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
547            V_VT(pDispParams->rgvarg));
548         /* TODO: Check text */
549         break;
550
551     case DISPID_PROPERTYCHANGE:
552         CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
553
554         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
555         ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
556         /* TODO: Check args */
557         break;
558
559     case DISPID_DOWNLOADBEGIN:
560         CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
561
562         ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
563         ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
564         break;
565
566     case DISPID_BEFORENAVIGATE2:
567         CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
568
569         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
570         ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
571         test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
572                               pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
573                               pDispParams->rgvarg);
574         break;
575
576     case DISPID_SETSECURELOCKICON:
577         CHECK_EXPECT(Invoke_SETSECURELOCKICON);
578
579         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
580         ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
581         /* TODO: Check args */
582         break;
583
584     case DISPID_FILEDOWNLOAD:
585         CHECK_EXPECT(Invoke_FILEDOWNLOAD);
586
587         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
588         ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
589         /* TODO: Check args */
590         break;
591
592     case DISPID_COMMANDSTATECHANGE:
593         CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
594
595         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
596         ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
597         /* TODO: Check args */
598         break;
599
600     case DISPID_DOWNLOADCOMPLETE:
601         CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
602
603         ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
604         ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
605         break;
606
607     case DISPID_ONMENUBAR:
608         CHECK_EXPECT(Invoke_ONMENUBAR);
609         test_invoke_bool(pDispParams, TRUE);
610         break;
611
612     case DISPID_ONADDRESSBAR:
613         CHECK_EXPECT(Invoke_ONADDRESSBAR);
614         test_invoke_bool(pDispParams, TRUE);
615         break;
616
617     case DISPID_ONSTATUSBAR:
618         CHECK_EXPECT(Invoke_ONSTATUSBAR);
619         test_invoke_bool(pDispParams, TRUE);
620         break;
621
622     case DISPID_ONTOOLBAR:
623         CHECK_EXPECT(Invoke_ONTOOLBAR);
624         test_invoke_bool(pDispParams, FALSE);
625         break;
626
627     case DISPID_ONFULLSCREEN:
628         CHECK_EXPECT(Invoke_ONFULLSCREEN);
629         test_invoke_bool(pDispParams, TRUE);
630         break;
631
632     case DISPID_ONTHEATERMODE:
633         CHECK_EXPECT(Invoke_ONTHEATERMODE);
634         test_invoke_bool(pDispParams, TRUE);
635         break;
636
637     case DISPID_WINDOWSETRESIZABLE:
638         CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
639         test_invoke_bool(pDispParams, TRUE);
640         break;
641
642     default:
643         ok(0, "unexpected dispIdMember %d\n", dispIdMember);
644     }
645
646     return S_OK;
647 }
648
649 static IDispatchVtbl WebBrowserEvents2Vtbl = {
650     WebBrowserEvents2_QueryInterface,
651     Dispatch_AddRef,
652     Dispatch_Release,
653     Dispatch_GetTypeInfoCount,
654     Dispatch_GetTypeInfo,
655     Dispatch_GetIDsOfNames,
656     WebBrowserEvents2_Invoke
657 };
658
659 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
660
661 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
662 {
663     return QueryInterface(riid, ppv);
664 }
665
666 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
667 {
668     return 2;
669 }
670
671 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
672 {
673     return 1;
674 }
675
676 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
677 {
678     ok(0, "unexpected call\n");
679     return E_NOTIMPL;
680 }
681
682 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
683         IMoniker **ppmon)
684 {
685     ok(0, "unexpected call\n");
686     return E_NOTIMPL;
687 }
688
689 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
690 {
691     CHECK_EXPECT(GetContainer);
692
693     ok(ppContainer != NULL, "ppContainer == NULL\n");
694     if(ppContainer)
695         *ppContainer = &OleContainer;
696
697     return S_OK;
698 }
699
700 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
701 {
702     CHECK_EXPECT(ShowObject);
703     return S_OK;
704 }
705
706 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
707 {
708     ok(0, "unexpected call\n");
709     return E_NOTIMPL;
710 }
711
712 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
713 {
714     ok(0, "unexpected call\n");
715     return E_NOTIMPL;
716 }
717
718 static const IOleClientSiteVtbl ClientSiteVtbl = {
719     ClientSite_QueryInterface,
720     ClientSite_AddRef,
721     ClientSite_Release,
722     ClientSite_SaveObject,
723     ClientSite_GetMoniker,
724     ClientSite_GetContainer,
725     ClientSite_ShowObject,
726     ClientSite_OnShowWindow,
727     ClientSite_RequestNewObjectLayout
728 };
729
730 static IOleClientSite ClientSite = { &ClientSiteVtbl };
731
732 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
733                                                      REFIID riid, void **ppv)
734 {
735     ok(0, "unexpected call\n");
736     return E_NOINTERFACE;
737 }
738
739 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
740 {
741     return 2;
742 }
743
744 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
745 {
746     return 1;
747 }
748
749 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
750 {
751     ok(0, "unexpected call\n");
752     return E_NOTIMPL;
753 }
754
755 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
756 {
757     CHECK_EXPECT(Frame_GetWindow);
758     ok(phwnd != NULL, "phwnd == NULL\n");
759     if(phwnd)
760         *phwnd = container_hwnd;
761     return S_OK;
762 }
763
764 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
765 {
766     ok(0, "unexpected call\n");
767     return E_NOTIMPL;
768 }
769
770 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
771 {
772     ok(0, "unexpected call\n");
773     return E_NOTIMPL;
774 }
775
776 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
777         LPCBORDERWIDTHS pborderwidths)
778 {
779     ok(0, "unexpected call\n");
780     return E_NOTIMPL;
781 }
782
783 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
784         LPCBORDERWIDTHS pborderwidths)
785 {
786     ok(0, "unexpected call\n");
787     return E_NOTIMPL;
788 }
789
790 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
791         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
792 {
793     CHECK_EXPECT(UIWindow_SetActiveObject);
794     ok(pActiveObject != NULL, "pActiveObject = NULL\n");
795     ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
796     return S_OK;
797 }
798
799 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
800         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
801 {
802     CHECK_EXPECT(Frame_SetActiveObject);
803     ok(pActiveObject != NULL, "pActiveObject = NULL\n");
804     ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
805     return S_OK;
806 }
807
808 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
809         LPOLEMENUGROUPWIDTHS lpMenuWidths)
810 {
811     ok(0, "unexpected call\n");
812     return E_NOTIMPL;
813 }
814
815 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
816         HOLEMENU holemenu, HWND hwndActiveObject)
817 {
818     CHECK_EXPECT(SetMenu);
819     ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
820     ok(holemenu == NULL, "holemenu=%p\n", holemenu);
821     ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
822        hwndActiveObject, shell_embedding_hwnd);
823     return S_OK;
824 }
825
826 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
827 {
828     ok(0, "unexpected call\n");
829     return E_NOTIMPL;
830 }
831
832 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
833 {
834     CHECK_EXPECT2(SetStatusText);
835     /* FIXME: Check pszStatusText */
836     return S_OK;
837 }
838
839 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
840 {
841     if(fEnable)
842         CHECK_EXPECT(EnableModeless_TRUE);
843     else
844         CHECK_EXPECT(EnableModeless_FALSE);
845     return S_OK;
846 }
847
848 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
849 {
850     ok(0, "unexpected call\n");
851     return E_NOTIMPL;
852 }
853
854 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
855     InPlaceUIWindow_QueryInterface,
856     InPlaceUIWindow_AddRef,
857     InPlaceUIWindow_Release,
858     InPlaceUIWindow_GetWindow,
859     InPlaceUIWindow_ContextSensitiveHelp,
860     InPlaceUIWindow_GetBorder,
861     InPlaceUIWindow_RequestBorderSpace,
862     InPlaceUIWindow_SetBorderSpace,
863     InPlaceUIWindow_SetActiveObject,
864 };
865
866 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
867
868 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
869     InPlaceUIWindow_QueryInterface,
870     InPlaceUIWindow_AddRef,
871     InPlaceUIWindow_Release,
872     InPlaceFrame_GetWindow,
873     InPlaceUIWindow_ContextSensitiveHelp,
874     InPlaceUIWindow_GetBorder,
875     InPlaceUIWindow_RequestBorderSpace,
876     InPlaceUIWindow_SetBorderSpace,
877     InPlaceFrame_SetActiveObject,
878     InPlaceFrame_InsertMenus,
879     InPlaceFrame_SetMenu,
880     InPlaceFrame_RemoveMenus,
881     InPlaceFrame_SetStatusText,
882     InPlaceFrame_EnableModeless,
883     InPlaceFrame_TranslateAccelerator
884 };
885
886 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
887
888 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
889 {
890     return QueryInterface(riid, ppv);
891 }
892
893 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
894 {
895     return 2;
896 }
897
898 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
899 {
900     return 1;
901 }
902
903 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
904 {
905     CHECK_EXPECT(Site_GetWindow);
906     ok(phwnd != NULL, "phwnd == NULL\n");
907     if(phwnd)
908         *phwnd = container_hwnd;
909     return S_OK;
910 }
911
912 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
913 {
914     ok(0, "unexpected call\n");
915     return E_NOTIMPL;
916 }
917
918 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
919 {
920     CHECK_EXPECT(CanInPlaceActivate);
921     return S_OK;
922 }
923
924 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
925 {
926     CHECK_EXPECT(OnInPlaceActivate);
927     return S_OK;
928 }
929
930 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
931 {
932     CHECK_EXPECT(OnUIActivate);
933     return S_OK;
934 }
935
936 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
937         IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
938         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
939 {
940     static const RECT pos_rect = {2,1,1002,901};
941     static const RECT clip_rect = {10,10,990,890};
942
943     CHECK_EXPECT(GetWindowContext);
944
945     ok(ppFrame != NULL, "ppFrame = NULL\n");
946     if(ppFrame)
947         *ppFrame = &InPlaceFrame;
948
949     ok(ppDoc != NULL, "ppDoc = NULL\n");
950     if(ppDoc)
951         *ppDoc = &InPlaceUIWindow;
952
953     ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
954     if(lprcPosRect)
955         memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
956
957     ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
958     if(lprcClipRect)
959         memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
960
961     ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
962     if(lpFrameInfo) {
963         lpFrameInfo->cb = sizeof(*lpFrameInfo);
964         lpFrameInfo->fMDIApp = FALSE;
965         lpFrameInfo->hwndFrame = container_hwnd;
966         lpFrameInfo->haccel = NULL;
967         lpFrameInfo->cAccelEntries = 0;
968     }
969
970     return S_OK;
971 }
972
973 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
974 {
975     ok(0, "unexpected call\n");
976     return E_NOTIMPL;
977 }
978
979 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
980 {
981     ok(0, "unexpected call\n");
982     return E_NOTIMPL;
983 }
984
985 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
986 {
987     ok(0, "unexpected call\n");
988     return E_NOTIMPL;
989 }
990
991 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
992 {
993     ok(0, "unexpected call\n");
994     return E_NOTIMPL;
995 }
996
997 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
998 {
999     ok(0, "unexpected call\n");
1000     return E_NOTIMPL;
1001 }
1002
1003 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1004 {
1005     ok(0, "unexpected call\n");
1006     return E_NOTIMPL;
1007 }
1008
1009 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1010                                                       BOOL *pNoRedraw, DWORD dwFlags)
1011 {
1012     ok(0, "unexpected call\n");
1013     return E_NOTIMPL;
1014 }
1015
1016 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1017                                                         BOOL fNoRedraw)
1018 {
1019     ok(0, "unexpected call\n");
1020     return E_NOTIMPL;
1021 }
1022
1023 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1024 {
1025     ok(0, "unexpected call\n");
1026     return S_OK;
1027 }
1028
1029 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1030     InPlaceSite_QueryInterface,
1031     InPlaceSite_AddRef,
1032     InPlaceSite_Release,
1033     InPlaceSite_GetWindow,
1034     InPlaceSite_ContextSensitiveHelp,
1035     InPlaceSite_CanInPlaceActivate,
1036     InPlaceSite_OnInPlaceActivate,
1037     InPlaceSite_OnUIActivate,
1038     InPlaceSite_GetWindowContext,
1039     InPlaceSite_Scroll,
1040     InPlaceSite_OnUIDeactivate,
1041     InPlaceSite_OnInPlaceDeactivate,
1042     InPlaceSite_DiscardUndoState,
1043     InPlaceSite_DeactivateAndUndo,
1044     InPlaceSite_OnPosRectChange,
1045     InPlaceSite_OnInPlaceActivateEx,
1046     InPlaceSite_OnInPlaceDeactivateEx,
1047     InPlaceSite_RequestUIActivate
1048 };
1049
1050 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1051
1052 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1053 {
1054     return QueryInterface(riid, ppv);
1055 }
1056
1057 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1058 {
1059     return 2;
1060 }
1061
1062 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1063 {
1064     return 1;
1065 }
1066
1067 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1068         IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1069 {
1070     ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1071     return S_FALSE;
1072 }
1073
1074 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1075 {
1076     CHECK_EXPECT(GetHostInfo);
1077     ok(pInfo != NULL, "pInfo=NULL\n");
1078     if(pInfo) {
1079         ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1080         ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1081         ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1082         ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1083         ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1084     }
1085     return E_FAIL;
1086 }
1087
1088 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1089         IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1090         IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1091 {
1092     ok(0, "unexpected call\n");
1093     return E_NOTIMPL;
1094 }
1095
1096 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1097 {
1098     ok(0, "unexpected call\n");
1099     return E_NOTIMPL;
1100 }
1101
1102 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1103 {
1104     CHECK_EXPECT(UpdateUI);
1105     return E_NOTIMPL;
1106 }
1107
1108 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1109 {
1110     ok(0, "unexpected call\n");
1111     return E_NOTIMPL;
1112 }
1113
1114 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1115 {
1116     ok(0, "unexpected call\n");
1117     return E_NOTIMPL;
1118 }
1119
1120 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1121 {
1122     ok(0, "unexpected call\n");
1123     return E_NOTIMPL;
1124 }
1125
1126 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1127         IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1128 {
1129     ok(0, "unexpected call\n");
1130     return E_NOTIMPL;
1131 }
1132
1133 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1134         const GUID *pguidCmdGroup, DWORD nCmdID)
1135 {
1136     ok(0, "unexpected call\n");
1137     return E_NOTIMPL;
1138 }
1139
1140 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1141         LPOLESTR *pchKey, DWORD dw)
1142 {
1143     CHECK_EXPECT(GetOptionKeyPath);
1144     ok(pchKey != NULL, "pchKey==NULL\n");
1145     if(pchKey)
1146         ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1147     ok(!dw, "dw=%x\n", dw);
1148     return E_NOTIMPL;
1149 }
1150
1151 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1152         IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1153 {
1154     ok(0, "unexpected call\n");
1155     return E_NOTIMPL;
1156 }
1157
1158 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1159 {
1160     ok(0, "unexpected call\n");
1161     return E_NOTIMPL;
1162 }
1163
1164 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1165         OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1166 {
1167     ok(0, "unexpected call\n");
1168     return E_NOTIMPL;
1169 }
1170
1171 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1172         IDataObject **ppPORet)
1173 {
1174     ok(0, "unexpected call\n");
1175     return E_NOTIMPL;
1176 }
1177
1178 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1179         LPOLESTR *pchKey, DWORD dw)
1180 {
1181     CHECK_EXPECT(GetOverridesKeyPath);
1182     ok(pchKey != NULL, "pchKey==NULL\n");
1183     if(pchKey)
1184         ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1185     ok(!dw, "dw=%x\n", dw);
1186     return E_NOTIMPL;
1187 }
1188
1189 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1190     DocHostUIHandler_QueryInterface,
1191     DocHostUIHandler_AddRef,
1192     DocHostUIHandler_Release,
1193     DocHostUIHandler_ShowContextMenu,
1194     DocHostUIHandler_GetHostInfo,
1195     DocHostUIHandler_ShowUI,
1196     DocHostUIHandler_HideUI,
1197     DocHostUIHandler_UpdateUI,
1198     DocHostUIHandler_EnableModeless,
1199     DocHostUIHandler_OnDocWindowActivate,
1200     DocHostUIHandler_OnFrameWindowActivate,
1201     DocHostUIHandler_ResizeBorder,
1202     DocHostUIHandler_TranslateAccelerator,
1203     DocHostUIHandler_GetOptionKeyPath,
1204     DocHostUIHandler_GetDropTarget,
1205     DocHostUIHandler_GetExternal,
1206     DocHostUIHandler_TranslateUrl,
1207     DocHostUIHandler_FilterDataObject,
1208     DocHostUIHandler_GetOverrideKeyPath
1209 };
1210
1211 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1212
1213 static HRESULT QueryInterface(REFIID riid, void **ppv)
1214 {
1215     *ppv = NULL;
1216
1217     if(IsEqualGUID(&IID_IUnknown, riid)
1218             || IsEqualGUID(&IID_IOleClientSite, riid))
1219         *ppv = &ClientSite;
1220     else if(IsEqualGUID(&IID_IOleWindow, riid)
1221             || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1222             || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1223         *ppv = &InPlaceSite;
1224     else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1225             || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1226         *ppv = &DocHostUIHandler;
1227     else if(IsEqualGUID(&IID_IDispatch, riid))
1228         *ppv = &Dispatch;
1229
1230     if(*ppv)
1231         return S_OK;
1232
1233     return E_NOINTERFACE;
1234 }
1235
1236 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1237 {
1238     return DefWindowProcW(hwnd, msg, wParam, lParam);
1239 }
1240
1241 static HWND create_container_window(void)
1242 {
1243     static const WCHAR wszWebBrowserContainer[] =
1244         {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1245     static WNDCLASSEXW wndclass = {
1246         sizeof(WNDCLASSEXW),
1247         0,
1248         wnd_proc,
1249         0, 0, NULL, NULL, NULL, NULL, NULL,
1250         wszWebBrowserContainer,
1251         NULL
1252     };
1253
1254     RegisterClassExW(&wndclass);
1255     return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1256             WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1257             CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1258 }
1259
1260 static void test_DoVerb(IUnknown *unk)
1261 {
1262     IOleObject *oleobj;
1263     RECT rect = {0,0,1000,1000};
1264     HRESULT hres;
1265
1266     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1267     ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1268     if(FAILED(hres))
1269         return;
1270
1271     SET_EXPECT(CanInPlaceActivate);
1272     SET_EXPECT(Site_GetWindow);
1273     SET_EXPECT(OnInPlaceActivate);
1274     SET_EXPECT(GetWindowContext);
1275     SET_EXPECT(ShowObject);
1276     SET_EXPECT(GetContainer);
1277     SET_EXPECT(Frame_GetWindow);
1278     SET_EXPECT(OnUIActivate);
1279     SET_EXPECT(Frame_SetActiveObject);
1280     SET_EXPECT(UIWindow_SetActiveObject);
1281     SET_EXPECT(SetMenu);
1282
1283     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1284                              0, (HWND)0xdeadbeef, &rect);
1285     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1286
1287     CHECK_CALLED(CanInPlaceActivate);
1288     CHECK_CALLED(Site_GetWindow);
1289     CHECK_CALLED(OnInPlaceActivate);
1290     CHECK_CALLED(GetWindowContext);
1291     CHECK_CALLED(ShowObject);
1292     CHECK_CALLED(GetContainer);
1293     CHECK_CALLED(Frame_GetWindow);
1294     CHECK_CALLED(OnUIActivate);
1295     CHECK_CALLED(Frame_SetActiveObject);
1296     CHECK_CALLED(UIWindow_SetActiveObject);
1297     CHECK_CALLED(SetMenu);
1298
1299     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1300                            0, (HWND)0xdeadbeef, &rect);
1301     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1302
1303     IOleObject_Release(oleobj);
1304 }
1305
1306 static void test_GetMiscStatus(IOleObject *oleobj)
1307 {
1308     DWORD st, i;
1309     HRESULT hres;
1310
1311     for(i=0; i<10; i++) {
1312         st = 0xdeadbeef;
1313         hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1314         ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1315         ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1316                   |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1317            "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1318            "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1319     }
1320 }
1321
1322 static void test_SetHostNames(IOleObject *oleobj)
1323 {
1324     HRESULT hres;
1325
1326     static const WCHAR test_appW[] =  {'t','e','s','t',' ','a','p','p',0};
1327
1328     hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1329     ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1330 }
1331
1332 static void test_ClientSite(IUnknown *unk, IOleClientSite *client)
1333 {
1334     IOleObject *oleobj;
1335     IOleInPlaceObject *inplace;
1336     HWND hwnd;
1337     HRESULT hres;
1338
1339     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1340     ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1341     if(FAILED(hres))
1342         return;
1343
1344     test_GetMiscStatus(oleobj);
1345     test_SetHostNames(oleobj);
1346
1347     hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1348     ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1349     if(FAILED(hres)) {
1350         IOleObject_Release(oleobj);
1351         return;
1352     }
1353
1354     hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1355     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1356     ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1357
1358     if(client) {
1359         SET_EXPECT(GetContainer);
1360         SET_EXPECT(Site_GetWindow);
1361         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1362         SET_EXPECT(Invoke_AMBIENT_SILENT);
1363     }else {
1364         SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1365         SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1366         SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1367     }
1368
1369     hres = IOleObject_SetClientSite(oleobj, client);
1370     ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1371
1372     if(client) {
1373         CHECK_CALLED(GetContainer);
1374         CHECK_CALLED(Site_GetWindow);
1375         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1376         CHECK_CALLED(Invoke_AMBIENT_SILENT);
1377     }else {
1378         todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1379         todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1380         todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1381    }
1382
1383     hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1384     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1385     ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1386
1387     shell_embedding_hwnd = hwnd;
1388
1389     test_SetHostNames(oleobj);
1390
1391     IOleInPlaceObject_Release(inplace);
1392     IOleObject_Release(oleobj);
1393 }
1394
1395 static void test_ClassInfo(IUnknown *unk)
1396 {
1397     IProvideClassInfo2 *class_info;
1398     GUID guid;
1399     HRESULT hres;
1400
1401     hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1402     ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo)  failed: %08x\n", hres);
1403     if(FAILED(hres))
1404         return;
1405
1406     hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1407     ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1408     ok(IsEqualGUID(&DIID_DWebBrowserEvents2, &guid), "wrong guid\n");
1409
1410     hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1411     ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1412     ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1413
1414     hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1415     ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1416     ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1417
1418     hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1419     ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1420
1421     hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1422     ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1423
1424     IProvideClassInfo2_Release(class_info);
1425 }
1426
1427 static void test_ie_funcs(IUnknown *unk)
1428 {
1429     IWebBrowser2 *wb;
1430     IDispatch *disp;
1431     VARIANT_BOOL b;
1432     int i;
1433     long hwnd;
1434     HRESULT hres;
1435
1436     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
1437     ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
1438     if(FAILED(hres))
1439         return;
1440
1441     /* HWND */
1442
1443     hwnd = 0xdeadbeef;
1444     hres = IWebBrowser2_get_HWND(wb, &hwnd);
1445     ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
1446     ok(hwnd == 0, "unexpected hwnd %lx\n", hwnd);
1447
1448     /* MenuBar */
1449
1450     hres = IWebBrowser2_get_MenuBar(wb, &b);
1451     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1452     ok(b == VARIANT_TRUE, "b=%x\n", b);
1453
1454     SET_EXPECT(Invoke_ONMENUBAR);
1455     hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
1456     ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1457     CHECK_CALLED(Invoke_ONMENUBAR);
1458
1459     hres = IWebBrowser2_get_MenuBar(wb, &b);
1460     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1461     ok(b == VARIANT_FALSE, "b=%x\n", b);
1462
1463     SET_EXPECT(Invoke_ONMENUBAR);
1464     hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
1465     ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1466     CHECK_CALLED(Invoke_ONMENUBAR);
1467
1468     hres = IWebBrowser2_get_MenuBar(wb, &b);
1469     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1470     ok(b == VARIANT_TRUE, "b=%x\n", b);
1471
1472     /* AddressBar */
1473
1474     hres = IWebBrowser2_get_AddressBar(wb, &b);
1475     ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1476     ok(b == VARIANT_TRUE, "b=%x\n", b);
1477
1478     SET_EXPECT(Invoke_ONADDRESSBAR);
1479     hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
1480     ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1481     CHECK_CALLED(Invoke_ONADDRESSBAR);
1482
1483     hres = IWebBrowser2_get_AddressBar(wb, &b);
1484     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1485     ok(b == VARIANT_FALSE, "b=%x\n", b);
1486
1487     SET_EXPECT(Invoke_ONADDRESSBAR);
1488     hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
1489     ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1490     CHECK_CALLED(Invoke_ONADDRESSBAR);
1491
1492     hres = IWebBrowser2_get_AddressBar(wb, &b);
1493     ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1494     ok(b == VARIANT_TRUE, "b=%x\n", b);
1495
1496     SET_EXPECT(Invoke_ONADDRESSBAR);
1497     hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
1498     ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1499     CHECK_CALLED(Invoke_ONADDRESSBAR);
1500
1501     /* StatusBar */
1502
1503     hres = IWebBrowser2_get_StatusBar(wb, &b);
1504     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1505     ok(b == VARIANT_TRUE, "b=%x\n", b);
1506
1507     SET_EXPECT(Invoke_ONSTATUSBAR);
1508     hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
1509     ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1510     CHECK_CALLED(Invoke_ONSTATUSBAR);
1511
1512     hres = IWebBrowser2_get_StatusBar(wb, &b);
1513     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1514     ok(b == VARIANT_TRUE, "b=%x\n", b);
1515
1516     SET_EXPECT(Invoke_ONSTATUSBAR);
1517     hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
1518     ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1519     CHECK_CALLED(Invoke_ONSTATUSBAR);
1520
1521     hres = IWebBrowser2_get_StatusBar(wb, &b);
1522     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1523     ok(b == VARIANT_FALSE, "b=%x\n", b);
1524
1525     SET_EXPECT(Invoke_ONSTATUSBAR);
1526     hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
1527     ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1528     CHECK_CALLED(Invoke_ONSTATUSBAR);
1529
1530     hres = IWebBrowser2_get_StatusBar(wb, &b);
1531     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1532     ok(b == VARIANT_TRUE, "b=%x\n", b);
1533
1534     /* ToolBar */
1535
1536     hres = IWebBrowser2_get_ToolBar(wb, &i);
1537     ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1538     ok(i, "i=%x\n", i);
1539
1540     SET_EXPECT(Invoke_ONTOOLBAR);
1541     hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
1542     ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1543     CHECK_CALLED(Invoke_ONTOOLBAR);
1544
1545     hres = IWebBrowser2_get_ToolBar(wb, &i);
1546     ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1547     ok(i == VARIANT_FALSE, "b=%x\n", i);
1548
1549     SET_EXPECT(Invoke_ONTOOLBAR);
1550     hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
1551     ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1552     CHECK_CALLED(Invoke_ONTOOLBAR);
1553
1554     hres = IWebBrowser2_get_ToolBar(wb, &i);
1555     ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1556     ok(i, "i=%x\n", i);
1557
1558     SET_EXPECT(Invoke_ONTOOLBAR);
1559     hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
1560     ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1561     CHECK_CALLED(Invoke_ONTOOLBAR);
1562
1563     /* FullScreen */
1564
1565     hres = IWebBrowser2_get_FullScreen(wb, &b);
1566     ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1567     ok(b == VARIANT_FALSE, "b=%x\n", b);
1568
1569     SET_EXPECT(Invoke_ONFULLSCREEN);
1570     hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
1571     ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1572     CHECK_CALLED(Invoke_ONFULLSCREEN);
1573
1574     hres = IWebBrowser2_get_FullScreen(wb, &b);
1575     ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1576     ok(b == VARIANT_TRUE, "b=%x\n", b);
1577
1578     SET_EXPECT(Invoke_ONFULLSCREEN);
1579     hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
1580     ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1581     CHECK_CALLED(Invoke_ONFULLSCREEN);
1582
1583     hres = IWebBrowser2_get_FullScreen(wb, &b);
1584     ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1585     ok(b == VARIANT_TRUE, "b=%x\n", b);
1586
1587     SET_EXPECT(Invoke_ONFULLSCREEN);
1588     hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
1589     ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1590     CHECK_CALLED(Invoke_ONFULLSCREEN);
1591
1592     /* TheaterMode */
1593
1594     hres = IWebBrowser2_get_TheaterMode(wb, &b);
1595     ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1596     ok(b == VARIANT_FALSE, "b=%x\n", b);
1597
1598     SET_EXPECT(Invoke_ONTHEATERMODE);
1599     hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
1600     ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1601     CHECK_CALLED(Invoke_ONTHEATERMODE);
1602
1603     hres = IWebBrowser2_get_TheaterMode(wb, &b);
1604     ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1605     ok(b == VARIANT_TRUE, "b=%x\n", b);
1606
1607     SET_EXPECT(Invoke_ONTHEATERMODE);
1608     hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
1609     ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1610     CHECK_CALLED(Invoke_ONTHEATERMODE);
1611
1612     hres = IWebBrowser2_get_TheaterMode(wb, &b);
1613     ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1614     ok(b == VARIANT_TRUE, "b=%x\n", b);
1615
1616     SET_EXPECT(Invoke_ONTHEATERMODE);
1617     hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
1618     ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1619     CHECK_CALLED(Invoke_ONTHEATERMODE);
1620
1621     /* Resizable */
1622
1623     b = 0x100;
1624     hres = IWebBrowser2_get_Resizable(wb, &b);
1625     ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
1626     ok(b == 0x100, "b=%x\n", b);
1627
1628     SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
1629     hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
1630     ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
1631     CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
1632
1633     SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
1634     hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
1635     ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
1636     CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
1637
1638     hres = IWebBrowser2_get_Resizable(wb, &b);
1639     ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
1640     ok(b == 0x100, "b=%x\n", b);
1641
1642     /* Application */
1643
1644     disp = NULL;
1645     hres = IWebBrowser2_get_Application(wb, &disp);
1646     ok(hres == S_OK, "get_Application failed: %08x\n", hres);
1647     ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
1648     if(disp)
1649         IDispatch_Release(disp);
1650
1651     hres = IWebBrowser2_get_Application(wb, NULL);
1652     ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
1653
1654     /* Quit */
1655
1656     hres = IWebBrowser2_Quit(wb);
1657     ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
1658
1659     IWebBrowser2_Release(wb);
1660 }
1661
1662 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1663 {
1664     VARIANT_BOOL b;
1665     HRESULT hres;
1666
1667     b = 100;
1668     hres = IWebBrowser2_get_Silent(wb, &b);
1669     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1670     ok(b == VARIANT_FALSE, "b=%x\n", b);
1671
1672     hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
1673     ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1674
1675     b = 100;
1676     hres = IWebBrowser2_get_Silent(wb, &b);
1677     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1678     ok(b == VARIANT_TRUE, "b=%x\n", b);
1679
1680     hres = IWebBrowser2_put_Silent(wb, 100);
1681     ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1682
1683     b = 100;
1684     hres = IWebBrowser2_get_Silent(wb, &b);
1685     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1686     ok(b == VARIANT_TRUE, "b=%x\n", b);
1687
1688     hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
1689     ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1690
1691     b = 100;
1692     hres = IWebBrowser2_get_Silent(wb, &b);
1693     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1694     ok(b == VARIANT_FALSE, "b=%x\n", b);
1695
1696     if(is_clientsite) {
1697         hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
1698         ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1699
1700         SET_EXPECT(Invoke_AMBIENT_SILENT);
1701     }
1702
1703     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
1704     ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1705
1706     if(is_clientsite)
1707         CHECK_CALLED(Invoke_AMBIENT_SILENT);
1708
1709     b = 100;
1710     hres = IWebBrowser2_get_Silent(wb, &b);
1711     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1712     ok(b == VARIANT_FALSE, "b=%x\n", b);
1713 }
1714
1715 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1716 {
1717     VARIANT_BOOL b;
1718     HRESULT hres;
1719
1720     b = 100;
1721     hres = IWebBrowser2_get_Offline(wb, &b);
1722     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1723     ok(b == VARIANT_FALSE, "b=%x\n", b);
1724
1725     hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
1726     ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1727
1728     b = 100;
1729     hres = IWebBrowser2_get_Offline(wb, &b);
1730     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1731     ok(b == VARIANT_TRUE, "b=%x\n", b);
1732
1733     hres = IWebBrowser2_put_Offline(wb, 100);
1734     ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1735
1736     b = 100;
1737     hres = IWebBrowser2_get_Offline(wb, &b);
1738     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1739     ok(b == VARIANT_TRUE, "b=%x\n", b);
1740
1741     hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
1742     ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1743
1744     b = 100;
1745     hres = IWebBrowser2_get_Offline(wb, &b);
1746     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1747     ok(b == VARIANT_FALSE, "b=%x\n", b);
1748
1749     if(is_clientsite) {
1750         hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
1751         ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1752
1753         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1754     }
1755
1756     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
1757     ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1758
1759     if(is_clientsite)
1760         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1761
1762     b = 100;
1763     hres = IWebBrowser2_get_Offline(wb, &b);
1764     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1765     ok(b == VARIANT_FALSE, "b=%x\n", b);
1766 }
1767
1768 static void test_wb_funcs(IUnknown *unk, BOOL is_clientsite)
1769 {
1770     IWebBrowser2 *wb;
1771     IOleControl *control;
1772     HRESULT hres;
1773
1774     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
1775     ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
1776
1777     hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
1778     ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
1779
1780     test_Silent(wb, control, is_clientsite);
1781     test_Offline(wb, control, is_clientsite);
1782
1783     IWebBrowser_Release(wb);
1784     IOleControl_Release(control);
1785 }
1786
1787 static void test_GetControlInfo(IUnknown *unk)
1788 {
1789     IOleControl *control;
1790     CONTROLINFO info;
1791     HRESULT hres;
1792
1793     hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
1794     ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
1795     if(FAILED(hres))
1796         return;
1797
1798     hres = IOleControl_GetControlInfo(control, &info);
1799     ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
1800     hres = IOleControl_GetControlInfo(control, NULL);
1801     ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
1802
1803     IOleControl_Release(control);
1804 }
1805
1806 static void test_Extent(IUnknown *unk)
1807 {
1808     IOleObject *oleobj;
1809     SIZE size;
1810     HRESULT hres;
1811
1812     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1813     ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
1814     if(FAILED(hres))
1815         return;
1816
1817     size.cx = size.cy = 0xdeadbeef;
1818     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
1819     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1820     ok(size.cx == 1323 && size.cy == 529, "size = {%d %d}\n", size.cx, size.cy);
1821
1822     size.cx = 800;
1823     size.cy = 700;
1824     hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
1825     ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
1826
1827     size.cx = size.cy = 0xdeadbeef;
1828     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
1829     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1830     ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
1831
1832     size.cx = size.cy = 0xdeadbeef;
1833     hres = IOleObject_GetExtent(oleobj, 0, &size);
1834     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1835     ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
1836
1837     size.cx = 900;
1838     size.cy = 800;
1839     hres = IOleObject_SetExtent(oleobj, 0, &size);
1840     ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
1841
1842     size.cx = size.cy = 0xdeadbeef;
1843     hres = IOleObject_GetExtent(oleobj, 0, &size);
1844     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1845     ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
1846
1847     size.cx = size.cy = 0xdeadbeef;
1848     hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
1849     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1850     ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
1851
1852     size.cx = 1000;
1853     size.cy = 900;
1854     hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
1855     ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
1856
1857     size.cx = size.cy = 0xdeadbeef;
1858     hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
1859     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1860     ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
1861
1862     size.cx = size.cy = 0xdeadbeef;
1863     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
1864     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
1865     ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
1866
1867     IOleObject_Release(oleobj);
1868 }
1869
1870 static void test_ConnectionPoint(IUnknown *unk, BOOL init)
1871 {
1872     IConnectionPointContainer *container;
1873     IConnectionPoint *point;
1874     HRESULT hres;
1875
1876     static DWORD dw = 100;
1877
1878     hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
1879     ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
1880     if(FAILED(hres))
1881         return;
1882
1883     hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
1884     IConnectionPointContainer_Release(container);
1885     ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
1886     if(FAILED(hres))
1887         return;
1888
1889     if(init) {
1890         hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
1891         ok(hres == S_OK, "Advise failed: %08x\n", hres);
1892         ok(dw == 1, "dw=%d, expected 1\n", dw);
1893     }else {
1894         hres = IConnectionPoint_Unadvise(point, dw);
1895         ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
1896     }
1897
1898     IConnectionPoint_Release(point);
1899 }
1900
1901 static void test_Navigate2(IUnknown *unk)
1902 {
1903     IWebBrowser2 *webbrowser;
1904     VARIANT url;
1905     HRESULT hres;
1906
1907     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&webbrowser);
1908     ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
1909     if(FAILED(hres))
1910         return;
1911
1912     test_LocationURL(unk, emptyW);
1913
1914     V_VT(&url) = VT_BSTR;
1915     V_BSTR(&url) = SysAllocString(about_blankW);
1916
1917     SET_EXPECT(Invoke_AMBIENT_USERMODE);
1918     SET_EXPECT(Invoke_PROPERTYCHANGE);
1919     SET_EXPECT(Invoke_BEFORENAVIGATE2);
1920     SET_EXPECT(Invoke_DOWNLOADBEGIN);
1921     SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
1922     SET_EXPECT(EnableModeless_FALSE);
1923     SET_EXPECT(Invoke_STATUSTEXTCHANGE);
1924     SET_EXPECT(SetStatusText);
1925     SET_EXPECT(GetHostInfo);
1926     SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1927     SET_EXPECT(Invoke_AMBIENT_USERAGENT);
1928     SET_EXPECT(Invoke_AMBIENT_PALETTE);
1929     SET_EXPECT(GetOptionKeyPath);
1930     SET_EXPECT(GetOverridesKeyPath);
1931     SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
1932     SET_EXPECT(Exec_SETPROGRESSMAX);
1933     SET_EXPECT(Exec_SETPROGRESSPOS);
1934     SET_EXPECT(Invoke_SETSECURELOCKICON);
1935     SET_EXPECT(Invoke_FILEDOWNLOAD);
1936     SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1937     SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1938     SET_EXPECT(EnableModeless_TRUE);
1939
1940     hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
1941     ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
1942
1943     CHECK_CALLED(Invoke_AMBIENT_USERMODE);
1944     todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
1945     CHECK_CALLED(Invoke_BEFORENAVIGATE2);
1946     todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
1947     todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
1948     CHECK_CALLED(EnableModeless_FALSE);
1949     CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
1950     CHECK_CALLED(SetStatusText);
1951     CHECK_CALLED(GetHostInfo);
1952     CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
1953     CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
1954     CHECK_CALLED(Invoke_AMBIENT_PALETTE);
1955     CHECK_CALLED(GetOptionKeyPath);
1956     CHECK_CALLED(GetOverridesKeyPath);
1957     todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
1958     todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
1959     todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
1960     todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
1961     todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
1962     todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1963     todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1964     CHECK_CALLED(EnableModeless_TRUE);
1965
1966     VariantClear(&url);
1967     IWebBrowser2_Release(webbrowser);
1968 }
1969
1970 static void test_QueryInterface(IUnknown *unk)
1971 {
1972     IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
1973     IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
1974     IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
1975     IOleInPlaceSite *inplace = (void*)0xdeadbeef;
1976     IOleCache *cache = (void*)0xdeadbeef;
1977     IObjectWithSite *site = (void*)0xdeadbeef;
1978     HRESULT hres;
1979
1980     hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
1981     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1982     ok(qa == NULL, "qa=%p, ezpected NULL\n", qa);
1983
1984     hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
1985     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1986     ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable);
1987
1988     hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
1989     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1990     ok(propbrowse == NULL, "propbrowse=%p, ezpected NULL\n", runnable);
1991
1992     hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
1993     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1994     ok(cache == NULL, "cache=%p, ezpected NULL\n", runnable);
1995
1996     hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
1997     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
1998     ok(inplace == NULL, "inplace=%p, ezpected NULL\n", runnable);
1999
2000     hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2001     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2002     ok(site == NULL, "inplace=%p, ezpected NULL\n", runnable);
2003 }
2004
2005 static void test_WebBrowser(void)
2006 {
2007     IUnknown *unk = NULL;
2008     ULONG ref;
2009     HRESULT hres;
2010
2011     hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2012             &IID_IUnknown, (void**)&unk);
2013     ok(hres == S_OK, "CoCreateInterface failed: %08x\n", hres);
2014     if(FAILED(hres))
2015         return;
2016
2017     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2018     ok(hres == S_OK, "Could not get IWebBrowser2 iface: %08x\n", hres);
2019
2020     test_QueryInterface(unk);
2021     test_ClassInfo(unk);
2022     test_LocationURL(unk, emptyW);
2023     test_ConnectionPoint(unk, TRUE);
2024     test_ClientSite(unk, &ClientSite);
2025     test_Extent(unk);
2026     test_wb_funcs(unk, TRUE);
2027     test_DoVerb(unk);
2028     test_Navigate2(unk);
2029     test_ClientSite(unk, NULL);
2030     test_ie_funcs(unk);
2031     test_GetControlInfo(unk);
2032     test_wb_funcs(unk, FALSE);
2033     test_ConnectionPoint(unk, FALSE);
2034
2035     IWebBrowser2_Release(wb);
2036     ref = IUnknown_Release(unk);
2037     ok(ref == 0, "ref=%d, expected 0\n", ref);
2038 }
2039
2040 static void gecko_installer_workaround(BOOL disable)
2041 {
2042     HKEY hkey;
2043     DWORD res;
2044
2045     static BOOL has_url = FALSE;
2046     static char url[2048];
2047
2048     if(!disable && !has_url)
2049         return;
2050
2051     res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2052     if(res != ERROR_SUCCESS)
2053         return;
2054
2055     if(disable) {
2056         DWORD type, size = sizeof(url);
2057
2058         res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2059         if(res == ERROR_SUCCESS && type == REG_SZ)
2060             has_url = TRUE;
2061
2062         RegDeleteValue(hkey, "GeckoUrl");
2063     }else {
2064         RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2065     }
2066
2067     RegCloseKey(hkey);
2068 }
2069
2070 START_TEST(webbrowser)
2071 {
2072     gecko_installer_workaround(TRUE);
2073
2074     container_hwnd = create_container_window();
2075
2076     OleInitialize(NULL);
2077
2078     test_WebBrowser();
2079
2080     OleUninitialize();
2081
2082     gecko_installer_workaround(FALSE);
2083 }