user32: Use the stored color and mask bitmaps instead of the raw bits in GetIconInfo.
[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 "mshtmcid.h"
34 #include "mshtml.h"
35 #include "idispids.h"
36 #include "olectl.h"
37 #include "mshtmdid.h"
38 #include "shobjidl.h"
39 #include "shlguid.h"
40 #include "exdispid.h"
41 #include "mimeinfo.h"
42
43 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
45
46 #define DEFINE_EXPECT(func) \
47     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
48
49 #define SET_EXPECT(func) \
50     expect_ ## func = TRUE
51
52 #define CHECK_EXPECT2(func) \
53     do { \
54         ok(expect_ ##func, "unexpected call " #func "\n"); \
55         called_ ## func = TRUE; \
56     }while(0)
57
58 #define CHECK_EXPECT(func) \
59     do { \
60         CHECK_EXPECT2(func); \
61         expect_ ## func = FALSE; \
62     }while(0)
63
64 #define CHECK_CALLED(func) \
65     do { \
66         ok(called_ ## func, "expected " #func "\n"); \
67         expect_ ## func = called_ ## func = FALSE; \
68     }while(0)
69
70 #define CHECK_CALLED_BROKEN(func) \
71     do { \
72         ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
73         expect_ ## func = called_ ## func = FALSE; \
74     }while(0)
75
76 #define CLEAR_CALLED(func) \
77     expect_ ## func = called_ ## func = FALSE
78
79 DEFINE_EXPECT(GetContainer);
80 DEFINE_EXPECT(Site_GetWindow);
81 DEFINE_EXPECT(ShowObject);
82 DEFINE_EXPECT(CanInPlaceActivate);
83 DEFINE_EXPECT(OnInPlaceActivate);
84 DEFINE_EXPECT(OnUIActivate);
85 DEFINE_EXPECT(GetWindowContext);
86 DEFINE_EXPECT(Frame_GetWindow);
87 DEFINE_EXPECT(Frame_SetActiveObject);
88 DEFINE_EXPECT(UIWindow_SetActiveObject);
89 DEFINE_EXPECT(SetMenu);
90 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
91 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
92 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
93 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
94 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
95 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
96 DEFINE_EXPECT(Invoke_STATUSTEXTCHANGE);
97 DEFINE_EXPECT(Invoke_PROPERTYCHANGE);
98 DEFINE_EXPECT(Invoke_DOWNLOADBEGIN);
99 DEFINE_EXPECT(Invoke_BEFORENAVIGATE2);
100 DEFINE_EXPECT(Invoke_SETSECURELOCKICON);
101 DEFINE_EXPECT(Invoke_FILEDOWNLOAD);
102 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE);
103 DEFINE_EXPECT(Invoke_DOWNLOADCOMPLETE);
104 DEFINE_EXPECT(Invoke_ONMENUBAR);
105 DEFINE_EXPECT(Invoke_ONADDRESSBAR);
106 DEFINE_EXPECT(Invoke_ONSTATUSBAR);
107 DEFINE_EXPECT(Invoke_ONTOOLBAR);
108 DEFINE_EXPECT(Invoke_ONFULLSCREEN);
109 DEFINE_EXPECT(Invoke_ONTHEATERMODE);
110 DEFINE_EXPECT(Invoke_WINDOWSETRESIZABLE);
111 DEFINE_EXPECT(Invoke_TITLECHANGE);
112 DEFINE_EXPECT(Invoke_NAVIGATECOMPLETE2);
113 DEFINE_EXPECT(Invoke_PROGRESSCHANGE);
114 DEFINE_EXPECT(Invoke_DOCUMENTCOMPLETE);
115 DEFINE_EXPECT(Invoke_282);
116 DEFINE_EXPECT(EnableModeless_TRUE);
117 DEFINE_EXPECT(EnableModeless_FALSE);
118 DEFINE_EXPECT(GetHostInfo);
119 DEFINE_EXPECT(GetOptionKeyPath);
120 DEFINE_EXPECT(GetOverridesKeyPath);
121 DEFINE_EXPECT(SetStatusText);
122 DEFINE_EXPECT(UpdateUI);
123 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
124 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
125 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
126 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
127 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
128 DEFINE_EXPECT(QueryStatus_STOP);
129 DEFINE_EXPECT(DocHost_EnableModeless_TRUE);
130 DEFINE_EXPECT(DocHost_EnableModeless_FALSE);
131 DEFINE_EXPECT(GetDropTarget);
132 DEFINE_EXPECT(TranslateUrl);
133
134 static const WCHAR wszItem[] = {'i','t','e','m',0};
135 static const WCHAR emptyW[] = {0};
136
137 static VARIANT_BOOL exvb;
138 static IWebBrowser2 *wb;
139
140 static HWND container_hwnd, shell_embedding_hwnd;
141 static BOOL is_downloading, is_first_load;
142 static const char *current_url;
143
144 #define DWL_EXPECT_BEFORE_NAVIGATE  0x01
145 #define DWL_FROM_PUT_HREF           0x02
146
147 static DWORD dwl_flags;
148
149 static int strcmp_wa(LPCWSTR strw, const char *stra)
150 {
151     CHAR buf[512];
152     WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
153     return lstrcmpA(stra, buf);
154 }
155
156 static const char *debugstr_guid(REFIID riid)
157 {
158     static char buf[50];
159
160     sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
161             riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
162             riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
163             riid->Data4[5], riid->Data4[6], riid->Data4[7]);
164
165     return buf;
166 }
167
168 static BSTR a2bstr(const char *str)
169 {
170     BSTR ret;
171     int len;
172
173     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
174     ret = SysAllocStringLen(NULL, len);
175     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
176
177     return ret;
178 }
179
180 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
181 static void _test_LocationURL(unsigned line, IUnknown *unk, const char *exurl)
182 {
183     IWebBrowser2 *wb;
184     BSTR url = (void*)0xdeadbeef;
185     HRESULT hres;
186
187     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
188     ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
189     if(FAILED(hres))
190         return;
191
192     hres = IWebBrowser2_get_LocationURL(wb, &url);
193     ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
194     ok_(__FILE__,line) (!strcmp_wa(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
195
196     SysFreeString(url);
197     IWebBrowser2_Release(wb);
198 }
199
200 #define test_ready_state(ex) _test_ready_state(__LINE__,ex);
201 static void _test_ready_state(unsigned line, READYSTATE exstate)
202 {
203     READYSTATE state;
204     HRESULT hres;
205
206     hres = IWebBrowser2_get_ReadyState(wb, &state);
207     ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
208     ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
209 }
210
211 static HRESULT QueryInterface(REFIID,void**);
212
213 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
214         REFIID riid, void **ppv)
215 {
216     ok(0, "unexpected call\n");
217     return E_NOINTERFACE;
218 }
219
220 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
221 {
222     return 2;
223 }
224
225 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
226 {
227     return 1;
228 }
229
230 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
231         ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
232 {
233     ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
234     ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
235     ok(!pCmdText, "pCmdText != NULL\n");
236
237     switch(prgCmds[0].cmdID) {
238     case OLECMDID_STOP:
239         CHECK_EXPECT2(QueryStatus_STOP);
240         prgCmds[0].cmdf = OLECMDF_SUPPORTED;
241         return S_OK;
242     case OLECMDID_SETPROGRESSTEXT:
243         CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
244         prgCmds[0].cmdf = OLECMDF_ENABLED;
245         return S_OK;
246     default:
247         ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
248     }
249
250     return E_FAIL;
251 }
252
253 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
254         DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
255 {
256     if(!pguidCmdGroup) {
257         switch(nCmdID) {
258         case OLECMDID_SETPROGRESSMAX:
259             CHECK_EXPECT2(Exec_SETPROGRESSMAX);
260             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
261             ok(pvaIn != NULL, "pvaIn == NULL\n");
262             if(pvaIn)
263                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
264             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
265             return S_OK;
266         case OLECMDID_SETPROGRESSPOS:
267             CHECK_EXPECT2(Exec_SETPROGRESSPOS);
268             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
269             ok(pvaIn != NULL, "pvaIn == NULL\n");
270             if(pvaIn)
271                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
272             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
273             return S_OK;
274         case OLECMDID_SETDOWNLOADSTATE:
275             if(is_downloading)
276                 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
277                    "nCmdexecopts=%08x\n", nCmdexecopt);
278             else
279                 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
280             ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
281             ok(pvaIn != NULL, "pvaIn == NULL\n");
282             ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
283             switch(V_I4(pvaIn)) {
284             case 0:
285                 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
286                 break;
287             case 1:
288                 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
289                 break;
290             default:
291                 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
292             }
293             return S_OK;
294         default:
295             ok(0, "unexpected nsCmdID %d\n", nCmdID);
296         }
297     }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
298         switch(nCmdID) {
299         case 24: /* TODO */
300         case 25: /* IE5 */
301         case 37: /* TODO */
302         case 39: /* TODO */
303         case 66: /* TODO */
304         case 67: /* TODO */
305         case 69: /* TODO */
306         case 101: /* TODO (IE8) */
307             return E_FAIL;
308         default:
309             ok(0, "unexpected nCmdID %d\n", nCmdID);
310         }
311     }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
312         switch(nCmdID) {
313         case 105: /* TODO */
314         case 140: /* TODO (Win7) */
315             return E_FAIL;
316         default:
317             ok(0, "unexpected nCmdID %d\n", nCmdID);
318         }
319     }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
320         switch(nCmdID) {
321         case 11: /* TODO */
322             break;
323         default:
324             ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
325         }
326     }else {
327         ok(0, "unexpected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
328     }
329
330     return E_FAIL;
331 }
332
333 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
334     OleCommandTarget_QueryInterface,
335     OleCommandTarget_AddRef,
336     OleCommandTarget_Release,
337     OleCommandTarget_QueryStatus,
338     OleCommandTarget_Exec
339 };
340
341 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
342
343 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
344 {
345     if(IsEqualGUID(&IID_ITargetContainer, riid))
346         return E_NOINTERFACE; /* TODO */
347
348     if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
349         *ppv = &OleCommandTarget;
350         return S_OK;
351     }
352
353     ok(0, "unexpected call\n");
354     return E_NOINTERFACE;
355 }
356
357 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
358 {
359     return 2;
360 }
361
362 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
363 {
364     return 1;
365 }
366
367 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
368         LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
369 {
370     ok(0, "unexpected call\n");
371     return E_NOTIMPL;
372 }
373
374 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
375         IEnumUnknown **ppenum)
376 {
377     ok(0, "unexpected call\n");
378     return E_NOTIMPL;
379 }
380
381 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
382 {
383     ok(0, "unexpected call\n");
384     return E_NOTIMPL;
385 }
386
387 static const IOleContainerVtbl OleContainerVtbl = {
388     OleContainer_QueryInterface,
389     OleContainer_AddRef,
390     OleContainer_Release,
391     OleContainer_ParseDisplayName,
392     OleContainer_EnumObjects,
393     OleContainer_LockContainer
394 };
395
396 static IOleContainer OleContainer = { &OleContainerVtbl };
397
398 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
399 {
400     return QueryInterface(riid, ppv);
401 }
402
403 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
404 {
405     return 2;
406 }
407
408 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
409 {
410     return 1;
411 }
412
413 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
414 {
415     ok(0, "unexpected call\n");
416     return E_NOTIMPL;
417 }
418
419 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
420         ITypeInfo **ppTInfo)
421 {
422     ok(0, "unexpected call\n");
423     return E_NOTIMPL;
424 }
425
426 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
427         UINT cNames, LCID lcid, DISPID *rgDispId)
428 {
429     ok(0, "unexpected call\n");
430     return E_NOTIMPL;
431 }
432
433 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
434         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
435         EXCEPINFO *pExcepInfo, UINT *puArgErr)
436 {
437     ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
438     ok(pDispParams != NULL, "pDispParams == NULL\n");
439     ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
440     ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
441     ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
442     ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
443     ok(pDispParams->rgdispidNamedArgs == NULL,
444        "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
445     ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
446     ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
447
448     switch(dispIdMember) {
449     case DISPID_AMBIENT_USERMODE:
450         CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
451         return E_FAIL;
452     case DISPID_AMBIENT_DLCONTROL:
453         CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
454         ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
455         return E_FAIL;
456     case DISPID_AMBIENT_USERAGENT:
457        CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
458         ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
459         return E_FAIL;
460     case DISPID_AMBIENT_PALETTE:
461         CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
462         ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
463         return E_FAIL;
464     case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
465         CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
466         ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
467         V_VT(pVarResult) = VT_BOOL;
468         V_BOOL(pVarResult) = VARIANT_FALSE;
469         return S_OK;
470     case DISPID_AMBIENT_SILENT:
471         CHECK_EXPECT(Invoke_AMBIENT_SILENT);
472         ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
473         V_VT(pVarResult) = VT_BOOL;
474         V_BOOL(pVarResult) = VARIANT_FALSE;
475         return S_OK;
476     }
477
478     ok(0, "unexpected dispIdMember %d\n", dispIdMember);
479     return E_NOTIMPL;
480 }
481
482 static IDispatchVtbl DispatchVtbl = {
483     Dispatch_QueryInterface,
484     Dispatch_AddRef,
485     Dispatch_Release,
486     Dispatch_GetTypeInfoCount,
487     Dispatch_GetTypeInfo,
488     Dispatch_GetIDsOfNames,
489     Dispatch_Invoke
490 };
491
492 static IDispatch Dispatch = { &DispatchVtbl };
493
494 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
495 {
496     *ppv = NULL;
497
498     if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
499         *ppv = iface;
500         return S_OK;
501     }
502
503     ok(0, "unexpected riid %s\n", debugstr_guid(riid));
504     return E_NOINTERFACE;
505 }
506
507 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
508 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
509 {
510     ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
511     ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
512     ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
513     if(strict)
514         ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
515                             V_BOOL(params->rgvarg), exvb);
516     else
517         ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
518                             V_BOOL(params->rgvarg), exvb);
519 }
520
521 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
522         const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
523 {
524     ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
525     ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
526     ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
527
528     ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
529     ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
530     if(V_VARIANTREF(url)) {
531         ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
532            V_VT(V_VARIANTREF(url)));
533         ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
534         ok(!strcmp_wa(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
535            wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), current_url);
536     }
537
538     ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
539        V_VT(flags));
540     ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
541        V_VT(flags));
542     ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
543     if(V_VARIANTREF(flags)) {
544         ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
545            V_VT(V_VARIANTREF(flags)));
546         if(is_first_load) {
547             ok(V_I4(V_VARIANTREF(flags)) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0\n",
548                V_I4(V_VARIANTREF(flags)));
549         }else {
550             ok((V_I4(V_VARIANTREF(flags)) & ~0x40) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0x40 or 0\n",
551                V_I4(V_VARIANTREF(flags)));
552         }
553     }
554
555     ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
556        V_VT(frame));
557     ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
558        V_VT(frame));
559     ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
560     if(V_VARIANTREF(frame)) {
561         ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
562            V_VT(V_VARIANTREF(frame)));
563         ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
564            V_BSTR(V_VARIANTREF(frame)));
565     }
566
567     ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
568        V_VT(post_data));
569     ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
570        V_VT(post_data));
571     ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
572     if(V_VARIANTREF(post_data)) {
573         ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
574            "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
575            V_VT(V_VARIANTREF(post_data)));
576         ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
577            "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
578         if(V_VARIANTREF(V_VARIANTREF(post_data))) {
579             ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
580                "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
581                V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
582
583             if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
584                 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
585
586                 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
587                 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
588             }
589         }
590     }
591
592     ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
593        V_VT(headers));
594     ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
595     if(V_VARIANTREF(headers)) {
596         ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
597            V_VT(V_VARIANTREF(headers)));
598         ok(V_BSTR(V_VARIANTREF(headers)) == NULL, "V_BSTR(V_VARIANTREF(heders)) = %p, expected NULL\n",
599            V_BSTR(V_VARIANTREF(headers)));
600     }
601
602     ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
603        V_VT(cancel));
604     ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
605     if(V_BOOLREF(cancel))
606         ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(calcel) = %x, expected VARIANT_FALSE\n",
607            *V_BOOLREF(cancel));
608 }
609
610 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
611         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
612         EXCEPINFO *pExcepInfo, UINT *puArgErr)
613 {
614     ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
615     ok(pDispParams != NULL, "pDispParams == NULL\n");
616     ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
617     ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
618     ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
619     ok(pDispParams->rgdispidNamedArgs == NULL,
620        "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
621     ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
622
623     switch(dispIdMember) {
624     case DISPID_STATUSTEXTCHANGE:
625         CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
626
627         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
628         ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
629         ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
630            V_VT(pDispParams->rgvarg));
631         /* TODO: Check text */
632         break;
633
634     case DISPID_PROPERTYCHANGE:
635         CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
636
637         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
638         ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
639         /* TODO: Check args */
640         break;
641
642     case DISPID_DOWNLOADBEGIN:
643         CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
644
645         ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
646         ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
647         test_ready_state(READYSTATE_LOADING);
648         break;
649
650     case DISPID_BEFORENAVIGATE2:
651         CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
652
653         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
654         ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
655         test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
656                               pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
657                               pDispParams->rgvarg);
658         test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
659         break;
660
661     case DISPID_SETSECURELOCKICON:
662         CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
663
664         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
665         ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
666         /* TODO: Check args */
667         break;
668
669     case DISPID_FILEDOWNLOAD:
670         CHECK_EXPECT(Invoke_FILEDOWNLOAD);
671
672         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
673         ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
674         /* TODO: Check args */
675         break;
676
677     case DISPID_COMMANDSTATECHANGE:
678         CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
679
680         ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
681         ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
682         /* TODO: Check args */
683         break;
684
685     case DISPID_DOWNLOADCOMPLETE:
686         CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
687
688         ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
689         ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
690         test_ready_state(READYSTATE_LOADING);
691         break;
692
693     case DISPID_ONMENUBAR:
694         CHECK_EXPECT(Invoke_ONMENUBAR);
695         test_invoke_bool(pDispParams, TRUE);
696         break;
697
698     case DISPID_ONADDRESSBAR:
699         CHECK_EXPECT(Invoke_ONADDRESSBAR);
700         test_invoke_bool(pDispParams, TRUE);
701         break;
702
703     case DISPID_ONSTATUSBAR:
704         CHECK_EXPECT(Invoke_ONSTATUSBAR);
705         test_invoke_bool(pDispParams, TRUE);
706         break;
707
708     case DISPID_ONTOOLBAR:
709         CHECK_EXPECT(Invoke_ONTOOLBAR);
710         test_invoke_bool(pDispParams, FALSE);
711         break;
712
713     case DISPID_ONFULLSCREEN:
714         CHECK_EXPECT(Invoke_ONFULLSCREEN);
715         test_invoke_bool(pDispParams, TRUE);
716         break;
717
718     case DISPID_ONTHEATERMODE:
719         CHECK_EXPECT(Invoke_ONTHEATERMODE);
720         test_invoke_bool(pDispParams, TRUE);
721         break;
722
723     case DISPID_WINDOWSETRESIZABLE:
724         CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
725         test_invoke_bool(pDispParams, TRUE);
726         break;
727
728     case DISPID_TITLECHANGE:
729         CHECK_EXPECT2(Invoke_TITLECHANGE);
730         /* FIXME */
731         break;
732
733     case DISPID_NAVIGATECOMPLETE2:
734         CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
735         /* FIXME */
736         test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
737         break;
738
739     case DISPID_PROGRESSCHANGE:
740         CHECK_EXPECT(Invoke_PROGRESSCHANGE);
741         /* FIXME */
742         break;
743
744     case DISPID_DOCUMENTCOMPLETE:
745         CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
746         /* FIXME */
747         test_ready_state(READYSTATE_COMPLETE);
748         break;
749
750     case 282: /* FIXME */
751         CHECK_EXPECT2(Invoke_282);
752         break;
753
754     default:
755         ok(0, "unexpected dispIdMember %d\n", dispIdMember);
756     }
757
758     return S_OK;
759 }
760
761 static IDispatchVtbl WebBrowserEvents2Vtbl = {
762     WebBrowserEvents2_QueryInterface,
763     Dispatch_AddRef,
764     Dispatch_Release,
765     Dispatch_GetTypeInfoCount,
766     Dispatch_GetTypeInfo,
767     Dispatch_GetIDsOfNames,
768     WebBrowserEvents2_Invoke
769 };
770
771 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
772
773 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
774 {
775     return QueryInterface(riid, ppv);
776 }
777
778 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
779 {
780     return 2;
781 }
782
783 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
784 {
785     return 1;
786 }
787
788 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
789 {
790     ok(0, "unexpected call\n");
791     return E_NOTIMPL;
792 }
793
794 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
795         IMoniker **ppmon)
796 {
797     ok(0, "unexpected call\n");
798     return E_NOTIMPL;
799 }
800
801 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
802 {
803     CHECK_EXPECT(GetContainer);
804
805     ok(ppContainer != NULL, "ppContainer == NULL\n");
806     if(ppContainer)
807         *ppContainer = &OleContainer;
808
809     return S_OK;
810 }
811
812 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
813 {
814     CHECK_EXPECT(ShowObject);
815     return S_OK;
816 }
817
818 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
819 {
820     ok(0, "unexpected call\n");
821     return E_NOTIMPL;
822 }
823
824 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
825 {
826     ok(0, "unexpected call\n");
827     return E_NOTIMPL;
828 }
829
830 static const IOleClientSiteVtbl ClientSiteVtbl = {
831     ClientSite_QueryInterface,
832     ClientSite_AddRef,
833     ClientSite_Release,
834     ClientSite_SaveObject,
835     ClientSite_GetMoniker,
836     ClientSite_GetContainer,
837     ClientSite_ShowObject,
838     ClientSite_OnShowWindow,
839     ClientSite_RequestNewObjectLayout
840 };
841
842 static IOleClientSite ClientSite = { &ClientSiteVtbl };
843
844 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
845                                                      REFIID riid, void **ppv)
846 {
847     ok(0, "unexpected call\n");
848     return E_NOINTERFACE;
849 }
850
851 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
852 {
853     return 2;
854 }
855
856 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
857 {
858     return 1;
859 }
860
861 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
862 {
863     ok(0, "unexpected call\n");
864     return E_NOTIMPL;
865 }
866
867 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
868 {
869     CHECK_EXPECT(Frame_GetWindow);
870     ok(phwnd != NULL, "phwnd == NULL\n");
871     if(phwnd)
872         *phwnd = container_hwnd;
873     return S_OK;
874 }
875
876 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
877 {
878     ok(0, "unexpected call\n");
879     return E_NOTIMPL;
880 }
881
882 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
883 {
884     ok(0, "unexpected call\n");
885     return E_NOTIMPL;
886 }
887
888 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
889         LPCBORDERWIDTHS pborderwidths)
890 {
891     ok(0, "unexpected call\n");
892     return E_NOTIMPL;
893 }
894
895 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
896         LPCBORDERWIDTHS pborderwidths)
897 {
898     ok(0, "unexpected call\n");
899     return E_NOTIMPL;
900 }
901
902 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
903         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
904 {
905     CHECK_EXPECT(UIWindow_SetActiveObject);
906     ok(pActiveObject != NULL, "pActiveObject = NULL\n");
907     ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
908     return S_OK;
909 }
910
911 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
912         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
913 {
914     CHECK_EXPECT(Frame_SetActiveObject);
915     ok(pActiveObject != NULL, "pActiveObject = NULL\n");
916     ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
917     return S_OK;
918 }
919
920 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
921         LPOLEMENUGROUPWIDTHS lpMenuWidths)
922 {
923     ok(0, "unexpected call\n");
924     return E_NOTIMPL;
925 }
926
927 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
928         HOLEMENU holemenu, HWND hwndActiveObject)
929 {
930     CHECK_EXPECT(SetMenu);
931     ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
932     ok(holemenu == NULL, "holemenu=%p\n", holemenu);
933     ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
934        hwndActiveObject, shell_embedding_hwnd);
935     return S_OK;
936 }
937
938 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
939 {
940     ok(0, "unexpected call\n");
941     return E_NOTIMPL;
942 }
943
944 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
945 {
946     CHECK_EXPECT2(SetStatusText);
947     /* FIXME: Check pszStatusText */
948     return S_OK;
949 }
950
951 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
952 {
953     if(fEnable)
954         CHECK_EXPECT2(EnableModeless_TRUE);
955     else
956         CHECK_EXPECT2(EnableModeless_FALSE);
957     return S_OK;
958 }
959
960 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
961 {
962     ok(0, "unexpected call\n");
963     return E_NOTIMPL;
964 }
965
966 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
967     InPlaceUIWindow_QueryInterface,
968     InPlaceUIWindow_AddRef,
969     InPlaceUIWindow_Release,
970     InPlaceUIWindow_GetWindow,
971     InPlaceUIWindow_ContextSensitiveHelp,
972     InPlaceUIWindow_GetBorder,
973     InPlaceUIWindow_RequestBorderSpace,
974     InPlaceUIWindow_SetBorderSpace,
975     InPlaceUIWindow_SetActiveObject,
976 };
977
978 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
979
980 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
981     InPlaceUIWindow_QueryInterface,
982     InPlaceUIWindow_AddRef,
983     InPlaceUIWindow_Release,
984     InPlaceFrame_GetWindow,
985     InPlaceUIWindow_ContextSensitiveHelp,
986     InPlaceUIWindow_GetBorder,
987     InPlaceUIWindow_RequestBorderSpace,
988     InPlaceUIWindow_SetBorderSpace,
989     InPlaceFrame_SetActiveObject,
990     InPlaceFrame_InsertMenus,
991     InPlaceFrame_SetMenu,
992     InPlaceFrame_RemoveMenus,
993     InPlaceFrame_SetStatusText,
994     InPlaceFrame_EnableModeless,
995     InPlaceFrame_TranslateAccelerator
996 };
997
998 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
999
1000 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1001 {
1002     return QueryInterface(riid, ppv);
1003 }
1004
1005 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1006 {
1007     return 2;
1008 }
1009
1010 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1011 {
1012     return 1;
1013 }
1014
1015 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1016 {
1017     CHECK_EXPECT(Site_GetWindow);
1018     ok(phwnd != NULL, "phwnd == NULL\n");
1019     if(phwnd)
1020         *phwnd = container_hwnd;
1021     return S_OK;
1022 }
1023
1024 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1025 {
1026     ok(0, "unexpected call\n");
1027     return E_NOTIMPL;
1028 }
1029
1030 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1031 {
1032     CHECK_EXPECT(CanInPlaceActivate);
1033     return S_OK;
1034 }
1035
1036 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1037 {
1038     CHECK_EXPECT(OnInPlaceActivate);
1039     return S_OK;
1040 }
1041
1042 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1043 {
1044     CHECK_EXPECT(OnUIActivate);
1045     return S_OK;
1046 }
1047
1048 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1049         IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1050         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1051 {
1052     static const RECT pos_rect = {2,1,1002,901};
1053     static const RECT clip_rect = {10,10,990,890};
1054
1055     CHECK_EXPECT(GetWindowContext);
1056
1057     ok(ppFrame != NULL, "ppFrame = NULL\n");
1058     if(ppFrame)
1059         *ppFrame = &InPlaceFrame;
1060
1061     ok(ppDoc != NULL, "ppDoc = NULL\n");
1062     if(ppDoc)
1063         *ppDoc = &InPlaceUIWindow;
1064
1065     ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1066     if(lprcPosRect)
1067         memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1068
1069     ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1070     if(lprcClipRect)
1071         memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1072
1073     ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1074     if(lpFrameInfo) {
1075         lpFrameInfo->cb = sizeof(*lpFrameInfo);
1076         lpFrameInfo->fMDIApp = FALSE;
1077         lpFrameInfo->hwndFrame = container_hwnd;
1078         lpFrameInfo->haccel = NULL;
1079         lpFrameInfo->cAccelEntries = 0;
1080     }
1081
1082     return S_OK;
1083 }
1084
1085 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1086 {
1087     ok(0, "unexpected call\n");
1088     return E_NOTIMPL;
1089 }
1090
1091 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1092 {
1093     ok(0, "unexpected call\n");
1094     return E_NOTIMPL;
1095 }
1096
1097 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1098 {
1099     ok(0, "unexpected call\n");
1100     return E_NOTIMPL;
1101 }
1102
1103 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1104 {
1105     ok(0, "unexpected call\n");
1106     return E_NOTIMPL;
1107 }
1108
1109 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1110 {
1111     ok(0, "unexpected call\n");
1112     return E_NOTIMPL;
1113 }
1114
1115 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1116 {
1117     ok(0, "unexpected call\n");
1118     return E_NOTIMPL;
1119 }
1120
1121 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1122                                                       BOOL *pNoRedraw, DWORD dwFlags)
1123 {
1124     ok(0, "unexpected call\n");
1125     return E_NOTIMPL;
1126 }
1127
1128 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1129                                                         BOOL fNoRedraw)
1130 {
1131     ok(0, "unexpected call\n");
1132     return E_NOTIMPL;
1133 }
1134
1135 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1136 {
1137     ok(0, "unexpected call\n");
1138     return S_OK;
1139 }
1140
1141 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1142     InPlaceSite_QueryInterface,
1143     InPlaceSite_AddRef,
1144     InPlaceSite_Release,
1145     InPlaceSite_GetWindow,
1146     InPlaceSite_ContextSensitiveHelp,
1147     InPlaceSite_CanInPlaceActivate,
1148     InPlaceSite_OnInPlaceActivate,
1149     InPlaceSite_OnUIActivate,
1150     InPlaceSite_GetWindowContext,
1151     InPlaceSite_Scroll,
1152     InPlaceSite_OnUIDeactivate,
1153     InPlaceSite_OnInPlaceDeactivate,
1154     InPlaceSite_DiscardUndoState,
1155     InPlaceSite_DeactivateAndUndo,
1156     InPlaceSite_OnPosRectChange,
1157     InPlaceSite_OnInPlaceActivateEx,
1158     InPlaceSite_OnInPlaceDeactivateEx,
1159     InPlaceSite_RequestUIActivate
1160 };
1161
1162 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1163
1164 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1165 {
1166     return QueryInterface(riid, ppv);
1167 }
1168
1169 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1170 {
1171     return 2;
1172 }
1173
1174 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1175 {
1176     return 1;
1177 }
1178
1179 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1180         IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1181 {
1182     ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1183     return S_FALSE;
1184 }
1185
1186 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1187 {
1188     CHECK_EXPECT2(GetHostInfo);
1189     ok(pInfo != NULL, "pInfo=NULL\n");
1190     if(pInfo) {
1191         ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1192         ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1193         ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1194         ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1195         ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1196     }
1197     return E_FAIL;
1198 }
1199
1200 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1201         IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1202         IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1203 {
1204     ok(0, "unexpected call\n");
1205     return E_NOTIMPL;
1206 }
1207
1208 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1209 {
1210     ok(0, "unexpected call\n");
1211     return E_NOTIMPL;
1212 }
1213
1214 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1215 {
1216     CHECK_EXPECT(UpdateUI);
1217     return E_NOTIMPL;
1218 }
1219
1220 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1221 {
1222     if(fEnable)
1223         CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1224     else
1225         CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1226
1227     return S_OK;
1228 }
1229
1230 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1231 {
1232     ok(0, "unexpected call\n");
1233     return E_NOTIMPL;
1234 }
1235
1236 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1237 {
1238     ok(0, "unexpected call\n");
1239     return E_NOTIMPL;
1240 }
1241
1242 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1243         IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1244 {
1245     ok(0, "unexpected call\n");
1246     return E_NOTIMPL;
1247 }
1248
1249 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1250         const GUID *pguidCmdGroup, DWORD nCmdID)
1251 {
1252     ok(0, "unexpected call\n");
1253     return E_NOTIMPL;
1254 }
1255
1256 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1257         LPOLESTR *pchKey, DWORD dw)
1258 {
1259     CHECK_EXPECT(GetOptionKeyPath);
1260     ok(pchKey != NULL, "pchKey==NULL\n");
1261     if(pchKey)
1262         ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1263     ok(!dw, "dw=%x\n", dw);
1264     return E_NOTIMPL;
1265 }
1266
1267 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1268         IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1269 {
1270     CHECK_EXPECT(GetDropTarget);
1271     return E_NOTIMPL;
1272 }
1273
1274 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1275 {
1276     ok(0, "unexpected call\n");
1277     return E_NOTIMPL;
1278 }
1279
1280 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1281         OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1282 {
1283     if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1284         todo_wine CHECK_EXPECT(TranslateUrl);
1285     else
1286         CHECK_EXPECT(TranslateUrl);
1287     return E_NOTIMPL;
1288 }
1289
1290 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1291         IDataObject **ppPORet)
1292 {
1293     ok(0, "unexpected call\n");
1294     return E_NOTIMPL;
1295 }
1296
1297 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1298         LPOLESTR *pchKey, DWORD dw)
1299 {
1300     CHECK_EXPECT(GetOverridesKeyPath);
1301     ok(pchKey != NULL, "pchKey==NULL\n");
1302     if(pchKey)
1303         ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1304     ok(!dw, "dw=%x\n", dw);
1305     return E_NOTIMPL;
1306 }
1307
1308 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1309     DocHostUIHandler_QueryInterface,
1310     DocHostUIHandler_AddRef,
1311     DocHostUIHandler_Release,
1312     DocHostUIHandler_ShowContextMenu,
1313     DocHostUIHandler_GetHostInfo,
1314     DocHostUIHandler_ShowUI,
1315     DocHostUIHandler_HideUI,
1316     DocHostUIHandler_UpdateUI,
1317     DocHostUIHandler_EnableModeless,
1318     DocHostUIHandler_OnDocWindowActivate,
1319     DocHostUIHandler_OnFrameWindowActivate,
1320     DocHostUIHandler_ResizeBorder,
1321     DocHostUIHandler_TranslateAccelerator,
1322     DocHostUIHandler_GetOptionKeyPath,
1323     DocHostUIHandler_GetDropTarget,
1324     DocHostUIHandler_GetExternal,
1325     DocHostUIHandler_TranslateUrl,
1326     DocHostUIHandler_FilterDataObject,
1327     DocHostUIHandler_GetOverrideKeyPath
1328 };
1329
1330 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1331
1332
1333 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1334 {
1335     return QueryInterface(riid, ppv);
1336 }
1337
1338 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1339 {
1340     return 2;
1341 }
1342
1343 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1344 {
1345     return 1;
1346 }
1347
1348 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1349                                     REFGUID guidService, REFIID riid, void **ppv)
1350 {
1351     *ppv = NULL;
1352
1353     if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1354         trace("Service SID_STopLevelBrowser\n");
1355     else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1356         trace("Service SID_SEditCommandTarget\n");
1357     else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1358         trace("Service IID_ITargetFrame2\n");
1359     else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1360         trace("Service SID_SInternetSecurityManager\n");
1361     else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1362         trace("Service SID_SOleUndoManager\n");
1363     else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1364         trace("Service SID_IMimeInfo\n");
1365     else if (IsEqualGUID(&SID_STopWindow, guidService))
1366         trace("Service SID_STopWindow\n");
1367
1368     /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1369     /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1370     /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1371     /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1372     /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1373     /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1374     /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1375     /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1376     /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1377     /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1378     /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1379
1380     else
1381         trace("Service %s not supported\n", debugstr_guid(guidService));
1382
1383     return E_NOINTERFACE;
1384 }
1385
1386
1387 static const IServiceProviderVtbl ServiceProviderVtbl = {
1388     ServiceProvider_QueryInterface,
1389     ServiceProvider_AddRef,
1390     ServiceProvider_Release,
1391     ServiceProvider_QueryService
1392 };
1393
1394 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1395
1396
1397 static HRESULT QueryInterface(REFIID riid, void **ppv)
1398 {
1399     *ppv = NULL;
1400
1401     if(IsEqualGUID(&IID_IUnknown, riid)
1402             || IsEqualGUID(&IID_IOleClientSite, riid))
1403         *ppv = &ClientSite;
1404     else if(IsEqualGUID(&IID_IOleWindow, riid)
1405             || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1406             || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1407         *ppv = &InPlaceSite;
1408     else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1409             || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1410         *ppv = &DocHostUIHandler;
1411     else if(IsEqualGUID(&IID_IDispatch, riid))
1412         *ppv = &Dispatch;
1413     else if(IsEqualGUID(&IID_IServiceProvider, riid))
1414         *ppv = &ServiceProvider;
1415     else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1416         trace("interface IID_IDocHostShowUI\n");
1417     else if(IsEqualGUID(&IID_IOleControlSite, riid))
1418         trace("interface IID_IOleControlSite\n");
1419     else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1420         trace("interface IID_IOleCommandTarget\n");
1421
1422     /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1423
1424     else
1425     {
1426         /* are there more interfaces, that a host can support? */
1427         trace("%s: interface not supported\n", debugstr_guid(riid));
1428     }
1429
1430     return (*ppv) ? S_OK : E_NOINTERFACE;
1431 }
1432
1433 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1434 {
1435     return DefWindowProcW(hwnd, msg, wParam, lParam);
1436 }
1437
1438 static HWND create_container_window(void)
1439 {
1440     static const WCHAR wszWebBrowserContainer[] =
1441         {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1442     static WNDCLASSEXW wndclass = {
1443         sizeof(WNDCLASSEXW),
1444         0,
1445         wnd_proc,
1446         0, 0, NULL, NULL, NULL, NULL, NULL,
1447         wszWebBrowserContainer,
1448         NULL
1449     };
1450
1451     RegisterClassExW(&wndclass);
1452     return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1453             WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1454             CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1455 }
1456
1457 static void test_DoVerb(IUnknown *unk)
1458 {
1459     IOleObject *oleobj;
1460     RECT rect = {0,0,1000,1000};
1461     HRESULT hres;
1462
1463     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1464     ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1465     if(FAILED(hres))
1466         return;
1467
1468     SET_EXPECT(CanInPlaceActivate);
1469     SET_EXPECT(Site_GetWindow);
1470     SET_EXPECT(OnInPlaceActivate);
1471     SET_EXPECT(GetWindowContext);
1472     SET_EXPECT(ShowObject);
1473     SET_EXPECT(GetContainer);
1474     SET_EXPECT(Frame_GetWindow);
1475     SET_EXPECT(OnUIActivate);
1476     SET_EXPECT(Frame_SetActiveObject);
1477     SET_EXPECT(UIWindow_SetActiveObject);
1478     SET_EXPECT(SetMenu);
1479
1480     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1481                              0, (HWND)0xdeadbeef, &rect);
1482     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1483
1484     CHECK_CALLED(CanInPlaceActivate);
1485     CHECK_CALLED(Site_GetWindow);
1486     CHECK_CALLED(OnInPlaceActivate);
1487     CHECK_CALLED(GetWindowContext);
1488     CHECK_CALLED(ShowObject);
1489     CHECK_CALLED(GetContainer);
1490     CHECK_CALLED(Frame_GetWindow);
1491     CHECK_CALLED(OnUIActivate);
1492     CHECK_CALLED(Frame_SetActiveObject);
1493     CHECK_CALLED(UIWindow_SetActiveObject);
1494     CHECK_CALLED(SetMenu);
1495
1496     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1497                            0, (HWND)0xdeadbeef, &rect);
1498     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1499
1500     IOleObject_Release(oleobj);
1501 }
1502
1503 static void test_GetMiscStatus(IOleObject *oleobj)
1504 {
1505     DWORD st, i;
1506     HRESULT hres;
1507
1508     for(i=0; i<10; i++) {
1509         st = 0xdeadbeef;
1510         hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1511         ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1512         ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1513                   |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1514            "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1515            "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1516     }
1517 }
1518
1519 static void test_SetHostNames(IOleObject *oleobj)
1520 {
1521     HRESULT hres;
1522
1523     static const WCHAR test_appW[] =  {'t','e','s','t',' ','a','p','p',0};
1524
1525     hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1526     ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1527 }
1528
1529 static void test_ClientSite(IUnknown *unk, IOleClientSite *client, BOOL stop_download)
1530 {
1531     IOleObject *oleobj;
1532     IOleInPlaceObject *inplace;
1533     HWND hwnd;
1534     HRESULT hres;
1535
1536     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1537     ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1538     if(FAILED(hres))
1539         return;
1540
1541     test_GetMiscStatus(oleobj);
1542     test_SetHostNames(oleobj);
1543
1544     hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1545     ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1546     if(FAILED(hres)) {
1547         IOleObject_Release(oleobj);
1548         return;
1549     }
1550
1551     hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1552     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1553     ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1554
1555     if(client) {
1556         SET_EXPECT(GetContainer);
1557         SET_EXPECT(Site_GetWindow);
1558         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1559         SET_EXPECT(Invoke_AMBIENT_SILENT);
1560     }else if(stop_download) {
1561         SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1562         SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1563         SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1564     }
1565
1566     hres = IOleObject_SetClientSite(oleobj, client);
1567     ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1568
1569     if(client) {
1570         CHECK_CALLED(GetContainer);
1571         CHECK_CALLED(Site_GetWindow);
1572         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1573         CHECK_CALLED(Invoke_AMBIENT_SILENT);
1574     }else if(stop_download) {
1575         todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1576         todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1577         todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1578    }
1579
1580     hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1581     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1582     ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1583
1584     shell_embedding_hwnd = hwnd;
1585
1586     test_SetHostNames(oleobj);
1587
1588     IOleInPlaceObject_Release(inplace);
1589     IOleObject_Release(oleobj);
1590 }
1591
1592 static void test_ClassInfo(IUnknown *unk)
1593 {
1594     IProvideClassInfo2 *class_info;
1595     GUID guid;
1596     HRESULT hres;
1597
1598     hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1599     ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo)  failed: %08x\n", hres);
1600     if(FAILED(hres))
1601         return;
1602
1603     hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1604     ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1605     ok(IsEqualGUID(&DIID_DWebBrowserEvents2, &guid), "wrong guid\n");
1606
1607     hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1608     ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1609     ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1610
1611     hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1612     ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1613     ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1614
1615     hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1616     ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1617
1618     hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1619     ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1620
1621     IProvideClassInfo2_Release(class_info);
1622 }
1623
1624 static void test_ie_funcs(IUnknown *unk)
1625 {
1626     IWebBrowser2 *wb;
1627     IDispatch *disp;
1628     VARIANT_BOOL b;
1629     int i;
1630     LONG hwnd;
1631     HRESULT hres;
1632     BSTR sName;
1633
1634     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
1635     ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
1636     if(FAILED(hres))
1637         return;
1638
1639     /* HWND */
1640
1641     hwnd = 0xdeadbeef;
1642     hres = IWebBrowser2_get_HWND(wb, &hwnd);
1643     ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
1644     ok(hwnd == 0, "unexpected hwnd %x\n", hwnd);
1645
1646     /* MenuBar */
1647
1648     hres = IWebBrowser2_get_MenuBar(wb, &b);
1649     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1650     ok(b == VARIANT_TRUE, "b=%x\n", b);
1651
1652     SET_EXPECT(Invoke_ONMENUBAR);
1653     hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
1654     ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1655     CHECK_CALLED(Invoke_ONMENUBAR);
1656
1657     hres = IWebBrowser2_get_MenuBar(wb, &b);
1658     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1659     ok(b == VARIANT_FALSE, "b=%x\n", b);
1660
1661     SET_EXPECT(Invoke_ONMENUBAR);
1662     hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
1663     ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1664     CHECK_CALLED(Invoke_ONMENUBAR);
1665
1666     hres = IWebBrowser2_get_MenuBar(wb, &b);
1667     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1668     ok(b == VARIANT_TRUE, "b=%x\n", b);
1669
1670     /* AddressBar */
1671
1672     hres = IWebBrowser2_get_AddressBar(wb, &b);
1673     ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1674     ok(b == VARIANT_TRUE, "b=%x\n", b);
1675
1676     SET_EXPECT(Invoke_ONADDRESSBAR);
1677     hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
1678     ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1679     CHECK_CALLED(Invoke_ONADDRESSBAR);
1680
1681     hres = IWebBrowser2_get_AddressBar(wb, &b);
1682     ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1683     ok(b == VARIANT_FALSE, "b=%x\n", b);
1684
1685     SET_EXPECT(Invoke_ONADDRESSBAR);
1686     hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
1687     ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1688     CHECK_CALLED(Invoke_ONADDRESSBAR);
1689
1690     hres = IWebBrowser2_get_AddressBar(wb, &b);
1691     ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1692     ok(b == VARIANT_TRUE, "b=%x\n", b);
1693
1694     SET_EXPECT(Invoke_ONADDRESSBAR);
1695     hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
1696     ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1697     CHECK_CALLED(Invoke_ONADDRESSBAR);
1698
1699     /* StatusBar */
1700
1701     hres = IWebBrowser2_get_StatusBar(wb, &b);
1702     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1703     ok(b == VARIANT_TRUE, "b=%x\n", b);
1704
1705     SET_EXPECT(Invoke_ONSTATUSBAR);
1706     hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
1707     ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1708     CHECK_CALLED(Invoke_ONSTATUSBAR);
1709
1710     hres = IWebBrowser2_get_StatusBar(wb, &b);
1711     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1712     ok(b == VARIANT_TRUE, "b=%x\n", b);
1713
1714     SET_EXPECT(Invoke_ONSTATUSBAR);
1715     hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
1716     ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1717     CHECK_CALLED(Invoke_ONSTATUSBAR);
1718
1719     hres = IWebBrowser2_get_StatusBar(wb, &b);
1720     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1721     ok(b == VARIANT_FALSE, "b=%x\n", b);
1722
1723     SET_EXPECT(Invoke_ONSTATUSBAR);
1724     hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
1725     ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1726     CHECK_CALLED(Invoke_ONSTATUSBAR);
1727
1728     hres = IWebBrowser2_get_StatusBar(wb, &b);
1729     ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1730     ok(b == VARIANT_TRUE, "b=%x\n", b);
1731
1732     /* ToolBar */
1733
1734     hres = IWebBrowser2_get_ToolBar(wb, &i);
1735     ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1736     ok(i, "i=%x\n", i);
1737
1738     SET_EXPECT(Invoke_ONTOOLBAR);
1739     hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
1740     ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1741     CHECK_CALLED(Invoke_ONTOOLBAR);
1742
1743     hres = IWebBrowser2_get_ToolBar(wb, &i);
1744     ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1745     ok(i == VARIANT_FALSE, "b=%x\n", i);
1746
1747     SET_EXPECT(Invoke_ONTOOLBAR);
1748     hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
1749     ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1750     CHECK_CALLED(Invoke_ONTOOLBAR);
1751
1752     hres = IWebBrowser2_get_ToolBar(wb, &i);
1753     ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1754     ok(i, "i=%x\n", i);
1755
1756     SET_EXPECT(Invoke_ONTOOLBAR);
1757     hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
1758     ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1759     CHECK_CALLED(Invoke_ONTOOLBAR);
1760
1761     /* FullScreen */
1762
1763     hres = IWebBrowser2_get_FullScreen(wb, &b);
1764     ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1765     ok(b == VARIANT_FALSE, "b=%x\n", b);
1766
1767     SET_EXPECT(Invoke_ONFULLSCREEN);
1768     hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
1769     ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1770     CHECK_CALLED(Invoke_ONFULLSCREEN);
1771
1772     hres = IWebBrowser2_get_FullScreen(wb, &b);
1773     ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1774     ok(b == VARIANT_TRUE, "b=%x\n", b);
1775
1776     SET_EXPECT(Invoke_ONFULLSCREEN);
1777     hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
1778     ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1779     CHECK_CALLED(Invoke_ONFULLSCREEN);
1780
1781     hres = IWebBrowser2_get_FullScreen(wb, &b);
1782     ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1783     ok(b == VARIANT_TRUE, "b=%x\n", b);
1784
1785     SET_EXPECT(Invoke_ONFULLSCREEN);
1786     hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
1787     ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1788     CHECK_CALLED(Invoke_ONFULLSCREEN);
1789
1790     /* TheaterMode */
1791
1792     hres = IWebBrowser2_get_TheaterMode(wb, &b);
1793     ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1794     ok(b == VARIANT_FALSE, "b=%x\n", b);
1795
1796     SET_EXPECT(Invoke_ONTHEATERMODE);
1797     hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
1798     ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1799     CHECK_CALLED(Invoke_ONTHEATERMODE);
1800
1801     hres = IWebBrowser2_get_TheaterMode(wb, &b);
1802     ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1803     ok(b == VARIANT_TRUE, "b=%x\n", b);
1804
1805     SET_EXPECT(Invoke_ONTHEATERMODE);
1806     hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
1807     ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1808     CHECK_CALLED(Invoke_ONTHEATERMODE);
1809
1810     hres = IWebBrowser2_get_TheaterMode(wb, &b);
1811     ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1812     ok(b == VARIANT_TRUE, "b=%x\n", b);
1813
1814     SET_EXPECT(Invoke_ONTHEATERMODE);
1815     hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
1816     ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1817     CHECK_CALLED(Invoke_ONTHEATERMODE);
1818
1819     /* Resizable */
1820
1821     b = 0x100;
1822     hres = IWebBrowser2_get_Resizable(wb, &b);
1823     ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
1824     ok(b == 0x100, "b=%x\n", b);
1825
1826     SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
1827     hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
1828     ok(hres == S_OK || broken(hres == E_NOTIMPL), "put_Resizable failed: %08x\n", hres);
1829     CHECK_CALLED_BROKEN(Invoke_WINDOWSETRESIZABLE);
1830
1831     SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
1832     hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
1833     ok(hres == S_OK || broken(hres == E_NOTIMPL), "put_Resizable failed: %08x\n", hres);
1834     CHECK_CALLED_BROKEN(Invoke_WINDOWSETRESIZABLE);
1835
1836     hres = IWebBrowser2_get_Resizable(wb, &b);
1837     ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
1838     ok(b == 0x100, "b=%x\n", b);
1839
1840     /* Application */
1841
1842     disp = NULL;
1843     hres = IWebBrowser2_get_Application(wb, &disp);
1844     ok(hres == S_OK, "get_Application failed: %08x\n", hres);
1845     ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
1846     if(disp)
1847         IDispatch_Release(disp);
1848
1849     hres = IWebBrowser2_get_Application(wb, NULL);
1850     ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
1851
1852     /* Name */
1853     hres = IWebBrowser2_get_Name(wb, &sName);
1854     ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
1855     if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) == LANG_ENGLISH)
1856         ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
1857     else /* Non-English cannot be blank. */
1858         ok(sName!=NULL, "get_Name return a NULL string.\n");
1859     SysFreeString(sName);
1860
1861     /* Quit */
1862
1863     hres = IWebBrowser2_Quit(wb);
1864     ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
1865
1866     IWebBrowser2_Release(wb);
1867 }
1868
1869 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1870 {
1871     VARIANT_BOOL b;
1872     HRESULT hres;
1873
1874     b = 100;
1875     hres = IWebBrowser2_get_Silent(wb, &b);
1876     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1877     ok(b == VARIANT_FALSE, "b=%x\n", b);
1878
1879     hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
1880     ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1881
1882     b = 100;
1883     hres = IWebBrowser2_get_Silent(wb, &b);
1884     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1885     ok(b == VARIANT_TRUE, "b=%x\n", b);
1886
1887     hres = IWebBrowser2_put_Silent(wb, 100);
1888     ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1889
1890     b = 100;
1891     hres = IWebBrowser2_get_Silent(wb, &b);
1892     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1893     ok(b == VARIANT_TRUE, "b=%x\n", b);
1894
1895     hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
1896     ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1897
1898     b = 100;
1899     hres = IWebBrowser2_get_Silent(wb, &b);
1900     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1901     ok(b == VARIANT_FALSE, "b=%x\n", b);
1902
1903     if(is_clientsite) {
1904         hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
1905         ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1906
1907         SET_EXPECT(Invoke_AMBIENT_SILENT);
1908     }
1909
1910     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
1911     ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1912
1913     if(is_clientsite)
1914         CHECK_CALLED(Invoke_AMBIENT_SILENT);
1915
1916     b = 100;
1917     hres = IWebBrowser2_get_Silent(wb, &b);
1918     ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1919     ok(b == VARIANT_FALSE, "b=%x\n", b);
1920 }
1921
1922 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1923 {
1924     VARIANT_BOOL b;
1925     HRESULT hres;
1926
1927     b = 100;
1928     hres = IWebBrowser2_get_Offline(wb, &b);
1929     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1930     ok(b == VARIANT_FALSE, "b=%x\n", b);
1931
1932     hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
1933     ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1934
1935     b = 100;
1936     hres = IWebBrowser2_get_Offline(wb, &b);
1937     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1938     ok(b == VARIANT_TRUE, "b=%x\n", b);
1939
1940     hres = IWebBrowser2_put_Offline(wb, 100);
1941     ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1942
1943     b = 100;
1944     hres = IWebBrowser2_get_Offline(wb, &b);
1945     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1946     ok(b == VARIANT_TRUE, "b=%x\n", b);
1947
1948     hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
1949     ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1950
1951     b = 100;
1952     hres = IWebBrowser2_get_Offline(wb, &b);
1953     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1954     ok(b == VARIANT_FALSE, "b=%x\n", b);
1955
1956     if(is_clientsite) {
1957         hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
1958         ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1959
1960         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1961     }
1962
1963     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
1964     ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1965
1966     if(is_clientsite)
1967         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1968
1969     b = 100;
1970     hres = IWebBrowser2_get_Offline(wb, &b);
1971     ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1972     ok(b == VARIANT_FALSE, "b=%x\n", b);
1973 }
1974
1975 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1976 {
1977     HRESULT hres;
1978
1979     SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1980     SET_EXPECT(Invoke_AMBIENT_SILENT);
1981     SET_EXPECT(Invoke_AMBIENT_USERMODE);
1982     SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1983     SET_EXPECT(Invoke_AMBIENT_USERAGENT);
1984     SET_EXPECT(Invoke_AMBIENT_PALETTE);
1985
1986     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
1987     ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1988
1989     CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1990     CHECK_EXPECT(Invoke_AMBIENT_SILENT);
1991     CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
1992     CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
1993     CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
1994     CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
1995
1996     CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1997     CLEAR_CALLED(Invoke_AMBIENT_SILENT);
1998     CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
1999     CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2000     CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2001     CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2002 }
2003
2004 static void test_wb_funcs(IUnknown *unk, BOOL is_clientsite)
2005 {
2006     IWebBrowser2 *wb;
2007     IOleControl *control;
2008     HRESULT hres;
2009
2010     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2011     ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
2012
2013     hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2014     ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2015
2016     test_Silent(wb, control, is_clientsite);
2017     test_Offline(wb, control, is_clientsite);
2018     test_ambient_unknown(wb, control, is_clientsite);
2019
2020     IWebBrowser_Release(wb);
2021     IOleControl_Release(control);
2022 }
2023
2024 static void test_GetControlInfo(IUnknown *unk)
2025 {
2026     IOleControl *control;
2027     CONTROLINFO info;
2028     HRESULT hres;
2029
2030     hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2031     ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2032     if(FAILED(hres))
2033         return;
2034
2035     hres = IOleControl_GetControlInfo(control, &info);
2036     ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
2037     hres = IOleControl_GetControlInfo(control, NULL);
2038     ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
2039
2040     IOleControl_Release(control);
2041 }
2042
2043 static void test_Extent(IUnknown *unk)
2044 {
2045     IOleObject *oleobj;
2046     SIZE size, expected;
2047     HRESULT hres;
2048     DWORD dpi_x;
2049     DWORD dpi_y;
2050     HDC hdc;
2051
2052     /* default aspect ratio is 96dpi / 96dpi */
2053     hdc = GetDC(0);
2054     dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2055     dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2056     ReleaseDC(0, hdc);
2057     if (dpi_x != 96 || dpi_y != 96)
2058         trace("dpi: %d / %d\n", dpi_y, dpi_y);
2059
2060     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2061     ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2062     if(FAILED(hres))
2063         return;
2064
2065     size.cx = size.cy = 0xdeadbeef;
2066     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2067     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2068     /* Default size is 50x20 pixels, in himetric units */
2069     expected.cx = MulDiv( 50, 2540, dpi_x );
2070     expected.cy = MulDiv( 20, 2540, dpi_y );
2071     ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2072        size.cx, size.cy, expected.cx, expected.cy );
2073
2074     size.cx = 800;
2075     size.cy = 700;
2076     hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2077     ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2078
2079     size.cx = size.cy = 0xdeadbeef;
2080     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2081     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2082     ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2083
2084     size.cx = size.cy = 0xdeadbeef;
2085     hres = IOleObject_GetExtent(oleobj, 0, &size);
2086     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2087     ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2088
2089     size.cx = 900;
2090     size.cy = 800;
2091     hres = IOleObject_SetExtent(oleobj, 0, &size);
2092     ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2093
2094     size.cx = size.cy = 0xdeadbeef;
2095     hres = IOleObject_GetExtent(oleobj, 0, &size);
2096     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2097     ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2098
2099     size.cx = size.cy = 0xdeadbeef;
2100     hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2101     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2102     ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2103
2104     size.cx = 1000;
2105     size.cy = 900;
2106     hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2107     ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2108
2109     size.cx = size.cy = 0xdeadbeef;
2110     hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2111     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2112     ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2113
2114     size.cx = size.cy = 0xdeadbeef;
2115     hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2116     ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2117     ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2118
2119     IOleObject_Release(oleobj);
2120 }
2121
2122 static void test_ConnectionPoint(IUnknown *unk, BOOL init)
2123 {
2124     IConnectionPointContainer *container;
2125     IConnectionPoint *point;
2126     HRESULT hres;
2127
2128     static DWORD dw = 100;
2129
2130     hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2131     ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2132     if(FAILED(hres))
2133         return;
2134
2135     hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2136     IConnectionPointContainer_Release(container);
2137     ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2138     if(FAILED(hres))
2139         return;
2140
2141     if(init) {
2142         hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2143         ok(hres == S_OK, "Advise failed: %08x\n", hres);
2144         ok(dw == 1, "dw=%d, expected 1\n", dw);
2145     }else {
2146         hres = IConnectionPoint_Unadvise(point, dw);
2147         ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2148     }
2149
2150     IConnectionPoint_Release(point);
2151 }
2152
2153 static void test_Navigate2(IUnknown *unk)
2154 {
2155     IWebBrowser2 *webbrowser;
2156     VARIANT url;
2157     HRESULT hres;
2158
2159     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&webbrowser);
2160     ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
2161     if(FAILED(hres))
2162         return;
2163
2164     test_LocationURL(unk, is_first_load ? "" : current_url);
2165     test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2166
2167     V_VT(&url) = VT_BSTR;
2168     V_BSTR(&url) = a2bstr("about:blank");
2169     current_url = "about:blank";
2170
2171     if(is_first_load) {
2172         SET_EXPECT(Invoke_AMBIENT_USERMODE);
2173         SET_EXPECT(Invoke_PROPERTYCHANGE);
2174         SET_EXPECT(Invoke_BEFORENAVIGATE2);
2175         SET_EXPECT(Invoke_DOWNLOADBEGIN);
2176         SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2177         SET_EXPECT(EnableModeless_FALSE);
2178         SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2179         SET_EXPECT(SetStatusText);
2180         SET_EXPECT(GetHostInfo);
2181         SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2182         SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2183         SET_EXPECT(Invoke_AMBIENT_PALETTE);
2184         SET_EXPECT(GetOptionKeyPath);
2185         SET_EXPECT(GetOverridesKeyPath);
2186         SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2187         SET_EXPECT(Exec_SETPROGRESSMAX);
2188         SET_EXPECT(Exec_SETPROGRESSPOS);
2189         SET_EXPECT(Invoke_SETSECURELOCKICON);
2190         SET_EXPECT(Invoke_FILEDOWNLOAD);
2191         SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2192         SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2193         SET_EXPECT(EnableModeless_TRUE);
2194     }
2195
2196     hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2197     ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2198
2199     if(is_first_load) {
2200         CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2201         todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2202         CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2203         todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2204         todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2205         CHECK_CALLED(EnableModeless_FALSE);
2206         CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2207         CHECK_CALLED(SetStatusText);
2208         CHECK_CALLED(GetHostInfo);
2209         CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2210         CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2211         CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2212         CHECK_CALLED(GetOptionKeyPath);
2213         CHECK_CALLED_BROKEN(GetOverridesKeyPath);
2214         todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2215         todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2216         todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2217         todo_wine CHECK_CALLED_BROKEN(Invoke_SETSECURELOCKICON);
2218         todo_wine CHECK_CALLED_BROKEN(Invoke_FILEDOWNLOAD);
2219         todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2220         todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2221         CHECK_CALLED(EnableModeless_TRUE);
2222     }
2223
2224     VariantClear(&url);
2225     IWebBrowser2_Release(webbrowser);
2226
2227     test_ready_state(READYSTATE_LOADING);
2228 }
2229
2230 static void test_download(DWORD flags)
2231 {
2232     MSG msg;
2233
2234     is_downloading = TRUE;
2235     dwl_flags = flags;
2236
2237     test_ready_state((flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2238
2239     if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2240         SET_EXPECT(Invoke_PROPERTYCHANGE);
2241         SET_EXPECT(Invoke_BEFORENAVIGATE2);
2242         SET_EXPECT(TranslateUrl);
2243     }
2244     SET_EXPECT(Exec_SETPROGRESSMAX);
2245     SET_EXPECT(Exec_SETPROGRESSPOS);
2246     SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2247     SET_EXPECT(DocHost_EnableModeless_FALSE);
2248     SET_EXPECT(DocHost_EnableModeless_TRUE);
2249     SET_EXPECT(Invoke_SETSECURELOCKICON);
2250     SET_EXPECT(Invoke_282);
2251     SET_EXPECT(EnableModeless_FALSE);
2252     SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2253     SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2254     SET_EXPECT(SetStatusText);
2255     SET_EXPECT(EnableModeless_TRUE);
2256     if(is_first_load)
2257         SET_EXPECT(QueryStatus_STOP);
2258     else
2259         SET_EXPECT(GetHostInfo);
2260     SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2261     SET_EXPECT(Invoke_TITLECHANGE);
2262     SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2263     if(is_first_load)
2264         SET_EXPECT(GetDropTarget);
2265     SET_EXPECT(Invoke_PROGRESSCHANGE);
2266     SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2267     while(!called_Invoke_DOCUMENTCOMPLETE && GetMessage(&msg, NULL, 0, 0)) {
2268         TranslateMessage(&msg);
2269         DispatchMessage(&msg);
2270     }
2271
2272     if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2273         todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2274         CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2275         CHECK_CALLED(TranslateUrl);
2276     }
2277     todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2278     todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2279     todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2280     CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
2281     CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
2282     todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2283     CLEAR_CALLED(Invoke_282); /* IE 7 */
2284     if(is_first_load)
2285         todo_wine CHECK_CALLED(EnableModeless_FALSE);
2286     else
2287         CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2288     CLEAR_CALLED(Invoke_COMMANDSTATECHANGE);
2289     todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2290     todo_wine CHECK_CALLED(SetStatusText);
2291     if(is_first_load)
2292         todo_wine CHECK_CALLED(EnableModeless_TRUE);
2293     else
2294         CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2295     if(is_first_load)
2296         todo_wine CHECK_CALLED(QueryStatus_STOP);
2297     else
2298         todo_wine CHECK_CALLED(GetHostInfo);
2299     todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2300     todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
2301     CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
2302     if(is_first_load)
2303         todo_wine CHECK_CALLED(GetDropTarget);
2304     todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2305     CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
2306
2307     is_downloading = FALSE;
2308
2309     test_ready_state(READYSTATE_COMPLETE);
2310 }
2311
2312 static void test_olecmd(IUnknown *unk, BOOL loaded)
2313 {
2314     IOleCommandTarget *cmdtrg;
2315     OLECMD cmds[3];
2316     HRESULT hres;
2317
2318     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2319     ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
2320     if(FAILED(hres))
2321         return;
2322
2323     cmds[0].cmdID = OLECMDID_SPELL;
2324     cmds[0].cmdf = 0xdeadbeef;
2325     cmds[1].cmdID = OLECMDID_REFRESH;
2326     cmds[1].cmdf = 0xdeadbeef;
2327     hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
2328     if(loaded) {
2329         ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2330         ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2331         ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
2332            "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
2333     }else {
2334         ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
2335         ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2336         ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
2337     }
2338
2339     IOleCommandTarget_Release(cmdtrg);
2340 }
2341
2342 static void test_IServiceProvider(IUnknown *unk)
2343 {
2344     IServiceProvider *servprov = (void*)0xdeadbeef;
2345     HRESULT hres;
2346     IUnknown *ret = NULL;
2347     static const IID IID_IBrowserService2 =
2348         {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
2349
2350     hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
2351     ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
2352     if(FAILED(hres))
2353         return;
2354
2355     hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&ret);
2356     ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
2357     ok(ret == NULL, "ret returned %p, expected NULL\n", ret);
2358     if(hres == S_OK)
2359     {
2360         IUnknown_Release(ret);
2361     }
2362
2363     IServiceProvider_Release(servprov);
2364 }
2365
2366 #define get_document(u) _get_document(__LINE__,u)
2367 static IDispatch *_get_document(unsigned line, IUnknown *unk)
2368 {
2369     IWebBrowser2 *wb;
2370     IDispatch *disp;
2371     HRESULT hres;
2372
2373     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2374     ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IWebBrowser2) failed: %08x\n", hres);
2375
2376     disp = NULL;
2377     hres = IWebBrowser2_get_Document(wb, &disp);
2378     IWebBrowser2_Release(wb);
2379     ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
2380     ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
2381
2382     return disp;
2383 }
2384
2385 static void test_put_href(IUnknown *unk)
2386 {
2387     IHTMLLocation *location;
2388     IHTMLDocument2 *doc;
2389     IDispatch *doc_disp;
2390     BSTR str;
2391     HRESULT hres;
2392
2393     doc_disp = get_document(unk);
2394
2395     hres = IDispatch_QueryInterface(doc_disp, &IID_IHTMLDocument2, (void**)&doc);
2396     IDispatch_Release(doc_disp);
2397     ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2 failed: %08x\n", hres);
2398
2399     location = NULL;
2400     hres = IHTMLDocument2_get_location(doc, &location);
2401     IHTMLDocument2_Release(doc);
2402     ok(hres == S_OK, "get_location failed: %08x\n", hres);
2403     ok(location != NULL, "location == NULL\n");
2404
2405     SET_EXPECT(TranslateUrl);
2406     SET_EXPECT(Invoke_BEFORENAVIGATE2);
2407     SET_EXPECT(Invoke_PROPERTYCHANGE);
2408
2409     dwl_flags = DWL_FROM_PUT_HREF;
2410
2411     str = a2bstr("about:test");
2412     current_url = "about:test";
2413     is_first_load = FALSE;
2414     hres = IHTMLLocation_put_href(location, str);
2415
2416     CHECK_CALLED(TranslateUrl);
2417     CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2418     todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2419
2420     IHTMLLocation_Release(location);
2421     SysFreeString(str);
2422     ok(hres == S_OK, "put_href failed: %08x\n", hres);
2423
2424     test_ready_state(READYSTATE_COMPLETE);
2425 }
2426
2427 static void test_QueryInterface(IUnknown *unk)
2428 {
2429     IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
2430     IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
2431     IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
2432     IOleInPlaceSite *inplace = (void*)0xdeadbeef;
2433     IOleCache *cache = (void*)0xdeadbeef;
2434     IObjectWithSite *site = (void*)0xdeadbeef;
2435     IViewObjectEx *viewex = (void*)0xdeadbeef;
2436     HRESULT hres;
2437
2438     hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
2439     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2440     ok(qa == NULL, "qa=%p, expected NULL\n", qa);
2441
2442     hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
2443     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2444     ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
2445
2446     hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
2447     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2448     ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
2449
2450     hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
2451     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2452     ok(cache == NULL, "cache=%p, expected NULL\n", cache);
2453
2454     hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
2455     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2456     ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
2457
2458     hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2459     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2460     ok(site == NULL, "site=%p, expected NULL\n", site);
2461
2462     hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
2463     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2464     ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
2465
2466 }
2467
2468 static void test_WebBrowser(BOOL do_download)
2469 {
2470     IUnknown *unk = NULL;
2471     ULONG ref;
2472     HRESULT hres;
2473
2474     hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2475             &IID_IUnknown, (void**)&unk);
2476     ok(hres == S_OK, "CoCreateInterface failed: %08x\n", hres);
2477     if(FAILED(hres))
2478         return;
2479
2480     is_downloading = FALSE;
2481     is_first_load = TRUE;
2482
2483     hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2484     ok(hres == S_OK, "Could not get IWebBrowser2 iface: %08x\n", hres);
2485
2486     test_QueryInterface(unk);
2487     test_ready_state(READYSTATE_UNINITIALIZED);
2488     test_ClassInfo(unk);
2489     test_LocationURL(unk, "");
2490     test_ConnectionPoint(unk, TRUE);
2491     test_ClientSite(unk, &ClientSite, !do_download);
2492     test_Extent(unk);
2493     test_wb_funcs(unk, TRUE);
2494     test_DoVerb(unk);
2495     test_olecmd(unk, FALSE);
2496     test_Navigate2(unk);
2497
2498     if(do_download) {
2499         IDispatch *doc, *doc2;
2500
2501         test_download(0);
2502         test_olecmd(unk, TRUE);
2503         doc = get_document(unk);
2504
2505         test_put_href(unk);
2506         test_download(DWL_FROM_PUT_HREF);
2507         doc2 = get_document(unk);
2508         ok(doc == doc2, "doc != doc2\n");
2509         IDispatch_Release(doc2);
2510
2511         test_Navigate2(unk);
2512         test_download(DWL_EXPECT_BEFORE_NAVIGATE);
2513         doc2 = get_document(unk);
2514         ok(doc == doc2, "doc != doc2\n");
2515         IDispatch_Release(doc2);
2516         IDispatch_Release(doc2);
2517     }
2518
2519     test_ClientSite(unk, NULL, !do_download);
2520     test_ie_funcs(unk);
2521     test_GetControlInfo(unk);
2522     test_wb_funcs(unk, FALSE);
2523     test_ConnectionPoint(unk, FALSE);
2524     test_IServiceProvider(unk);
2525
2526     IWebBrowser2_Release(wb);
2527     ref = IUnknown_Release(unk);
2528     ok(ref == 0, "ref=%d, expected 0\n", ref);
2529 }
2530
2531 START_TEST(webbrowser)
2532 {
2533     container_hwnd = create_container_window();
2534
2535     OleInitialize(NULL);
2536
2537     trace("Testing WebBrowser (no download)...\n");
2538     test_WebBrowser(FALSE);
2539     trace("Testing WebBrowser...\n");
2540     test_WebBrowser(TRUE);
2541
2542     OleUninitialize();
2543 }