shdocvw: Return IHTMLDocument2's IDispatch in get_Document.
[wine/testsucceed.git] / dlls / shdocvw / tests / webbrowser.c
blob15fc1ec0d72430c69bf325f0c1ac453c37654800
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
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"
43 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
46 #define DEFINE_EXPECT(func) \
47 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
49 #define SET_EXPECT(func) \
50 expect_ ## func = TRUE
52 #define CHECK_EXPECT2(func) \
53 do { \
54 ok(expect_ ##func, "unexpected call " #func "\n"); \
55 called_ ## func = TRUE; \
56 }while(0)
58 #define CHECK_EXPECT(func) \
59 do { \
60 CHECK_EXPECT2(func); \
61 expect_ ## func = FALSE; \
62 }while(0)
64 #define CHECK_CALLED(func) \
65 do { \
66 ok(called_ ## func, "expected " #func "\n"); \
67 expect_ ## func = called_ ## func = FALSE; \
68 }while(0)
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)
76 #define CLEAR_CALLED(func) \
77 expect_ ## func = called_ ## func = FALSE
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);
134 static const WCHAR wszItem[] = {'i','t','e','m',0};
135 static const WCHAR emptyW[] = {0};
137 static VARIANT_BOOL exvb;
138 static IWebBrowser2 *wb;
140 static HWND container_hwnd, shell_embedding_hwnd;
141 static BOOL is_downloading, is_first_load;
142 static const char *current_url;
144 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
145 #define DWL_FROM_PUT_HREF 0x02
147 static DWORD dwl_flags;
149 static int strcmp_wa(LPCWSTR strw, const char *stra)
151 CHAR buf[512];
152 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
153 return lstrcmpA(stra, buf);
156 static const char *debugstr_guid(REFIID riid)
158 static char buf[50];
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]);
165 return buf;
168 static BSTR a2bstr(const char *str)
170 BSTR ret;
171 int len;
173 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
174 ret = SysAllocStringLen(NULL, len);
175 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
177 return ret;
180 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
181 static void _test_LocationURL(unsigned line, IUnknown *unk, const char *exurl)
183 IWebBrowser2 *wb;
184 BSTR url = (void*)0xdeadbeef;
185 HRESULT hres;
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;
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));
196 SysFreeString(url);
197 IWebBrowser2_Release(wb);
200 #define test_ready_state(ex) _test_ready_state(__LINE__,ex);
201 static void _test_ready_state(unsigned line, READYSTATE exstate)
203 READYSTATE state;
204 HRESULT hres;
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);
211 static HRESULT QueryInterface(REFIID,void**);
213 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
214 REFIID riid, void **ppv)
216 ok(0, "unexpected call\n");
217 return E_NOINTERFACE;
220 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
222 return 2;
225 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
227 return 1;
230 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
231 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
233 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
234 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
235 ok(!pCmdText, "pCmdText != NULL\n");
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);
250 return E_FAIL;
253 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
254 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
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));
293 return S_OK;
294 default:
295 ok(0, "unexpected nsCmdID %d\n", nCmdID);
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);
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);
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);
326 }else {
327 ok(0, "unexpected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
330 return E_FAIL;
333 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
334 OleCommandTarget_QueryInterface,
335 OleCommandTarget_AddRef,
336 OleCommandTarget_Release,
337 OleCommandTarget_QueryStatus,
338 OleCommandTarget_Exec
341 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
343 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
345 if(IsEqualGUID(&IID_ITargetContainer, riid))
346 return E_NOINTERFACE; /* TODO */
348 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
349 *ppv = &OleCommandTarget;
350 return S_OK;
353 ok(0, "unexpected call\n");
354 return E_NOINTERFACE;
357 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
359 return 2;
362 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
364 return 1;
367 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
368 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
370 ok(0, "unexpected call\n");
371 return E_NOTIMPL;
374 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
375 IEnumUnknown **ppenum)
377 ok(0, "unexpected call\n");
378 return E_NOTIMPL;
381 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
383 ok(0, "unexpected call\n");
384 return E_NOTIMPL;
387 static const IOleContainerVtbl OleContainerVtbl = {
388 OleContainer_QueryInterface,
389 OleContainer_AddRef,
390 OleContainer_Release,
391 OleContainer_ParseDisplayName,
392 OleContainer_EnumObjects,
393 OleContainer_LockContainer
396 static IOleContainer OleContainer = { &OleContainerVtbl };
398 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
400 return QueryInterface(riid, ppv);
403 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
405 return 2;
408 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
410 return 1;
413 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
415 ok(0, "unexpected call\n");
416 return E_NOTIMPL;
419 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
420 ITypeInfo **ppTInfo)
422 ok(0, "unexpected call\n");
423 return E_NOTIMPL;
426 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
427 UINT cNames, LCID lcid, DISPID *rgDispId)
429 ok(0, "unexpected call\n");
430 return E_NOTIMPL;
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)
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);
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;
478 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
479 return E_NOTIMPL;
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
492 static IDispatch Dispatch = { &DispatchVtbl };
494 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
496 *ppv = NULL;
498 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
499 *ppv = iface;
500 return S_OK;
503 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
504 return E_NOINTERFACE;
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)
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);
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)
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);
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);
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)));
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)));
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))));
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)));
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);
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)));
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));
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)
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);
623 switch(dispIdMember) {
624 case DISPID_STATUSTEXTCHANGE:
625 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
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;
634 case DISPID_PROPERTYCHANGE:
635 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
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;
642 case DISPID_DOWNLOADBEGIN:
643 CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
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;
650 case DISPID_BEFORENAVIGATE2:
651 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
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;
661 case DISPID_SETSECURELOCKICON:
662 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
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;
669 case DISPID_FILEDOWNLOAD:
670 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
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;
677 case DISPID_COMMANDSTATECHANGE:
678 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
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;
685 case DISPID_DOWNLOADCOMPLETE:
686 CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
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;
693 case DISPID_ONMENUBAR:
694 CHECK_EXPECT(Invoke_ONMENUBAR);
695 test_invoke_bool(pDispParams, TRUE);
696 break;
698 case DISPID_ONADDRESSBAR:
699 CHECK_EXPECT(Invoke_ONADDRESSBAR);
700 test_invoke_bool(pDispParams, TRUE);
701 break;
703 case DISPID_ONSTATUSBAR:
704 CHECK_EXPECT(Invoke_ONSTATUSBAR);
705 test_invoke_bool(pDispParams, TRUE);
706 break;
708 case DISPID_ONTOOLBAR:
709 CHECK_EXPECT(Invoke_ONTOOLBAR);
710 test_invoke_bool(pDispParams, FALSE);
711 break;
713 case DISPID_ONFULLSCREEN:
714 CHECK_EXPECT(Invoke_ONFULLSCREEN);
715 test_invoke_bool(pDispParams, TRUE);
716 break;
718 case DISPID_ONTHEATERMODE:
719 CHECK_EXPECT(Invoke_ONTHEATERMODE);
720 test_invoke_bool(pDispParams, TRUE);
721 break;
723 case DISPID_WINDOWSETRESIZABLE:
724 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
725 test_invoke_bool(pDispParams, TRUE);
726 break;
728 case DISPID_TITLECHANGE:
729 CHECK_EXPECT2(Invoke_TITLECHANGE);
730 /* FIXME */
731 break;
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;
739 case DISPID_PROGRESSCHANGE:
740 CHECK_EXPECT(Invoke_PROGRESSCHANGE);
741 /* FIXME */
742 break;
744 case DISPID_DOCUMENTCOMPLETE:
745 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
746 /* FIXME */
747 test_ready_state(READYSTATE_COMPLETE);
748 break;
750 case 282: /* FIXME */
751 CHECK_EXPECT2(Invoke_282);
752 break;
754 default:
755 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
758 return S_OK;
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
771 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
773 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
775 return QueryInterface(riid, ppv);
778 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
780 return 2;
783 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
785 return 1;
788 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
790 ok(0, "unexpected call\n");
791 return E_NOTIMPL;
794 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
795 IMoniker **ppmon)
797 ok(0, "unexpected call\n");
798 return E_NOTIMPL;
801 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
803 CHECK_EXPECT(GetContainer);
805 ok(ppContainer != NULL, "ppContainer == NULL\n");
806 if(ppContainer)
807 *ppContainer = &OleContainer;
809 return S_OK;
812 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
814 CHECK_EXPECT(ShowObject);
815 return S_OK;
818 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
820 ok(0, "unexpected call\n");
821 return E_NOTIMPL;
824 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
826 ok(0, "unexpected call\n");
827 return E_NOTIMPL;
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
842 static IOleClientSite ClientSite = { &ClientSiteVtbl };
844 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
845 REFIID riid, void **ppv)
847 ok(0, "unexpected call\n");
848 return E_NOINTERFACE;
851 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
853 return 2;
856 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
858 return 1;
861 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
863 ok(0, "unexpected call\n");
864 return E_NOTIMPL;
867 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
869 CHECK_EXPECT(Frame_GetWindow);
870 ok(phwnd != NULL, "phwnd == NULL\n");
871 if(phwnd)
872 *phwnd = container_hwnd;
873 return S_OK;
876 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
878 ok(0, "unexpected call\n");
879 return E_NOTIMPL;
882 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
884 ok(0, "unexpected call\n");
885 return E_NOTIMPL;
888 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
889 LPCBORDERWIDTHS pborderwidths)
891 ok(0, "unexpected call\n");
892 return E_NOTIMPL;
895 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
896 LPCBORDERWIDTHS pborderwidths)
898 ok(0, "unexpected call\n");
899 return E_NOTIMPL;
902 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
903 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
905 CHECK_EXPECT(UIWindow_SetActiveObject);
906 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
907 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
908 return S_OK;
911 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
912 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
914 CHECK_EXPECT(Frame_SetActiveObject);
915 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
916 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
917 return S_OK;
920 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
921 LPOLEMENUGROUPWIDTHS lpMenuWidths)
923 ok(0, "unexpected call\n");
924 return E_NOTIMPL;
927 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
928 HOLEMENU holemenu, HWND hwndActiveObject)
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;
938 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
940 ok(0, "unexpected call\n");
941 return E_NOTIMPL;
944 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
946 CHECK_EXPECT2(SetStatusText);
947 /* FIXME: Check pszStatusText */
948 return S_OK;
951 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
953 if(fEnable)
954 CHECK_EXPECT2(EnableModeless_TRUE);
955 else
956 CHECK_EXPECT2(EnableModeless_FALSE);
957 return S_OK;
960 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
962 ok(0, "unexpected call\n");
963 return E_NOTIMPL;
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,
978 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
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
998 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1000 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1002 return QueryInterface(riid, ppv);
1005 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1007 return 2;
1010 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1012 return 1;
1015 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1017 CHECK_EXPECT(Site_GetWindow);
1018 ok(phwnd != NULL, "phwnd == NULL\n");
1019 if(phwnd)
1020 *phwnd = container_hwnd;
1021 return S_OK;
1024 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1026 ok(0, "unexpected call\n");
1027 return E_NOTIMPL;
1030 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1032 CHECK_EXPECT(CanInPlaceActivate);
1033 return S_OK;
1036 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1038 CHECK_EXPECT(OnInPlaceActivate);
1039 return S_OK;
1042 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1044 CHECK_EXPECT(OnUIActivate);
1045 return S_OK;
1048 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1049 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1050 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1052 static const RECT pos_rect = {2,1,1002,901};
1053 static const RECT clip_rect = {10,10,990,890};
1055 CHECK_EXPECT(GetWindowContext);
1057 ok(ppFrame != NULL, "ppFrame = NULL\n");
1058 if(ppFrame)
1059 *ppFrame = &InPlaceFrame;
1061 ok(ppDoc != NULL, "ppDoc = NULL\n");
1062 if(ppDoc)
1063 *ppDoc = &InPlaceUIWindow;
1065 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1066 if(lprcPosRect)
1067 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1069 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1070 if(lprcClipRect)
1071 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
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;
1082 return S_OK;
1085 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1087 ok(0, "unexpected call\n");
1088 return E_NOTIMPL;
1091 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1093 ok(0, "unexpected call\n");
1094 return E_NOTIMPL;
1097 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1099 ok(0, "unexpected call\n");
1100 return E_NOTIMPL;
1103 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1105 ok(0, "unexpected call\n");
1106 return E_NOTIMPL;
1109 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1111 ok(0, "unexpected call\n");
1112 return E_NOTIMPL;
1115 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1117 ok(0, "unexpected call\n");
1118 return E_NOTIMPL;
1121 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1122 BOOL *pNoRedraw, DWORD dwFlags)
1124 ok(0, "unexpected call\n");
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1129 BOOL fNoRedraw)
1131 ok(0, "unexpected call\n");
1132 return E_NOTIMPL;
1135 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1137 ok(0, "unexpected call\n");
1138 return S_OK;
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
1162 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1164 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1166 return QueryInterface(riid, ppv);
1169 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1171 return 2;
1174 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1176 return 1;
1179 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1180 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1182 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1183 return S_FALSE;
1186 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
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);
1197 return E_FAIL;
1200 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1201 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1202 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1204 ok(0, "unexpected call\n");
1205 return E_NOTIMPL;
1208 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1210 ok(0, "unexpected call\n");
1211 return E_NOTIMPL;
1214 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1216 CHECK_EXPECT(UpdateUI);
1217 return E_NOTIMPL;
1220 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1222 if(fEnable)
1223 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1224 else
1225 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1227 return S_OK;
1230 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1232 ok(0, "unexpected call\n");
1233 return E_NOTIMPL;
1236 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1238 ok(0, "unexpected call\n");
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1243 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1245 ok(0, "unexpected call\n");
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1250 const GUID *pguidCmdGroup, DWORD nCmdID)
1252 ok(0, "unexpected call\n");
1253 return E_NOTIMPL;
1256 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1257 LPOLESTR *pchKey, DWORD dw)
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;
1267 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1268 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1270 CHECK_EXPECT(GetDropTarget);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1276 ok(0, "unexpected call\n");
1277 return E_NOTIMPL;
1280 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1281 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
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;
1290 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1291 IDataObject **ppPORet)
1293 ok(0, "unexpected call\n");
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1298 LPOLESTR *pchKey, DWORD dw)
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;
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
1330 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1333 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1335 return QueryInterface(riid, ppv);
1338 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1340 return 2;
1343 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1345 return 1;
1348 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1349 REFGUID guidService, REFIID riid, void **ppv)
1351 *ppv = NULL;
1353 if(!winetest_interactive)
1354 return E_NOINTERFACE;
1356 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1357 trace("Service SID_STopLevelBrowser\n");
1358 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1359 trace("Service SID_SEditCommandTarget\n");
1360 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1361 trace("Service IID_ITargetFrame2\n");
1362 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1363 trace("Service SID_SInternetSecurityManager\n");
1364 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1365 trace("Service SID_SOleUndoManager\n");
1366 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1367 trace("Service SID_IMimeInfo\n");
1368 else if (IsEqualGUID(&SID_STopWindow, guidService))
1369 trace("Service SID_STopWindow\n");
1371 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1372 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1373 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1374 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1375 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1376 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1377 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1378 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1379 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1380 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1381 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1383 else
1384 trace("Service %s not supported\n", debugstr_guid(guidService));
1386 return E_NOINTERFACE;
1390 static const IServiceProviderVtbl ServiceProviderVtbl = {
1391 ServiceProvider_QueryInterface,
1392 ServiceProvider_AddRef,
1393 ServiceProvider_Release,
1394 ServiceProvider_QueryService
1397 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1400 static HRESULT QueryInterface(REFIID riid, void **ppv)
1402 *ppv = NULL;
1404 if(IsEqualGUID(&IID_IUnknown, riid)
1405 || IsEqualGUID(&IID_IOleClientSite, riid))
1406 *ppv = &ClientSite;
1407 else if(IsEqualGUID(&IID_IOleWindow, riid)
1408 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1409 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1410 *ppv = &InPlaceSite;
1411 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1412 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1413 *ppv = &DocHostUIHandler;
1414 else if(IsEqualGUID(&IID_IDispatch, riid))
1415 *ppv = &Dispatch;
1416 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1417 *ppv = &ServiceProvider;
1418 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1419 trace("interface IID_IDocHostShowUI\n");
1420 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1421 trace("interface IID_IOleControlSite\n");
1422 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1423 trace("interface IID_IOleCommandTarget\n");
1425 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1427 else
1429 /* are there more interfaces, that a host can support? */
1430 trace("%s: interface not supported\n", debugstr_guid(riid));
1433 return (*ppv) ? S_OK : E_NOINTERFACE;
1436 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1438 return DefWindowProcW(hwnd, msg, wParam, lParam);
1441 static HWND create_container_window(void)
1443 static const WCHAR wszWebBrowserContainer[] =
1444 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1445 static WNDCLASSEXW wndclass = {
1446 sizeof(WNDCLASSEXW),
1448 wnd_proc,
1449 0, 0, NULL, NULL, NULL, NULL, NULL,
1450 wszWebBrowserContainer,
1451 NULL
1454 RegisterClassExW(&wndclass);
1455 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1456 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1457 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1460 static void test_DoVerb(IUnknown *unk)
1462 IOleObject *oleobj;
1463 RECT rect = {0,0,1000,1000};
1464 HRESULT hres;
1466 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1467 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1468 if(FAILED(hres))
1469 return;
1471 SET_EXPECT(CanInPlaceActivate);
1472 SET_EXPECT(Site_GetWindow);
1473 SET_EXPECT(OnInPlaceActivate);
1474 SET_EXPECT(GetWindowContext);
1475 SET_EXPECT(ShowObject);
1476 SET_EXPECT(GetContainer);
1477 SET_EXPECT(Frame_GetWindow);
1478 SET_EXPECT(OnUIActivate);
1479 SET_EXPECT(Frame_SetActiveObject);
1480 SET_EXPECT(UIWindow_SetActiveObject);
1481 SET_EXPECT(SetMenu);
1483 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1484 0, (HWND)0xdeadbeef, &rect);
1485 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1487 CHECK_CALLED(CanInPlaceActivate);
1488 CHECK_CALLED(Site_GetWindow);
1489 CHECK_CALLED(OnInPlaceActivate);
1490 CHECK_CALLED(GetWindowContext);
1491 CHECK_CALLED(ShowObject);
1492 CHECK_CALLED(GetContainer);
1493 CHECK_CALLED(Frame_GetWindow);
1494 CHECK_CALLED(OnUIActivate);
1495 CHECK_CALLED(Frame_SetActiveObject);
1496 CHECK_CALLED(UIWindow_SetActiveObject);
1497 CHECK_CALLED(SetMenu);
1499 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1500 0, (HWND)0xdeadbeef, &rect);
1501 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1503 IOleObject_Release(oleobj);
1506 static void test_GetMiscStatus(IOleObject *oleobj)
1508 DWORD st, i;
1509 HRESULT hres;
1511 for(i=0; i<10; i++) {
1512 st = 0xdeadbeef;
1513 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1514 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1515 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1516 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1517 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1518 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1522 static void test_SetHostNames(IOleObject *oleobj)
1524 HRESULT hres;
1526 static const WCHAR test_appW[] = {'t','e','s','t',' ','a','p','p',0};
1528 hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1529 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1532 static void test_ClientSite(IUnknown *unk, IOleClientSite *client, BOOL stop_download)
1534 IOleObject *oleobj;
1535 IOleInPlaceObject *inplace;
1536 HWND hwnd;
1537 HRESULT hres;
1539 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1540 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1541 if(FAILED(hres))
1542 return;
1544 test_GetMiscStatus(oleobj);
1545 test_SetHostNames(oleobj);
1547 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1548 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1549 if(FAILED(hres)) {
1550 IOleObject_Release(oleobj);
1551 return;
1554 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1555 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1556 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1558 if(client) {
1559 SET_EXPECT(GetContainer);
1560 SET_EXPECT(Site_GetWindow);
1561 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1562 SET_EXPECT(Invoke_AMBIENT_SILENT);
1563 }else if(stop_download) {
1564 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1565 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1566 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1569 hres = IOleObject_SetClientSite(oleobj, client);
1570 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1572 if(client) {
1573 CHECK_CALLED(GetContainer);
1574 CHECK_CALLED(Site_GetWindow);
1575 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1576 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1577 }else if(stop_download) {
1578 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1579 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1580 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1583 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1584 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1585 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1587 shell_embedding_hwnd = hwnd;
1589 test_SetHostNames(oleobj);
1591 IOleInPlaceObject_Release(inplace);
1592 IOleObject_Release(oleobj);
1595 static void test_ClassInfo(IUnknown *unk)
1597 IProvideClassInfo2 *class_info;
1598 GUID guid;
1599 HRESULT hres;
1601 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1602 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
1603 if(FAILED(hres))
1604 return;
1606 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1607 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1608 ok(IsEqualGUID(&DIID_DWebBrowserEvents2, &guid), "wrong guid\n");
1610 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1611 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1612 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1614 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1615 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1616 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1618 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1619 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1621 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1622 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1624 IProvideClassInfo2_Release(class_info);
1627 static void test_ie_funcs(IUnknown *unk)
1629 IWebBrowser2 *wb;
1630 IDispatch *disp;
1631 VARIANT_BOOL b;
1632 int i;
1633 LONG hwnd;
1634 HRESULT hres;
1635 BSTR sName;
1637 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
1638 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
1639 if(FAILED(hres))
1640 return;
1642 /* HWND */
1644 hwnd = 0xdeadbeef;
1645 hres = IWebBrowser2_get_HWND(wb, &hwnd);
1646 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
1647 ok(hwnd == 0, "unexpected hwnd %x\n", hwnd);
1649 /* MenuBar */
1651 hres = IWebBrowser2_get_MenuBar(wb, &b);
1652 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1653 ok(b == VARIANT_TRUE, "b=%x\n", b);
1655 SET_EXPECT(Invoke_ONMENUBAR);
1656 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
1657 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1658 CHECK_CALLED(Invoke_ONMENUBAR);
1660 hres = IWebBrowser2_get_MenuBar(wb, &b);
1661 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1662 ok(b == VARIANT_FALSE, "b=%x\n", b);
1664 SET_EXPECT(Invoke_ONMENUBAR);
1665 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
1666 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1667 CHECK_CALLED(Invoke_ONMENUBAR);
1669 hres = IWebBrowser2_get_MenuBar(wb, &b);
1670 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1671 ok(b == VARIANT_TRUE, "b=%x\n", b);
1673 /* AddressBar */
1675 hres = IWebBrowser2_get_AddressBar(wb, &b);
1676 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1677 ok(b == VARIANT_TRUE, "b=%x\n", b);
1679 SET_EXPECT(Invoke_ONADDRESSBAR);
1680 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
1681 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1682 CHECK_CALLED(Invoke_ONADDRESSBAR);
1684 hres = IWebBrowser2_get_AddressBar(wb, &b);
1685 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1686 ok(b == VARIANT_FALSE, "b=%x\n", b);
1688 SET_EXPECT(Invoke_ONADDRESSBAR);
1689 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
1690 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1691 CHECK_CALLED(Invoke_ONADDRESSBAR);
1693 hres = IWebBrowser2_get_AddressBar(wb, &b);
1694 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1695 ok(b == VARIANT_TRUE, "b=%x\n", b);
1697 SET_EXPECT(Invoke_ONADDRESSBAR);
1698 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
1699 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1700 CHECK_CALLED(Invoke_ONADDRESSBAR);
1702 /* StatusBar */
1704 hres = IWebBrowser2_get_StatusBar(wb, &b);
1705 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1706 ok(b == VARIANT_TRUE, "b=%x\n", b);
1708 SET_EXPECT(Invoke_ONSTATUSBAR);
1709 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
1710 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1711 CHECK_CALLED(Invoke_ONSTATUSBAR);
1713 hres = IWebBrowser2_get_StatusBar(wb, &b);
1714 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1715 ok(b == VARIANT_TRUE, "b=%x\n", b);
1717 SET_EXPECT(Invoke_ONSTATUSBAR);
1718 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
1719 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1720 CHECK_CALLED(Invoke_ONSTATUSBAR);
1722 hres = IWebBrowser2_get_StatusBar(wb, &b);
1723 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1724 ok(b == VARIANT_FALSE, "b=%x\n", b);
1726 SET_EXPECT(Invoke_ONSTATUSBAR);
1727 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
1728 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1729 CHECK_CALLED(Invoke_ONSTATUSBAR);
1731 hres = IWebBrowser2_get_StatusBar(wb, &b);
1732 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1733 ok(b == VARIANT_TRUE, "b=%x\n", b);
1735 /* ToolBar */
1737 hres = IWebBrowser2_get_ToolBar(wb, &i);
1738 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1739 ok(i, "i=%x\n", i);
1741 SET_EXPECT(Invoke_ONTOOLBAR);
1742 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
1743 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1744 CHECK_CALLED(Invoke_ONTOOLBAR);
1746 hres = IWebBrowser2_get_ToolBar(wb, &i);
1747 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1748 ok(i == VARIANT_FALSE, "b=%x\n", i);
1750 SET_EXPECT(Invoke_ONTOOLBAR);
1751 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
1752 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1753 CHECK_CALLED(Invoke_ONTOOLBAR);
1755 hres = IWebBrowser2_get_ToolBar(wb, &i);
1756 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1757 ok(i, "i=%x\n", i);
1759 SET_EXPECT(Invoke_ONTOOLBAR);
1760 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
1761 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1762 CHECK_CALLED(Invoke_ONTOOLBAR);
1764 /* FullScreen */
1766 hres = IWebBrowser2_get_FullScreen(wb, &b);
1767 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1768 ok(b == VARIANT_FALSE, "b=%x\n", b);
1770 SET_EXPECT(Invoke_ONFULLSCREEN);
1771 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
1772 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1773 CHECK_CALLED(Invoke_ONFULLSCREEN);
1775 hres = IWebBrowser2_get_FullScreen(wb, &b);
1776 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1777 ok(b == VARIANT_TRUE, "b=%x\n", b);
1779 SET_EXPECT(Invoke_ONFULLSCREEN);
1780 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
1781 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1782 CHECK_CALLED(Invoke_ONFULLSCREEN);
1784 hres = IWebBrowser2_get_FullScreen(wb, &b);
1785 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
1786 ok(b == VARIANT_TRUE, "b=%x\n", b);
1788 SET_EXPECT(Invoke_ONFULLSCREEN);
1789 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
1790 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
1791 CHECK_CALLED(Invoke_ONFULLSCREEN);
1793 /* TheaterMode */
1795 hres = IWebBrowser2_get_TheaterMode(wb, &b);
1796 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1797 ok(b == VARIANT_FALSE, "b=%x\n", b);
1799 SET_EXPECT(Invoke_ONTHEATERMODE);
1800 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
1801 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1802 CHECK_CALLED(Invoke_ONTHEATERMODE);
1804 hres = IWebBrowser2_get_TheaterMode(wb, &b);
1805 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1806 ok(b == VARIANT_TRUE, "b=%x\n", b);
1808 SET_EXPECT(Invoke_ONTHEATERMODE);
1809 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
1810 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1811 CHECK_CALLED(Invoke_ONTHEATERMODE);
1813 hres = IWebBrowser2_get_TheaterMode(wb, &b);
1814 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
1815 ok(b == VARIANT_TRUE, "b=%x\n", b);
1817 SET_EXPECT(Invoke_ONTHEATERMODE);
1818 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
1819 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
1820 CHECK_CALLED(Invoke_ONTHEATERMODE);
1822 /* Resizable */
1824 b = 0x100;
1825 hres = IWebBrowser2_get_Resizable(wb, &b);
1826 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
1827 ok(b == 0x100, "b=%x\n", b);
1829 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
1830 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
1831 ok(hres == S_OK || broken(hres == E_NOTIMPL), "put_Resizable failed: %08x\n", hres);
1832 CHECK_CALLED_BROKEN(Invoke_WINDOWSETRESIZABLE);
1834 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
1835 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
1836 ok(hres == S_OK || broken(hres == E_NOTIMPL), "put_Resizable failed: %08x\n", hres);
1837 CHECK_CALLED_BROKEN(Invoke_WINDOWSETRESIZABLE);
1839 hres = IWebBrowser2_get_Resizable(wb, &b);
1840 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
1841 ok(b == 0x100, "b=%x\n", b);
1843 /* Application */
1845 disp = NULL;
1846 hres = IWebBrowser2_get_Application(wb, &disp);
1847 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
1848 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
1849 if(disp)
1850 IDispatch_Release(disp);
1852 hres = IWebBrowser2_get_Application(wb, NULL);
1853 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
1855 /* Name */
1856 hres = IWebBrowser2_get_Name(wb, &sName);
1857 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
1858 if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) == LANG_ENGLISH)
1859 ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
1860 else /* Non-English cannot be blank. */
1861 ok(sName!=NULL, "get_Name return a NULL string.\n");
1862 SysFreeString(sName);
1864 /* Quit */
1866 hres = IWebBrowser2_Quit(wb);
1867 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
1869 IWebBrowser2_Release(wb);
1872 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1874 VARIANT_BOOL b;
1875 HRESULT hres;
1877 b = 100;
1878 hres = IWebBrowser2_get_Silent(wb, &b);
1879 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1880 ok(b == VARIANT_FALSE, "b=%x\n", b);
1882 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
1883 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1885 b = 100;
1886 hres = IWebBrowser2_get_Silent(wb, &b);
1887 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1888 ok(b == VARIANT_TRUE, "b=%x\n", b);
1890 hres = IWebBrowser2_put_Silent(wb, 100);
1891 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1893 b = 100;
1894 hres = IWebBrowser2_get_Silent(wb, &b);
1895 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1896 ok(b == VARIANT_TRUE, "b=%x\n", b);
1898 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
1899 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1901 b = 100;
1902 hres = IWebBrowser2_get_Silent(wb, &b);
1903 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1904 ok(b == VARIANT_FALSE, "b=%x\n", b);
1906 if(is_clientsite) {
1907 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
1908 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
1910 SET_EXPECT(Invoke_AMBIENT_SILENT);
1913 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
1914 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1916 if(is_clientsite)
1917 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1919 b = 100;
1920 hres = IWebBrowser2_get_Silent(wb, &b);
1921 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
1922 ok(b == VARIANT_FALSE, "b=%x\n", b);
1925 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1927 VARIANT_BOOL b;
1928 HRESULT hres;
1930 b = 100;
1931 hres = IWebBrowser2_get_Offline(wb, &b);
1932 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1933 ok(b == VARIANT_FALSE, "b=%x\n", b);
1935 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
1936 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1938 b = 100;
1939 hres = IWebBrowser2_get_Offline(wb, &b);
1940 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1941 ok(b == VARIANT_TRUE, "b=%x\n", b);
1943 hres = IWebBrowser2_put_Offline(wb, 100);
1944 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1946 b = 100;
1947 hres = IWebBrowser2_get_Offline(wb, &b);
1948 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1949 ok(b == VARIANT_TRUE, "b=%x\n", b);
1951 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
1952 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1954 b = 100;
1955 hres = IWebBrowser2_get_Offline(wb, &b);
1956 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1957 ok(b == VARIANT_FALSE, "b=%x\n", b);
1959 if(is_clientsite) {
1960 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
1961 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
1963 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1966 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
1967 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1969 if(is_clientsite)
1970 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1972 b = 100;
1973 hres = IWebBrowser2_get_Offline(wb, &b);
1974 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
1975 ok(b == VARIANT_FALSE, "b=%x\n", b);
1978 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
1980 HRESULT hres;
1982 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1983 SET_EXPECT(Invoke_AMBIENT_SILENT);
1984 SET_EXPECT(Invoke_AMBIENT_USERMODE);
1985 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
1986 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
1987 SET_EXPECT(Invoke_AMBIENT_PALETTE);
1989 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
1990 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
1992 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1993 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
1994 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
1995 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
1996 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
1997 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
1999 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2000 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2001 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2002 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2003 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2004 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2007 static void test_wb_funcs(IUnknown *unk, BOOL is_clientsite)
2009 IWebBrowser2 *wb;
2010 IOleControl *control;
2011 HRESULT hres;
2013 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2014 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
2016 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2017 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2019 test_Silent(wb, control, is_clientsite);
2020 test_Offline(wb, control, is_clientsite);
2021 test_ambient_unknown(wb, control, is_clientsite);
2023 IWebBrowser_Release(wb);
2024 IOleControl_Release(control);
2027 static void test_GetControlInfo(IUnknown *unk)
2029 IOleControl *control;
2030 CONTROLINFO info;
2031 HRESULT hres;
2033 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2034 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2035 if(FAILED(hres))
2036 return;
2038 hres = IOleControl_GetControlInfo(control, &info);
2039 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
2040 hres = IOleControl_GetControlInfo(control, NULL);
2041 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, exxpected E_NOTIMPL\n", hres);
2043 IOleControl_Release(control);
2046 static void test_Extent(IUnknown *unk)
2048 IOleObject *oleobj;
2049 SIZE size, expected;
2050 HRESULT hres;
2051 DWORD dpi_x;
2052 DWORD dpi_y;
2053 HDC hdc;
2055 /* default aspect ratio is 96dpi / 96dpi */
2056 hdc = GetDC(0);
2057 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2058 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2059 ReleaseDC(0, hdc);
2060 if (dpi_x != 96 || dpi_y != 96)
2061 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2063 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2064 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2065 if(FAILED(hres))
2066 return;
2068 size.cx = size.cy = 0xdeadbeef;
2069 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2070 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2071 /* Default size is 50x20 pixels, in himetric units */
2072 expected.cx = MulDiv( 50, 2540, dpi_x );
2073 expected.cy = MulDiv( 20, 2540, dpi_y );
2074 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2075 size.cx, size.cy, expected.cx, expected.cy );
2077 size.cx = 800;
2078 size.cy = 700;
2079 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2080 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2082 size.cx = size.cy = 0xdeadbeef;
2083 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2084 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2085 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2087 size.cx = size.cy = 0xdeadbeef;
2088 hres = IOleObject_GetExtent(oleobj, 0, &size);
2089 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2090 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2092 size.cx = 900;
2093 size.cy = 800;
2094 hres = IOleObject_SetExtent(oleobj, 0, &size);
2095 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2097 size.cx = size.cy = 0xdeadbeef;
2098 hres = IOleObject_GetExtent(oleobj, 0, &size);
2099 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2100 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2102 size.cx = size.cy = 0xdeadbeef;
2103 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2104 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2105 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2107 size.cx = 1000;
2108 size.cy = 900;
2109 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2110 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2112 size.cx = size.cy = 0xdeadbeef;
2113 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2114 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2115 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2117 size.cx = size.cy = 0xdeadbeef;
2118 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2119 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2120 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2122 IOleObject_Release(oleobj);
2125 static void test_ConnectionPoint(IUnknown *unk, BOOL init)
2127 IConnectionPointContainer *container;
2128 IConnectionPoint *point;
2129 HRESULT hres;
2131 static DWORD dw = 100;
2133 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2134 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2135 if(FAILED(hres))
2136 return;
2138 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2139 IConnectionPointContainer_Release(container);
2140 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2141 if(FAILED(hres))
2142 return;
2144 if(init) {
2145 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2146 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2147 ok(dw == 1, "dw=%d, expected 1\n", dw);
2148 }else {
2149 hres = IConnectionPoint_Unadvise(point, dw);
2150 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2153 IConnectionPoint_Release(point);
2156 static void test_Navigate2(IUnknown *unk)
2158 IWebBrowser2 *webbrowser;
2159 VARIANT url;
2160 HRESULT hres;
2162 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&webbrowser);
2163 ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
2164 if(FAILED(hres))
2165 return;
2167 test_LocationURL(unk, is_first_load ? "" : current_url);
2168 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2170 V_VT(&url) = VT_BSTR;
2171 V_BSTR(&url) = a2bstr("about:blank");
2172 current_url = "about:blank";
2174 if(is_first_load) {
2175 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2176 SET_EXPECT(Invoke_PROPERTYCHANGE);
2177 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2178 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2179 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2180 SET_EXPECT(EnableModeless_FALSE);
2181 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2182 SET_EXPECT(SetStatusText);
2183 SET_EXPECT(GetHostInfo);
2184 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2185 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2186 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2187 SET_EXPECT(GetOptionKeyPath);
2188 SET_EXPECT(GetOverridesKeyPath);
2189 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2190 SET_EXPECT(Exec_SETPROGRESSMAX);
2191 SET_EXPECT(Exec_SETPROGRESSPOS);
2192 SET_EXPECT(Invoke_SETSECURELOCKICON);
2193 SET_EXPECT(Invoke_FILEDOWNLOAD);
2194 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2195 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2196 SET_EXPECT(EnableModeless_TRUE);
2199 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2200 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2202 if(is_first_load) {
2203 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2204 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2205 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2206 todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2207 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2208 CHECK_CALLED(EnableModeless_FALSE);
2209 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2210 CHECK_CALLED(SetStatusText);
2211 CHECK_CALLED(GetHostInfo);
2212 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2213 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2214 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2215 CHECK_CALLED(GetOptionKeyPath);
2216 CHECK_CALLED_BROKEN(GetOverridesKeyPath);
2217 todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2218 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2219 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2220 todo_wine CHECK_CALLED_BROKEN(Invoke_SETSECURELOCKICON);
2221 todo_wine CHECK_CALLED_BROKEN(Invoke_FILEDOWNLOAD);
2222 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2223 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2224 CHECK_CALLED(EnableModeless_TRUE);
2227 VariantClear(&url);
2228 IWebBrowser2_Release(webbrowser);
2230 test_ready_state(READYSTATE_LOADING);
2233 static void test_download(DWORD flags)
2235 MSG msg;
2237 is_downloading = TRUE;
2238 dwl_flags = flags;
2240 test_ready_state((flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2242 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2243 SET_EXPECT(Invoke_PROPERTYCHANGE);
2244 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2245 SET_EXPECT(TranslateUrl);
2247 SET_EXPECT(Exec_SETPROGRESSMAX);
2248 SET_EXPECT(Exec_SETPROGRESSPOS);
2249 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2250 SET_EXPECT(DocHost_EnableModeless_FALSE);
2251 SET_EXPECT(DocHost_EnableModeless_TRUE);
2252 SET_EXPECT(Invoke_SETSECURELOCKICON);
2253 SET_EXPECT(Invoke_282);
2254 SET_EXPECT(EnableModeless_FALSE);
2255 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2256 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2257 SET_EXPECT(SetStatusText);
2258 SET_EXPECT(EnableModeless_TRUE);
2259 if(is_first_load)
2260 SET_EXPECT(QueryStatus_STOP);
2261 else
2262 SET_EXPECT(GetHostInfo);
2263 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2264 SET_EXPECT(Invoke_TITLECHANGE);
2265 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2266 if(is_first_load)
2267 SET_EXPECT(GetDropTarget);
2268 SET_EXPECT(Invoke_PROGRESSCHANGE);
2269 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2270 while(!called_Invoke_DOCUMENTCOMPLETE && GetMessage(&msg, NULL, 0, 0)) {
2271 TranslateMessage(&msg);
2272 DispatchMessage(&msg);
2275 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2276 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2277 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2278 CHECK_CALLED(TranslateUrl);
2280 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2281 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2282 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2283 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
2284 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
2285 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2286 CLEAR_CALLED(Invoke_282); /* IE 7 */
2287 if(is_first_load)
2288 todo_wine CHECK_CALLED(EnableModeless_FALSE);
2289 else
2290 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2291 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE);
2292 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2293 todo_wine CHECK_CALLED(SetStatusText);
2294 if(is_first_load)
2295 todo_wine CHECK_CALLED(EnableModeless_TRUE);
2296 else
2297 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2298 if(is_first_load)
2299 todo_wine CHECK_CALLED(QueryStatus_STOP);
2300 else
2301 todo_wine CHECK_CALLED(GetHostInfo);
2302 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2303 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
2304 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
2305 if(is_first_load)
2306 todo_wine CHECK_CALLED(GetDropTarget);
2307 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2308 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
2310 is_downloading = FALSE;
2312 test_ready_state(READYSTATE_COMPLETE);
2315 static void test_olecmd(IUnknown *unk, BOOL loaded)
2317 IOleCommandTarget *cmdtrg;
2318 OLECMD cmds[3];
2319 HRESULT hres;
2321 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2322 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
2323 if(FAILED(hres))
2324 return;
2326 cmds[0].cmdID = OLECMDID_SPELL;
2327 cmds[0].cmdf = 0xdeadbeef;
2328 cmds[1].cmdID = OLECMDID_REFRESH;
2329 cmds[1].cmdf = 0xdeadbeef;
2330 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
2331 if(loaded) {
2332 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2333 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2334 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
2335 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
2336 }else {
2337 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
2338 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2339 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
2342 IOleCommandTarget_Release(cmdtrg);
2345 static void test_IServiceProvider(IUnknown *unk)
2347 IServiceProvider *servprov = (void*)0xdeadbeef;
2348 HRESULT hres;
2349 IUnknown *ret = NULL;
2350 static const IID IID_IBrowserService2 =
2351 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
2353 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
2354 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
2355 if(FAILED(hres))
2356 return;
2358 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&ret);
2359 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
2360 ok(ret == NULL, "ret returned %p, expected NULL\n", ret);
2361 if(hres == S_OK)
2363 IUnknown_Release(ret);
2366 IServiceProvider_Release(servprov);
2369 #define get_document(u) _get_document(__LINE__,u)
2370 static IDispatch *_get_document(unsigned line, IUnknown *unk)
2372 IHTMLDocument2 *html_doc;
2373 IWebBrowser2 *wb;
2374 IDispatch *disp;
2375 HRESULT hres;
2377 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2378 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IWebBrowser2) failed: %08x\n", hres);
2380 disp = NULL;
2381 hres = IWebBrowser2_get_Document(wb, &disp);
2382 IWebBrowser2_Release(wb);
2383 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
2384 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
2386 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
2387 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
2388 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
2389 IHTMLDocument_Release(html_doc);
2391 return disp;
2394 static void test_put_href(IUnknown *unk)
2396 IHTMLLocation *location;
2397 IHTMLDocument2 *doc;
2398 IDispatch *doc_disp;
2399 BSTR str;
2400 HRESULT hres;
2402 doc_disp = get_document(unk);
2404 hres = IDispatch_QueryInterface(doc_disp, &IID_IHTMLDocument2, (void**)&doc);
2405 IDispatch_Release(doc_disp);
2406 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2 failed: %08x\n", hres);
2408 location = NULL;
2409 hres = IHTMLDocument2_get_location(doc, &location);
2410 IHTMLDocument2_Release(doc);
2411 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2412 ok(location != NULL, "location == NULL\n");
2414 SET_EXPECT(TranslateUrl);
2415 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2416 SET_EXPECT(Invoke_PROPERTYCHANGE);
2418 dwl_flags = DWL_FROM_PUT_HREF;
2420 str = a2bstr("about:test");
2421 current_url = "about:test";
2422 is_first_load = FALSE;
2423 hres = IHTMLLocation_put_href(location, str);
2425 CHECK_CALLED(TranslateUrl);
2426 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2427 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2429 IHTMLLocation_Release(location);
2430 SysFreeString(str);
2431 ok(hres == S_OK, "put_href failed: %08x\n", hres);
2433 test_ready_state(READYSTATE_COMPLETE);
2436 static void test_QueryInterface(IUnknown *unk)
2438 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
2439 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
2440 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
2441 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
2442 IOleCache *cache = (void*)0xdeadbeef;
2443 IObjectWithSite *site = (void*)0xdeadbeef;
2444 IViewObjectEx *viewex = (void*)0xdeadbeef;
2445 HRESULT hres;
2447 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
2448 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2449 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
2451 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
2452 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2453 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
2455 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
2456 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2457 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
2459 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
2460 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2461 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
2463 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
2464 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2465 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
2467 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2468 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2469 ok(site == NULL, "site=%p, expected NULL\n", site);
2471 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
2472 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2473 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
2477 static void test_WebBrowser(BOOL do_download)
2479 IUnknown *unk = NULL;
2480 ULONG ref;
2481 HRESULT hres;
2483 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2484 &IID_IUnknown, (void**)&unk);
2485 ok(hres == S_OK, "CoCreateInterface failed: %08x\n", hres);
2486 if(FAILED(hres))
2487 return;
2489 is_downloading = FALSE;
2490 is_first_load = TRUE;
2492 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2493 ok(hres == S_OK, "Could not get IWebBrowser2 iface: %08x\n", hres);
2495 test_QueryInterface(unk);
2496 test_ready_state(READYSTATE_UNINITIALIZED);
2497 test_ClassInfo(unk);
2498 test_LocationURL(unk, "");
2499 test_ConnectionPoint(unk, TRUE);
2500 test_ClientSite(unk, &ClientSite, !do_download);
2501 test_Extent(unk);
2502 test_wb_funcs(unk, TRUE);
2503 test_DoVerb(unk);
2504 test_olecmd(unk, FALSE);
2505 test_Navigate2(unk);
2507 if(do_download) {
2508 IDispatch *doc, *doc2;
2510 test_download(0);
2511 test_olecmd(unk, TRUE);
2512 doc = get_document(unk);
2514 test_put_href(unk);
2515 test_download(DWL_FROM_PUT_HREF);
2516 doc2 = get_document(unk);
2517 ok(doc == doc2, "doc != doc2\n");
2518 IDispatch_Release(doc2);
2520 test_Navigate2(unk);
2521 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
2522 doc2 = get_document(unk);
2523 ok(doc == doc2, "doc != doc2\n");
2524 IDispatch_Release(doc2);
2525 IDispatch_Release(doc2);
2528 test_ClientSite(unk, NULL, !do_download);
2529 test_ie_funcs(unk);
2530 test_GetControlInfo(unk);
2531 test_wb_funcs(unk, FALSE);
2532 test_ConnectionPoint(unk, FALSE);
2533 test_IServiceProvider(unk);
2535 IWebBrowser2_Release(wb);
2536 ref = IUnknown_Release(unk);
2537 ok(ref == 0, "ref=%d, expected 0\n", ref);
2540 START_TEST(webbrowser)
2542 container_hwnd = create_container_window();
2544 OleInitialize(NULL);
2546 trace("Testing WebBrowser (no download)...\n");
2547 test_WebBrowser(FALSE);
2548 trace("Testing WebBrowser...\n");
2549 test_WebBrowser(TRUE);
2551 OleUninitialize();