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