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(Exec_DocHostCommandHandler_2300);
130 DEFINE_EXPECT(QueryStatus_STOP);
131 DEFINE_EXPECT(QueryStatus_IDM_STOP);
132 DEFINE_EXPECT(DocHost_EnableModeless_TRUE);
133 DEFINE_EXPECT(DocHost_EnableModeless_FALSE);
134 DEFINE_EXPECT(DocHost_TranslateAccelerator);
135 DEFINE_EXPECT(GetDropTarget);
136 DEFINE_EXPECT(TranslateUrl);
137 DEFINE_EXPECT(ShowUI);
138 DEFINE_EXPECT(HideUI);
139 DEFINE_EXPECT(OnUIDeactivate);
140 DEFINE_EXPECT(OnInPlaceDeactivate);
141 DEFINE_EXPECT(RequestUIActivate);
142 DEFINE_EXPECT(ControlSite_TranslateAccelerator);
143 DEFINE_EXPECT(OnFocus);
144 DEFINE_EXPECT(GetExternal);
146 static const WCHAR wszItem[] = {'i','t','e','m',0};
147 static const WCHAR emptyW[] = {0};
149 static VARIANT_BOOL exvb;
151 static IWebBrowser2 *wb;
153 static HWND container_hwnd, shell_embedding_hwnd;
154 static BOOL is_downloading, is_first_load, use_container_olecmd, test_close, is_http, use_container_dochostui;
155 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
156 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
157 static const char *current_url;
158 static int wb_version;
160 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
161 #define DWL_FROM_PUT_HREF 0x02
162 #define DWL_FROM_GOBACK 0x04
163 #define DWL_HTTP 0x08
164 #define DWL_REFRESH 0x10
166 static DWORD dwl_flags;
169 /* Returns true if the user interface is in English. Note that this does not
170 * presume of the formatting of dates, numbers, etc.
172 static BOOL is_lang_english(void)
174 static HMODULE hkernel32 = NULL;
175 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
176 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
180 hkernel32 = GetModuleHandleA("kernel32.dll");
181 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
182 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
184 if (pGetThreadUILanguage)
185 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
186 if (pGetUserDefaultUILanguage)
187 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
189 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
192 static int strcmp_wa(LPCWSTR strw, const char *stra)
195 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
196 return lstrcmpA(stra, buf);
199 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
201 IUnknown *unk1, *unk2;
206 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
207 IUnknown_Release(unk1);
208 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
209 IUnknown_Release(unk2);
214 static const char *debugstr_guid(REFIID riid)
218 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
219 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
220 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
221 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
226 static BSTR a2bstr(const char *str)
231 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
232 ret = SysAllocStringLen(NULL, len);
233 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
238 #define create_webbrowser() _create_webbrowser(__LINE__)
239 static IWebBrowser2 *_create_webbrowser(unsigned line)
246 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
247 &IID_IWebBrowser2, (void**)&ret);
248 ok_(__FILE__,line)(hres == S_OK, "Creating WebBrowser object failed: %08x\n", hres);
252 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
253 static void _test_LocationURL(unsigned line, IWebBrowser2 *wb, const char *exurl)
255 BSTR url = (void*)0xdeadbeef;
258 hres = IWebBrowser2_get_LocationURL(wb, &url);
259 ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
262 ok_(__FILE__,line) (!strcmp_wa(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
267 #define test_ready_state(ex) _test_ready_state(__LINE__,ex);
268 static void _test_ready_state(unsigned line, READYSTATE exstate)
273 hres = IWebBrowser2_get_ReadyState(wb, &state);
274 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
275 ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
278 #define get_document(u) _get_document(__LINE__,u)
279 static IDispatch *_get_document(unsigned line, IWebBrowser2 *wb)
281 IHTMLDocument2 *html_doc;
286 hres = IWebBrowser2_get_Document(wb, &disp);
287 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
288 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
290 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
291 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
292 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
293 IHTMLDocument2_Release(html_doc);
298 #define get_dochost(u) _get_dochost(__LINE__,u)
299 static IOleClientSite *_get_dochost(unsigned line, IWebBrowser2 *unk)
301 IOleClientSite *client_site;
306 doc = _get_document(line, unk);
307 hres = IDispatch_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
308 IDispatch_Release(doc);
309 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
311 hres = IOleObject_GetClientSite(oleobj, &client_site);
312 IOleObject_Release(oleobj);
313 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
318 static HRESULT QueryInterface(REFIID,void**);
320 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
321 REFIID riid, void **ppv)
323 ok(0, "unexpected call\n");
324 return E_NOINTERFACE;
327 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
332 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
337 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
338 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
340 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
341 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
342 ok(!pCmdText, "pCmdText != NULL\n");
344 switch(prgCmds[0].cmdID) {
346 CHECK_EXPECT2(QueryStatus_STOP);
347 prgCmds[0].cmdf = OLECMDF_SUPPORTED;
349 case OLECMDID_SETPROGRESSTEXT:
350 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
351 prgCmds[0].cmdf = OLECMDF_ENABLED;
355 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
356 * This command appears here for the ExecWB and QueryStatusWB tests in order
357 * to help demonstrate that these routines use a NULL pguidCmdGroup.
359 CHECK_EXPECT(QueryStatus_IDM_STOP);
363 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
369 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
370 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
374 case OLECMDID_SETPROGRESSMAX:
375 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
376 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
377 ok(pvaIn != NULL, "pvaIn == NULL\n");
379 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
380 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
382 case OLECMDID_SETPROGRESSPOS:
383 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
384 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
385 ok(pvaIn != NULL, "pvaIn == NULL\n");
387 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
388 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
390 case OLECMDID_SETDOWNLOADSTATE:
392 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
393 "nCmdexecopts=%08x\n", nCmdexecopt);
395 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
396 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
397 ok(pvaIn != NULL, "pvaIn == NULL\n");
398 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
399 switch(V_I4(pvaIn)) {
401 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
404 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
407 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
410 case OLECMDID_UPDATECOMMANDS:
411 CHECK_EXPECT2(Exec_UPDATECOMMANDS);
412 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
413 ok(!pvaIn, "pvaIn != NULL\n");
414 ok(!pvaOut, "pvaOut=%p, expected NULL\n", pvaOut);
416 case OLECMDID_SETTITLE:
417 CHECK_EXPECT(Exec_SETTITLE);
418 /* TODO: test args */
421 CHECK_EXPECT(Exec_STOP);
425 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
426 * This command appears here for the ExecWB and QueryStatusWB tests in order
427 * to help demonstrate that these routines use a NULL pguidCmdGroup.
429 CHECK_EXPECT(Exec_IDM_STOP);
430 return OLECMDERR_E_NOTSUPPORTED;
431 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
432 case 6058: /* TODO */
435 ok(0, "unexpected nsCmdID %d\n", nCmdID);
437 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
447 case 101: /* TODO (IE8) */
448 case 109: /* TODO (IE9) */
451 ok(0, "unexpected nCmdID %d\n", nCmdID);
453 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
457 case 140: /* TODO (Win7) */
461 ok(0, "unexpected nCmdID %d\n", nCmdID);
463 }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
468 ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
470 }else if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
472 case 6041: /* TODO */
475 CHECK_EXPECT(Exec_DocHostCommandHandler_2300);
478 ok(0, "unexpected nCmdID %d of CGID_DocHostCommandHandler\n", nCmdID);
481 ok(0, "unexpected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
487 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
488 OleCommandTarget_QueryInterface,
489 OleCommandTarget_AddRef,
490 OleCommandTarget_Release,
491 OleCommandTarget_QueryStatus,
492 OleCommandTarget_Exec
495 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
497 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
499 if(IsEqualGUID(&IID_ITargetContainer, riid))
500 return E_NOINTERFACE; /* TODO */
502 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
503 if(use_container_olecmd)
505 *ppv = &OleCommandTarget;
509 return E_NOINTERFACE;
512 ok(0, "unexpected call\n");
513 return E_NOINTERFACE;
516 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
521 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
526 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
527 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
529 ok(0, "unexpected call\n");
533 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
534 IEnumUnknown **ppenum)
536 ok(0, "unexpected call\n");
540 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
542 ok(0, "unexpected call\n");
546 static const IOleContainerVtbl OleContainerVtbl = {
547 OleContainer_QueryInterface,
549 OleContainer_Release,
550 OleContainer_ParseDisplayName,
551 OleContainer_EnumObjects,
552 OleContainer_LockContainer
555 static IOleContainer OleContainer = { &OleContainerVtbl };
557 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
559 return QueryInterface(riid, ppv);
562 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
567 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
572 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
574 ok(0, "unexpected call\n");
578 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
581 ok(0, "unexpected call\n");
585 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
586 UINT cNames, LCID lcid, DISPID *rgDispId)
588 ok(0, "unexpected call\n");
592 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
593 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
594 EXCEPINFO *pExcepInfo, UINT *puArgErr)
596 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
597 ok(pDispParams != NULL, "pDispParams == NULL\n");
598 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
599 ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
600 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
601 ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
602 ok(pDispParams->rgdispidNamedArgs == NULL,
603 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
604 ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
605 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
607 switch(dispIdMember) {
608 case DISPID_AMBIENT_USERMODE:
609 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
611 case DISPID_AMBIENT_DLCONTROL:
612 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
613 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
615 case DISPID_AMBIENT_USERAGENT:
616 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
617 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
619 case DISPID_AMBIENT_PALETTE:
620 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
621 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
623 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
624 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
625 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
626 V_VT(pVarResult) = VT_BOOL;
627 V_BOOL(pVarResult) = VARIANT_FALSE;
629 case DISPID_AMBIENT_SILENT:
630 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
631 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
632 V_VT(pVarResult) = VT_BOOL;
633 V_BOOL(pVarResult) = VARIANT_FALSE;
637 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
641 static IDispatchVtbl DispatchVtbl = {
642 Dispatch_QueryInterface,
645 Dispatch_GetTypeInfoCount,
646 Dispatch_GetTypeInfo,
647 Dispatch_GetIDsOfNames,
651 static IDispatch Dispatch = { &DispatchVtbl };
653 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
657 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
662 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
663 return E_NOINTERFACE;
666 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
667 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
669 ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
670 ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
671 ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
673 ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
674 V_BOOL(params->rgvarg), exvb);
676 ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
677 V_BOOL(params->rgvarg), exvb);
680 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
681 const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
683 ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
684 ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
685 ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
687 ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
688 ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
689 if(V_VARIANTREF(url)) {
690 ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
691 V_VT(V_VARIANTREF(url)));
692 ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
693 ok(!strcmp_wa(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
694 wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), current_url);
697 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
699 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
701 ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
702 if(V_VARIANTREF(flags)) {
703 ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
704 V_VT(V_VARIANTREF(flags)));
706 ok(V_I4(V_VARIANTREF(flags)) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0\n",
707 V_I4(V_VARIANTREF(flags)));
709 ok((V_I4(V_VARIANTREF(flags)) & ~0x40) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0x40 or 0\n",
710 V_I4(V_VARIANTREF(flags)));
714 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
716 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
718 ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
719 if(V_VARIANTREF(frame)) {
720 ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
721 V_VT(V_VARIANTREF(frame)));
722 ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
723 V_BSTR(V_VARIANTREF(frame)));
726 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
728 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
730 ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
731 if(V_VARIANTREF(post_data)) {
732 ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
733 "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
734 V_VT(V_VARIANTREF(post_data)));
735 ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
736 "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
737 if(V_VARIANTREF(V_VARIANTREF(post_data))) {
738 ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
739 "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
740 V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
742 if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
743 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
745 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
746 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
751 ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
753 ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
754 if(V_VARIANTREF(headers)) {
755 ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
756 V_VT(V_VARIANTREF(headers)));
757 ok(V_BSTR(V_VARIANTREF(headers)) == NULL, "V_BSTR(V_VARIANTREF(headers)) = %p, expected NULL\n",
758 V_BSTR(V_VARIANTREF(headers)));
761 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
763 ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
764 if(V_BOOLREF(cancel))
765 ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(cancel) = %x, expected VARIANT_FALSE\n",
769 static void test_navigatecomplete2(DISPPARAMS *dp)
773 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
775 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
776 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
778 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
779 v = V_VARIANTREF(dp->rgvarg);
780 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
781 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
783 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
784 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
786 test_ready_state((dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
789 static void test_documentcomplete(DISPPARAMS *dp)
793 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
795 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
796 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
798 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
799 v = V_VARIANTREF(dp->rgvarg);
800 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
801 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
803 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
804 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
806 test_ready_state(READYSTATE_COMPLETE);
809 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
810 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
811 EXCEPINFO *pExcepInfo, UINT *puArgErr)
813 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
814 ok(pDispParams != NULL, "pDispParams == NULL\n");
815 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
816 ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
817 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
818 ok(pDispParams->rgdispidNamedArgs == NULL,
819 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
820 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
822 switch(dispIdMember) {
823 case DISPID_STATUSTEXTCHANGE:
824 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
826 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
827 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
828 ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
829 V_VT(pDispParams->rgvarg));
830 /* TODO: Check text */
833 case DISPID_PROPERTYCHANGE:
834 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
836 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
837 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
838 /* TODO: Check args */
841 case DISPID_DOWNLOADBEGIN:
842 CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
844 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
845 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
846 test_ready_state(READYSTATE_LOADING);
849 case DISPID_BEFORENAVIGATE2:
850 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
852 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
853 ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
854 test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
855 pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
856 pDispParams->rgvarg);
857 test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
860 case DISPID_SETSECURELOCKICON:
861 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
863 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
864 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
865 /* TODO: Check args */
868 case DISPID_FILEDOWNLOAD:
869 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
871 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
872 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
873 /* TODO: Check args */
876 case DISPID_COMMANDSTATECHANGE:
877 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
879 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
880 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
882 ok(V_VT(pDispParams->rgvarg) == VT_BOOL, "V_VT(pDispParams->rgvarg) = %d\n", V_VT(pDispParams->rgvarg));
883 ok(V_VT(pDispParams->rgvarg+1) == VT_I4, "V_VT(pDispParams->rgvarg+1) = %d\n", V_VT(pDispParams->rgvarg+1));
885 /* TODO: Check args */
888 case DISPID_DOWNLOADCOMPLETE:
889 CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
891 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
892 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
893 test_ready_state(READYSTATE_LOADING);
896 case DISPID_ONMENUBAR:
897 CHECK_EXPECT(Invoke_ONMENUBAR);
898 test_invoke_bool(pDispParams, TRUE);
901 case DISPID_ONADDRESSBAR:
902 CHECK_EXPECT(Invoke_ONADDRESSBAR);
903 test_invoke_bool(pDispParams, TRUE);
906 case DISPID_ONSTATUSBAR:
907 CHECK_EXPECT(Invoke_ONSTATUSBAR);
908 test_invoke_bool(pDispParams, TRUE);
911 case DISPID_ONTOOLBAR:
912 CHECK_EXPECT(Invoke_ONTOOLBAR);
913 test_invoke_bool(pDispParams, FALSE);
916 case DISPID_ONFULLSCREEN:
917 CHECK_EXPECT(Invoke_ONFULLSCREEN);
918 test_invoke_bool(pDispParams, TRUE);
921 case DISPID_ONTHEATERMODE:
922 CHECK_EXPECT(Invoke_ONTHEATERMODE);
923 test_invoke_bool(pDispParams, TRUE);
926 case DISPID_WINDOWSETRESIZABLE:
927 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
928 test_invoke_bool(pDispParams, TRUE);
931 case DISPID_TITLECHANGE:
932 CHECK_EXPECT2(Invoke_TITLECHANGE);
936 case DISPID_NAVIGATECOMPLETE2:
937 test_navigatecomplete2(pDispParams);
940 case DISPID_PROGRESSCHANGE:
941 CHECK_EXPECT2(Invoke_PROGRESSCHANGE);
945 case DISPID_DOCUMENTCOMPLETE:
946 test_documentcomplete(pDispParams);
949 case 282: /* FIXME */
950 CHECK_EXPECT2(Invoke_282);
954 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
960 static IDispatchVtbl WebBrowserEvents2Vtbl = {
961 WebBrowserEvents2_QueryInterface,
964 Dispatch_GetTypeInfoCount,
965 Dispatch_GetTypeInfo,
966 Dispatch_GetIDsOfNames,
967 WebBrowserEvents2_Invoke
970 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
972 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
974 return QueryInterface(riid, ppv);
977 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
982 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
987 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
989 ok(0, "unexpected call\n");
993 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
996 ok(0, "unexpected call\n");
1000 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1002 CHECK_EXPECT(GetContainer);
1004 ok(ppContainer != NULL, "ppContainer == NULL\n");
1006 *ppContainer = &OleContainer;
1011 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1013 CHECK_EXPECT(ShowObject);
1017 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1019 ok(0, "unexpected call\n");
1023 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1025 ok(0, "unexpected call\n");
1029 static const IOleClientSiteVtbl ClientSiteVtbl = {
1030 ClientSite_QueryInterface,
1033 ClientSite_SaveObject,
1034 ClientSite_GetMoniker,
1035 ClientSite_GetContainer,
1036 ClientSite_ShowObject,
1037 ClientSite_OnShowWindow,
1038 ClientSite_RequestNewObjectLayout
1041 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1043 static HRESULT WINAPI IOleControlSite_fnQueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1046 return E_NOINTERFACE;
1049 static ULONG WINAPI IOleControlSite_fnAddRef(IOleControlSite *iface)
1054 static ULONG WINAPI IOleControlSite_fnRelease(IOleControlSite *iface)
1059 static HRESULT WINAPI IOleControlSite_fnOnControlInfoChanged(IOleControlSite* This)
1061 ok(0, "unexpected call\n");
1065 static HRESULT WINAPI IOleControlSite_fnLockInPlaceActive(IOleControlSite* This,
1068 ok(0, "unexpected call\n");
1072 static HRESULT WINAPI IOleControlSite_fnGetExtendedControl(IOleControlSite* This,
1075 ok(0, "unexpected call\n");
1079 static HRESULT WINAPI IOleControlSite_fnTransformCoords(IOleControlSite* This,
1080 POINTL *pPtlHimetric,
1081 POINTF *pPtfContainer,
1084 ok(0, "unexpected call\n");
1088 static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* This, MSG *pMsg,
1091 CHECK_EXPECT(ControlSite_TranslateAccelerator);
1092 return hr_site_TranslateAccelerator;
1095 static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus)
1097 CHECK_EXPECT2(OnFocus);
1101 static HRESULT WINAPI IOleControlSite_fnShowPropertyFrame(IOleControlSite* This)
1103 ok(0, "unexpected call\n");
1107 static IOleControlSiteVtbl ControlSiteVtbl = {
1108 IOleControlSite_fnQueryInterface,
1109 IOleControlSite_fnAddRef,
1110 IOleControlSite_fnRelease,
1111 IOleControlSite_fnOnControlInfoChanged,
1112 IOleControlSite_fnLockInPlaceActive,
1113 IOleControlSite_fnGetExtendedControl,
1114 IOleControlSite_fnTransformCoords,
1115 IOleControlSite_fnTranslateAccelerator,
1116 IOleControlSite_fnOnFocus,
1117 IOleControlSite_fnShowPropertyFrame
1120 static IOleControlSite ControlSite = { &ControlSiteVtbl };
1122 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
1123 REFIID riid, void **ppv)
1125 ok(0, "unexpected call\n");
1126 return E_NOINTERFACE;
1129 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
1134 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
1139 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1141 ok(0, "unexpected call\n");
1145 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1147 CHECK_EXPECT(Frame_GetWindow);
1148 ok(phwnd != NULL, "phwnd == NULL\n");
1150 *phwnd = container_hwnd;
1154 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1156 ok(0, "unexpected call\n");
1160 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1162 ok(0, "unexpected call\n");
1166 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
1167 LPCBORDERWIDTHS pborderwidths)
1169 ok(0, "unexpected call\n");
1173 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
1174 LPCBORDERWIDTHS pborderwidths)
1176 ok(0, "unexpected call\n");
1180 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1181 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1183 CHECK_EXPECT(UIWindow_SetActiveObject);
1185 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1186 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1188 ok(!pActiveObject, "pActiveObject != NULL\n");
1189 ok(!pszObjName, "pszObjName != NULL\n");
1194 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1195 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1197 CHECK_EXPECT(Frame_SetActiveObject);
1199 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1200 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1202 ok(!pActiveObject, "pActiveObject != NULL\n");
1203 ok(!pszObjName, "pszObjName != NULL\n");
1208 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1209 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1211 ok(0, "unexpected call\n");
1215 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1216 HOLEMENU holemenu, HWND hwndActiveObject)
1218 CHECK_EXPECT(SetMenu);
1219 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
1220 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
1221 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
1222 hwndActiveObject, shell_embedding_hwnd);
1226 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1228 ok(0, "unexpected call\n");
1232 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1234 CHECK_EXPECT2(SetStatusText);
1235 /* FIXME: Check pszStatusText */
1239 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1242 CHECK_EXPECT2(EnableModeless_TRUE);
1244 CHECK_EXPECT2(EnableModeless_FALSE);
1248 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1250 ok(0, "unexpected call\n");
1254 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1255 InPlaceUIWindow_QueryInterface,
1256 InPlaceUIWindow_AddRef,
1257 InPlaceUIWindow_Release,
1258 InPlaceUIWindow_GetWindow,
1259 InPlaceUIWindow_ContextSensitiveHelp,
1260 InPlaceUIWindow_GetBorder,
1261 InPlaceUIWindow_RequestBorderSpace,
1262 InPlaceUIWindow_SetBorderSpace,
1263 InPlaceUIWindow_SetActiveObject,
1266 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
1268 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1269 InPlaceUIWindow_QueryInterface,
1270 InPlaceUIWindow_AddRef,
1271 InPlaceUIWindow_Release,
1272 InPlaceFrame_GetWindow,
1273 InPlaceUIWindow_ContextSensitiveHelp,
1274 InPlaceUIWindow_GetBorder,
1275 InPlaceUIWindow_RequestBorderSpace,
1276 InPlaceUIWindow_SetBorderSpace,
1277 InPlaceFrame_SetActiveObject,
1278 InPlaceFrame_InsertMenus,
1279 InPlaceFrame_SetMenu,
1280 InPlaceFrame_RemoveMenus,
1281 InPlaceFrame_SetStatusText,
1282 InPlaceFrame_EnableModeless,
1283 InPlaceFrame_TranslateAccelerator
1286 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1288 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1290 return QueryInterface(riid, ppv);
1293 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1298 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1303 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1305 CHECK_EXPECT(Site_GetWindow);
1306 ok(phwnd != NULL, "phwnd == NULL\n");
1308 *phwnd = container_hwnd;
1312 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1314 ok(0, "unexpected call\n");
1318 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1320 CHECK_EXPECT(CanInPlaceActivate);
1324 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1326 CHECK_EXPECT(OnInPlaceActivate);
1330 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1332 CHECK_EXPECT(OnUIActivate);
1336 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1337 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1338 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1340 static const RECT pos_rect = {2,1,1002,901};
1341 static const RECT clip_rect = {10,10,990,890};
1343 CHECK_EXPECT(GetWindowContext);
1345 ok(ppFrame != NULL, "ppFrame = NULL\n");
1347 *ppFrame = &InPlaceFrame;
1349 ok(ppDoc != NULL, "ppDoc = NULL\n");
1351 *ppDoc = &InPlaceUIWindow;
1353 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1355 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1357 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1359 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1361 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1363 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1364 lpFrameInfo->fMDIApp = FALSE;
1365 lpFrameInfo->hwndFrame = container_hwnd;
1366 lpFrameInfo->haccel = NULL;
1367 lpFrameInfo->cAccelEntries = 0;
1373 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1375 ok(0, "unexpected call\n");
1379 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1381 CHECK_EXPECT(OnUIDeactivate);
1382 ok(!fUndoable, "fUndoable should be FALSE\n");
1386 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1388 CHECK_EXPECT(OnInPlaceDeactivate);
1392 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1394 ok(0, "unexpected call\n");
1398 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1400 ok(0, "unexpected call\n");
1404 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1406 ok(0, "unexpected call\n");
1410 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1411 BOOL *pNoRedraw, DWORD dwFlags)
1413 ok(0, "unexpected call\n");
1417 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1420 ok(0, "unexpected call\n");
1424 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1426 CHECK_EXPECT2(RequestUIActivate);
1430 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1431 InPlaceSite_QueryInterface,
1433 InPlaceSite_Release,
1434 InPlaceSite_GetWindow,
1435 InPlaceSite_ContextSensitiveHelp,
1436 InPlaceSite_CanInPlaceActivate,
1437 InPlaceSite_OnInPlaceActivate,
1438 InPlaceSite_OnUIActivate,
1439 InPlaceSite_GetWindowContext,
1441 InPlaceSite_OnUIDeactivate,
1442 InPlaceSite_OnInPlaceDeactivate,
1443 InPlaceSite_DiscardUndoState,
1444 InPlaceSite_DeactivateAndUndo,
1445 InPlaceSite_OnPosRectChange,
1446 InPlaceSite_OnInPlaceActivateEx,
1447 InPlaceSite_OnInPlaceDeactivateEx,
1448 InPlaceSite_RequestUIActivate
1451 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1453 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1455 return QueryInterface(riid, ppv);
1458 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1463 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1468 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1469 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1471 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1475 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1477 CHECK_EXPECT2(GetHostInfo);
1478 ok(pInfo != NULL, "pInfo=NULL\n");
1480 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1481 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1482 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1483 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1484 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1489 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1490 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1491 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1493 CHECK_EXPECT(ShowUI);
1497 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1499 CHECK_EXPECT(HideUI);
1503 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1505 CHECK_EXPECT2(UpdateUI);
1509 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1512 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1514 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1519 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1521 ok(0, "unexpected call\n");
1525 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1527 ok(0, "unexpected call\n");
1531 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1532 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1534 ok(0, "unexpected call\n");
1538 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1539 const GUID *pguidCmdGroup, DWORD nCmdID)
1541 CHECK_EXPECT(DocHost_TranslateAccelerator);
1542 ok(pguidCmdGroup != NULL, "Got NULL pguidCmdGroup.\n");
1544 ok(IsEqualGUID(pguidCmdGroup, &CGID_MSHTML), "Unexpected pguidCmdGroup\n");
1545 ok(lpMsg != NULL, "Got NULL lpMsg.\n");
1546 return hr_dochost_TranslateAccelerator;
1549 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1550 LPOLESTR *pchKey, DWORD dw)
1552 CHECK_EXPECT(GetOptionKeyPath);
1553 ok(pchKey != NULL, "pchKey==NULL\n");
1555 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1556 ok(!dw, "dw=%x\n", dw);
1560 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1561 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1563 CHECK_EXPECT(GetDropTarget);
1567 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1569 CHECK_EXPECT(GetExternal);
1574 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1575 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1577 if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1578 todo_wine CHECK_EXPECT(TranslateUrl);
1580 CHECK_EXPECT(TranslateUrl);
1584 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1585 IDataObject **ppPORet)
1587 ok(0, "unexpected call\n");
1591 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1592 LPOLESTR *pchKey, DWORD dw)
1594 CHECK_EXPECT(GetOverridesKeyPath);
1595 ok(pchKey != NULL, "pchKey==NULL\n");
1597 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1598 ok(!dw, "dw=%x\n", dw);
1602 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1603 DocHostUIHandler_QueryInterface,
1604 DocHostUIHandler_AddRef,
1605 DocHostUIHandler_Release,
1606 DocHostUIHandler_ShowContextMenu,
1607 DocHostUIHandler_GetHostInfo,
1608 DocHostUIHandler_ShowUI,
1609 DocHostUIHandler_HideUI,
1610 DocHostUIHandler_UpdateUI,
1611 DocHostUIHandler_EnableModeless,
1612 DocHostUIHandler_OnDocWindowActivate,
1613 DocHostUIHandler_OnFrameWindowActivate,
1614 DocHostUIHandler_ResizeBorder,
1615 DocHostUIHandler_TranslateAccelerator,
1616 DocHostUIHandler_GetOptionKeyPath,
1617 DocHostUIHandler_GetDropTarget,
1618 DocHostUIHandler_GetExternal,
1619 DocHostUIHandler_TranslateUrl,
1620 DocHostUIHandler_FilterDataObject,
1621 DocHostUIHandler_GetOverrideKeyPath
1624 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1627 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1629 return QueryInterface(riid, ppv);
1632 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1637 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1642 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1643 REFGUID guidService, REFIID riid, void **ppv)
1647 if(!winetest_interactive)
1648 return E_NOINTERFACE;
1650 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1651 trace("Service SID_STopLevelBrowser\n");
1652 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1653 trace("Service SID_SEditCommandTarget\n");
1654 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1655 trace("Service IID_ITargetFrame2\n");
1656 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1657 trace("Service SID_SInternetSecurityManager\n");
1658 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1659 trace("Service SID_SOleUndoManager\n");
1660 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1661 trace("Service SID_IMimeInfo\n");
1662 else if (IsEqualGUID(&SID_STopWindow, guidService))
1663 trace("Service SID_STopWindow\n");
1665 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1666 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1667 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1668 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1669 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1670 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1671 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1672 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1673 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1674 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1675 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1678 trace("Service %s not supported\n", debugstr_guid(guidService));
1680 return E_NOINTERFACE;
1684 static const IServiceProviderVtbl ServiceProviderVtbl = {
1685 ServiceProvider_QueryInterface,
1686 ServiceProvider_AddRef,
1687 ServiceProvider_Release,
1688 ServiceProvider_QueryService
1691 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1694 static HRESULT QueryInterface(REFIID riid, void **ppv)
1698 if(IsEqualGUID(&IID_IUnknown, riid)
1699 || IsEqualGUID(&IID_IOleClientSite, riid))
1701 else if(IsEqualGUID(&IID_IOleWindow, riid)
1702 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1703 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1704 *ppv = &InPlaceSite;
1705 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1706 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1707 *ppv = use_container_dochostui ? &DocHostUIHandler : NULL;
1708 else if(IsEqualGUID(&IID_IDispatch, riid))
1710 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1711 *ppv = &ServiceProvider;
1712 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1713 trace("interface IID_IDocHostShowUI\n");
1714 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1715 *ppv = &ControlSite;
1716 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1717 trace("interface IID_IOleCommandTarget\n");
1719 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1723 /* are there more interfaces, that a host can support? */
1724 trace("%s: interface not supported\n", debugstr_guid(riid));
1727 return (*ppv) ? S_OK : E_NOINTERFACE;
1730 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1732 return DefWindowProcW(hwnd, msg, wParam, lParam);
1735 static HWND create_container_window(void)
1737 static const WCHAR wszWebBrowserContainer[] =
1738 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1739 static WNDCLASSEXW wndclass = {
1740 sizeof(WNDCLASSEXW),
1743 0, 0, NULL, NULL, NULL, NULL, NULL,
1744 wszWebBrowserContainer,
1748 RegisterClassExW(&wndclass);
1749 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1750 WS_OVERLAPPEDWINDOW, 10, 10, 600, 600, NULL, NULL, NULL, NULL);
1753 static void test_DoVerb(IWebBrowser2 *unk)
1756 RECT rect = {0,0,1000,1000};
1759 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1760 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1764 SET_EXPECT(CanInPlaceActivate);
1765 SET_EXPECT(Site_GetWindow);
1766 SET_EXPECT(OnInPlaceActivate);
1767 SET_EXPECT(GetWindowContext);
1768 SET_EXPECT(ShowObject);
1769 SET_EXPECT(GetContainer);
1770 SET_EXPECT(Frame_GetWindow);
1771 SET_EXPECT(OnUIActivate);
1772 SET_EXPECT(Frame_SetActiveObject);
1773 SET_EXPECT(UIWindow_SetActiveObject);
1774 SET_EXPECT(SetMenu);
1775 SET_EXPECT(OnFocus);
1777 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1778 0, (HWND)0xdeadbeef, &rect);
1779 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1781 CHECK_CALLED(CanInPlaceActivate);
1782 CHECK_CALLED(Site_GetWindow);
1783 CHECK_CALLED(OnInPlaceActivate);
1784 CHECK_CALLED(GetWindowContext);
1785 CHECK_CALLED(ShowObject);
1786 CHECK_CALLED(GetContainer);
1787 CHECK_CALLED(Frame_GetWindow);
1788 CHECK_CALLED(OnUIActivate);
1789 CHECK_CALLED(Frame_SetActiveObject);
1790 CHECK_CALLED(UIWindow_SetActiveObject);
1791 CHECK_CALLED(SetMenu);
1792 todo_wine CHECK_CALLED(OnFocus);
1794 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1795 0, (HWND)0xdeadbeef, &rect);
1796 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1798 IOleObject_Release(oleobj);
1801 static void call_DoVerb(IWebBrowser2 *unk, LONG verb)
1804 RECT rect = {60,60,600,600};
1807 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1808 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1812 hres = IOleObject_DoVerb(oleobj, verb, NULL, &ClientSite,
1813 -1, container_hwnd, &rect);
1814 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1816 IOleObject_Release(oleobj);
1819 static HWND get_hwnd(IWebBrowser2 *unk)
1821 IOleInPlaceObject *inplace;
1825 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1826 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1828 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1829 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1831 IOleInPlaceObject_Release(inplace);
1835 static void test_GetMiscStatus(IOleObject *oleobj)
1840 for(i=0; i<10; i++) {
1842 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1843 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1844 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1845 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1846 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1847 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1851 static void test_SetHostNames(IOleObject *oleobj)
1855 static const WCHAR test_appW[] = {'t','e','s','t',' ','a','p','p',0};
1857 hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1858 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1861 static void test_ClientSite(IWebBrowser2 *unk, IOleClientSite *client, BOOL stop_download)
1864 IOleInPlaceObject *inplace;
1868 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1869 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1873 test_GetMiscStatus(oleobj);
1874 test_SetHostNames(oleobj);
1876 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1877 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1879 IOleObject_Release(oleobj);
1883 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1884 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1885 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1888 SET_EXPECT(GetContainer);
1889 SET_EXPECT(Site_GetWindow);
1890 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1891 SET_EXPECT(Invoke_AMBIENT_SILENT);
1892 }else if(stop_download) {
1893 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1894 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1895 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1897 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
1898 SET_EXPECT(Invoke_PROGRESSCHANGE);
1901 hres = IOleObject_SetClientSite(oleobj, client);
1902 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1905 CHECK_CALLED(GetContainer);
1906 CHECK_CALLED(Site_GetWindow);
1907 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1908 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1909 }else if(stop_download) {
1910 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1911 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1912 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1914 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
1915 CLEAR_CALLED(Invoke_PROGRESSCHANGE);
1918 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1919 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1920 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1922 shell_embedding_hwnd = hwnd;
1924 test_SetHostNames(oleobj);
1926 IOleInPlaceObject_Release(inplace);
1927 IOleObject_Release(oleobj);
1930 static void test_ClassInfo(IWebBrowser2 *unk)
1932 IProvideClassInfo2 *class_info;
1933 TYPEATTR *type_attr;
1934 ITypeInfo *typeinfo;
1938 hres = IWebBrowser2_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1939 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
1943 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1944 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1945 ok(IsEqualGUID(wb_version > 1 ? &DIID_DWebBrowserEvents2 : &DIID_DWebBrowserEvents, &guid), "wrong guid\n");
1947 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1948 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1949 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1951 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1952 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1953 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1955 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1956 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1958 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1959 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1962 hres = IProvideClassInfo2_GetClassInfo(class_info, &typeinfo);
1963 ok(hres == S_OK, "GetClassInfo failed: %08x\n", hres);
1964 ok(typeinfo != NULL, "typeinfo == NULL\n");
1966 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
1967 ok(hres == S_OK, "GetTypeAtr failed: %08x\n", hres);
1969 ok(IsEqualGUID(&type_attr->guid, wb_version > 1 ? &CLSID_WebBrowser : &CLSID_WebBrowser_V1),
1970 "guid = %s\n", debugstr_guid(&type_attr->guid));
1972 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
1973 ITypeInfo_Release(typeinfo);
1975 IProvideClassInfo2_Release(class_info);
1978 static void test_EnumVerbs(IWebBrowser2 *wb)
1980 IEnumOLEVERB *enum_verbs;
1986 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oleobj);
1987 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
1989 hres = IOleObject_EnumVerbs(oleobj, &enum_verbs);
1990 IOleObject_Release(oleobj);
1991 ok(hres == S_OK, "EnumVerbs failed: %08x\n", hres);
1992 ok(enum_verbs != NULL, "enum_verbs == NULL\n");
1994 fetched = 0xdeadbeef;
1995 hres = IEnumOLEVERB_Next(enum_verbs, sizeof(verbs)/sizeof(*verbs), verbs, &fetched);
1996 ok(hres == S_OK, "Next failed: %08x\n", hres);
1997 ok(!fetched, "fetched = %d\n", fetched);
1999 fetched = 0xdeadbeef;
2000 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2001 ok(hres == S_OK, "Next failed: %08x\n", hres);
2002 ok(!fetched, "fetched = %d\n", fetched);
2004 hres = IEnumOLEVERB_Reset(enum_verbs);
2005 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2007 fetched = 0xdeadbeef;
2008 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2009 ok(hres == S_OK, "Next failed: %08x\n", hres);
2010 ok(!fetched, "fetched = %d\n", fetched);
2012 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, NULL);
2013 ok(hres == S_OK, "Next failed: %08x\n", hres);
2015 hres = IEnumOLEVERB_Skip(enum_verbs, 20);
2016 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2018 fetched = 0xdeadbeef;
2019 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2020 ok(hres == S_OK, "Next failed: %08x\n", hres);
2021 ok(!fetched, "fetched = %d\n", fetched);
2023 IEnumOLEVERB_Release(enum_verbs);
2026 static void test_ie_funcs(IWebBrowser2 *wb)
2038 hres = IWebBrowser2_get_HWND(wb, &hwnd);
2039 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
2040 ok(hwnd == 0, "unexpected hwnd %x\n", hwnd);
2044 hres = IWebBrowser2_get_MenuBar(wb, &b);
2045 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2046 ok(b == VARIANT_TRUE, "b=%x\n", b);
2048 SET_EXPECT(Invoke_ONMENUBAR);
2049 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
2050 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2051 CHECK_CALLED(Invoke_ONMENUBAR);
2053 hres = IWebBrowser2_get_MenuBar(wb, &b);
2054 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2055 ok(b == VARIANT_FALSE, "b=%x\n", b);
2057 SET_EXPECT(Invoke_ONMENUBAR);
2058 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
2059 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2060 CHECK_CALLED(Invoke_ONMENUBAR);
2062 hres = IWebBrowser2_get_MenuBar(wb, &b);
2063 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2064 ok(b == VARIANT_TRUE, "b=%x\n", b);
2068 hres = IWebBrowser2_get_AddressBar(wb, &b);
2069 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2070 ok(b == VARIANT_TRUE, "b=%x\n", b);
2072 SET_EXPECT(Invoke_ONADDRESSBAR);
2073 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
2074 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2075 CHECK_CALLED(Invoke_ONADDRESSBAR);
2077 hres = IWebBrowser2_get_AddressBar(wb, &b);
2078 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2079 ok(b == VARIANT_FALSE, "b=%x\n", b);
2081 SET_EXPECT(Invoke_ONADDRESSBAR);
2082 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
2083 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2084 CHECK_CALLED(Invoke_ONADDRESSBAR);
2086 hres = IWebBrowser2_get_AddressBar(wb, &b);
2087 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2088 ok(b == VARIANT_TRUE, "b=%x\n", b);
2090 SET_EXPECT(Invoke_ONADDRESSBAR);
2091 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
2092 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2093 CHECK_CALLED(Invoke_ONADDRESSBAR);
2097 hres = IWebBrowser2_get_StatusBar(wb, &b);
2098 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2099 ok(b == VARIANT_TRUE, "b=%x\n", b);
2101 SET_EXPECT(Invoke_ONSTATUSBAR);
2102 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
2103 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2104 CHECK_CALLED(Invoke_ONSTATUSBAR);
2106 hres = IWebBrowser2_get_StatusBar(wb, &b);
2107 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2108 ok(b == VARIANT_TRUE, "b=%x\n", b);
2110 SET_EXPECT(Invoke_ONSTATUSBAR);
2111 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
2112 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2113 CHECK_CALLED(Invoke_ONSTATUSBAR);
2115 hres = IWebBrowser2_get_StatusBar(wb, &b);
2116 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2117 ok(b == VARIANT_FALSE, "b=%x\n", b);
2119 SET_EXPECT(Invoke_ONSTATUSBAR);
2120 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
2121 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2122 CHECK_CALLED(Invoke_ONSTATUSBAR);
2124 hres = IWebBrowser2_get_StatusBar(wb, &b);
2125 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2126 ok(b == VARIANT_TRUE, "b=%x\n", b);
2130 hres = IWebBrowser2_get_ToolBar(wb, &i);
2131 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2134 SET_EXPECT(Invoke_ONTOOLBAR);
2135 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
2136 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2137 CHECK_CALLED(Invoke_ONTOOLBAR);
2139 hres = IWebBrowser2_get_ToolBar(wb, &i);
2140 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2141 ok(i == VARIANT_FALSE, "b=%x\n", i);
2143 SET_EXPECT(Invoke_ONTOOLBAR);
2144 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
2145 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2146 CHECK_CALLED(Invoke_ONTOOLBAR);
2148 hres = IWebBrowser2_get_ToolBar(wb, &i);
2149 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2152 SET_EXPECT(Invoke_ONTOOLBAR);
2153 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
2154 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2155 CHECK_CALLED(Invoke_ONTOOLBAR);
2159 hres = IWebBrowser2_get_FullScreen(wb, &b);
2160 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2161 ok(b == VARIANT_FALSE, "b=%x\n", b);
2163 SET_EXPECT(Invoke_ONFULLSCREEN);
2164 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
2165 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2166 CHECK_CALLED(Invoke_ONFULLSCREEN);
2168 hres = IWebBrowser2_get_FullScreen(wb, &b);
2169 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2170 ok(b == VARIANT_TRUE, "b=%x\n", b);
2172 SET_EXPECT(Invoke_ONFULLSCREEN);
2173 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
2174 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2175 CHECK_CALLED(Invoke_ONFULLSCREEN);
2177 hres = IWebBrowser2_get_FullScreen(wb, &b);
2178 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2179 ok(b == VARIANT_TRUE, "b=%x\n", b);
2181 SET_EXPECT(Invoke_ONFULLSCREEN);
2182 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
2183 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2184 CHECK_CALLED(Invoke_ONFULLSCREEN);
2188 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2189 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2190 ok(b == VARIANT_FALSE, "b=%x\n", b);
2192 SET_EXPECT(Invoke_ONTHEATERMODE);
2193 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
2194 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2195 CHECK_CALLED(Invoke_ONTHEATERMODE);
2197 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2198 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2199 ok(b == VARIANT_TRUE, "b=%x\n", b);
2201 SET_EXPECT(Invoke_ONTHEATERMODE);
2202 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
2203 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2204 CHECK_CALLED(Invoke_ONTHEATERMODE);
2206 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2207 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2208 ok(b == VARIANT_TRUE, "b=%x\n", b);
2210 SET_EXPECT(Invoke_ONTHEATERMODE);
2211 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
2212 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2213 CHECK_CALLED(Invoke_ONTHEATERMODE);
2218 hres = IWebBrowser2_get_Resizable(wb, &b);
2219 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2220 ok(b == 0x100, "b=%x\n", b);
2222 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2223 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
2224 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2225 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2227 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2228 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
2229 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2230 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2232 hres = IWebBrowser2_get_Resizable(wb, &b);
2233 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2234 ok(b == 0x100, "b=%x\n", b);
2239 hres = IWebBrowser2_get_Application(wb, &disp);
2240 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
2241 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
2243 IDispatch_Release(disp);
2245 hres = IWebBrowser2_get_Application(wb, NULL);
2246 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
2249 hres = IWebBrowser2_get_Name(wb, &sName);
2250 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
2251 if (is_lang_english())
2252 ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
2253 else /* Non-English cannot be blank. */
2254 ok(sName!=NULL, "get_Name return a NULL string.\n");
2255 SysFreeString(sName);
2259 hres = IWebBrowser2_Quit(wb);
2260 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
2263 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2269 hres = IWebBrowser2_get_Silent(wb, &b);
2270 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2271 ok(b == VARIANT_FALSE, "b=%x\n", b);
2273 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2274 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2277 hres = IWebBrowser2_get_Silent(wb, &b);
2278 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2279 ok(b == VARIANT_TRUE, "b=%x\n", b);
2281 hres = IWebBrowser2_put_Silent(wb, 100);
2282 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2285 hres = IWebBrowser2_get_Silent(wb, &b);
2286 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2287 ok(b == VARIANT_TRUE, "b=%x\n", b);
2289 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
2290 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2293 hres = IWebBrowser2_get_Silent(wb, &b);
2294 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2295 ok(b == VARIANT_FALSE, "b=%x\n", b);
2298 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2299 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2301 SET_EXPECT(Invoke_AMBIENT_SILENT);
2304 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2305 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2308 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2311 hres = IWebBrowser2_get_Silent(wb, &b);
2312 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2313 ok(b == VARIANT_FALSE, "b=%x\n", b);
2316 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2322 hres = IWebBrowser2_get_Offline(wb, &b);
2323 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2324 ok(b == VARIANT_FALSE, "b=%x\n", b);
2326 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2327 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2330 hres = IWebBrowser2_get_Offline(wb, &b);
2331 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2332 ok(b == VARIANT_TRUE, "b=%x\n", b);
2334 hres = IWebBrowser2_put_Offline(wb, 100);
2335 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2338 hres = IWebBrowser2_get_Offline(wb, &b);
2339 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2340 ok(b == VARIANT_TRUE, "b=%x\n", b);
2342 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
2343 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2346 hres = IWebBrowser2_get_Offline(wb, &b);
2347 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2348 ok(b == VARIANT_FALSE, "b=%x\n", b);
2351 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2352 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2354 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2357 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2358 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2361 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2364 hres = IWebBrowser2_get_Offline(wb, &b);
2365 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2366 ok(b == VARIANT_FALSE, "b=%x\n", b);
2369 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2373 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2374 SET_EXPECT(Invoke_AMBIENT_SILENT);
2375 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2376 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2377 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2378 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2380 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
2381 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2383 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2384 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
2385 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
2386 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
2387 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2388 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2390 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2391 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2392 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2393 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2394 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2395 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2398 static void test_wb_funcs(IWebBrowser2 *wb, BOOL is_clientsite)
2400 IOleControl *control;
2403 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleControl, (void**)&control);
2404 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2406 test_Silent(wb, control, is_clientsite);
2407 test_Offline(wb, control, is_clientsite);
2408 test_ambient_unknown(wb, control, is_clientsite);
2410 IOleControl_Release(control);
2413 static void test_GetControlInfo(IWebBrowser2 *unk)
2415 IOleControl *control;
2419 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2420 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2424 hres = IOleControl_GetControlInfo(control, &info);
2425 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2426 hres = IOleControl_GetControlInfo(control, NULL);
2427 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2429 IOleControl_Release(control);
2432 static void test_Extent(IWebBrowser2 *unk)
2435 SIZE size, expected;
2441 /* default aspect ratio is 96dpi / 96dpi */
2443 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2444 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2446 if (dpi_x != 96 || dpi_y != 96)
2447 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2449 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2450 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2454 size.cx = size.cy = 0xdeadbeef;
2455 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2456 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2457 /* Default size is 50x20 pixels, in himetric units */
2458 expected.cx = MulDiv( 50, 2540, dpi_x );
2459 expected.cy = MulDiv( 20, 2540, dpi_y );
2460 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2461 size.cx, size.cy, expected.cx, expected.cy );
2465 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2466 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2468 size.cx = size.cy = 0xdeadbeef;
2469 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2470 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2471 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2473 size.cx = size.cy = 0xdeadbeef;
2474 hres = IOleObject_GetExtent(oleobj, 0, &size);
2475 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2476 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2480 hres = IOleObject_SetExtent(oleobj, 0, &size);
2481 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2483 size.cx = size.cy = 0xdeadbeef;
2484 hres = IOleObject_GetExtent(oleobj, 0, &size);
2485 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2486 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2488 size.cx = size.cy = 0xdeadbeef;
2489 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2490 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2491 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2495 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2496 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2498 size.cx = size.cy = 0xdeadbeef;
2499 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2500 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2501 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2503 size.cx = size.cy = 0xdeadbeef;
2504 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2505 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2506 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2508 IOleObject_Release(oleobj);
2511 static void test_ConnectionPoint(IWebBrowser2 *unk, BOOL init)
2513 IConnectionPointContainer *container;
2514 IConnectionPoint *point;
2517 static DWORD dw = 100;
2519 hres = IWebBrowser2_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2520 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2524 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2525 IConnectionPointContainer_Release(container);
2526 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2531 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2532 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2533 ok(dw == 1, "dw=%d, expected 1\n", dw);
2535 hres = IConnectionPoint_Unadvise(point, dw);
2536 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2539 IConnectionPoint_Release(point);
2542 static void test_Navigate2(IWebBrowser2 *webbrowser, const char *nav_url)
2548 test_LocationURL(webbrowser, is_first_load ? "" : current_url);
2549 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2551 is_http = !memcmp(nav_url, "http:", 5);
2552 V_VT(&url) = VT_BSTR;
2553 V_BSTR(&url) = a2bstr(current_url = nav_url);
2555 if((is_file = !strncasecmp(nav_url, "file://", 7)))
2556 current_url = nav_url + 7;
2559 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2560 SET_EXPECT(Invoke_PROPERTYCHANGE);
2561 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2562 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2563 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2564 SET_EXPECT(EnableModeless_FALSE);
2565 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2566 SET_EXPECT(SetStatusText);
2567 if(use_container_dochostui)
2568 SET_EXPECT(GetHostInfo);
2569 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2570 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2571 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2572 if(use_container_dochostui) {
2573 SET_EXPECT(GetOptionKeyPath);
2574 SET_EXPECT(GetOverridesKeyPath);
2576 if (use_container_olecmd) SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2577 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSMAX);
2578 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSPOS);
2579 SET_EXPECT(Invoke_SETSECURELOCKICON);
2580 SET_EXPECT(Invoke_FILEDOWNLOAD);
2581 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2582 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2583 SET_EXPECT(EnableModeless_TRUE);
2584 if (!use_container_olecmd) SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2585 if (is_file) SET_EXPECT(Invoke_PROGRESSCHANGE);
2588 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2589 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2592 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2593 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2594 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2595 todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2596 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2597 CHECK_CALLED(EnableModeless_FALSE);
2598 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2599 CHECK_CALLED(SetStatusText);
2600 if(use_container_dochostui)
2601 CHECK_CALLED(GetHostInfo);
2602 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2603 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2604 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* Not called by IE9 */
2605 if(use_container_dochostui) {
2606 CLEAR_CALLED(GetOptionKeyPath);
2607 CHECK_CALLED(GetOverridesKeyPath);
2609 if (use_container_olecmd) todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2610 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2611 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2612 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2613 todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
2614 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2615 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2616 CHECK_CALLED(EnableModeless_TRUE);
2617 if (is_file) todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2622 test_ready_state(READYSTATE_LOADING);
2625 static void test_QueryStatusWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2627 HRESULT hres, success_state;
2628 OLECMDF success_flags;
2629 enum OLECMDF status;
2632 * We can tell the difference between the custom container target and the built-in target
2633 * since the custom target returns OLECMDF_SUPPORTED instead of OLECMDF_ENABLED.
2635 if (use_custom_target)
2636 success_flags = OLECMDF_SUPPORTED;
2638 success_flags = OLECMDF_ENABLED;
2640 /* When no target is available (no document or custom target) an error is returned */
2642 success_state = S_OK;
2644 success_state = E_UNEXPECTED;
2647 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2648 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2649 * is enabled and IDM_STOP is not.
2651 status = 0xdeadbeef;
2652 if (use_custom_target) SET_EXPECT(QueryStatus_STOP);
2653 hres = IWebBrowser2_QueryStatusWB(webbrowser, OLECMDID_STOP, &status);
2654 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2655 if (!use_custom_target && has_document)
2656 todo_wine ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2657 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2659 ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2660 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2661 status = 0xdeadbeef;
2662 if (use_custom_target) SET_EXPECT(QueryStatus_IDM_STOP);
2663 hres = IWebBrowser2_QueryStatusWB(webbrowser, IDM_STOP, &status);
2664 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2665 ok((has_document && status == 0) || (!has_document && status == 0xdeadbeef),
2666 "IDM_STOP is enabled/supported: %08x %d\n", status, has_document);
2669 static void test_ExecWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2671 HRESULT hres, olecmdid_state, idm_state;
2673 /* When no target is available (no document or custom target) an error is returned */
2676 olecmdid_state = S_OK;
2677 idm_state = OLECMDERR_E_NOTSUPPORTED;
2681 olecmdid_state = E_UNEXPECTED;
2682 idm_state = E_UNEXPECTED;
2686 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2687 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2688 * succeeds (S_OK) and IDM_STOP does not (OLECMDERR_E_NOTSUPPORTED).
2690 if(use_custom_target) {
2691 SET_EXPECT(Exec_STOP);
2692 }else if(has_document) {
2693 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2694 SET_EXPECT(SetStatusText);
2696 hres = IWebBrowser2_ExecWB(webbrowser, OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2697 if(!use_custom_target && has_document) {
2698 todo_wine ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2699 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2700 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
2702 ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2704 if (use_custom_target)
2705 SET_EXPECT(Exec_IDM_STOP);
2706 hres = IWebBrowser2_ExecWB(webbrowser, IDM_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2707 ok(hres == idm_state, "ExecWB failed: %08x %08x\n", hres, idm_state);
2710 static void test_download(DWORD flags)
2712 BOOL *b = (flags & DWL_REFRESH) ? &called_Exec_SETDOWNLOADSTATE_0 : &called_Invoke_DOCUMENTCOMPLETE;
2715 is_downloading = TRUE;
2718 test_ready_state((flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK|DWL_REFRESH)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2720 if((is_http && !(flags & (DWL_FROM_GOBACK|DWL_REFRESH))) || (flags & DWL_EXPECT_BEFORE_NAVIGATE))
2721 SET_EXPECT(Invoke_PROPERTYCHANGE);
2723 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2724 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2725 SET_EXPECT(TranslateUrl);
2727 SET_EXPECT(Exec_SETPROGRESSMAX);
2728 SET_EXPECT(Exec_SETPROGRESSPOS);
2729 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2730 SET_EXPECT(DocHost_EnableModeless_FALSE);
2731 SET_EXPECT(DocHost_EnableModeless_TRUE);
2732 SET_EXPECT(Invoke_SETSECURELOCKICON);
2733 SET_EXPECT(Invoke_282);
2734 SET_EXPECT(EnableModeless_FALSE);
2735 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2736 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2737 SET_EXPECT(SetStatusText);
2738 SET_EXPECT(EnableModeless_TRUE);
2740 SET_EXPECT(GetHostInfo);
2741 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2742 SET_EXPECT(Invoke_TITLECHANGE);
2743 if(!(flags & DWL_REFRESH))
2744 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2746 SET_EXPECT(GetDropTarget);
2747 SET_EXPECT(Invoke_PROGRESSCHANGE);
2748 if(!(flags & DWL_REFRESH))
2749 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2751 if(flags & DWL_HTTP)
2752 SET_EXPECT(Exec_SETTITLE);
2753 SET_EXPECT(UpdateUI);
2754 SET_EXPECT(Exec_UPDATECOMMANDS);
2755 SET_EXPECT(QueryStatus_STOP);
2757 while(!*b && GetMessage(&msg, NULL, 0, 0)) {
2758 TranslateMessage(&msg);
2759 DispatchMessage(&msg);
2762 if((is_http && !(flags & (DWL_FROM_GOBACK|DWL_REFRESH))) || (flags & DWL_EXPECT_BEFORE_NAVIGATE))
2763 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2765 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2766 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2767 CHECK_CALLED(TranslateUrl);
2769 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2770 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2771 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2772 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
2773 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
2774 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2775 CLEAR_CALLED(Invoke_282); /* IE 7 */
2777 todo_wine CHECK_CALLED(EnableModeless_FALSE);
2779 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2780 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE);
2781 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2782 todo_wine CHECK_CALLED(SetStatusText);
2784 todo_wine CHECK_CALLED(EnableModeless_TRUE);
2786 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2788 todo_wine CHECK_CALLED(GetHostInfo);
2789 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2790 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
2791 if(!(flags & DWL_REFRESH))
2792 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
2794 todo_wine CHECK_CALLED(GetDropTarget);
2795 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2796 if(!(flags & DWL_REFRESH))
2797 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
2799 is_downloading = FALSE;
2801 test_ready_state(READYSTATE_COMPLETE);
2803 while(!called_Exec_UPDATECOMMANDS && GetMessage(&msg, NULL, 0, 0)) {
2804 TranslateMessage(&msg);
2805 DispatchMessage(&msg);
2808 if(flags & DWL_HTTP)
2809 CLEAR_CALLED(Exec_SETTITLE); /* FIXME: make it more strict */
2810 CHECK_CALLED(UpdateUI);
2811 CHECK_CALLED(Exec_UPDATECOMMANDS);
2812 CLEAR_CALLED(QueryStatus_STOP);
2815 static void test_Refresh(IWebBrowser2 *webbrowser)
2819 trace("Refresh...\n");
2821 SET_EXPECT(Exec_DocHostCommandHandler_2300);
2822 hres = IWebBrowser2_Refresh(webbrowser);
2823 ok(hres == S_OK, "Refresh failed: %08x\n", hres);
2824 CHECK_CALLED(Exec_DocHostCommandHandler_2300);
2826 test_download(DWL_REFRESH);
2829 static void test_olecmd(IWebBrowser2 *unk, BOOL loaded)
2831 IOleCommandTarget *cmdtrg;
2835 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2836 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
2840 cmds[0].cmdID = OLECMDID_SPELL;
2841 cmds[0].cmdf = 0xdeadbeef;
2842 cmds[1].cmdID = OLECMDID_REFRESH;
2843 cmds[1].cmdf = 0xdeadbeef;
2844 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
2846 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2847 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2848 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
2849 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
2851 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
2852 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2853 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
2856 IOleCommandTarget_Release(cmdtrg);
2859 static void test_IServiceProvider(IWebBrowser2 *unk)
2861 IServiceProvider *servprov = (void*)0xdeadbeef;
2865 hres = IWebBrowser2_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
2866 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
2870 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&iface);
2871 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
2872 ok(!iface, "QueryService returned %p, expected NULL\n", iface);
2874 IUnknown_Release(iface);
2876 hres = IServiceProvider_QueryService(servprov, &SID_SHTMLWindow, &IID_IHTMLWindow2, (LPVOID*)&iface);
2877 ok(hres == S_OK, "QueryService returned %08x, expected S_OK\n", hres);
2878 ok(iface != NULL, "QueryService returned NULL\n");
2880 IUnknown_Release(iface);
2882 IServiceProvider_Release(servprov);
2885 static void test_put_href(IWebBrowser2 *unk, const char *url)
2887 IHTMLLocation *location;
2888 IHTMLDocument2 *doc;
2889 IDispatch *doc_disp;
2893 doc_disp = get_document(unk);
2895 hres = IDispatch_QueryInterface(doc_disp, &IID_IHTMLDocument2, (void**)&doc);
2896 IDispatch_Release(doc_disp);
2897 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2 failed: %08x\n", hres);
2900 hres = IHTMLDocument2_get_location(doc, &location);
2901 IHTMLDocument2_Release(doc);
2902 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2903 ok(location != NULL, "location == NULL\n");
2905 SET_EXPECT(TranslateUrl);
2906 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2908 SET_EXPECT(Invoke_PROPERTYCHANGE);
2910 dwl_flags = DWL_FROM_PUT_HREF;
2912 is_http = !memcmp(url, "http:", 5);
2913 str = a2bstr(current_url = url);
2914 is_first_load = FALSE;
2915 hres = IHTMLLocation_put_href(location, str);
2917 CHECK_CALLED(TranslateUrl);
2918 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2920 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2922 IHTMLLocation_Release(location);
2924 ok(hres == S_OK, "put_href failed: %08x\n", hres);
2926 test_ready_state(READYSTATE_COMPLETE);
2929 static void test_go_back(IWebBrowser2 *wb, const char *back_url)
2933 current_url = back_url;
2935 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2936 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2937 hres = IWebBrowser2_GoBack(wb);
2938 ok(hres == S_OK, "GoBack failed: %08x\n", hres);
2939 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2940 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2943 static void test_QueryInterface(IWebBrowser2 *wb)
2945 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
2946 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
2947 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
2948 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
2949 IOleCache *cache = (void*)0xdeadbeef;
2950 IObjectWithSite *site = (void*)0xdeadbeef;
2951 IViewObjectEx *viewex = (void*)0xdeadbeef;
2952 IOleLink *link = (void*)0xdeadbeef;
2953 IMarshal *marshal = (void*)0xdeadbeef;
2954 IStdMarshalInfo *marshalinfo = (void*)0xdeadbeef;
2955 IUnknown *unk = (IUnknown*)wb;
2958 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
2959 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2960 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
2962 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
2963 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2964 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
2966 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
2967 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2968 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
2970 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
2971 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2972 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
2974 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
2975 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2976 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
2978 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2979 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2980 ok(site == NULL, "site=%p, expected NULL\n", site);
2982 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
2983 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2984 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
2986 hres = IUnknown_QueryInterface(unk, &IID_IOleLink, (void**)&link);
2987 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2988 ok(link == NULL, "link=%p, expected NULL\n", link);
2990 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&marshal);
2991 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2992 ok(marshal == NULL, "marshal=%p, expected NULL\n", marshal);
2994 hres = IUnknown_QueryInterface(unk, &IID_IStdMarshalInfo, (void**)&marshalinfo);
2995 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2996 ok(marshalinfo == NULL, "marshalinfo=%p, expected NULL\n", marshalinfo);
3000 static void test_UIActivate(IWebBrowser2 *unk, BOOL activate)
3002 IOleDocumentView *docview;
3006 disp = get_document(unk);
3008 hres = IDispatch_QueryInterface(disp, &IID_IOleDocumentView, (void**)&docview);
3009 ok(hres == S_OK, "Got 0x%08x\n", hres);
3010 if(SUCCEEDED(hres)) {
3012 SET_EXPECT(RequestUIActivate);
3015 SET_EXPECT(OnFocus);
3018 hres = IOleDocumentView_UIActivate(docview, activate);
3020 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
3022 ok(hres == S_OK, "Got 0x%08x\n", hres);
3026 CHECK_CALLED(RequestUIActivate);
3027 CHECK_CALLED(ShowUI);
3028 CHECK_CALLED(HideUI);
3029 CHECK_CALLED(OnFocus);
3033 IOleDocumentView_Release(docview);
3036 IDispatch_Release(disp);
3039 static void test_external(IWebBrowser2 *unk)
3041 IDocHostUIHandler2 *dochost;
3042 IOleClientSite *client;
3046 client = get_dochost(unk);
3048 hres = IOleClientSite_QueryInterface(client, &IID_IDocHostUIHandler2, (void**)&dochost);
3049 ok(hres == S_OK, "Could not get IDocHostUIHandler2 iface: %08x\n", hres);
3050 IOleClientSite_Release(client);
3052 if(use_container_dochostui)
3053 SET_EXPECT(GetExternal);
3054 disp = (void*)0xdeadbeef;
3055 hres = IDocHostUIHandler2_GetExternal(dochost, &disp);
3056 if(use_container_dochostui) {
3057 CHECK_CALLED(GetExternal);
3058 ok(hres == S_FALSE, "GetExternal failed: %08x\n", hres);
3059 ok(!disp, "disp = %p\n", disp);
3061 IShellUIHelper *uihelper;
3063 ok(hres == S_OK, "GetExternal failed: %08x\n", hres);
3064 ok(disp != NULL, "disp == NULL\n");
3066 hres = IDispatch_QueryInterface(disp, &IID_IShellUIHelper, (void**)&uihelper);
3067 ok(hres == S_OK, "Could not get IShellUIHelper iface: %08x\n", hres);
3068 IShellUIHelper_Release(uihelper);
3071 IDocHostUIHandler2_Release(dochost);
3074 static void test_TranslateAccelerator(IWebBrowser2 *unk)
3076 IOleClientSite *doc_clientsite;
3077 IOleInPlaceActiveObject *pao;
3087 test_Navigate2(unk, "about:blank");
3089 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3090 ok(hres == S_OK, "Got 0x%08x\n", hres);
3091 if(SUCCEEDED(hres)) {
3092 /* One accelerator that should be handled by mshtml */
3093 msg_a.message = WM_KEYDOWN;
3094 msg_a.wParam = VK_F1;
3095 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3096 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3098 /* And one that should not */
3099 msg_a.message = WM_KEYDOWN;
3100 msg_a.wParam = VK_F5;
3101 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3102 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3104 IOleInPlaceActiveObject_Release(pao);
3107 test_UIActivate(unk, TRUE);
3109 /* Test again after UIActivate */
3110 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3111 ok(hres == S_OK, "Got 0x%08x\n", hres);
3112 if(SUCCEEDED(hres)) {
3113 /* One accelerator that should be handled by mshtml */
3114 msg_a.message = WM_KEYDOWN;
3115 msg_a.wParam = VK_F1;
3116 SET_EXPECT(DocHost_TranslateAccelerator);
3117 SET_EXPECT(ControlSite_TranslateAccelerator);
3118 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3119 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3120 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3121 todo_wine CHECK_CALLED(ControlSite_TranslateAccelerator);
3123 /* And one that should not */
3124 msg_a.message = WM_KEYDOWN;
3125 msg_a.wParam = VK_F5;
3126 SET_EXPECT(DocHost_TranslateAccelerator);
3127 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3128 todo_wine ok(hres == S_OK, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3129 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3131 IOleInPlaceActiveObject_Release(pao);
3134 doc_clientsite = get_dochost(unk);
3135 if(doc_clientsite) {
3136 IDocHostUIHandler2 *dochost;
3137 IOleControlSite *doc_controlsite;
3140 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleInPlaceFrame, (void**)&unk_test);
3141 ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
3142 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3144 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostShowUI, (void**)&unk_test);
3145 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
3146 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3148 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler, (void**)&unk_test);
3149 ok(hres == S_OK, "Got 0x%08x\n", hres);
3150 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3152 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler2, (void**)&dochost);
3153 ok(hres == S_OK, "Got 0x%08x\n", hres);
3154 if(SUCCEEDED(hres)) {
3155 msg_a.message = WM_KEYDOWN;
3156 hr_dochost_TranslateAccelerator = 0xdeadbeef;
3157 for(keycode = 0; keycode <= 0x100; keycode++) {
3158 msg_a.wParam = keycode;
3159 SET_EXPECT(DocHost_TranslateAccelerator);
3160 hres = IDocHostUIHandler2_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3161 ok(hres == 0xdeadbeef, "Got 0x%08x\n", hres);
3162 CHECK_CALLED(DocHost_TranslateAccelerator);
3164 hr_dochost_TranslateAccelerator = E_NOTIMPL;
3166 SET_EXPECT(DocHost_TranslateAccelerator);
3167 hres = IDocHostUIHandler2_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3168 ok(hres == E_NOTIMPL, "Got 0x%08x\n", hres);
3169 CHECK_CALLED(DocHost_TranslateAccelerator);
3171 IDocHostUIHandler2_Release(dochost);
3174 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleControlSite, (void**)&doc_controlsite);
3175 ok(hres == S_OK, "Got 0x%08x\n", hres);
3176 if(SUCCEEDED(hres)) {
3177 msg_a.message = WM_KEYDOWN;
3178 hr_site_TranslateAccelerator = 0xdeadbeef;
3179 for(keycode = 0; keycode < 0x100; keycode++) {
3180 msg_a.wParam = keycode;
3181 SET_EXPECT(ControlSite_TranslateAccelerator);
3182 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3183 if(keycode == 0x9 || keycode == 0x75)
3184 todo_wine ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3186 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3188 CHECK_CALLED(ControlSite_TranslateAccelerator);
3190 msg_a.wParam = VK_LEFT;
3191 SET_EXPECT(ControlSite_TranslateAccelerator);
3192 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3193 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3194 CHECK_CALLED(ControlSite_TranslateAccelerator);
3196 hr_site_TranslateAccelerator = S_OK;
3197 SET_EXPECT(ControlSite_TranslateAccelerator);
3198 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3199 ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3200 CHECK_CALLED(ControlSite_TranslateAccelerator);
3202 hr_site_TranslateAccelerator = E_NOTIMPL;
3203 SET_EXPECT(ControlSite_TranslateAccelerator);
3204 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3205 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3206 CHECK_CALLED(ControlSite_TranslateAccelerator);
3208 IOleControlSite_Release(doc_controlsite);
3211 IOleClientSite_Release(doc_clientsite);
3214 test_UIActivate(unk, FALSE);
3217 static void test_dochost_qs(IWebBrowser2 *webbrowser)
3219 IOleClientSite *client_site;
3220 IServiceProvider *serv_prov;
3224 client_site = get_dochost(webbrowser);
3225 hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
3226 IOleClientSite_Release(client_site);
3227 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
3229 hres = IServiceProvider_QueryService(serv_prov, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&service);
3230 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3231 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3232 IUnknown_Release(service);
3234 hres = IServiceProvider_QueryService(serv_prov, &IID_IWebBrowserApp, &IID_IHlinkFrame, (void**)&service);
3235 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3236 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3237 IUnknown_Release(service);
3239 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IShellBrowser, (void**)&service);
3240 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3241 IUnknown_Release(service);
3243 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IBrowserService, (void**)&service);
3244 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3245 IUnknown_Release(service);
3247 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IDocObjectService, (void**)&service);
3248 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3249 IUnknown_Release(service);
3251 IServiceProvider_Release(serv_prov);
3254 static void test_Close(IWebBrowser2 *wb, BOOL do_download)
3257 IOleClientSite *ocs;
3260 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oo);
3261 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3267 SET_EXPECT(Frame_SetActiveObject);
3268 SET_EXPECT(UIWindow_SetActiveObject);
3269 SET_EXPECT(OnUIDeactivate);
3270 SET_EXPECT(OnFocus);
3271 SET_EXPECT(OnInPlaceDeactivate);
3272 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
3274 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
3275 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3277 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3278 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3279 CHECK_CALLED(Frame_SetActiveObject);
3280 CHECK_CALLED(UIWindow_SetActiveObject);
3281 CHECK_CALLED(OnUIDeactivate);
3282 todo_wine CHECK_CALLED(OnFocus);
3283 CHECK_CALLED(OnInPlaceDeactivate);
3284 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
3286 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
3287 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3290 hres = IOleObject_GetClientSite(oo, &ocs);
3291 ok(hres == S_OK, "hres = %x\n", hres);
3292 ok(!ocs, "ocs != NULL\n");
3294 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3295 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3298 IOleObject_Release(oo);
3301 #define TEST_DOWNLOAD 0x0001
3302 #define TEST_NOOLECMD 0x0002
3303 #define TEST_NODOCHOST 0x0004
3305 static void init_test(IWebBrowser2 *webbrowser, DWORD flags)
3309 is_downloading = (flags & TEST_DOWNLOAD) != 0;
3310 is_first_load = TRUE;
3311 use_container_olecmd = !(flags & TEST_NOOLECMD);
3312 use_container_dochostui = !(flags & TEST_NODOCHOST);
3315 static void test_WebBrowser(BOOL do_download, BOOL do_close)
3317 IWebBrowser2 *webbrowser;
3320 webbrowser = create_webbrowser();
3324 init_test(webbrowser, do_download ? TEST_DOWNLOAD : 0);
3326 test_QueryStatusWB(webbrowser, FALSE, FALSE);
3327 test_ExecWB(webbrowser, FALSE, FALSE);
3328 test_QueryInterface(webbrowser);
3329 test_ready_state(READYSTATE_UNINITIALIZED);
3330 test_ClassInfo(webbrowser);
3331 test_EnumVerbs(webbrowser);
3332 test_LocationURL(webbrowser, "");
3333 test_ConnectionPoint(webbrowser, TRUE);
3334 test_ClientSite(webbrowser, &ClientSite, !do_download);
3335 test_Extent(webbrowser);
3336 test_wb_funcs(webbrowser, TRUE);
3337 test_DoVerb(webbrowser);
3338 test_olecmd(webbrowser, FALSE);
3339 test_Navigate2(webbrowser, "about:blank");
3340 test_QueryStatusWB(webbrowser, TRUE, TRUE);
3341 test_ExecWB(webbrowser, TRUE, TRUE);
3344 IDispatch *doc, *doc2;
3347 test_olecmd(webbrowser, TRUE);
3348 doc = get_document(webbrowser);
3350 test_put_href(webbrowser, "about:test");
3351 test_download(DWL_FROM_PUT_HREF);
3352 doc2 = get_document(webbrowser);
3353 ok(doc == doc2, "doc != doc2\n");
3354 IDispatch_Release(doc2);
3356 trace("Navigate2 repeated...\n");
3357 test_Navigate2(webbrowser, "about:blank");
3358 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3359 doc2 = get_document(webbrowser);
3360 ok(doc == doc2, "doc != doc2\n");
3361 IDispatch_Release(doc2);
3362 IDispatch_Release(doc);
3365 trace("Navigate2 http URL...\n");
3366 test_ready_state(READYSTATE_COMPLETE);
3367 test_Navigate2(webbrowser, "http://test.winehq.org/tests/hello.html");
3368 test_download(DWL_EXPECT_BEFORE_NAVIGATE|DWL_HTTP);
3370 test_Refresh(webbrowser);
3372 trace("put_href http URL...\n");
3373 test_put_href(webbrowser, "http://www.winehq.org/");
3374 test_download(DWL_FROM_PUT_HREF|DWL_HTTP);
3376 trace("GoBack...\n");
3377 test_go_back(webbrowser, "http://test.winehq.org/tests/hello.html");
3378 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3381 test_EnumVerbs(webbrowser);
3382 test_TranslateAccelerator(webbrowser);
3384 test_dochost_qs(webbrowser);
3387 test_external(webbrowser);
3390 test_Close(webbrowser, do_download);
3392 test_ClientSite(webbrowser, NULL, !do_download);
3393 test_ie_funcs(webbrowser);
3394 test_GetControlInfo(webbrowser);
3395 test_wb_funcs(webbrowser, FALSE);
3396 test_ConnectionPoint(webbrowser, FALSE);
3397 test_IServiceProvider(webbrowser);
3399 ref = IWebBrowser2_Release(webbrowser);
3400 ok(ref == 0 || broken(do_download && !do_close && ref == 1), "ref=%d, expected 0\n", ref);
3403 static void test_WebBrowserV1(void)
3409 hres = CoCreateInstance(&CLSID_WebBrowser_V1, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3410 &IID_IWebBrowser2, (void**)&wb);
3411 ok(hres == S_OK, "Could not get WebBrowserV1 instance: %08x\n", hres);
3416 test_QueryStatusWB(wb, FALSE, FALSE);
3417 test_ExecWB(wb, FALSE, FALSE);
3418 test_QueryInterface(wb);
3419 test_ready_state(READYSTATE_UNINITIALIZED);
3423 ref = IWebBrowser2_Release(wb);
3424 ok(ref == 0, "ref=%d, expected 0\n", ref);
3427 static void test_WebBrowser_slim_container(void)
3429 IWebBrowser2 *webbrowser;
3432 webbrowser = create_webbrowser();
3433 init_test(webbrowser, TEST_NOOLECMD|TEST_NODOCHOST);
3435 test_ConnectionPoint(webbrowser, TRUE);
3436 test_ClientSite(webbrowser, &ClientSite, TRUE);
3437 test_DoVerb(webbrowser);
3438 test_Navigate2(webbrowser, "about:blank");
3440 /* Tests of interest */
3441 test_QueryStatusWB(webbrowser, FALSE, TRUE);
3442 test_ExecWB(webbrowser, FALSE, TRUE);
3443 test_external(webbrowser);
3446 test_ClientSite(webbrowser, NULL, TRUE);
3447 test_ConnectionPoint(webbrowser, FALSE);
3449 ref = IWebBrowser2_Release(webbrowser);
3450 ok(ref == 0, "ref=%d, expected 0\n", ref);
3453 static void test_WebBrowser_DoVerb(void)
3455 IWebBrowser2 *webbrowser;
3461 webbrowser = create_webbrowser();
3462 init_test(webbrowser, 0);
3464 test_ClientSite(webbrowser, &ClientSite, FALSE);
3466 SET_EXPECT(CanInPlaceActivate);
3467 SET_EXPECT(Site_GetWindow);
3468 SET_EXPECT(OnInPlaceActivate);
3469 SET_EXPECT(GetWindowContext);
3470 SET_EXPECT(ShowObject);
3471 SET_EXPECT(GetContainer);
3472 SET_EXPECT(Frame_GetWindow);
3473 call_DoVerb(webbrowser, OLEIVERB_INPLACEACTIVATE);
3474 CHECK_CALLED(CanInPlaceActivate);
3475 CHECK_CALLED(Site_GetWindow);
3476 CHECK_CALLED(OnInPlaceActivate);
3477 CHECK_CALLED(GetWindowContext);
3478 CHECK_CALLED(ShowObject);
3479 CHECK_CALLED(GetContainer);
3480 CHECK_CALLED(Frame_GetWindow);
3482 hwnd = get_hwnd(webbrowser);
3484 memset(&rect, 0xa, sizeof(rect));
3485 res = GetWindowRect(hwnd, &rect);
3486 ok(res, "GetWindowRect failed: %u\n", GetLastError());
3488 SET_EXPECT(OnInPlaceDeactivate);
3489 call_DoVerb(webbrowser, OLEIVERB_HIDE);
3490 CHECK_CALLED(OnInPlaceDeactivate);
3492 test_ClientSite(webbrowser, NULL, FALSE);
3494 ref = IWebBrowser2_Release(webbrowser);
3495 ok(ref == 0, "ref=%d, expected 0\n", ref);
3499 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
3500 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
3501 static BOOL is_ie_hardened(void)
3504 DWORD ie_harden, type, size;
3507 if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
3508 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
3509 size = sizeof(DWORD);
3510 if (RegQueryValueEx(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
3511 type != REG_DWORD) {
3514 RegCloseKey(zone_map);
3517 return ie_harden != 0;
3520 static void test_FileProtocol(void)
3522 IWebBrowser2 *webbrowser;
3525 char file_path[MAX_PATH];
3526 char file_url[MAX_PATH] = "File://";
3528 static const char test_file[] = "wine_test.html";
3530 GetTempPathA(MAX_PATH, file_path);
3531 strcat(file_path, test_file);
3532 GetLongPathNameA(file_path, file_path, sizeof(file_path));
3533 strcat(file_url, file_path);
3535 webbrowser = create_webbrowser();
3539 init_test(webbrowser, 0);
3541 file = CreateFileA(file_path, GENERIC_WRITE, 0, NULL,
3542 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
3543 if(file == INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_EXISTS){
3544 ok(0, "CreateFile failed\n");
3549 test_ConnectionPoint(webbrowser, TRUE);
3550 test_ClientSite(webbrowser, &ClientSite, TRUE);
3551 test_DoVerb(webbrowser);
3552 test_Navigate2(webbrowser, file_url);
3553 test_ClientSite(webbrowser, NULL, TRUE);
3555 ref = IWebBrowser2_Release(webbrowser);
3556 ok(ref == 0, "ref=%u, expected 0\n", ref);
3558 if(file != INVALID_HANDLE_VALUE)
3559 DeleteFileA(file_path);
3562 START_TEST(webbrowser)
3564 OleInitialize(NULL);
3566 container_hwnd = create_container_window();
3568 trace("Testing WebBrowser (no download)...\n");
3569 test_WebBrowser(FALSE, FALSE);
3570 test_WebBrowser(FALSE, TRUE);
3572 if(!is_ie_hardened()) {
3573 trace("Testing WebBrowser...\n");
3574 test_WebBrowser(TRUE, FALSE);
3576 win_skip("Skipping http tests in hardened mode\n");
3579 trace("Testing WebBrowser DoVerb\n");
3580 test_WebBrowser_DoVerb();
3581 trace("Testing WebBrowser (with close)...\n");
3582 test_WebBrowser(TRUE, TRUE);
3583 trace("Testing WebBrowser w/o container-based olecmd...\n");
3584 test_WebBrowser_slim_container();
3585 trace("Testing WebBrowserV1...\n");
3586 test_WebBrowserV1();
3587 test_FileProtocol();