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
22 #include <wine/test.h>
39 #include "shdeprecated.h"
44 #include "docobjectservice.h"
46 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
47 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
49 #define DEFINE_EXPECT(func) \
50 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
52 #define SET_EXPECT(func) \
53 expect_ ## func = TRUE
55 #define CHECK_EXPECT2(func) \
57 ok(expect_ ##func, "unexpected call " #func "\n"); \
58 called_ ## func = TRUE; \
61 #define CHECK_EXPECT(func) \
63 CHECK_EXPECT2(func); \
64 expect_ ## func = FALSE; \
67 #define CHECK_CALLED(func) \
69 ok(called_ ## func, "expected " #func "\n"); \
70 expect_ ## func = called_ ## func = FALSE; \
73 #define CLEAR_CALLED(func) \
74 expect_ ## func = called_ ## func = FALSE
76 DEFINE_EXPECT(GetContainer);
77 DEFINE_EXPECT(Site_GetWindow);
78 DEFINE_EXPECT(ShowObject);
79 DEFINE_EXPECT(CanInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivate);
81 DEFINE_EXPECT(OnUIActivate);
82 DEFINE_EXPECT(GetWindowContext);
83 DEFINE_EXPECT(Frame_GetWindow);
84 DEFINE_EXPECT(Frame_SetActiveObject);
85 DEFINE_EXPECT(UIWindow_SetActiveObject);
86 DEFINE_EXPECT(SetMenu);
87 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
88 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
89 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
90 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
91 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
92 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
93 DEFINE_EXPECT(Invoke_STATUSTEXTCHANGE);
94 DEFINE_EXPECT(Invoke_PROPERTYCHANGE);
95 DEFINE_EXPECT(Invoke_DOWNLOADBEGIN);
96 DEFINE_EXPECT(Invoke_BEFORENAVIGATE2);
97 DEFINE_EXPECT(Invoke_SETSECURELOCKICON);
98 DEFINE_EXPECT(Invoke_FILEDOWNLOAD);
99 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE);
100 DEFINE_EXPECT(Invoke_DOWNLOADCOMPLETE);
101 DEFINE_EXPECT(Invoke_ONMENUBAR);
102 DEFINE_EXPECT(Invoke_ONADDRESSBAR);
103 DEFINE_EXPECT(Invoke_ONSTATUSBAR);
104 DEFINE_EXPECT(Invoke_ONTOOLBAR);
105 DEFINE_EXPECT(Invoke_ONFULLSCREEN);
106 DEFINE_EXPECT(Invoke_ONTHEATERMODE);
107 DEFINE_EXPECT(Invoke_WINDOWSETRESIZABLE);
108 DEFINE_EXPECT(Invoke_TITLECHANGE);
109 DEFINE_EXPECT(Invoke_NAVIGATECOMPLETE2);
110 DEFINE_EXPECT(Invoke_PROGRESSCHANGE);
111 DEFINE_EXPECT(Invoke_DOCUMENTCOMPLETE);
112 DEFINE_EXPECT(Invoke_282);
113 DEFINE_EXPECT(EnableModeless_TRUE);
114 DEFINE_EXPECT(EnableModeless_FALSE);
115 DEFINE_EXPECT(GetHostInfo);
116 DEFINE_EXPECT(GetOptionKeyPath);
117 DEFINE_EXPECT(GetOverridesKeyPath);
118 DEFINE_EXPECT(SetStatusText);
119 DEFINE_EXPECT(UpdateUI);
120 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
121 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
122 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
123 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
124 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
125 DEFINE_EXPECT(Exec_SETTITLE);
126 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
127 DEFINE_EXPECT(Exec_STOP);
128 DEFINE_EXPECT(Exec_IDM_STOP);
129 DEFINE_EXPECT(QueryStatus_STOP);
130 DEFINE_EXPECT(QueryStatus_IDM_STOP);
131 DEFINE_EXPECT(DocHost_EnableModeless_TRUE);
132 DEFINE_EXPECT(DocHost_EnableModeless_FALSE);
133 DEFINE_EXPECT(DocHost_TranslateAccelerator);
134 DEFINE_EXPECT(GetDropTarget);
135 DEFINE_EXPECT(TranslateUrl);
136 DEFINE_EXPECT(ShowUI);
137 DEFINE_EXPECT(HideUI);
138 DEFINE_EXPECT(OnUIDeactivate);
139 DEFINE_EXPECT(OnInPlaceDeactivate);
140 DEFINE_EXPECT(RequestUIActivate);
141 DEFINE_EXPECT(ControlSite_TranslateAccelerator);
142 DEFINE_EXPECT(OnFocus);
143 DEFINE_EXPECT(GetExternal);
145 static const WCHAR wszItem[] = {'i','t','e','m',0};
146 static const WCHAR emptyW[] = {0};
148 static VARIANT_BOOL exvb;
150 static IWebBrowser2 *wb;
152 static HWND container_hwnd, shell_embedding_hwnd;
153 static BOOL is_downloading, is_first_load, use_container_olecmd, test_close, is_http, use_container_dochostui;
154 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
155 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
156 static const char *current_url;
157 static int wb_version;
159 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
160 #define DWL_FROM_PUT_HREF 0x02
161 #define DWL_FROM_GOBACK 0x04
162 #define DWL_HTTP 0x08
164 static DWORD dwl_flags;
167 /* Returns true if the user interface is in English. Note that this does not
168 * presume of the formatting of dates, numbers, etc.
170 static BOOL is_lang_english(void)
172 static HMODULE hkernel32 = NULL;
173 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
174 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
178 hkernel32 = GetModuleHandleA("kernel32.dll");
179 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
180 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
182 if (pGetThreadUILanguage)
183 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
184 if (pGetUserDefaultUILanguage)
185 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
187 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
190 static int strcmp_wa(LPCWSTR strw, const char *stra)
193 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
194 return lstrcmpA(stra, buf);
197 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
199 IUnknown *unk1, *unk2;
204 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
205 IUnknown_Release(unk1);
206 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
207 IUnknown_Release(unk2);
212 static const char *debugstr_guid(REFIID riid)
216 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
217 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
218 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
219 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
224 static BSTR a2bstr(const char *str)
229 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
230 ret = SysAllocStringLen(NULL, len);
231 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
236 #define create_webbrowser() _create_webbrowser(__LINE__)
237 static IWebBrowser2 *_create_webbrowser(unsigned line)
244 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
245 &IID_IWebBrowser2, (void**)&ret);
246 ok_(__FILE__,line)(hres == S_OK, "Creating WebBrowser object failed: %08x\n", hres);
250 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
251 static void _test_LocationURL(unsigned line, IWebBrowser2 *wb, const char *exurl)
253 BSTR url = (void*)0xdeadbeef;
256 hres = IWebBrowser2_get_LocationURL(wb, &url);
257 ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
260 ok_(__FILE__,line) (!strcmp_wa(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
265 #define test_ready_state(ex) _test_ready_state(__LINE__,ex);
266 static void _test_ready_state(unsigned line, READYSTATE exstate)
271 hres = IWebBrowser2_get_ReadyState(wb, &state);
272 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
273 ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
276 #define get_document(u) _get_document(__LINE__,u)
277 static IDispatch *_get_document(unsigned line, IWebBrowser2 *wb)
279 IHTMLDocument2 *html_doc;
284 hres = IWebBrowser2_get_Document(wb, &disp);
285 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
286 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
288 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
289 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
290 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
291 IHTMLDocument_Release(html_doc);
296 #define get_dochost(u) _get_dochost(__LINE__,u)
297 static IOleClientSite *_get_dochost(unsigned line, IWebBrowser2 *unk)
299 IOleClientSite *client_site;
304 doc = _get_document(line, unk);
305 hres = IDispatch_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
306 IDispatch_Release(doc);
307 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
309 hres = IOleObject_GetClientSite(oleobj, &client_site);
310 IOleObject_Release(oleobj);
311 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
316 static HRESULT QueryInterface(REFIID,void**);
318 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
319 REFIID riid, void **ppv)
321 ok(0, "unexpected call\n");
322 return E_NOINTERFACE;
325 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
330 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
335 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
336 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
338 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
339 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
340 ok(!pCmdText, "pCmdText != NULL\n");
342 switch(prgCmds[0].cmdID) {
344 CHECK_EXPECT2(QueryStatus_STOP);
345 prgCmds[0].cmdf = OLECMDF_SUPPORTED;
347 case OLECMDID_SETPROGRESSTEXT:
348 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
349 prgCmds[0].cmdf = OLECMDF_ENABLED;
353 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
354 * This command appears here for the ExecWB and QueryStatusWB tests in order
355 * to help demonstrate that these routines use a NULL pguidCmdGroup.
357 CHECK_EXPECT(QueryStatus_IDM_STOP);
361 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
367 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
368 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
372 case OLECMDID_SETPROGRESSMAX:
373 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
374 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
375 ok(pvaIn != NULL, "pvaIn == NULL\n");
377 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
378 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
380 case OLECMDID_SETPROGRESSPOS:
381 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
382 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
383 ok(pvaIn != NULL, "pvaIn == NULL\n");
385 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
386 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
388 case OLECMDID_SETDOWNLOADSTATE:
390 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
391 "nCmdexecopts=%08x\n", nCmdexecopt);
393 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
394 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
395 ok(pvaIn != NULL, "pvaIn == NULL\n");
396 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
397 switch(V_I4(pvaIn)) {
399 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
402 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
405 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
408 case OLECMDID_UPDATECOMMANDS:
409 CHECK_EXPECT2(Exec_UPDATECOMMANDS);
410 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
411 ok(!pvaIn, "pvaIn != NULL\n");
412 ok(!pvaOut, "pvaOut=%p, expected NULL\n", pvaOut);
414 case OLECMDID_SETTITLE:
415 CHECK_EXPECT(Exec_SETTITLE);
416 /* TODO: test args */
419 CHECK_EXPECT(Exec_STOP);
423 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
424 * This command appears here for the ExecWB and QueryStatusWB tests in order
425 * to help demonstrate that these routines use a NULL pguidCmdGroup.
427 CHECK_EXPECT(Exec_IDM_STOP);
428 return OLECMDERR_E_NOTSUPPORTED;
429 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
430 case 6058: /* TODO */
433 ok(0, "unexpected nsCmdID %d\n", nCmdID);
435 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
445 case 101: /* TODO (IE8) */
446 case 109: /* TODO (IE9) */
449 ok(0, "unexpected nCmdID %d\n", nCmdID);
451 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
455 case 140: /* TODO (Win7) */
458 ok(0, "unexpected nCmdID %d\n", nCmdID);
460 }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
465 ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
467 }else if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
469 case 6041: /* TODO */
472 ok(0, "unexpected nCmdID %d of CGID_DocHostCommandHandler\n", nCmdID);
475 ok(0, "unexpected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
481 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
482 OleCommandTarget_QueryInterface,
483 OleCommandTarget_AddRef,
484 OleCommandTarget_Release,
485 OleCommandTarget_QueryStatus,
486 OleCommandTarget_Exec
489 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
491 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
493 if(IsEqualGUID(&IID_ITargetContainer, riid))
494 return E_NOINTERFACE; /* TODO */
496 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
497 if(use_container_olecmd)
499 *ppv = &OleCommandTarget;
503 return E_NOINTERFACE;
506 ok(0, "unexpected call\n");
507 return E_NOINTERFACE;
510 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
515 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
520 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
521 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
523 ok(0, "unexpected call\n");
527 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
528 IEnumUnknown **ppenum)
530 ok(0, "unexpected call\n");
534 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
536 ok(0, "unexpected call\n");
540 static const IOleContainerVtbl OleContainerVtbl = {
541 OleContainer_QueryInterface,
543 OleContainer_Release,
544 OleContainer_ParseDisplayName,
545 OleContainer_EnumObjects,
546 OleContainer_LockContainer
549 static IOleContainer OleContainer = { &OleContainerVtbl };
551 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
553 return QueryInterface(riid, ppv);
556 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
561 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
566 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
568 ok(0, "unexpected call\n");
572 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
575 ok(0, "unexpected call\n");
579 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
580 UINT cNames, LCID lcid, DISPID *rgDispId)
582 ok(0, "unexpected call\n");
586 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
587 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
588 EXCEPINFO *pExcepInfo, UINT *puArgErr)
590 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
591 ok(pDispParams != NULL, "pDispParams == NULL\n");
592 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
593 ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
594 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
595 ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
596 ok(pDispParams->rgdispidNamedArgs == NULL,
597 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
598 ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
599 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
601 switch(dispIdMember) {
602 case DISPID_AMBIENT_USERMODE:
603 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
605 case DISPID_AMBIENT_DLCONTROL:
606 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
607 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
609 case DISPID_AMBIENT_USERAGENT:
610 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
611 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
613 case DISPID_AMBIENT_PALETTE:
614 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
615 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
617 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
618 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
619 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
620 V_VT(pVarResult) = VT_BOOL;
621 V_BOOL(pVarResult) = VARIANT_FALSE;
623 case DISPID_AMBIENT_SILENT:
624 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
625 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
626 V_VT(pVarResult) = VT_BOOL;
627 V_BOOL(pVarResult) = VARIANT_FALSE;
631 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
635 static IDispatchVtbl DispatchVtbl = {
636 Dispatch_QueryInterface,
639 Dispatch_GetTypeInfoCount,
640 Dispatch_GetTypeInfo,
641 Dispatch_GetIDsOfNames,
645 static IDispatch Dispatch = { &DispatchVtbl };
647 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
651 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
656 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
657 return E_NOINTERFACE;
660 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
661 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
663 ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
664 ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
665 ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
667 ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
668 V_BOOL(params->rgvarg), exvb);
670 ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
671 V_BOOL(params->rgvarg), exvb);
674 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
675 const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
677 ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
678 ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
679 ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
681 ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
682 ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
683 if(V_VARIANTREF(url)) {
684 ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
685 V_VT(V_VARIANTREF(url)));
686 ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
687 ok(!strcmp_wa(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
688 wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), current_url);
691 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
693 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
695 ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
696 if(V_VARIANTREF(flags)) {
697 ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
698 V_VT(V_VARIANTREF(flags)));
700 ok(V_I4(V_VARIANTREF(flags)) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0\n",
701 V_I4(V_VARIANTREF(flags)));
703 ok((V_I4(V_VARIANTREF(flags)) & ~0x40) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0x40 or 0\n",
704 V_I4(V_VARIANTREF(flags)));
708 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
710 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
712 ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
713 if(V_VARIANTREF(frame)) {
714 ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
715 V_VT(V_VARIANTREF(frame)));
716 ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
717 V_BSTR(V_VARIANTREF(frame)));
720 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
722 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
724 ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
725 if(V_VARIANTREF(post_data)) {
726 ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
727 "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
728 V_VT(V_VARIANTREF(post_data)));
729 ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
730 "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
731 if(V_VARIANTREF(V_VARIANTREF(post_data))) {
732 ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
733 "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
734 V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
736 if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
737 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
739 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
740 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
745 ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
747 ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
748 if(V_VARIANTREF(headers)) {
749 ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
750 V_VT(V_VARIANTREF(headers)));
751 ok(V_BSTR(V_VARIANTREF(headers)) == NULL, "V_BSTR(V_VARIANTREF(headers)) = %p, expected NULL\n",
752 V_BSTR(V_VARIANTREF(headers)));
755 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
757 ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
758 if(V_BOOLREF(cancel))
759 ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(cancel) = %x, expected VARIANT_FALSE\n",
763 static void test_navigatecomplete2(DISPPARAMS *dp)
767 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
769 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
770 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
772 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
773 v = V_VARIANTREF(dp->rgvarg);
774 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
775 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
777 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
778 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
780 test_ready_state((dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
783 static void test_documentcomplete(DISPPARAMS *dp)
787 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
789 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
790 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
792 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
793 v = V_VARIANTREF(dp->rgvarg);
794 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
795 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
797 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
798 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
800 test_ready_state(READYSTATE_COMPLETE);
803 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
804 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
805 EXCEPINFO *pExcepInfo, UINT *puArgErr)
807 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
808 ok(pDispParams != NULL, "pDispParams == NULL\n");
809 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
810 ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
811 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
812 ok(pDispParams->rgdispidNamedArgs == NULL,
813 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
814 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
816 switch(dispIdMember) {
817 case DISPID_STATUSTEXTCHANGE:
818 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
820 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
821 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
822 ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
823 V_VT(pDispParams->rgvarg));
824 /* TODO: Check text */
827 case DISPID_PROPERTYCHANGE:
828 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
830 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
831 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
832 /* TODO: Check args */
835 case DISPID_DOWNLOADBEGIN:
836 CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
838 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
839 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
840 test_ready_state(READYSTATE_LOADING);
843 case DISPID_BEFORENAVIGATE2:
844 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
846 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
847 ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
848 test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
849 pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
850 pDispParams->rgvarg);
851 test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
854 case DISPID_SETSECURELOCKICON:
855 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
857 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
858 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
859 /* TODO: Check args */
862 case DISPID_FILEDOWNLOAD:
863 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
865 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
866 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
867 /* TODO: Check args */
870 case DISPID_COMMANDSTATECHANGE:
871 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
873 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
874 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
876 ok(V_VT(pDispParams->rgvarg) == VT_BOOL, "V_VT(pDispParams->rgvarg) = %d\n", V_VT(pDispParams->rgvarg));
877 ok(V_VT(pDispParams->rgvarg+1) == VT_I4, "V_VT(pDispParams->rgvarg+1) = %d\n", V_VT(pDispParams->rgvarg+1));
879 /* TODO: Check args */
882 case DISPID_DOWNLOADCOMPLETE:
883 CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
885 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
886 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
887 test_ready_state(READYSTATE_LOADING);
890 case DISPID_ONMENUBAR:
891 CHECK_EXPECT(Invoke_ONMENUBAR);
892 test_invoke_bool(pDispParams, TRUE);
895 case DISPID_ONADDRESSBAR:
896 CHECK_EXPECT(Invoke_ONADDRESSBAR);
897 test_invoke_bool(pDispParams, TRUE);
900 case DISPID_ONSTATUSBAR:
901 CHECK_EXPECT(Invoke_ONSTATUSBAR);
902 test_invoke_bool(pDispParams, TRUE);
905 case DISPID_ONTOOLBAR:
906 CHECK_EXPECT(Invoke_ONTOOLBAR);
907 test_invoke_bool(pDispParams, FALSE);
910 case DISPID_ONFULLSCREEN:
911 CHECK_EXPECT(Invoke_ONFULLSCREEN);
912 test_invoke_bool(pDispParams, TRUE);
915 case DISPID_ONTHEATERMODE:
916 CHECK_EXPECT(Invoke_ONTHEATERMODE);
917 test_invoke_bool(pDispParams, TRUE);
920 case DISPID_WINDOWSETRESIZABLE:
921 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
922 test_invoke_bool(pDispParams, TRUE);
925 case DISPID_TITLECHANGE:
926 CHECK_EXPECT2(Invoke_TITLECHANGE);
930 case DISPID_NAVIGATECOMPLETE2:
931 test_navigatecomplete2(pDispParams);
934 case DISPID_PROGRESSCHANGE:
935 CHECK_EXPECT2(Invoke_PROGRESSCHANGE);
939 case DISPID_DOCUMENTCOMPLETE:
940 test_documentcomplete(pDispParams);
943 case 282: /* FIXME */
944 CHECK_EXPECT2(Invoke_282);
948 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
954 static IDispatchVtbl WebBrowserEvents2Vtbl = {
955 WebBrowserEvents2_QueryInterface,
958 Dispatch_GetTypeInfoCount,
959 Dispatch_GetTypeInfo,
960 Dispatch_GetIDsOfNames,
961 WebBrowserEvents2_Invoke
964 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
966 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
968 return QueryInterface(riid, ppv);
971 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
976 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
981 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
983 ok(0, "unexpected call\n");
987 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
990 ok(0, "unexpected call\n");
994 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
996 CHECK_EXPECT(GetContainer);
998 ok(ppContainer != NULL, "ppContainer == NULL\n");
1000 *ppContainer = &OleContainer;
1005 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1007 CHECK_EXPECT(ShowObject);
1011 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1013 ok(0, "unexpected call\n");
1017 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1019 ok(0, "unexpected call\n");
1023 static const IOleClientSiteVtbl ClientSiteVtbl = {
1024 ClientSite_QueryInterface,
1027 ClientSite_SaveObject,
1028 ClientSite_GetMoniker,
1029 ClientSite_GetContainer,
1030 ClientSite_ShowObject,
1031 ClientSite_OnShowWindow,
1032 ClientSite_RequestNewObjectLayout
1035 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1037 static HRESULT WINAPI IOleControlSite_fnQueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1040 return E_NOINTERFACE;
1043 static ULONG WINAPI IOleControlSite_fnAddRef(IOleControlSite *iface)
1048 static ULONG WINAPI IOleControlSite_fnRelease(IOleControlSite *iface)
1053 static HRESULT WINAPI IOleControlSite_fnOnControlInfoChanged(IOleControlSite* This)
1055 ok(0, "unexpected call\n");
1059 static HRESULT WINAPI IOleControlSite_fnLockInPlaceActive(IOleControlSite* This,
1062 ok(0, "unexpected call\n");
1066 static HRESULT WINAPI IOleControlSite_fnGetExtendedControl(IOleControlSite* This,
1069 ok(0, "unexpected call\n");
1073 static HRESULT WINAPI IOleControlSite_fnTransformCoords(IOleControlSite* This,
1074 POINTL *pPtlHimetric,
1075 POINTF *pPtfContainer,
1078 ok(0, "unexpected call\n");
1082 static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* This, MSG *pMsg,
1085 CHECK_EXPECT(ControlSite_TranslateAccelerator);
1086 return hr_site_TranslateAccelerator;
1089 static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus)
1091 CHECK_EXPECT2(OnFocus);
1095 static HRESULT WINAPI IOleControlSite_fnShowPropertyFrame(IOleControlSite* This)
1097 ok(0, "unexpected call\n");
1101 static IOleControlSiteVtbl ControlSiteVtbl = {
1102 IOleControlSite_fnQueryInterface,
1103 IOleControlSite_fnAddRef,
1104 IOleControlSite_fnRelease,
1105 IOleControlSite_fnOnControlInfoChanged,
1106 IOleControlSite_fnLockInPlaceActive,
1107 IOleControlSite_fnGetExtendedControl,
1108 IOleControlSite_fnTransformCoords,
1109 IOleControlSite_fnTranslateAccelerator,
1110 IOleControlSite_fnOnFocus,
1111 IOleControlSite_fnShowPropertyFrame
1114 static IOleControlSite ControlSite = { &ControlSiteVtbl };
1116 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
1117 REFIID riid, void **ppv)
1119 ok(0, "unexpected call\n");
1120 return E_NOINTERFACE;
1123 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
1128 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
1133 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1135 ok(0, "unexpected call\n");
1139 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1141 CHECK_EXPECT(Frame_GetWindow);
1142 ok(phwnd != NULL, "phwnd == NULL\n");
1144 *phwnd = container_hwnd;
1148 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1150 ok(0, "unexpected call\n");
1154 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1156 ok(0, "unexpected call\n");
1160 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
1161 LPCBORDERWIDTHS pborderwidths)
1163 ok(0, "unexpected call\n");
1167 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
1168 LPCBORDERWIDTHS pborderwidths)
1170 ok(0, "unexpected call\n");
1174 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1175 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1177 CHECK_EXPECT(UIWindow_SetActiveObject);
1179 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1180 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1182 ok(!pActiveObject, "pActiveObject != NULL\n");
1183 ok(!pszObjName, "pszObjName != NULL\n");
1188 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1189 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1191 CHECK_EXPECT(Frame_SetActiveObject);
1193 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1194 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1196 ok(!pActiveObject, "pActiveObject != NULL\n");
1197 ok(!pszObjName, "pszObjName != NULL\n");
1202 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1203 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1205 ok(0, "unexpected call\n");
1209 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1210 HOLEMENU holemenu, HWND hwndActiveObject)
1212 CHECK_EXPECT(SetMenu);
1213 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
1214 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
1215 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
1216 hwndActiveObject, shell_embedding_hwnd);
1220 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1222 ok(0, "unexpected call\n");
1226 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1228 CHECK_EXPECT2(SetStatusText);
1229 /* FIXME: Check pszStatusText */
1233 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1236 CHECK_EXPECT2(EnableModeless_TRUE);
1238 CHECK_EXPECT2(EnableModeless_FALSE);
1242 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1244 ok(0, "unexpected call\n");
1248 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1249 InPlaceUIWindow_QueryInterface,
1250 InPlaceUIWindow_AddRef,
1251 InPlaceUIWindow_Release,
1252 InPlaceUIWindow_GetWindow,
1253 InPlaceUIWindow_ContextSensitiveHelp,
1254 InPlaceUIWindow_GetBorder,
1255 InPlaceUIWindow_RequestBorderSpace,
1256 InPlaceUIWindow_SetBorderSpace,
1257 InPlaceUIWindow_SetActiveObject,
1260 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
1262 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1263 InPlaceUIWindow_QueryInterface,
1264 InPlaceUIWindow_AddRef,
1265 InPlaceUIWindow_Release,
1266 InPlaceFrame_GetWindow,
1267 InPlaceUIWindow_ContextSensitiveHelp,
1268 InPlaceUIWindow_GetBorder,
1269 InPlaceUIWindow_RequestBorderSpace,
1270 InPlaceUIWindow_SetBorderSpace,
1271 InPlaceFrame_SetActiveObject,
1272 InPlaceFrame_InsertMenus,
1273 InPlaceFrame_SetMenu,
1274 InPlaceFrame_RemoveMenus,
1275 InPlaceFrame_SetStatusText,
1276 InPlaceFrame_EnableModeless,
1277 InPlaceFrame_TranslateAccelerator
1280 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1282 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1284 return QueryInterface(riid, ppv);
1287 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1292 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1297 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1299 CHECK_EXPECT(Site_GetWindow);
1300 ok(phwnd != NULL, "phwnd == NULL\n");
1302 *phwnd = container_hwnd;
1306 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1308 ok(0, "unexpected call\n");
1312 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1314 CHECK_EXPECT(CanInPlaceActivate);
1318 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1320 CHECK_EXPECT(OnInPlaceActivate);
1324 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1326 CHECK_EXPECT(OnUIActivate);
1330 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1331 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1332 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1334 static const RECT pos_rect = {2,1,1002,901};
1335 static const RECT clip_rect = {10,10,990,890};
1337 CHECK_EXPECT(GetWindowContext);
1339 ok(ppFrame != NULL, "ppFrame = NULL\n");
1341 *ppFrame = &InPlaceFrame;
1343 ok(ppDoc != NULL, "ppDoc = NULL\n");
1345 *ppDoc = &InPlaceUIWindow;
1347 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1349 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1351 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1353 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1355 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1357 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1358 lpFrameInfo->fMDIApp = FALSE;
1359 lpFrameInfo->hwndFrame = container_hwnd;
1360 lpFrameInfo->haccel = NULL;
1361 lpFrameInfo->cAccelEntries = 0;
1367 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1369 ok(0, "unexpected call\n");
1373 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1375 CHECK_EXPECT(OnUIDeactivate);
1376 ok(!fUndoable, "fUndoable should be FALSE\n");
1380 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1382 CHECK_EXPECT(OnInPlaceDeactivate);
1386 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1388 ok(0, "unexpected call\n");
1392 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1394 ok(0, "unexpected call\n");
1398 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1400 ok(0, "unexpected call\n");
1404 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1405 BOOL *pNoRedraw, DWORD dwFlags)
1407 ok(0, "unexpected call\n");
1411 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1414 ok(0, "unexpected call\n");
1418 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1420 CHECK_EXPECT2(RequestUIActivate);
1424 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1425 InPlaceSite_QueryInterface,
1427 InPlaceSite_Release,
1428 InPlaceSite_GetWindow,
1429 InPlaceSite_ContextSensitiveHelp,
1430 InPlaceSite_CanInPlaceActivate,
1431 InPlaceSite_OnInPlaceActivate,
1432 InPlaceSite_OnUIActivate,
1433 InPlaceSite_GetWindowContext,
1435 InPlaceSite_OnUIDeactivate,
1436 InPlaceSite_OnInPlaceDeactivate,
1437 InPlaceSite_DiscardUndoState,
1438 InPlaceSite_DeactivateAndUndo,
1439 InPlaceSite_OnPosRectChange,
1440 InPlaceSite_OnInPlaceActivateEx,
1441 InPlaceSite_OnInPlaceDeactivateEx,
1442 InPlaceSite_RequestUIActivate
1445 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1447 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1449 return QueryInterface(riid, ppv);
1452 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1457 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1462 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1463 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1465 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1469 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1471 CHECK_EXPECT2(GetHostInfo);
1472 ok(pInfo != NULL, "pInfo=NULL\n");
1474 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1475 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1476 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1477 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1478 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1483 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1484 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1485 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1487 CHECK_EXPECT(ShowUI);
1491 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1493 CHECK_EXPECT(HideUI);
1497 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1499 CHECK_EXPECT2(UpdateUI);
1503 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1506 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1508 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1513 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1515 ok(0, "unexpected call\n");
1519 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1521 ok(0, "unexpected call\n");
1525 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1526 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1528 ok(0, "unexpected call\n");
1532 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1533 const GUID *pguidCmdGroup, DWORD nCmdID)
1535 CHECK_EXPECT(DocHost_TranslateAccelerator);
1536 ok(pguidCmdGroup != NULL, "Got NULL pguidCmdGroup.\n");
1538 ok(IsEqualGUID(pguidCmdGroup, &CGID_MSHTML), "Unexpected pguidCmdGroup\n");
1539 ok(lpMsg != NULL, "Got NULL lpMsg.\n");
1540 return hr_dochost_TranslateAccelerator;
1543 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1544 LPOLESTR *pchKey, DWORD dw)
1546 CHECK_EXPECT(GetOptionKeyPath);
1547 ok(pchKey != NULL, "pchKey==NULL\n");
1549 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1550 ok(!dw, "dw=%x\n", dw);
1554 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1555 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1557 CHECK_EXPECT(GetDropTarget);
1561 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1563 CHECK_EXPECT(GetExternal);
1568 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1569 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1571 if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1572 todo_wine CHECK_EXPECT(TranslateUrl);
1574 CHECK_EXPECT(TranslateUrl);
1578 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1579 IDataObject **ppPORet)
1581 ok(0, "unexpected call\n");
1585 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1586 LPOLESTR *pchKey, DWORD dw)
1588 CHECK_EXPECT(GetOverridesKeyPath);
1589 ok(pchKey != NULL, "pchKey==NULL\n");
1591 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1592 ok(!dw, "dw=%x\n", dw);
1596 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1597 DocHostUIHandler_QueryInterface,
1598 DocHostUIHandler_AddRef,
1599 DocHostUIHandler_Release,
1600 DocHostUIHandler_ShowContextMenu,
1601 DocHostUIHandler_GetHostInfo,
1602 DocHostUIHandler_ShowUI,
1603 DocHostUIHandler_HideUI,
1604 DocHostUIHandler_UpdateUI,
1605 DocHostUIHandler_EnableModeless,
1606 DocHostUIHandler_OnDocWindowActivate,
1607 DocHostUIHandler_OnFrameWindowActivate,
1608 DocHostUIHandler_ResizeBorder,
1609 DocHostUIHandler_TranslateAccelerator,
1610 DocHostUIHandler_GetOptionKeyPath,
1611 DocHostUIHandler_GetDropTarget,
1612 DocHostUIHandler_GetExternal,
1613 DocHostUIHandler_TranslateUrl,
1614 DocHostUIHandler_FilterDataObject,
1615 DocHostUIHandler_GetOverrideKeyPath
1618 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1621 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1623 return QueryInterface(riid, ppv);
1626 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1631 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1636 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1637 REFGUID guidService, REFIID riid, void **ppv)
1641 if(!winetest_interactive)
1642 return E_NOINTERFACE;
1644 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1645 trace("Service SID_STopLevelBrowser\n");
1646 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1647 trace("Service SID_SEditCommandTarget\n");
1648 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1649 trace("Service IID_ITargetFrame2\n");
1650 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1651 trace("Service SID_SInternetSecurityManager\n");
1652 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1653 trace("Service SID_SOleUndoManager\n");
1654 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1655 trace("Service SID_IMimeInfo\n");
1656 else if (IsEqualGUID(&SID_STopWindow, guidService))
1657 trace("Service SID_STopWindow\n");
1659 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1660 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1661 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1662 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1663 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1664 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1665 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1666 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1667 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1668 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1669 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1672 trace("Service %s not supported\n", debugstr_guid(guidService));
1674 return E_NOINTERFACE;
1678 static const IServiceProviderVtbl ServiceProviderVtbl = {
1679 ServiceProvider_QueryInterface,
1680 ServiceProvider_AddRef,
1681 ServiceProvider_Release,
1682 ServiceProvider_QueryService
1685 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1688 static HRESULT QueryInterface(REFIID riid, void **ppv)
1692 if(IsEqualGUID(&IID_IUnknown, riid)
1693 || IsEqualGUID(&IID_IOleClientSite, riid))
1695 else if(IsEqualGUID(&IID_IOleWindow, riid)
1696 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1697 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1698 *ppv = &InPlaceSite;
1699 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1700 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1701 *ppv = use_container_dochostui ? &DocHostUIHandler : NULL;
1702 else if(IsEqualGUID(&IID_IDispatch, riid))
1704 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1705 *ppv = &ServiceProvider;
1706 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1707 trace("interface IID_IDocHostShowUI\n");
1708 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1709 *ppv = &ControlSite;
1710 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1711 trace("interface IID_IOleCommandTarget\n");
1713 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1717 /* are there more interfaces, that a host can support? */
1718 trace("%s: interface not supported\n", debugstr_guid(riid));
1721 return (*ppv) ? S_OK : E_NOINTERFACE;
1724 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1726 return DefWindowProcW(hwnd, msg, wParam, lParam);
1729 static HWND create_container_window(void)
1731 static const WCHAR wszWebBrowserContainer[] =
1732 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1733 static WNDCLASSEXW wndclass = {
1734 sizeof(WNDCLASSEXW),
1737 0, 0, NULL, NULL, NULL, NULL, NULL,
1738 wszWebBrowserContainer,
1742 RegisterClassExW(&wndclass);
1743 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1744 WS_OVERLAPPEDWINDOW, 10, 10, 600, 600, NULL, NULL, NULL, NULL);
1747 static void test_DoVerb(IWebBrowser2 *unk)
1750 RECT rect = {0,0,1000,1000};
1753 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1754 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1758 SET_EXPECT(CanInPlaceActivate);
1759 SET_EXPECT(Site_GetWindow);
1760 SET_EXPECT(OnInPlaceActivate);
1761 SET_EXPECT(GetWindowContext);
1762 SET_EXPECT(ShowObject);
1763 SET_EXPECT(GetContainer);
1764 SET_EXPECT(Frame_GetWindow);
1765 SET_EXPECT(OnUIActivate);
1766 SET_EXPECT(Frame_SetActiveObject);
1767 SET_EXPECT(UIWindow_SetActiveObject);
1768 SET_EXPECT(SetMenu);
1769 SET_EXPECT(OnFocus);
1771 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1772 0, (HWND)0xdeadbeef, &rect);
1773 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1775 CHECK_CALLED(CanInPlaceActivate);
1776 CHECK_CALLED(Site_GetWindow);
1777 CHECK_CALLED(OnInPlaceActivate);
1778 CHECK_CALLED(GetWindowContext);
1779 CHECK_CALLED(ShowObject);
1780 CHECK_CALLED(GetContainer);
1781 CHECK_CALLED(Frame_GetWindow);
1782 CHECK_CALLED(OnUIActivate);
1783 CHECK_CALLED(Frame_SetActiveObject);
1784 CHECK_CALLED(UIWindow_SetActiveObject);
1785 CHECK_CALLED(SetMenu);
1786 todo_wine CHECK_CALLED(OnFocus);
1788 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1789 0, (HWND)0xdeadbeef, &rect);
1790 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1792 IOleObject_Release(oleobj);
1795 static void call_DoVerb(IWebBrowser2 *unk, LONG verb)
1798 RECT rect = {60,60,600,600};
1801 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1802 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1806 hres = IOleObject_DoVerb(oleobj, verb, NULL, &ClientSite,
1807 -1, container_hwnd, &rect);
1808 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1810 IOleObject_Release(oleobj);
1813 static HWND get_hwnd(IWebBrowser2 *unk)
1815 IOleInPlaceObject *inplace;
1819 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1820 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1822 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1823 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1825 IOleInPlaceObject_Release(inplace);
1829 static void test_GetMiscStatus(IOleObject *oleobj)
1834 for(i=0; i<10; i++) {
1836 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1837 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1838 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1839 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1840 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1841 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1845 static void test_SetHostNames(IOleObject *oleobj)
1849 static const WCHAR test_appW[] = {'t','e','s','t',' ','a','p','p',0};
1851 hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1852 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1855 static void test_ClientSite(IWebBrowser2 *unk, IOleClientSite *client, BOOL stop_download)
1858 IOleInPlaceObject *inplace;
1862 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1863 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1867 test_GetMiscStatus(oleobj);
1868 test_SetHostNames(oleobj);
1870 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1871 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1873 IOleObject_Release(oleobj);
1877 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1878 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1879 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1882 SET_EXPECT(GetContainer);
1883 SET_EXPECT(Site_GetWindow);
1884 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1885 SET_EXPECT(Invoke_AMBIENT_SILENT);
1886 }else if(stop_download) {
1887 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1888 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1889 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1891 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
1892 SET_EXPECT(Invoke_PROGRESSCHANGE);
1895 hres = IOleObject_SetClientSite(oleobj, client);
1896 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1899 CHECK_CALLED(GetContainer);
1900 CHECK_CALLED(Site_GetWindow);
1901 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1902 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1903 }else if(stop_download) {
1904 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1905 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1906 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1908 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
1909 CLEAR_CALLED(Invoke_PROGRESSCHANGE);
1912 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1913 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1914 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1916 shell_embedding_hwnd = hwnd;
1918 test_SetHostNames(oleobj);
1920 IOleInPlaceObject_Release(inplace);
1921 IOleObject_Release(oleobj);
1924 static void test_ClassInfo(IWebBrowser2 *unk)
1926 IProvideClassInfo2 *class_info;
1927 TYPEATTR *type_attr;
1928 ITypeInfo *typeinfo;
1932 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1933 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
1937 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1938 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1939 ok(IsEqualGUID(wb_version > 1 ? &DIID_DWebBrowserEvents2 : &DIID_DWebBrowserEvents, &guid), "wrong guid\n");
1941 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1942 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1943 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1945 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1946 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1947 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1949 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1950 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1952 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1953 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1956 hres = IProvideClassInfo2_GetClassInfo(class_info, &typeinfo);
1957 ok(hres == S_OK, "GetClassInfo failed: %08x\n", hres);
1958 ok(typeinfo != NULL, "typeinfo == NULL\n");
1960 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
1961 ok(hres == S_OK, "GetTypeAtr failed: %08x\n", hres);
1963 ok(IsEqualGUID(&type_attr->guid, wb_version > 1 ? &CLSID_WebBrowser : &CLSID_WebBrowser_V1),
1964 "guid = %s\n", debugstr_guid(&type_attr->guid));
1966 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
1967 ITypeInfo_Release(typeinfo);
1969 IProvideClassInfo2_Release(class_info);
1972 static void test_EnumVerbs(IWebBrowser2 *wb)
1974 IEnumOLEVERB *enum_verbs;
1980 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oleobj);
1981 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
1983 hres = IOleObject_EnumVerbs(oleobj, &enum_verbs);
1984 IOleObject_Release(oleobj);
1985 ok(hres == S_OK, "EnumVerbs failed: %08x\n", hres);
1986 ok(enum_verbs != NULL, "enum_verbs == NULL\n");
1988 fetched = 0xdeadbeef;
1989 hres = IEnumOLEVERB_Next(enum_verbs, sizeof(verbs)/sizeof(*verbs), verbs, &fetched);
1990 ok(hres == S_OK, "Next failed: %08x\n", hres);
1991 ok(!fetched, "fetched = %d\n", fetched);
1993 fetched = 0xdeadbeef;
1994 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
1995 ok(hres == S_OK, "Next failed: %08x\n", hres);
1996 ok(!fetched, "fetched = %d\n", fetched);
1998 hres = IEnumOLEVERB_Reset(enum_verbs);
1999 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2001 fetched = 0xdeadbeef;
2002 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2003 ok(hres == S_OK, "Next failed: %08x\n", hres);
2004 ok(!fetched, "fetched = %d\n", fetched);
2006 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, NULL);
2007 ok(hres == S_OK, "Next failed: %08x\n", hres);
2009 hres = IEnumOLEVERB_Skip(enum_verbs, 20);
2010 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2012 fetched = 0xdeadbeef;
2013 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2014 ok(hres == S_OK, "Next failed: %08x\n", hres);
2015 ok(!fetched, "fetched = %d\n", fetched);
2017 IEnumOLEVERB_Release(enum_verbs);
2020 static void test_ie_funcs(IWebBrowser2 *wb)
2032 hres = IWebBrowser2_get_HWND(wb, &hwnd);
2033 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
2034 ok(hwnd == 0, "unexpected hwnd %x\n", hwnd);
2038 hres = IWebBrowser2_get_MenuBar(wb, &b);
2039 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2040 ok(b == VARIANT_TRUE, "b=%x\n", b);
2042 SET_EXPECT(Invoke_ONMENUBAR);
2043 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
2044 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2045 CHECK_CALLED(Invoke_ONMENUBAR);
2047 hres = IWebBrowser2_get_MenuBar(wb, &b);
2048 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2049 ok(b == VARIANT_FALSE, "b=%x\n", b);
2051 SET_EXPECT(Invoke_ONMENUBAR);
2052 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
2053 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2054 CHECK_CALLED(Invoke_ONMENUBAR);
2056 hres = IWebBrowser2_get_MenuBar(wb, &b);
2057 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2058 ok(b == VARIANT_TRUE, "b=%x\n", b);
2062 hres = IWebBrowser2_get_AddressBar(wb, &b);
2063 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2064 ok(b == VARIANT_TRUE, "b=%x\n", b);
2066 SET_EXPECT(Invoke_ONADDRESSBAR);
2067 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
2068 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2069 CHECK_CALLED(Invoke_ONADDRESSBAR);
2071 hres = IWebBrowser2_get_AddressBar(wb, &b);
2072 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2073 ok(b == VARIANT_FALSE, "b=%x\n", b);
2075 SET_EXPECT(Invoke_ONADDRESSBAR);
2076 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
2077 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2078 CHECK_CALLED(Invoke_ONADDRESSBAR);
2080 hres = IWebBrowser2_get_AddressBar(wb, &b);
2081 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2082 ok(b == VARIANT_TRUE, "b=%x\n", b);
2084 SET_EXPECT(Invoke_ONADDRESSBAR);
2085 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
2086 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2087 CHECK_CALLED(Invoke_ONADDRESSBAR);
2091 hres = IWebBrowser2_get_StatusBar(wb, &b);
2092 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2093 ok(b == VARIANT_TRUE, "b=%x\n", b);
2095 SET_EXPECT(Invoke_ONSTATUSBAR);
2096 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
2097 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2098 CHECK_CALLED(Invoke_ONSTATUSBAR);
2100 hres = IWebBrowser2_get_StatusBar(wb, &b);
2101 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2102 ok(b == VARIANT_TRUE, "b=%x\n", b);
2104 SET_EXPECT(Invoke_ONSTATUSBAR);
2105 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
2106 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2107 CHECK_CALLED(Invoke_ONSTATUSBAR);
2109 hres = IWebBrowser2_get_StatusBar(wb, &b);
2110 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2111 ok(b == VARIANT_FALSE, "b=%x\n", b);
2113 SET_EXPECT(Invoke_ONSTATUSBAR);
2114 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
2115 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2116 CHECK_CALLED(Invoke_ONSTATUSBAR);
2118 hres = IWebBrowser2_get_StatusBar(wb, &b);
2119 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2120 ok(b == VARIANT_TRUE, "b=%x\n", b);
2124 hres = IWebBrowser2_get_ToolBar(wb, &i);
2125 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2128 SET_EXPECT(Invoke_ONTOOLBAR);
2129 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
2130 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2131 CHECK_CALLED(Invoke_ONTOOLBAR);
2133 hres = IWebBrowser2_get_ToolBar(wb, &i);
2134 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2135 ok(i == VARIANT_FALSE, "b=%x\n", i);
2137 SET_EXPECT(Invoke_ONTOOLBAR);
2138 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
2139 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2140 CHECK_CALLED(Invoke_ONTOOLBAR);
2142 hres = IWebBrowser2_get_ToolBar(wb, &i);
2143 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2146 SET_EXPECT(Invoke_ONTOOLBAR);
2147 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
2148 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2149 CHECK_CALLED(Invoke_ONTOOLBAR);
2153 hres = IWebBrowser2_get_FullScreen(wb, &b);
2154 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2155 ok(b == VARIANT_FALSE, "b=%x\n", b);
2157 SET_EXPECT(Invoke_ONFULLSCREEN);
2158 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
2159 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2160 CHECK_CALLED(Invoke_ONFULLSCREEN);
2162 hres = IWebBrowser2_get_FullScreen(wb, &b);
2163 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2164 ok(b == VARIANT_TRUE, "b=%x\n", b);
2166 SET_EXPECT(Invoke_ONFULLSCREEN);
2167 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
2168 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2169 CHECK_CALLED(Invoke_ONFULLSCREEN);
2171 hres = IWebBrowser2_get_FullScreen(wb, &b);
2172 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2173 ok(b == VARIANT_TRUE, "b=%x\n", b);
2175 SET_EXPECT(Invoke_ONFULLSCREEN);
2176 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
2177 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2178 CHECK_CALLED(Invoke_ONFULLSCREEN);
2182 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2183 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2184 ok(b == VARIANT_FALSE, "b=%x\n", b);
2186 SET_EXPECT(Invoke_ONTHEATERMODE);
2187 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
2188 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2189 CHECK_CALLED(Invoke_ONTHEATERMODE);
2191 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2192 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2193 ok(b == VARIANT_TRUE, "b=%x\n", b);
2195 SET_EXPECT(Invoke_ONTHEATERMODE);
2196 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
2197 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2198 CHECK_CALLED(Invoke_ONTHEATERMODE);
2200 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2201 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2202 ok(b == VARIANT_TRUE, "b=%x\n", b);
2204 SET_EXPECT(Invoke_ONTHEATERMODE);
2205 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
2206 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2207 CHECK_CALLED(Invoke_ONTHEATERMODE);
2212 hres = IWebBrowser2_get_Resizable(wb, &b);
2213 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2214 ok(b == 0x100, "b=%x\n", b);
2216 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2217 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
2218 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2219 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2221 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2222 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
2223 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2224 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2226 hres = IWebBrowser2_get_Resizable(wb, &b);
2227 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2228 ok(b == 0x100, "b=%x\n", b);
2233 hres = IWebBrowser2_get_Application(wb, &disp);
2234 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
2235 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
2237 IDispatch_Release(disp);
2239 hres = IWebBrowser2_get_Application(wb, NULL);
2240 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
2243 hres = IWebBrowser2_get_Name(wb, &sName);
2244 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
2245 if (is_lang_english())
2246 ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
2247 else /* Non-English cannot be blank. */
2248 ok(sName!=NULL, "get_Name return a NULL string.\n");
2249 SysFreeString(sName);
2253 hres = IWebBrowser2_Quit(wb);
2254 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
2257 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2263 hres = IWebBrowser2_get_Silent(wb, &b);
2264 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2265 ok(b == VARIANT_FALSE, "b=%x\n", b);
2267 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2268 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2271 hres = IWebBrowser2_get_Silent(wb, &b);
2272 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2273 ok(b == VARIANT_TRUE, "b=%x\n", b);
2275 hres = IWebBrowser2_put_Silent(wb, 100);
2276 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2279 hres = IWebBrowser2_get_Silent(wb, &b);
2280 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2281 ok(b == VARIANT_TRUE, "b=%x\n", b);
2283 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
2284 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2287 hres = IWebBrowser2_get_Silent(wb, &b);
2288 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2289 ok(b == VARIANT_FALSE, "b=%x\n", b);
2292 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2293 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2295 SET_EXPECT(Invoke_AMBIENT_SILENT);
2298 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2299 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2302 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2305 hres = IWebBrowser2_get_Silent(wb, &b);
2306 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2307 ok(b == VARIANT_FALSE, "b=%x\n", b);
2310 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2316 hres = IWebBrowser2_get_Offline(wb, &b);
2317 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2318 ok(b == VARIANT_FALSE, "b=%x\n", b);
2320 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2321 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2324 hres = IWebBrowser2_get_Offline(wb, &b);
2325 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2326 ok(b == VARIANT_TRUE, "b=%x\n", b);
2328 hres = IWebBrowser2_put_Offline(wb, 100);
2329 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2332 hres = IWebBrowser2_get_Offline(wb, &b);
2333 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2334 ok(b == VARIANT_TRUE, "b=%x\n", b);
2336 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
2337 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2340 hres = IWebBrowser2_get_Offline(wb, &b);
2341 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2342 ok(b == VARIANT_FALSE, "b=%x\n", b);
2345 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2346 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2348 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2351 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2352 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2355 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2358 hres = IWebBrowser2_get_Offline(wb, &b);
2359 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2360 ok(b == VARIANT_FALSE, "b=%x\n", b);
2363 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2367 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2368 SET_EXPECT(Invoke_AMBIENT_SILENT);
2369 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2370 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2371 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2372 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2374 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
2375 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2377 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2378 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
2379 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
2380 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
2381 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2382 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2384 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2385 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2386 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2387 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2388 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2389 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2392 static void test_wb_funcs(IWebBrowser2 *wb, BOOL is_clientsite)
2394 IOleControl *control;
2397 hres = IUnknown_QueryInterface(wb, &IID_IOleControl, (void**)&control);
2398 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2400 test_Silent(wb, control, is_clientsite);
2401 test_Offline(wb, control, is_clientsite);
2402 test_ambient_unknown(wb, control, is_clientsite);
2404 IOleControl_Release(control);
2407 static void test_GetControlInfo(IWebBrowser2 *unk)
2409 IOleControl *control;
2413 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2414 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2418 hres = IOleControl_GetControlInfo(control, &info);
2419 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2420 hres = IOleControl_GetControlInfo(control, NULL);
2421 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2423 IOleControl_Release(control);
2426 static void test_Extent(IWebBrowser2 *unk)
2429 SIZE size, expected;
2435 /* default aspect ratio is 96dpi / 96dpi */
2437 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2438 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2440 if (dpi_x != 96 || dpi_y != 96)
2441 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2443 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2444 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2448 size.cx = size.cy = 0xdeadbeef;
2449 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2450 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2451 /* Default size is 50x20 pixels, in himetric units */
2452 expected.cx = MulDiv( 50, 2540, dpi_x );
2453 expected.cy = MulDiv( 20, 2540, dpi_y );
2454 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2455 size.cx, size.cy, expected.cx, expected.cy );
2459 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2460 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2462 size.cx = size.cy = 0xdeadbeef;
2463 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2464 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2465 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2467 size.cx = size.cy = 0xdeadbeef;
2468 hres = IOleObject_GetExtent(oleobj, 0, &size);
2469 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2470 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2474 hres = IOleObject_SetExtent(oleobj, 0, &size);
2475 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2477 size.cx = size.cy = 0xdeadbeef;
2478 hres = IOleObject_GetExtent(oleobj, 0, &size);
2479 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2480 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2482 size.cx = size.cy = 0xdeadbeef;
2483 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2484 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2485 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2489 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2490 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2492 size.cx = size.cy = 0xdeadbeef;
2493 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2494 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2495 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2497 size.cx = size.cy = 0xdeadbeef;
2498 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2499 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2500 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2502 IOleObject_Release(oleobj);
2505 static void test_ConnectionPoint(IWebBrowser2 *unk, BOOL init)
2507 IConnectionPointContainer *container;
2508 IConnectionPoint *point;
2511 static DWORD dw = 100;
2513 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2514 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2518 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2519 IConnectionPointContainer_Release(container);
2520 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2525 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2526 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2527 ok(dw == 1, "dw=%d, expected 1\n", dw);
2529 hres = IConnectionPoint_Unadvise(point, dw);
2530 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2533 IConnectionPoint_Release(point);
2536 static void test_Navigate2(IWebBrowser2 *webbrowser, const char *nav_url)
2541 test_LocationURL(webbrowser, is_first_load ? "" : current_url);
2542 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2544 is_http = !memcmp(nav_url, "http:", 5);
2545 V_VT(&url) = VT_BSTR;
2546 V_BSTR(&url) = a2bstr(current_url = nav_url);
2549 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2550 SET_EXPECT(Invoke_PROPERTYCHANGE);
2551 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2552 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2553 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2554 SET_EXPECT(EnableModeless_FALSE);
2555 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2556 SET_EXPECT(SetStatusText);
2557 if(use_container_dochostui)
2558 SET_EXPECT(GetHostInfo);
2559 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2560 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2561 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2562 if(use_container_dochostui) {
2563 SET_EXPECT(GetOptionKeyPath);
2564 SET_EXPECT(GetOverridesKeyPath);
2566 if (use_container_olecmd) SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2567 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSMAX);
2568 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSPOS);
2569 SET_EXPECT(Invoke_SETSECURELOCKICON);
2570 SET_EXPECT(Invoke_FILEDOWNLOAD);
2571 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2572 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2573 SET_EXPECT(EnableModeless_TRUE);
2574 if (!use_container_olecmd) SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2577 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2578 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2581 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2582 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2583 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2584 todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2585 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2586 CHECK_CALLED(EnableModeless_FALSE);
2587 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2588 CHECK_CALLED(SetStatusText);
2589 if(use_container_dochostui)
2590 CHECK_CALLED(GetHostInfo);
2591 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2592 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2593 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* Not called by IE9 */
2594 if(use_container_dochostui) {
2595 CLEAR_CALLED(GetOptionKeyPath);
2596 CHECK_CALLED(GetOverridesKeyPath);
2598 if (use_container_olecmd) todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2599 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2600 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2601 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2602 todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
2603 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2604 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2605 CHECK_CALLED(EnableModeless_TRUE);
2610 test_ready_state(READYSTATE_LOADING);
2613 static void test_QueryStatusWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2615 HRESULT hres, success_state;
2616 OLECMDF success_flags;
2617 enum OLECMDF status;
2620 * We can tell the difference between the custom container target and the built-in target
2621 * since the custom target returns OLECMDF_SUPPORTED instead of OLECMDF_ENABLED.
2623 if (use_custom_target)
2624 success_flags = OLECMDF_SUPPORTED;
2626 success_flags = OLECMDF_ENABLED;
2628 /* When no target is available (no document or custom target) an error is returned */
2630 success_state = S_OK;
2632 success_state = E_UNEXPECTED;
2635 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2636 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2637 * is enabled and IDM_STOP is not.
2639 status = 0xdeadbeef;
2640 if (use_custom_target) SET_EXPECT(QueryStatus_STOP);
2641 hres = IWebBrowser2_QueryStatusWB(webbrowser, OLECMDID_STOP, &status);
2642 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2643 if (!use_custom_target && has_document)
2644 todo_wine ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2645 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2647 ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2648 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2649 status = 0xdeadbeef;
2650 if (use_custom_target) SET_EXPECT(QueryStatus_IDM_STOP);
2651 hres = IWebBrowser2_QueryStatusWB(webbrowser, IDM_STOP, &status);
2652 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2653 ok((has_document && status == 0) || (!has_document && status == 0xdeadbeef),
2654 "IDM_STOP is enabled/supported: %08x %d\n", status, has_document);
2657 static void test_ExecWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2659 HRESULT hres, olecmdid_state, idm_state;
2661 /* When no target is available (no document or custom target) an error is returned */
2664 olecmdid_state = S_OK;
2665 idm_state = OLECMDERR_E_NOTSUPPORTED;
2669 olecmdid_state = E_UNEXPECTED;
2670 idm_state = E_UNEXPECTED;
2674 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2675 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2676 * succeeds (S_OK) and IDM_STOP does not (OLECMDERR_E_NOTSUPPORTED).
2678 if(use_custom_target) {
2679 SET_EXPECT(Exec_STOP);
2680 }else if(has_document) {
2681 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2682 SET_EXPECT(SetStatusText);
2684 hres = IWebBrowser2_ExecWB(webbrowser, OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2685 if(!use_custom_target && has_document) {
2686 todo_wine ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2687 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2688 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
2690 ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2692 if (use_custom_target)
2693 SET_EXPECT(Exec_IDM_STOP);
2694 hres = IWebBrowser2_ExecWB(webbrowser, IDM_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2695 ok(hres == idm_state, "ExecWB failed: %08x %08x\n", hres, idm_state);
2698 static void test_download(DWORD flags)
2702 is_downloading = TRUE;
2705 test_ready_state((flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2707 if((is_http && !(flags & DWL_FROM_GOBACK)) || (flags & DWL_EXPECT_BEFORE_NAVIGATE))
2708 SET_EXPECT(Invoke_PROPERTYCHANGE);
2710 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2711 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2712 SET_EXPECT(TranslateUrl);
2714 SET_EXPECT(Exec_SETPROGRESSMAX);
2715 SET_EXPECT(Exec_SETPROGRESSPOS);
2716 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2717 SET_EXPECT(DocHost_EnableModeless_FALSE);
2718 SET_EXPECT(DocHost_EnableModeless_TRUE);
2719 SET_EXPECT(Invoke_SETSECURELOCKICON);
2720 SET_EXPECT(Invoke_282);
2721 SET_EXPECT(EnableModeless_FALSE);
2722 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2723 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2724 SET_EXPECT(SetStatusText);
2725 SET_EXPECT(EnableModeless_TRUE);
2727 SET_EXPECT(GetHostInfo);
2728 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2729 SET_EXPECT(Invoke_TITLECHANGE);
2730 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2732 SET_EXPECT(GetDropTarget);
2733 SET_EXPECT(Invoke_PROGRESSCHANGE);
2734 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2736 if(flags & DWL_HTTP)
2737 SET_EXPECT(Exec_SETTITLE);
2738 SET_EXPECT(UpdateUI);
2739 SET_EXPECT(Exec_UPDATECOMMANDS);
2740 SET_EXPECT(QueryStatus_STOP);
2742 while(!called_Invoke_DOCUMENTCOMPLETE && GetMessage(&msg, NULL, 0, 0)) {
2743 TranslateMessage(&msg);
2744 DispatchMessage(&msg);
2747 if((is_http && !(flags & DWL_FROM_GOBACK)) || (flags & DWL_EXPECT_BEFORE_NAVIGATE))
2748 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2750 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2751 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2752 CHECK_CALLED(TranslateUrl);
2754 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2755 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2756 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2757 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
2758 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
2759 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2760 CLEAR_CALLED(Invoke_282); /* IE 7 */
2762 todo_wine CHECK_CALLED(EnableModeless_FALSE);
2764 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2765 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE);
2766 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2767 todo_wine CHECK_CALLED(SetStatusText);
2769 todo_wine CHECK_CALLED(EnableModeless_TRUE);
2771 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2773 todo_wine CHECK_CALLED(GetHostInfo);
2774 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2775 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
2776 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
2778 todo_wine CHECK_CALLED(GetDropTarget);
2779 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2780 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
2782 is_downloading = FALSE;
2784 test_ready_state(READYSTATE_COMPLETE);
2786 while(!called_Exec_UPDATECOMMANDS && GetMessage(&msg, NULL, 0, 0)) {
2787 TranslateMessage(&msg);
2788 DispatchMessage(&msg);
2791 if(flags & DWL_HTTP)
2792 CLEAR_CALLED(Exec_SETTITLE); /* FIXME: make it more strict */
2793 CHECK_CALLED(UpdateUI);
2794 CHECK_CALLED(Exec_UPDATECOMMANDS);
2795 CLEAR_CALLED(QueryStatus_STOP);
2798 static void test_olecmd(IWebBrowser2 *unk, BOOL loaded)
2800 IOleCommandTarget *cmdtrg;
2804 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2805 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
2809 cmds[0].cmdID = OLECMDID_SPELL;
2810 cmds[0].cmdf = 0xdeadbeef;
2811 cmds[1].cmdID = OLECMDID_REFRESH;
2812 cmds[1].cmdf = 0xdeadbeef;
2813 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
2815 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2816 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2817 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
2818 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
2820 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
2821 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2822 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
2825 IOleCommandTarget_Release(cmdtrg);
2828 static void test_IServiceProvider(IWebBrowser2 *unk)
2830 IServiceProvider *servprov = (void*)0xdeadbeef;
2834 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
2835 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
2839 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&iface);
2840 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
2841 ok(!iface, "QueryService returned %p, expected NULL\n", iface);
2843 IUnknown_Release(iface);
2845 hres = IServiceProvider_QueryService(servprov, &SID_SHTMLWindow, &IID_IHTMLWindow2, (LPVOID*)&iface);
2846 ok(hres == S_OK, "QueryService returned %08x, expected S_OK\n", hres);
2847 ok(iface != NULL, "QueryService returned NULL\n");
2849 IUnknown_Release(iface);
2851 IServiceProvider_Release(servprov);
2854 static void test_put_href(IWebBrowser2 *unk, const char *url)
2856 IHTMLLocation *location;
2857 IHTMLDocument2 *doc;
2858 IDispatch *doc_disp;
2862 doc_disp = get_document(unk);
2864 hres = IDispatch_QueryInterface(doc_disp, &IID_IHTMLDocument2, (void**)&doc);
2865 IDispatch_Release(doc_disp);
2866 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2 failed: %08x\n", hres);
2869 hres = IHTMLDocument2_get_location(doc, &location);
2870 IHTMLDocument2_Release(doc);
2871 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2872 ok(location != NULL, "location == NULL\n");
2874 SET_EXPECT(TranslateUrl);
2875 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2877 SET_EXPECT(Invoke_PROPERTYCHANGE);
2879 dwl_flags = DWL_FROM_PUT_HREF;
2881 is_http = !memcmp(url, "http:", 5);
2882 str = a2bstr(current_url = url);
2883 is_first_load = FALSE;
2884 hres = IHTMLLocation_put_href(location, str);
2886 CHECK_CALLED(TranslateUrl);
2887 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2889 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2891 IHTMLLocation_Release(location);
2893 ok(hres == S_OK, "put_href failed: %08x\n", hres);
2895 test_ready_state(READYSTATE_COMPLETE);
2898 static void test_go_back(IWebBrowser2 *wb, const char *back_url)
2902 current_url = back_url;
2904 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2905 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2906 hres = IWebBrowser2_GoBack(wb);
2907 ok(hres == S_OK, "GoBack failed: %08x\n", hres);
2908 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2909 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2912 static void test_QueryInterface(IWebBrowser2 *unk)
2914 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
2915 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
2916 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
2917 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
2918 IOleCache *cache = (void*)0xdeadbeef;
2919 IObjectWithSite *site = (void*)0xdeadbeef;
2920 IViewObjectEx *viewex = (void*)0xdeadbeef;
2921 IOleLink *link = (void*)0xdeadbeef;
2922 IMarshal *marshal = (void*)0xdeadbeef;
2923 IStdMarshalInfo *marshalinfo = (void*)0xdeadbeef;
2926 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
2927 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2928 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
2930 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
2931 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2932 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
2934 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
2935 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2936 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
2938 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
2939 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2940 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
2942 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
2943 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2944 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
2946 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2947 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2948 ok(site == NULL, "site=%p, expected NULL\n", site);
2950 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
2951 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2952 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
2954 hres = IUnknown_QueryInterface(unk, &IID_IOleLink, (void**)&link);
2955 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2956 ok(link == NULL, "link=%p, expected NULL\n", link);
2958 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&marshal);
2959 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2960 ok(marshal == NULL, "marshal=%p, expected NULL\n", marshal);
2962 hres = IUnknown_QueryInterface(unk, &IID_IStdMarshalInfo, (void**)&marshalinfo);
2963 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2964 ok(marshalinfo == NULL, "marshalinfo=%p, expected NULL\n", marshalinfo);
2968 static void test_UIActivate(IWebBrowser2 *unk, BOOL activate)
2970 IOleDocumentView *docview;
2974 disp = get_document(unk);
2976 hres = IDispatch_QueryInterface(disp, &IID_IOleDocumentView, (void**)&docview);
2977 ok(hres == S_OK, "Got 0x%08x\n", hres);
2978 if(SUCCEEDED(hres)) {
2980 SET_EXPECT(RequestUIActivate);
2983 SET_EXPECT(OnFocus);
2986 hres = IOleDocumentView_UIActivate(docview, activate);
2988 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
2990 ok(hres == S_OK, "Got 0x%08x\n", hres);
2994 CHECK_CALLED(RequestUIActivate);
2995 CHECK_CALLED(ShowUI);
2996 CHECK_CALLED(HideUI);
2997 CHECK_CALLED(OnFocus);
3001 IOleDocumentView_Release(docview);
3004 IDispatch_Release(disp);
3007 static void test_external(IWebBrowser2 *unk)
3009 IDocHostUIHandler2 *dochost;
3010 IOleClientSite *client;
3014 client = get_dochost(unk);
3016 hres = IOleClientSite_QueryInterface(client, &IID_IDocHostUIHandler2, (void**)&dochost);
3017 ok(hres == S_OK, "Could not get IDocHostUIHandler2 iface: %08x\n", hres);
3018 IOleClientSite_Release(client);
3020 if(use_container_dochostui)
3021 SET_EXPECT(GetExternal);
3022 disp = (void*)0xdeadbeef;
3023 hres = IDocHostUIHandler2_GetExternal(dochost, &disp);
3024 if(use_container_dochostui) {
3025 CHECK_CALLED(GetExternal);
3026 ok(hres == S_FALSE, "GetExternal failed: %08x\n", hres);
3027 ok(!disp, "disp = %p\n", disp);
3029 IShellUIHelper *uihelper;
3031 ok(hres == S_OK, "GetExternal failed: %08x\n", hres);
3032 ok(disp != NULL, "disp == NULL\n");
3034 hres = IDispatch_QueryInterface(disp, &IID_IShellUIHelper, (void**)&uihelper);
3035 ok(hres == S_OK, "Could not get IShellUIHelper iface: %08x\n", hres);
3036 IShellUIHelper_Release(uihelper);
3039 IDocHostUIHandler2_Release(dochost);
3042 static void test_TranslateAccelerator(IWebBrowser2 *unk)
3044 IOleClientSite *doc_clientsite;
3045 IOleInPlaceActiveObject *pao;
3055 test_Navigate2(unk, "about:blank");
3057 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3058 ok(hres == S_OK, "Got 0x%08x\n", hres);
3059 if(SUCCEEDED(hres)) {
3060 /* One accelerator that should be handled by mshtml */
3061 msg_a.message = WM_KEYDOWN;
3062 msg_a.wParam = VK_F1;
3063 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3064 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3066 /* And one that should not */
3067 msg_a.message = WM_KEYDOWN;
3068 msg_a.wParam = VK_F5;
3069 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3070 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3072 IOleInPlaceActiveObject_Release(pao);
3075 test_UIActivate(unk, TRUE);
3077 /* Test again after UIActivate */
3078 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3079 ok(hres == S_OK, "Got 0x%08x\n", hres);
3080 if(SUCCEEDED(hres)) {
3081 /* One accelerator that should be handled by mshtml */
3082 msg_a.message = WM_KEYDOWN;
3083 msg_a.wParam = VK_F1;
3084 SET_EXPECT(DocHost_TranslateAccelerator);
3085 SET_EXPECT(ControlSite_TranslateAccelerator);
3086 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3087 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3088 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3089 todo_wine CHECK_CALLED(ControlSite_TranslateAccelerator);
3091 /* And one that should not */
3092 msg_a.message = WM_KEYDOWN;
3093 msg_a.wParam = VK_F5;
3094 SET_EXPECT(DocHost_TranslateAccelerator);
3095 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3096 todo_wine ok(hres == S_OK, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3097 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3099 IOleInPlaceActiveObject_Release(pao);
3102 doc_clientsite = get_dochost(unk);
3103 if(doc_clientsite) {
3104 IDocHostUIHandler2 *dochost;
3105 IOleControlSite *doc_controlsite;
3108 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleInPlaceFrame, (void**)&unk_test);
3109 ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
3110 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3112 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostShowUI, (void**)&unk_test);
3113 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
3114 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3116 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler, (void**)&unk_test);
3117 ok(hres == S_OK, "Got 0x%08x\n", hres);
3118 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3120 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler2, (void**)&dochost);
3121 ok(hres == S_OK, "Got 0x%08x\n", hres);
3122 if(SUCCEEDED(hres)) {
3123 msg_a.message = WM_KEYDOWN;
3124 hr_dochost_TranslateAccelerator = 0xdeadbeef;
3125 for(keycode = 0; keycode <= 0x100; keycode++) {
3126 msg_a.wParam = keycode;
3127 SET_EXPECT(DocHost_TranslateAccelerator);
3128 hres = IDocHostUIHandler_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3129 ok(hres == 0xdeadbeef, "Got 0x%08x\n", hres);
3130 CHECK_CALLED(DocHost_TranslateAccelerator);
3132 hr_dochost_TranslateAccelerator = E_NOTIMPL;
3134 SET_EXPECT(DocHost_TranslateAccelerator);
3135 hres = IDocHostUIHandler_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3136 ok(hres == E_NOTIMPL, "Got 0x%08x\n", hres);
3137 CHECK_CALLED(DocHost_TranslateAccelerator);
3139 IDocHostUIHandler2_Release(dochost);
3142 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleControlSite, (void**)&doc_controlsite);
3143 ok(hres == S_OK, "Got 0x%08x\n", hres);
3144 if(SUCCEEDED(hres)) {
3145 msg_a.message = WM_KEYDOWN;
3146 hr_site_TranslateAccelerator = 0xdeadbeef;
3147 for(keycode = 0; keycode < 0x100; keycode++) {
3148 msg_a.wParam = keycode;
3149 SET_EXPECT(ControlSite_TranslateAccelerator);
3150 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3151 if(keycode == 0x9 || keycode == 0x75)
3152 todo_wine ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3154 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3156 CHECK_CALLED(ControlSite_TranslateAccelerator);
3158 msg_a.wParam = VK_LEFT;
3159 SET_EXPECT(ControlSite_TranslateAccelerator);
3160 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3161 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3162 CHECK_CALLED(ControlSite_TranslateAccelerator);
3164 hr_site_TranslateAccelerator = S_OK;
3165 SET_EXPECT(ControlSite_TranslateAccelerator);
3166 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3167 ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3168 CHECK_CALLED(ControlSite_TranslateAccelerator);
3170 hr_site_TranslateAccelerator = E_NOTIMPL;
3171 SET_EXPECT(ControlSite_TranslateAccelerator);
3172 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3173 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3174 CHECK_CALLED(ControlSite_TranslateAccelerator);
3176 IOleControlSite_Release(doc_controlsite);
3179 IOleClientSite_Release(doc_clientsite);
3182 test_UIActivate(unk, FALSE);
3185 static void test_dochost_qs(IWebBrowser2 *webbrowser)
3187 IOleClientSite *client_site;
3188 IServiceProvider *serv_prov;
3192 client_site = get_dochost(webbrowser);
3193 hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
3194 IOleClientSite_Release(client_site);
3195 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
3197 hres = IServiceProvider_QueryService(serv_prov, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&service);
3198 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3199 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3200 IUnknown_Release(service);
3202 hres = IServiceProvider_QueryService(serv_prov, &IID_IWebBrowserApp, &IID_IHlinkFrame, (void**)&service);
3203 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3204 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3205 IUnknown_Release(service);
3207 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IShellBrowser, (void**)&service);
3208 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3209 IUnknown_Release(service);
3211 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IBrowserService, (void**)&service);
3212 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3213 IUnknown_Release(service);
3215 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IDocObjectService, (void**)&service);
3216 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3217 IUnknown_Release(service);
3219 IServiceProvider_Release(serv_prov);
3222 static void test_Close(IWebBrowser2 *wb, BOOL do_download)
3225 IOleClientSite *ocs;
3228 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oo);
3229 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3235 SET_EXPECT(Frame_SetActiveObject);
3236 SET_EXPECT(UIWindow_SetActiveObject);
3237 SET_EXPECT(OnUIDeactivate);
3238 SET_EXPECT(OnFocus);
3239 SET_EXPECT(OnInPlaceDeactivate);
3240 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
3242 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
3243 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3245 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3246 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3247 CHECK_CALLED(Frame_SetActiveObject);
3248 CHECK_CALLED(UIWindow_SetActiveObject);
3249 CHECK_CALLED(OnUIDeactivate);
3250 todo_wine CHECK_CALLED(OnFocus);
3251 CHECK_CALLED(OnInPlaceDeactivate);
3252 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
3254 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
3255 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3258 hres = IOleObject_GetClientSite(oo, &ocs);
3259 ok(hres == S_OK, "hres = %x\n", hres);
3260 ok(!ocs, "ocs != NULL\n");
3262 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3263 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3266 IOleObject_Release(oo);
3269 #define TEST_DOWNLOAD 0x0001
3270 #define TEST_NOOLECMD 0x0002
3271 #define TEST_NODOCHOST 0x0004
3273 static void init_test(IWebBrowser2 *webbrowser, DWORD flags)
3277 is_downloading = (flags & TEST_DOWNLOAD) != 0;
3278 is_first_load = TRUE;
3279 use_container_olecmd = !(flags & TEST_NOOLECMD);
3280 use_container_dochostui = !(flags & TEST_NODOCHOST);
3283 static void test_WebBrowser(BOOL do_download, BOOL do_close)
3285 IWebBrowser2 *webbrowser;
3288 webbrowser = create_webbrowser();
3292 init_test(webbrowser, do_download ? TEST_DOWNLOAD : 0);
3294 test_QueryStatusWB(webbrowser, FALSE, FALSE);
3295 test_ExecWB(webbrowser, FALSE, FALSE);
3296 test_QueryInterface(webbrowser);
3297 test_ready_state(READYSTATE_UNINITIALIZED);
3298 test_ClassInfo(webbrowser);
3299 test_EnumVerbs(webbrowser);
3300 test_LocationURL(webbrowser, "");
3301 test_ConnectionPoint(webbrowser, TRUE);
3302 test_ClientSite(webbrowser, &ClientSite, !do_download);
3303 test_Extent(webbrowser);
3304 test_wb_funcs(webbrowser, TRUE);
3305 test_DoVerb(webbrowser);
3306 test_olecmd(webbrowser, FALSE);
3307 test_Navigate2(webbrowser, "about:blank");
3308 test_QueryStatusWB(webbrowser, TRUE, TRUE);
3309 test_ExecWB(webbrowser, TRUE, TRUE);
3312 IDispatch *doc, *doc2;
3315 test_olecmd(webbrowser, TRUE);
3316 doc = get_document(webbrowser);
3318 test_put_href(webbrowser, "about:test");
3319 test_download(DWL_FROM_PUT_HREF);
3320 doc2 = get_document(webbrowser);
3321 ok(doc == doc2, "doc != doc2\n");
3322 IDispatch_Release(doc2);
3324 trace("Navigate2 repeated...\n");
3325 test_Navigate2(webbrowser, "about:blank");
3326 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3327 doc2 = get_document(webbrowser);
3328 ok(doc == doc2, "doc != doc2\n");
3329 IDispatch_Release(doc2);
3330 IDispatch_Release(doc);
3333 trace("Navigate2 http URL...\n");
3334 test_ready_state(READYSTATE_COMPLETE);
3335 test_Navigate2(webbrowser, "http://test.winehq.org/tests/hello.html");
3336 test_download(DWL_EXPECT_BEFORE_NAVIGATE|DWL_HTTP);
3338 trace("put_href http URL...\n");
3339 test_put_href(webbrowser, "http://www.winehq.org/");
3340 test_download(DWL_FROM_PUT_HREF|DWL_HTTP);
3342 trace("GoBack...\n");
3343 test_go_back(webbrowser, "http://test.winehq.org/tests/hello.html");
3344 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3347 test_EnumVerbs(webbrowser);
3348 test_TranslateAccelerator(webbrowser);
3350 test_dochost_qs(webbrowser);
3353 test_external(webbrowser);
3356 test_Close(webbrowser, do_download);
3358 test_ClientSite(webbrowser, NULL, !do_download);
3359 test_ie_funcs(webbrowser);
3360 test_GetControlInfo(webbrowser);
3361 test_wb_funcs(webbrowser, FALSE);
3362 test_ConnectionPoint(webbrowser, FALSE);
3363 test_IServiceProvider(webbrowser);
3365 ref = IWebBrowser2_Release(webbrowser);
3366 ok(ref == 0 || broken(do_download && !do_close && ref == 1), "ref=%d, expected 0\n", ref);
3369 static void test_WebBrowserV1(void)
3375 hres = CoCreateInstance(&CLSID_WebBrowser_V1, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3376 &IID_IWebBrowser2, (void**)&wb);
3377 ok(hres == S_OK, "Could not get WebBrowserV1 instance: %08x\n", hres);
3382 test_QueryStatusWB(wb, FALSE, FALSE);
3383 test_ExecWB(wb, FALSE, FALSE);
3384 test_QueryInterface(wb);
3385 test_ready_state(READYSTATE_UNINITIALIZED);
3389 ref = IWebBrowser2_Release(wb);
3390 ok(ref == 0, "ref=%d, expected 0\n", ref);
3393 static void test_WebBrowser_slim_container(void)
3395 IWebBrowser2 *webbrowser;
3398 webbrowser = create_webbrowser();
3399 init_test(webbrowser, TEST_NOOLECMD|TEST_NODOCHOST);
3401 test_ConnectionPoint(webbrowser, TRUE);
3402 test_ClientSite(webbrowser, &ClientSite, TRUE);
3403 test_DoVerb(webbrowser);
3404 test_Navigate2(webbrowser, "about:blank");
3406 /* Tests of interest */
3407 test_QueryStatusWB(webbrowser, FALSE, TRUE);
3408 test_ExecWB(webbrowser, FALSE, TRUE);
3409 test_external(webbrowser);
3412 test_ClientSite(webbrowser, NULL, TRUE);
3413 test_ConnectionPoint(webbrowser, FALSE);
3415 ref = IWebBrowser2_Release(webbrowser);
3416 ok(ref == 0, "ref=%d, expected 0\n", ref);
3419 static void test_WebBrowser_DoVerb(void)
3421 IWebBrowser2 *webbrowser;
3427 webbrowser = create_webbrowser();
3428 init_test(webbrowser, 0);
3430 test_ClientSite(webbrowser, &ClientSite, FALSE);
3432 SET_EXPECT(CanInPlaceActivate);
3433 SET_EXPECT(Site_GetWindow);
3434 SET_EXPECT(OnInPlaceActivate);
3435 SET_EXPECT(GetWindowContext);
3436 SET_EXPECT(ShowObject);
3437 SET_EXPECT(GetContainer);
3438 SET_EXPECT(Frame_GetWindow);
3439 call_DoVerb(webbrowser, OLEIVERB_INPLACEACTIVATE);
3440 CHECK_CALLED(CanInPlaceActivate);
3441 CHECK_CALLED(Site_GetWindow);
3442 CHECK_CALLED(OnInPlaceActivate);
3443 CHECK_CALLED(GetWindowContext);
3444 CHECK_CALLED(ShowObject);
3445 CHECK_CALLED(GetContainer);
3446 CHECK_CALLED(Frame_GetWindow);
3448 hwnd = get_hwnd(webbrowser);
3450 memset(&rect, 0xa, sizeof(rect));
3451 res = GetWindowRect(hwnd, &rect);
3452 ok(res, "GetWindowRect failed: %u\n", GetLastError());
3454 SET_EXPECT(OnInPlaceDeactivate);
3455 call_DoVerb(webbrowser, OLEIVERB_HIDE);
3456 CHECK_CALLED(OnInPlaceDeactivate);
3458 test_ClientSite(webbrowser, NULL, FALSE);
3460 ref = IWebBrowser2_Release(webbrowser);
3461 ok(ref == 0, "ref=%d, expected 0\n", ref);
3465 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
3466 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
3467 static BOOL is_ie_hardened(void)
3470 DWORD ie_harden, type, size;
3473 if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
3474 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
3475 size = sizeof(DWORD);
3476 if (RegQueryValueEx(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
3477 type != REG_DWORD) {
3480 RegCloseKey(zone_map);
3483 return ie_harden != 0;
3486 START_TEST(webbrowser)
3488 OleInitialize(NULL);
3490 container_hwnd = create_container_window();
3492 trace("Testing WebBrowser (no download)...\n");
3493 test_WebBrowser(FALSE, FALSE);
3494 test_WebBrowser(FALSE, TRUE);
3496 if(!is_ie_hardened()) {
3497 trace("Testing WebBrowser...\n");
3498 test_WebBrowser(TRUE, FALSE);
3500 win_skip("Skipping http tests in hardened mode\n");
3503 trace("Testing WebBrowser DoVerb\n");
3504 test_WebBrowser_DoVerb();
3505 trace("Testing WebBrowser (with close)...\n");
3506 test_WebBrowser(TRUE, TRUE);
3507 trace("Testing WebBrowser w/o container-based olecmd...\n");
3508 test_WebBrowser_slim_container();
3509 trace("Testing WebBrowserV1...\n");
3510 test_WebBrowserV1();