ieframe: Added GetExternal tests.
[wine.git] / dlls / ieframe / tests / webbrowser.c
blob12d2bba654421dc1636bc2776da23bd5cf7ef86e
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "exdisp.h"
31 #include "htiframe.h"
32 #include "mshtmhst.h"
33 #include "mshtmcid.h"
34 #include "mshtml.h"
35 #include "idispids.h"
36 #include "olectl.h"
37 #include "mshtmdid.h"
38 #include "shobjidl.h"
39 #include "shdeprecated.h"
40 #include "shlguid.h"
41 #include "exdispid.h"
42 #include "mimeinfo.h"
43 #include "hlink.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) \
56 do { \
57 ok(expect_ ##func, "unexpected call " #func "\n"); \
58 called_ ## func = TRUE; \
59 }while(0)
61 #define CHECK_EXPECT(func) \
62 do { \
63 CHECK_EXPECT2(func); \
64 expect_ ## func = FALSE; \
65 }while(0)
67 #define CHECK_CALLED(func) \
68 do { \
69 ok(called_ ## func, "expected " #func "\n"); \
70 expect_ ## func = called_ ## func = FALSE; \
71 }while(0)
73 #define CLEAR_CALLED(func) \
74 expect_ ## func = called_ ## func = FALSE
76 DEFINE_EXPECT(GetContainer);
77 DEFINE_EXPECT(Site_GetWindow);
78 DEFINE_EXPECT(ShowObject);
79 DEFINE_EXPECT(CanInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivate);
81 DEFINE_EXPECT(OnUIActivate);
82 DEFINE_EXPECT(GetWindowContext);
83 DEFINE_EXPECT(Frame_GetWindow);
84 DEFINE_EXPECT(Frame_SetActiveObject);
85 DEFINE_EXPECT(UIWindow_SetActiveObject);
86 DEFINE_EXPECT(SetMenu);
87 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
88 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
89 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
90 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
91 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
92 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
93 DEFINE_EXPECT(Invoke_STATUSTEXTCHANGE);
94 DEFINE_EXPECT(Invoke_PROPERTYCHANGE);
95 DEFINE_EXPECT(Invoke_DOWNLOADBEGIN);
96 DEFINE_EXPECT(Invoke_BEFORENAVIGATE2);
97 DEFINE_EXPECT(Invoke_SETSECURELOCKICON);
98 DEFINE_EXPECT(Invoke_FILEDOWNLOAD);
99 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE);
100 DEFINE_EXPECT(Invoke_DOWNLOADCOMPLETE);
101 DEFINE_EXPECT(Invoke_ONMENUBAR);
102 DEFINE_EXPECT(Invoke_ONADDRESSBAR);
103 DEFINE_EXPECT(Invoke_ONSTATUSBAR);
104 DEFINE_EXPECT(Invoke_ONTOOLBAR);
105 DEFINE_EXPECT(Invoke_ONFULLSCREEN);
106 DEFINE_EXPECT(Invoke_ONTHEATERMODE);
107 DEFINE_EXPECT(Invoke_WINDOWSETRESIZABLE);
108 DEFINE_EXPECT(Invoke_TITLECHANGE);
109 DEFINE_EXPECT(Invoke_NAVIGATECOMPLETE2);
110 DEFINE_EXPECT(Invoke_PROGRESSCHANGE);
111 DEFINE_EXPECT(Invoke_DOCUMENTCOMPLETE);
112 DEFINE_EXPECT(Invoke_282);
113 DEFINE_EXPECT(EnableModeless_TRUE);
114 DEFINE_EXPECT(EnableModeless_FALSE);
115 DEFINE_EXPECT(GetHostInfo);
116 DEFINE_EXPECT(GetOptionKeyPath);
117 DEFINE_EXPECT(GetOverridesKeyPath);
118 DEFINE_EXPECT(SetStatusText);
119 DEFINE_EXPECT(UpdateUI);
120 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
121 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
122 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
123 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
124 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
125 DEFINE_EXPECT(Exec_SETTITLE);
126 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
127 DEFINE_EXPECT(Exec_STOP);
128 DEFINE_EXPECT(Exec_IDM_STOP);
129 DEFINE_EXPECT(QueryStatus_STOP);
130 DEFINE_EXPECT(QueryStatus_IDM_STOP);
131 DEFINE_EXPECT(DocHost_EnableModeless_TRUE);
132 DEFINE_EXPECT(DocHost_EnableModeless_FALSE);
133 DEFINE_EXPECT(DocHost_TranslateAccelerator);
134 DEFINE_EXPECT(GetDropTarget);
135 DEFINE_EXPECT(TranslateUrl);
136 DEFINE_EXPECT(ShowUI);
137 DEFINE_EXPECT(HideUI);
138 DEFINE_EXPECT(OnUIDeactivate);
139 DEFINE_EXPECT(OnInPlaceDeactivate);
140 DEFINE_EXPECT(RequestUIActivate);
141 DEFINE_EXPECT(ControlSite_TranslateAccelerator);
142 DEFINE_EXPECT(OnFocus);
143 DEFINE_EXPECT(GetExternal);
145 static const WCHAR wszItem[] = {'i','t','e','m',0};
146 static const WCHAR emptyW[] = {0};
148 static VARIANT_BOOL exvb;
150 static IWebBrowser2 *wb;
152 static HWND container_hwnd, shell_embedding_hwnd;
153 static BOOL is_downloading, is_first_load, use_container_olecmd, test_close, is_http, use_container_dochostui;
154 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
155 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
156 static const char *current_url;
157 static int wb_version;
159 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
160 #define DWL_FROM_PUT_HREF 0x02
161 #define DWL_FROM_GOBACK 0x04
162 #define DWL_HTTP 0x08
164 static DWORD dwl_flags;
167 /* Returns true if the user interface is in English. Note that this does not
168 * presume of the formatting of dates, numbers, etc.
170 static BOOL is_lang_english(void)
172 static HMODULE hkernel32 = NULL;
173 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
174 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
176 if (!hkernel32)
178 hkernel32 = GetModuleHandleA("kernel32.dll");
179 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
180 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
182 if (pGetThreadUILanguage)
183 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
184 if (pGetUserDefaultUILanguage)
185 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
187 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
190 static int strcmp_wa(LPCWSTR strw, const char *stra)
192 CHAR buf[512];
193 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
194 return lstrcmpA(stra, buf);
197 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
199 IUnknown *unk1, *unk2;
201 if(iface1 == iface2)
202 return TRUE;
204 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
205 IUnknown_Release(unk1);
206 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
207 IUnknown_Release(unk2);
209 return unk1 == unk2;
212 static const char *debugstr_guid(REFIID riid)
214 static char buf[50];
216 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
217 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
218 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
219 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
221 return buf;
224 static BSTR a2bstr(const char *str)
226 BSTR ret;
227 int len;
229 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
230 ret = SysAllocStringLen(NULL, len);
231 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
233 return ret;
236 #define create_WebBrowser(a) _create_WebBrowser(__LINE__,a)
237 static HRESULT _create_WebBrowser(unsigned line, IUnknown **unk)
239 HRESULT hres;
241 wb_version = 2;
243 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
244 &IID_IUnknown, (void**)unk);
245 ok_(__FILE__,line)(hres == S_OK, "Creating WebBrowser object failed: %08x\n", hres);
246 return hres;
249 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
250 static void _test_LocationURL(unsigned line, IUnknown *unk, const char *exurl)
252 IWebBrowser2 *wb;
253 BSTR url = (void*)0xdeadbeef;
254 HRESULT hres;
256 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
257 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
258 if(FAILED(hres))
259 return;
261 hres = IWebBrowser2_get_LocationURL(wb, &url);
262 ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
263 if (hres == S_OK)
265 ok_(__FILE__,line) (!strcmp_wa(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
266 SysFreeString(url);
269 IWebBrowser2_Release(wb);
272 #define test_ready_state(ex) _test_ready_state(__LINE__,ex);
273 static void _test_ready_state(unsigned line, READYSTATE exstate)
275 READYSTATE state;
276 HRESULT hres;
278 hres = IWebBrowser2_get_ReadyState(wb, &state);
279 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
280 ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
283 #define get_document(u) _get_document(__LINE__,u)
284 static IDispatch *_get_document(unsigned line, IUnknown *unk)
286 IHTMLDocument2 *html_doc;
287 IWebBrowser2 *wb;
288 IDispatch *disp;
289 HRESULT hres;
291 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
292 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IWebBrowser2) failed: %08x\n", hres);
294 disp = NULL;
295 hres = IWebBrowser2_get_Document(wb, &disp);
296 IWebBrowser2_Release(wb);
297 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
298 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
300 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
301 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
302 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
303 IHTMLDocument_Release(html_doc);
305 return disp;
308 #define get_dochost(u) _get_dochost(__LINE__,u)
309 static IOleClientSite *_get_dochost(unsigned line, IUnknown *unk)
311 IOleClientSite *client_site;
312 IOleObject *oleobj;
313 IDispatch *doc;
314 HRESULT hres;
316 doc = _get_document(line, unk);
317 hres = IDispatch_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
318 IDispatch_Release(doc);
319 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
321 hres = IOleObject_GetClientSite(oleobj, &client_site);
322 IOleObject_Release(oleobj);
323 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
325 return client_site;
328 static HRESULT QueryInterface(REFIID,void**);
330 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
331 REFIID riid, void **ppv)
333 ok(0, "unexpected call\n");
334 return E_NOINTERFACE;
337 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
339 return 2;
342 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
344 return 1;
347 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
348 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
350 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
351 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
352 ok(!pCmdText, "pCmdText != NULL\n");
354 switch(prgCmds[0].cmdID) {
355 case OLECMDID_STOP:
356 CHECK_EXPECT2(QueryStatus_STOP);
357 prgCmds[0].cmdf = OLECMDF_SUPPORTED;
358 return S_OK;
359 case OLECMDID_SETPROGRESSTEXT:
360 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
361 prgCmds[0].cmdf = OLECMDF_ENABLED;
362 return S_OK;
363 case IDM_STOP:
364 /* Note:
365 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
366 * This command appears here for the ExecWB and QueryStatusWB tests in order
367 * to help demonstrate that these routines use a NULL pguidCmdGroup.
369 CHECK_EXPECT(QueryStatus_IDM_STOP);
370 prgCmds[0].cmdf = 0;
371 return S_OK;
372 default:
373 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
376 return E_FAIL;
379 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
380 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
382 if(!pguidCmdGroup) {
383 switch(nCmdID) {
384 case OLECMDID_SETPROGRESSMAX:
385 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
386 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
387 ok(pvaIn != NULL, "pvaIn == NULL\n");
388 if(pvaIn)
389 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
390 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
391 return S_OK;
392 case OLECMDID_SETPROGRESSPOS:
393 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
394 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
395 ok(pvaIn != NULL, "pvaIn == NULL\n");
396 if(pvaIn)
397 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
398 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
399 return S_OK;
400 case OLECMDID_SETDOWNLOADSTATE:
401 if(is_downloading)
402 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
403 "nCmdexecopts=%08x\n", nCmdexecopt);
404 else
405 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
406 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
407 ok(pvaIn != NULL, "pvaIn == NULL\n");
408 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
409 switch(V_I4(pvaIn)) {
410 case 0:
411 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
412 break;
413 case 1:
414 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
415 break;
416 default:
417 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
419 return S_OK;
420 case OLECMDID_UPDATECOMMANDS:
421 CHECK_EXPECT2(Exec_UPDATECOMMANDS);
422 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
423 ok(!pvaIn, "pvaIn != NULL\n");
424 ok(!pvaOut, "pvaOut=%p, expected NULL\n", pvaOut);
425 return S_OK;
426 case OLECMDID_SETTITLE:
427 CHECK_EXPECT(Exec_SETTITLE);
428 /* TODO: test args */
429 return S_OK;
430 case OLECMDID_STOP:
431 CHECK_EXPECT(Exec_STOP);
432 return S_OK;
433 case IDM_STOP:
434 /* Note:
435 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
436 * This command appears here for the ExecWB and QueryStatusWB tests in order
437 * to help demonstrate that these routines use a NULL pguidCmdGroup.
439 CHECK_EXPECT(Exec_IDM_STOP);
440 return OLECMDERR_E_NOTSUPPORTED;
441 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
442 case 6058: /* TODO */
443 return E_NOTIMPL;
444 default:
445 ok(0, "unexpected nsCmdID %d\n", nCmdID);
447 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
448 switch(nCmdID) {
449 case 20: /* TODO */
450 case 24: /* TODO */
451 case 25: /* IE5 */
452 case 37: /* TODO */
453 case 39: /* TODO */
454 case 66: /* TODO */
455 case 67: /* TODO */
456 case 69: /* TODO */
457 case 101: /* TODO (IE8) */
458 case 109: /* TODO (IE9) */
459 return E_FAIL;
460 default:
461 ok(0, "unexpected nCmdID %d\n", nCmdID);
463 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
464 switch(nCmdID) {
465 case 105: /* TODO */
466 case 138: /* TODO */
467 case 140: /* TODO (Win7) */
468 return E_FAIL;
469 default:
470 ok(0, "unexpected nCmdID %d\n", nCmdID);
472 }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
473 switch(nCmdID) {
474 case 11: /* TODO */
475 break;
476 default:
477 ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
479 }else if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
480 switch(nCmdID) {
481 case 6041: /* TODO */
482 break;
483 default:
484 ok(0, "unexpected nCmdID %d of CGID_DocHostCommandHandler\n", nCmdID);
486 }else {
487 ok(0, "unexpected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
490 return E_FAIL;
493 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
494 OleCommandTarget_QueryInterface,
495 OleCommandTarget_AddRef,
496 OleCommandTarget_Release,
497 OleCommandTarget_QueryStatus,
498 OleCommandTarget_Exec
501 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
503 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
505 if(IsEqualGUID(&IID_ITargetContainer, riid))
506 return E_NOINTERFACE; /* TODO */
508 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
509 if(use_container_olecmd)
511 *ppv = &OleCommandTarget;
512 return S_OK;
514 else
515 return E_NOINTERFACE;
518 ok(0, "unexpected call\n");
519 return E_NOINTERFACE;
522 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
524 return 2;
527 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
529 return 1;
532 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
533 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
535 ok(0, "unexpected call\n");
536 return E_NOTIMPL;
539 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
540 IEnumUnknown **ppenum)
542 ok(0, "unexpected call\n");
543 return E_NOTIMPL;
546 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
548 ok(0, "unexpected call\n");
549 return E_NOTIMPL;
552 static const IOleContainerVtbl OleContainerVtbl = {
553 OleContainer_QueryInterface,
554 OleContainer_AddRef,
555 OleContainer_Release,
556 OleContainer_ParseDisplayName,
557 OleContainer_EnumObjects,
558 OleContainer_LockContainer
561 static IOleContainer OleContainer = { &OleContainerVtbl };
563 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
565 return QueryInterface(riid, ppv);
568 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
570 return 2;
573 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
575 return 1;
578 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
580 ok(0, "unexpected call\n");
581 return E_NOTIMPL;
584 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
585 ITypeInfo **ppTInfo)
587 ok(0, "unexpected call\n");
588 return E_NOTIMPL;
591 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
592 UINT cNames, LCID lcid, DISPID *rgDispId)
594 ok(0, "unexpected call\n");
595 return E_NOTIMPL;
598 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
599 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
600 EXCEPINFO *pExcepInfo, UINT *puArgErr)
602 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
603 ok(pDispParams != NULL, "pDispParams == NULL\n");
604 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
605 ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
606 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
607 ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
608 ok(pDispParams->rgdispidNamedArgs == NULL,
609 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
610 ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
611 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
613 switch(dispIdMember) {
614 case DISPID_AMBIENT_USERMODE:
615 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
616 return E_FAIL;
617 case DISPID_AMBIENT_DLCONTROL:
618 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
619 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
620 return E_FAIL;
621 case DISPID_AMBIENT_USERAGENT:
622 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
623 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
624 return E_FAIL;
625 case DISPID_AMBIENT_PALETTE:
626 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
627 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
628 return E_FAIL;
629 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
630 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
631 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
632 V_VT(pVarResult) = VT_BOOL;
633 V_BOOL(pVarResult) = VARIANT_FALSE;
634 return S_OK;
635 case DISPID_AMBIENT_SILENT:
636 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
637 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
638 V_VT(pVarResult) = VT_BOOL;
639 V_BOOL(pVarResult) = VARIANT_FALSE;
640 return S_OK;
643 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
644 return E_NOTIMPL;
647 static IDispatchVtbl DispatchVtbl = {
648 Dispatch_QueryInterface,
649 Dispatch_AddRef,
650 Dispatch_Release,
651 Dispatch_GetTypeInfoCount,
652 Dispatch_GetTypeInfo,
653 Dispatch_GetIDsOfNames,
654 Dispatch_Invoke
657 static IDispatch Dispatch = { &DispatchVtbl };
659 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
661 *ppv = NULL;
663 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
664 *ppv = iface;
665 return S_OK;
668 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
669 return E_NOINTERFACE;
672 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
673 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
675 ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
676 ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
677 ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
678 if(strict)
679 ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
680 V_BOOL(params->rgvarg), exvb);
681 else
682 ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
683 V_BOOL(params->rgvarg), exvb);
686 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
687 const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
689 ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
690 ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
691 ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
693 ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
694 ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
695 if(V_VARIANTREF(url)) {
696 ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
697 V_VT(V_VARIANTREF(url)));
698 ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
699 ok(!strcmp_wa(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
700 wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), current_url);
703 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
704 V_VT(flags));
705 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
706 V_VT(flags));
707 ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
708 if(V_VARIANTREF(flags)) {
709 ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
710 V_VT(V_VARIANTREF(flags)));
711 if(is_first_load) {
712 ok(V_I4(V_VARIANTREF(flags)) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0\n",
713 V_I4(V_VARIANTREF(flags)));
714 }else {
715 ok((V_I4(V_VARIANTREF(flags)) & ~0x40) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0x40 or 0\n",
716 V_I4(V_VARIANTREF(flags)));
720 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
721 V_VT(frame));
722 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
723 V_VT(frame));
724 ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
725 if(V_VARIANTREF(frame)) {
726 ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
727 V_VT(V_VARIANTREF(frame)));
728 ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
729 V_BSTR(V_VARIANTREF(frame)));
732 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
733 V_VT(post_data));
734 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
735 V_VT(post_data));
736 ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
737 if(V_VARIANTREF(post_data)) {
738 ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
739 "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
740 V_VT(V_VARIANTREF(post_data)));
741 ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
742 "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
743 if(V_VARIANTREF(V_VARIANTREF(post_data))) {
744 ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
745 "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
746 V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
748 if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
749 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
751 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
752 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
757 ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
758 V_VT(headers));
759 ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
760 if(V_VARIANTREF(headers)) {
761 ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
762 V_VT(V_VARIANTREF(headers)));
763 ok(V_BSTR(V_VARIANTREF(headers)) == NULL, "V_BSTR(V_VARIANTREF(headers)) = %p, expected NULL\n",
764 V_BSTR(V_VARIANTREF(headers)));
767 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
768 V_VT(cancel));
769 ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
770 if(V_BOOLREF(cancel))
771 ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(cancel) = %x, expected VARIANT_FALSE\n",
772 *V_BOOLREF(cancel));
775 static void test_navigatecomplete2(DISPPARAMS *dp)
777 VARIANT *v;
779 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
781 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
782 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
784 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
785 v = V_VARIANTREF(dp->rgvarg);
786 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
787 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
789 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
790 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
792 test_ready_state((dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
795 static void test_documentcomplete(DISPPARAMS *dp)
797 VARIANT *v;
799 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
801 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
802 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
804 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
805 v = V_VARIANTREF(dp->rgvarg);
806 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
807 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
809 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
810 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
812 test_ready_state(READYSTATE_COMPLETE);
815 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
816 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
817 EXCEPINFO *pExcepInfo, UINT *puArgErr)
819 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
820 ok(pDispParams != NULL, "pDispParams == NULL\n");
821 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
822 ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
823 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
824 ok(pDispParams->rgdispidNamedArgs == NULL,
825 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
826 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
828 switch(dispIdMember) {
829 case DISPID_STATUSTEXTCHANGE:
830 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
832 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
833 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
834 ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
835 V_VT(pDispParams->rgvarg));
836 /* TODO: Check text */
837 break;
839 case DISPID_PROPERTYCHANGE:
840 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
842 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
843 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
844 /* TODO: Check args */
845 break;
847 case DISPID_DOWNLOADBEGIN:
848 CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
850 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
851 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
852 test_ready_state(READYSTATE_LOADING);
853 break;
855 case DISPID_BEFORENAVIGATE2:
856 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
858 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
859 ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
860 test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
861 pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
862 pDispParams->rgvarg);
863 test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
864 break;
866 case DISPID_SETSECURELOCKICON:
867 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
869 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
870 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
871 /* TODO: Check args */
872 break;
874 case DISPID_FILEDOWNLOAD:
875 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
877 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
878 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
879 /* TODO: Check args */
880 break;
882 case DISPID_COMMANDSTATECHANGE:
883 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
885 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
886 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
888 ok(V_VT(pDispParams->rgvarg) == VT_BOOL, "V_VT(pDispParams->rgvarg) = %d\n", V_VT(pDispParams->rgvarg));
889 ok(V_VT(pDispParams->rgvarg+1) == VT_I4, "V_VT(pDispParams->rgvarg+1) = %d\n", V_VT(pDispParams->rgvarg+1));
891 /* TODO: Check args */
892 break;
894 case DISPID_DOWNLOADCOMPLETE:
895 CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
897 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
898 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
899 test_ready_state(READYSTATE_LOADING);
900 break;
902 case DISPID_ONMENUBAR:
903 CHECK_EXPECT(Invoke_ONMENUBAR);
904 test_invoke_bool(pDispParams, TRUE);
905 break;
907 case DISPID_ONADDRESSBAR:
908 CHECK_EXPECT(Invoke_ONADDRESSBAR);
909 test_invoke_bool(pDispParams, TRUE);
910 break;
912 case DISPID_ONSTATUSBAR:
913 CHECK_EXPECT(Invoke_ONSTATUSBAR);
914 test_invoke_bool(pDispParams, TRUE);
915 break;
917 case DISPID_ONTOOLBAR:
918 CHECK_EXPECT(Invoke_ONTOOLBAR);
919 test_invoke_bool(pDispParams, FALSE);
920 break;
922 case DISPID_ONFULLSCREEN:
923 CHECK_EXPECT(Invoke_ONFULLSCREEN);
924 test_invoke_bool(pDispParams, TRUE);
925 break;
927 case DISPID_ONTHEATERMODE:
928 CHECK_EXPECT(Invoke_ONTHEATERMODE);
929 test_invoke_bool(pDispParams, TRUE);
930 break;
932 case DISPID_WINDOWSETRESIZABLE:
933 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
934 test_invoke_bool(pDispParams, TRUE);
935 break;
937 case DISPID_TITLECHANGE:
938 CHECK_EXPECT2(Invoke_TITLECHANGE);
939 /* FIXME */
940 break;
942 case DISPID_NAVIGATECOMPLETE2:
943 test_navigatecomplete2(pDispParams);
944 break;
946 case DISPID_PROGRESSCHANGE:
947 CHECK_EXPECT2(Invoke_PROGRESSCHANGE);
948 /* FIXME */
949 break;
951 case DISPID_DOCUMENTCOMPLETE:
952 test_documentcomplete(pDispParams);
953 break;
955 case 282: /* FIXME */
956 CHECK_EXPECT2(Invoke_282);
957 break;
959 default:
960 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
963 return S_OK;
966 static IDispatchVtbl WebBrowserEvents2Vtbl = {
967 WebBrowserEvents2_QueryInterface,
968 Dispatch_AddRef,
969 Dispatch_Release,
970 Dispatch_GetTypeInfoCount,
971 Dispatch_GetTypeInfo,
972 Dispatch_GetIDsOfNames,
973 WebBrowserEvents2_Invoke
976 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
978 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
980 return QueryInterface(riid, ppv);
983 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
985 return 2;
988 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
990 return 1;
993 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
995 ok(0, "unexpected call\n");
996 return E_NOTIMPL;
999 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1000 IMoniker **ppmon)
1002 ok(0, "unexpected call\n");
1003 return E_NOTIMPL;
1006 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1008 CHECK_EXPECT(GetContainer);
1010 ok(ppContainer != NULL, "ppContainer == NULL\n");
1011 if(ppContainer)
1012 *ppContainer = &OleContainer;
1014 return S_OK;
1017 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1019 CHECK_EXPECT(ShowObject);
1020 return S_OK;
1023 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1025 ok(0, "unexpected call\n");
1026 return E_NOTIMPL;
1029 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1031 ok(0, "unexpected call\n");
1032 return E_NOTIMPL;
1035 static const IOleClientSiteVtbl ClientSiteVtbl = {
1036 ClientSite_QueryInterface,
1037 ClientSite_AddRef,
1038 ClientSite_Release,
1039 ClientSite_SaveObject,
1040 ClientSite_GetMoniker,
1041 ClientSite_GetContainer,
1042 ClientSite_ShowObject,
1043 ClientSite_OnShowWindow,
1044 ClientSite_RequestNewObjectLayout
1047 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1049 static HRESULT WINAPI IOleControlSite_fnQueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1051 *ppv = NULL;
1052 return E_NOINTERFACE;
1055 static ULONG WINAPI IOleControlSite_fnAddRef(IOleControlSite *iface)
1057 return 2;
1060 static ULONG WINAPI IOleControlSite_fnRelease(IOleControlSite *iface)
1062 return 1;
1065 static HRESULT WINAPI IOleControlSite_fnOnControlInfoChanged(IOleControlSite* This)
1067 ok(0, "unexpected call\n");
1068 return E_NOTIMPL;
1071 static HRESULT WINAPI IOleControlSite_fnLockInPlaceActive(IOleControlSite* This,
1072 BOOL fLock)
1074 ok(0, "unexpected call\n");
1075 return E_NOTIMPL;
1078 static HRESULT WINAPI IOleControlSite_fnGetExtendedControl(IOleControlSite* This,
1079 IDispatch **ppDisp)
1081 ok(0, "unexpected call\n");
1082 return E_NOTIMPL;
1085 static HRESULT WINAPI IOleControlSite_fnTransformCoords(IOleControlSite* This,
1086 POINTL *pPtlHimetric,
1087 POINTF *pPtfContainer,
1088 DWORD dwFlags)
1090 ok(0, "unexpected call\n");
1091 return E_NOTIMPL;
1094 static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* This, MSG *pMsg,
1095 DWORD grfModifiers)
1097 CHECK_EXPECT(ControlSite_TranslateAccelerator);
1098 return hr_site_TranslateAccelerator;
1101 static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus)
1103 CHECK_EXPECT2(OnFocus);
1104 return E_NOTIMPL;
1107 static HRESULT WINAPI IOleControlSite_fnShowPropertyFrame(IOleControlSite* This)
1109 ok(0, "unexpected call\n");
1110 return E_NOTIMPL;
1113 static IOleControlSiteVtbl ControlSiteVtbl = {
1114 IOleControlSite_fnQueryInterface,
1115 IOleControlSite_fnAddRef,
1116 IOleControlSite_fnRelease,
1117 IOleControlSite_fnOnControlInfoChanged,
1118 IOleControlSite_fnLockInPlaceActive,
1119 IOleControlSite_fnGetExtendedControl,
1120 IOleControlSite_fnTransformCoords,
1121 IOleControlSite_fnTranslateAccelerator,
1122 IOleControlSite_fnOnFocus,
1123 IOleControlSite_fnShowPropertyFrame
1126 static IOleControlSite ControlSite = { &ControlSiteVtbl };
1128 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
1129 REFIID riid, void **ppv)
1131 ok(0, "unexpected call\n");
1132 return E_NOINTERFACE;
1135 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
1137 return 2;
1140 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
1142 return 1;
1145 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1147 ok(0, "unexpected call\n");
1148 return E_NOTIMPL;
1151 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1153 CHECK_EXPECT(Frame_GetWindow);
1154 ok(phwnd != NULL, "phwnd == NULL\n");
1155 if(phwnd)
1156 *phwnd = container_hwnd;
1157 return S_OK;
1160 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1162 ok(0, "unexpected call\n");
1163 return E_NOTIMPL;
1166 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1168 ok(0, "unexpected call\n");
1169 return E_NOTIMPL;
1172 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
1173 LPCBORDERWIDTHS pborderwidths)
1175 ok(0, "unexpected call\n");
1176 return E_NOTIMPL;
1179 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
1180 LPCBORDERWIDTHS pborderwidths)
1182 ok(0, "unexpected call\n");
1183 return E_NOTIMPL;
1186 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1187 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1189 CHECK_EXPECT(UIWindow_SetActiveObject);
1190 if(!test_close) {
1191 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1192 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1193 } else {
1194 ok(!pActiveObject, "pActiveObject != NULL\n");
1195 ok(!pszObjName, "pszObjName != NULL\n");
1197 return S_OK;
1200 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1201 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1203 CHECK_EXPECT(Frame_SetActiveObject);
1204 if(!test_close) {
1205 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1206 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1207 } else {
1208 ok(!pActiveObject, "pActiveObject != NULL\n");
1209 ok(!pszObjName, "pszObjName != NULL\n");
1211 return S_OK;
1214 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1215 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1217 ok(0, "unexpected call\n");
1218 return E_NOTIMPL;
1221 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1222 HOLEMENU holemenu, HWND hwndActiveObject)
1224 CHECK_EXPECT(SetMenu);
1225 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
1226 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
1227 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
1228 hwndActiveObject, shell_embedding_hwnd);
1229 return S_OK;
1232 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1234 ok(0, "unexpected call\n");
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1240 CHECK_EXPECT2(SetStatusText);
1241 /* FIXME: Check pszStatusText */
1242 return S_OK;
1245 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1247 if(fEnable)
1248 CHECK_EXPECT2(EnableModeless_TRUE);
1249 else
1250 CHECK_EXPECT2(EnableModeless_FALSE);
1251 return S_OK;
1254 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1256 ok(0, "unexpected call\n");
1257 return E_NOTIMPL;
1260 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1261 InPlaceUIWindow_QueryInterface,
1262 InPlaceUIWindow_AddRef,
1263 InPlaceUIWindow_Release,
1264 InPlaceUIWindow_GetWindow,
1265 InPlaceUIWindow_ContextSensitiveHelp,
1266 InPlaceUIWindow_GetBorder,
1267 InPlaceUIWindow_RequestBorderSpace,
1268 InPlaceUIWindow_SetBorderSpace,
1269 InPlaceUIWindow_SetActiveObject,
1272 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
1274 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1275 InPlaceUIWindow_QueryInterface,
1276 InPlaceUIWindow_AddRef,
1277 InPlaceUIWindow_Release,
1278 InPlaceFrame_GetWindow,
1279 InPlaceUIWindow_ContextSensitiveHelp,
1280 InPlaceUIWindow_GetBorder,
1281 InPlaceUIWindow_RequestBorderSpace,
1282 InPlaceUIWindow_SetBorderSpace,
1283 InPlaceFrame_SetActiveObject,
1284 InPlaceFrame_InsertMenus,
1285 InPlaceFrame_SetMenu,
1286 InPlaceFrame_RemoveMenus,
1287 InPlaceFrame_SetStatusText,
1288 InPlaceFrame_EnableModeless,
1289 InPlaceFrame_TranslateAccelerator
1292 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1294 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1296 return QueryInterface(riid, ppv);
1299 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1301 return 2;
1304 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1306 return 1;
1309 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1311 CHECK_EXPECT(Site_GetWindow);
1312 ok(phwnd != NULL, "phwnd == NULL\n");
1313 if(phwnd)
1314 *phwnd = container_hwnd;
1315 return S_OK;
1318 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1320 ok(0, "unexpected call\n");
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1326 CHECK_EXPECT(CanInPlaceActivate);
1327 return S_OK;
1330 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1332 CHECK_EXPECT(OnInPlaceActivate);
1333 return S_OK;
1336 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1338 CHECK_EXPECT(OnUIActivate);
1339 return S_OK;
1342 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1343 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1344 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1346 static const RECT pos_rect = {2,1,1002,901};
1347 static const RECT clip_rect = {10,10,990,890};
1349 CHECK_EXPECT(GetWindowContext);
1351 ok(ppFrame != NULL, "ppFrame = NULL\n");
1352 if(ppFrame)
1353 *ppFrame = &InPlaceFrame;
1355 ok(ppDoc != NULL, "ppDoc = NULL\n");
1356 if(ppDoc)
1357 *ppDoc = &InPlaceUIWindow;
1359 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1360 if(lprcPosRect)
1361 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1363 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1364 if(lprcClipRect)
1365 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1367 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1368 if(lpFrameInfo) {
1369 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1370 lpFrameInfo->fMDIApp = FALSE;
1371 lpFrameInfo->hwndFrame = container_hwnd;
1372 lpFrameInfo->haccel = NULL;
1373 lpFrameInfo->cAccelEntries = 0;
1376 return S_OK;
1379 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1381 ok(0, "unexpected call\n");
1382 return E_NOTIMPL;
1385 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1387 CHECK_EXPECT(OnUIDeactivate);
1388 ok(!fUndoable, "fUndoable should be FALSE\n");
1389 return S_OK;
1392 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1394 CHECK_EXPECT(OnInPlaceDeactivate);
1395 return S_OK;
1398 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1400 ok(0, "unexpected call\n");
1401 return E_NOTIMPL;
1404 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1406 ok(0, "unexpected call\n");
1407 return E_NOTIMPL;
1410 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1412 ok(0, "unexpected call\n");
1413 return E_NOTIMPL;
1416 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1417 BOOL *pNoRedraw, DWORD dwFlags)
1419 ok(0, "unexpected call\n");
1420 return E_NOTIMPL;
1423 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1424 BOOL fNoRedraw)
1426 ok(0, "unexpected call\n");
1427 return E_NOTIMPL;
1430 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1432 CHECK_EXPECT2(RequestUIActivate);
1433 return S_OK;
1436 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1437 InPlaceSite_QueryInterface,
1438 InPlaceSite_AddRef,
1439 InPlaceSite_Release,
1440 InPlaceSite_GetWindow,
1441 InPlaceSite_ContextSensitiveHelp,
1442 InPlaceSite_CanInPlaceActivate,
1443 InPlaceSite_OnInPlaceActivate,
1444 InPlaceSite_OnUIActivate,
1445 InPlaceSite_GetWindowContext,
1446 InPlaceSite_Scroll,
1447 InPlaceSite_OnUIDeactivate,
1448 InPlaceSite_OnInPlaceDeactivate,
1449 InPlaceSite_DiscardUndoState,
1450 InPlaceSite_DeactivateAndUndo,
1451 InPlaceSite_OnPosRectChange,
1452 InPlaceSite_OnInPlaceActivateEx,
1453 InPlaceSite_OnInPlaceDeactivateEx,
1454 InPlaceSite_RequestUIActivate
1457 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1459 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1461 return QueryInterface(riid, ppv);
1464 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1466 return 2;
1469 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1471 return 1;
1474 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1475 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1477 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1478 return S_FALSE;
1481 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1483 CHECK_EXPECT2(GetHostInfo);
1484 ok(pInfo != NULL, "pInfo=NULL\n");
1485 if(pInfo) {
1486 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1487 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1488 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1489 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1490 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1492 return E_FAIL;
1495 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1496 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1497 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1499 CHECK_EXPECT(ShowUI);
1500 return E_NOTIMPL;
1503 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1505 CHECK_EXPECT(HideUI);
1506 return E_NOTIMPL;
1509 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1511 CHECK_EXPECT2(UpdateUI);
1512 return E_NOTIMPL;
1515 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1517 if(fEnable)
1518 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1519 else
1520 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1522 return S_OK;
1525 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1527 ok(0, "unexpected call\n");
1528 return E_NOTIMPL;
1531 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1533 ok(0, "unexpected call\n");
1534 return E_NOTIMPL;
1537 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1538 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1540 ok(0, "unexpected call\n");
1541 return E_NOTIMPL;
1544 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1545 const GUID *pguidCmdGroup, DWORD nCmdID)
1547 CHECK_EXPECT(DocHost_TranslateAccelerator);
1548 ok(pguidCmdGroup != NULL, "Got NULL pguidCmdGroup.\n");
1549 if(pguidCmdGroup)
1550 ok(IsEqualGUID(pguidCmdGroup, &CGID_MSHTML), "Unexpected pguidCmdGroup\n");
1551 ok(lpMsg != NULL, "Got NULL lpMsg.\n");
1552 return hr_dochost_TranslateAccelerator;
1555 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1556 LPOLESTR *pchKey, DWORD dw)
1558 CHECK_EXPECT(GetOptionKeyPath);
1559 ok(pchKey != NULL, "pchKey==NULL\n");
1560 if(pchKey)
1561 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1562 ok(!dw, "dw=%x\n", dw);
1563 return E_NOTIMPL;
1566 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1567 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1569 CHECK_EXPECT(GetDropTarget);
1570 return E_NOTIMPL;
1573 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1575 CHECK_EXPECT(GetExternal);
1576 *ppDispatch = NULL;
1577 return S_FALSE;
1580 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1581 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1583 if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1584 todo_wine CHECK_EXPECT(TranslateUrl);
1585 else
1586 CHECK_EXPECT(TranslateUrl);
1587 return E_NOTIMPL;
1590 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1591 IDataObject **ppPORet)
1593 ok(0, "unexpected call\n");
1594 return E_NOTIMPL;
1597 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1598 LPOLESTR *pchKey, DWORD dw)
1600 CHECK_EXPECT(GetOverridesKeyPath);
1601 ok(pchKey != NULL, "pchKey==NULL\n");
1602 if(pchKey)
1603 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1604 ok(!dw, "dw=%x\n", dw);
1605 return E_NOTIMPL;
1608 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1609 DocHostUIHandler_QueryInterface,
1610 DocHostUIHandler_AddRef,
1611 DocHostUIHandler_Release,
1612 DocHostUIHandler_ShowContextMenu,
1613 DocHostUIHandler_GetHostInfo,
1614 DocHostUIHandler_ShowUI,
1615 DocHostUIHandler_HideUI,
1616 DocHostUIHandler_UpdateUI,
1617 DocHostUIHandler_EnableModeless,
1618 DocHostUIHandler_OnDocWindowActivate,
1619 DocHostUIHandler_OnFrameWindowActivate,
1620 DocHostUIHandler_ResizeBorder,
1621 DocHostUIHandler_TranslateAccelerator,
1622 DocHostUIHandler_GetOptionKeyPath,
1623 DocHostUIHandler_GetDropTarget,
1624 DocHostUIHandler_GetExternal,
1625 DocHostUIHandler_TranslateUrl,
1626 DocHostUIHandler_FilterDataObject,
1627 DocHostUIHandler_GetOverrideKeyPath
1630 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1633 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1635 return QueryInterface(riid, ppv);
1638 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1640 return 2;
1643 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1645 return 1;
1648 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1649 REFGUID guidService, REFIID riid, void **ppv)
1651 *ppv = NULL;
1653 if(!winetest_interactive)
1654 return E_NOINTERFACE;
1656 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1657 trace("Service SID_STopLevelBrowser\n");
1658 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1659 trace("Service SID_SEditCommandTarget\n");
1660 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1661 trace("Service IID_ITargetFrame2\n");
1662 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1663 trace("Service SID_SInternetSecurityManager\n");
1664 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1665 trace("Service SID_SOleUndoManager\n");
1666 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1667 trace("Service SID_IMimeInfo\n");
1668 else if (IsEqualGUID(&SID_STopWindow, guidService))
1669 trace("Service SID_STopWindow\n");
1671 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1672 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1673 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1674 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1675 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1676 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1677 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1678 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1679 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1680 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1681 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1683 else
1684 trace("Service %s not supported\n", debugstr_guid(guidService));
1686 return E_NOINTERFACE;
1690 static const IServiceProviderVtbl ServiceProviderVtbl = {
1691 ServiceProvider_QueryInterface,
1692 ServiceProvider_AddRef,
1693 ServiceProvider_Release,
1694 ServiceProvider_QueryService
1697 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1700 static HRESULT QueryInterface(REFIID riid, void **ppv)
1702 *ppv = NULL;
1704 if(IsEqualGUID(&IID_IUnknown, riid)
1705 || IsEqualGUID(&IID_IOleClientSite, riid))
1706 *ppv = &ClientSite;
1707 else if(IsEqualGUID(&IID_IOleWindow, riid)
1708 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1709 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1710 *ppv = &InPlaceSite;
1711 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1712 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1713 *ppv = use_container_dochostui ? &DocHostUIHandler : NULL;
1714 else if(IsEqualGUID(&IID_IDispatch, riid))
1715 *ppv = &Dispatch;
1716 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1717 *ppv = &ServiceProvider;
1718 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1719 trace("interface IID_IDocHostShowUI\n");
1720 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1721 *ppv = &ControlSite;
1722 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1723 trace("interface IID_IOleCommandTarget\n");
1725 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1727 else
1729 /* are there more interfaces, that a host can support? */
1730 trace("%s: interface not supported\n", debugstr_guid(riid));
1733 return (*ppv) ? S_OK : E_NOINTERFACE;
1736 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1738 return DefWindowProcW(hwnd, msg, wParam, lParam);
1741 static HWND create_container_window(void)
1743 static const WCHAR wszWebBrowserContainer[] =
1744 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1745 static WNDCLASSEXW wndclass = {
1746 sizeof(WNDCLASSEXW),
1748 wnd_proc,
1749 0, 0, NULL, NULL, NULL, NULL, NULL,
1750 wszWebBrowserContainer,
1751 NULL
1754 RegisterClassExW(&wndclass);
1755 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1756 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1757 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1760 static void test_DoVerb(IUnknown *unk)
1762 IOleObject *oleobj;
1763 RECT rect = {0,0,1000,1000};
1764 HRESULT hres;
1766 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1767 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1768 if(FAILED(hres))
1769 return;
1771 SET_EXPECT(CanInPlaceActivate);
1772 SET_EXPECT(Site_GetWindow);
1773 SET_EXPECT(OnInPlaceActivate);
1774 SET_EXPECT(GetWindowContext);
1775 SET_EXPECT(ShowObject);
1776 SET_EXPECT(GetContainer);
1777 SET_EXPECT(Frame_GetWindow);
1778 SET_EXPECT(OnUIActivate);
1779 SET_EXPECT(Frame_SetActiveObject);
1780 SET_EXPECT(UIWindow_SetActiveObject);
1781 SET_EXPECT(SetMenu);
1782 SET_EXPECT(OnFocus);
1784 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1785 0, (HWND)0xdeadbeef, &rect);
1786 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1788 CHECK_CALLED(CanInPlaceActivate);
1789 CHECK_CALLED(Site_GetWindow);
1790 CHECK_CALLED(OnInPlaceActivate);
1791 CHECK_CALLED(GetWindowContext);
1792 CHECK_CALLED(ShowObject);
1793 CHECK_CALLED(GetContainer);
1794 CHECK_CALLED(Frame_GetWindow);
1795 CHECK_CALLED(OnUIActivate);
1796 CHECK_CALLED(Frame_SetActiveObject);
1797 CHECK_CALLED(UIWindow_SetActiveObject);
1798 CHECK_CALLED(SetMenu);
1799 todo_wine CHECK_CALLED(OnFocus);
1801 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1802 0, (HWND)0xdeadbeef, &rect);
1803 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1805 IOleObject_Release(oleobj);
1808 static void test_GetMiscStatus(IOleObject *oleobj)
1810 DWORD st, i;
1811 HRESULT hres;
1813 for(i=0; i<10; i++) {
1814 st = 0xdeadbeef;
1815 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1816 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1817 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1818 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1819 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1820 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1824 static void test_SetHostNames(IOleObject *oleobj)
1826 HRESULT hres;
1828 static const WCHAR test_appW[] = {'t','e','s','t',' ','a','p','p',0};
1830 hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1831 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1834 static void test_ClientSite(IUnknown *unk, IOleClientSite *client, BOOL stop_download)
1836 IOleObject *oleobj;
1837 IOleInPlaceObject *inplace;
1838 HWND hwnd;
1839 HRESULT hres;
1841 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1842 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1843 if(FAILED(hres))
1844 return;
1846 test_GetMiscStatus(oleobj);
1847 test_SetHostNames(oleobj);
1849 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1850 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1851 if(FAILED(hres)) {
1852 IOleObject_Release(oleobj);
1853 return;
1856 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1857 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1858 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1860 if(client) {
1861 SET_EXPECT(GetContainer);
1862 SET_EXPECT(Site_GetWindow);
1863 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1864 SET_EXPECT(Invoke_AMBIENT_SILENT);
1865 }else if(stop_download) {
1866 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1867 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1868 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1869 }else {
1870 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
1871 SET_EXPECT(Invoke_PROGRESSCHANGE);
1874 hres = IOleObject_SetClientSite(oleobj, client);
1875 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1877 if(client) {
1878 CHECK_CALLED(GetContainer);
1879 CHECK_CALLED(Site_GetWindow);
1880 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1881 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1882 }else if(stop_download) {
1883 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1884 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1885 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1886 }else {
1887 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
1888 CLEAR_CALLED(Invoke_PROGRESSCHANGE);
1891 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1892 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1893 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1895 shell_embedding_hwnd = hwnd;
1897 test_SetHostNames(oleobj);
1899 IOleInPlaceObject_Release(inplace);
1900 IOleObject_Release(oleobj);
1903 static void test_ClassInfo(IUnknown *unk)
1905 IProvideClassInfo2 *class_info;
1906 TYPEATTR *type_attr;
1907 ITypeInfo *typeinfo;
1908 GUID guid;
1909 HRESULT hres;
1911 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1912 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
1913 if(FAILED(hres))
1914 return;
1916 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1917 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1918 ok(IsEqualGUID(wb_version > 1 ? &DIID_DWebBrowserEvents2 : &DIID_DWebBrowserEvents, &guid), "wrong guid\n");
1920 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1921 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1922 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1924 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1925 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1926 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1928 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1929 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1931 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1932 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1934 typeinfo = NULL;
1935 hres = IProvideClassInfo2_GetClassInfo(class_info, &typeinfo);
1936 ok(hres == S_OK, "GetClassInfo failed: %08x\n", hres);
1937 ok(typeinfo != NULL, "typeinfo == NULL\n");
1939 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
1940 ok(hres == S_OK, "GetTypeAtr failed: %08x\n", hres);
1942 ok(IsEqualGUID(&type_attr->guid, wb_version > 1 ? &CLSID_WebBrowser : &CLSID_WebBrowser_V1),
1943 "guid = %s\n", debugstr_guid(&type_attr->guid));
1945 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
1946 ITypeInfo_Release(typeinfo);
1948 IProvideClassInfo2_Release(class_info);
1951 static void test_EnumVerbs(IWebBrowser2 *wb)
1953 IEnumOLEVERB *enum_verbs;
1954 IOleObject *oleobj;
1955 OLEVERB verbs[20];
1956 ULONG fetched;
1957 HRESULT hres;
1959 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oleobj);
1960 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
1962 hres = IOleObject_EnumVerbs(oleobj, &enum_verbs);
1963 IOleObject_Release(oleobj);
1964 ok(hres == S_OK, "EnumVerbs failed: %08x\n", hres);
1965 ok(enum_verbs != NULL, "enum_verbs == NULL\n");
1967 fetched = 0xdeadbeef;
1968 hres = IEnumOLEVERB_Next(enum_verbs, sizeof(verbs)/sizeof(*verbs), verbs, &fetched);
1969 ok(hres == S_OK, "Next failed: %08x\n", hres);
1970 ok(!fetched, "fetched = %d\n", fetched);
1972 fetched = 0xdeadbeef;
1973 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
1974 ok(hres == S_OK, "Next failed: %08x\n", hres);
1975 ok(!fetched, "fetched = %d\n", fetched);
1977 hres = IEnumOLEVERB_Reset(enum_verbs);
1978 ok(hres == S_OK, "Reset failed: %08x\n", hres);
1980 fetched = 0xdeadbeef;
1981 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
1982 ok(hres == S_OK, "Next failed: %08x\n", hres);
1983 ok(!fetched, "fetched = %d\n", fetched);
1985 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, NULL);
1986 ok(hres == S_OK, "Next failed: %08x\n", hres);
1988 hres = IEnumOLEVERB_Skip(enum_verbs, 20);
1989 ok(hres == S_OK, "Reset failed: %08x\n", hres);
1991 fetched = 0xdeadbeef;
1992 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
1993 ok(hres == S_OK, "Next failed: %08x\n", hres);
1994 ok(!fetched, "fetched = %d\n", fetched);
1996 IEnumOLEVERB_Release(enum_verbs);
1999 static void test_ie_funcs(IUnknown *unk)
2001 IWebBrowser2 *wb;
2002 IDispatch *disp;
2003 VARIANT_BOOL b;
2004 int i;
2005 LONG hwnd;
2006 HRESULT hres;
2007 BSTR sName;
2009 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2010 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
2011 if(FAILED(hres))
2012 return;
2014 /* HWND */
2016 hwnd = 0xdeadbeef;
2017 hres = IWebBrowser2_get_HWND(wb, &hwnd);
2018 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
2019 ok(hwnd == 0, "unexpected hwnd %x\n", hwnd);
2021 /* MenuBar */
2023 hres = IWebBrowser2_get_MenuBar(wb, &b);
2024 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2025 ok(b == VARIANT_TRUE, "b=%x\n", b);
2027 SET_EXPECT(Invoke_ONMENUBAR);
2028 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
2029 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2030 CHECK_CALLED(Invoke_ONMENUBAR);
2032 hres = IWebBrowser2_get_MenuBar(wb, &b);
2033 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2034 ok(b == VARIANT_FALSE, "b=%x\n", b);
2036 SET_EXPECT(Invoke_ONMENUBAR);
2037 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
2038 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2039 CHECK_CALLED(Invoke_ONMENUBAR);
2041 hres = IWebBrowser2_get_MenuBar(wb, &b);
2042 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2043 ok(b == VARIANT_TRUE, "b=%x\n", b);
2045 /* AddressBar */
2047 hres = IWebBrowser2_get_AddressBar(wb, &b);
2048 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2049 ok(b == VARIANT_TRUE, "b=%x\n", b);
2051 SET_EXPECT(Invoke_ONADDRESSBAR);
2052 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
2053 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2054 CHECK_CALLED(Invoke_ONADDRESSBAR);
2056 hres = IWebBrowser2_get_AddressBar(wb, &b);
2057 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2058 ok(b == VARIANT_FALSE, "b=%x\n", b);
2060 SET_EXPECT(Invoke_ONADDRESSBAR);
2061 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
2062 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2063 CHECK_CALLED(Invoke_ONADDRESSBAR);
2065 hres = IWebBrowser2_get_AddressBar(wb, &b);
2066 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2067 ok(b == VARIANT_TRUE, "b=%x\n", b);
2069 SET_EXPECT(Invoke_ONADDRESSBAR);
2070 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
2071 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2072 CHECK_CALLED(Invoke_ONADDRESSBAR);
2074 /* StatusBar */
2076 hres = IWebBrowser2_get_StatusBar(wb, &b);
2077 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2078 ok(b == VARIANT_TRUE, "b=%x\n", b);
2080 SET_EXPECT(Invoke_ONSTATUSBAR);
2081 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
2082 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2083 CHECK_CALLED(Invoke_ONSTATUSBAR);
2085 hres = IWebBrowser2_get_StatusBar(wb, &b);
2086 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2087 ok(b == VARIANT_TRUE, "b=%x\n", b);
2089 SET_EXPECT(Invoke_ONSTATUSBAR);
2090 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
2091 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2092 CHECK_CALLED(Invoke_ONSTATUSBAR);
2094 hres = IWebBrowser2_get_StatusBar(wb, &b);
2095 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2096 ok(b == VARIANT_FALSE, "b=%x\n", b);
2098 SET_EXPECT(Invoke_ONSTATUSBAR);
2099 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
2100 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2101 CHECK_CALLED(Invoke_ONSTATUSBAR);
2103 hres = IWebBrowser2_get_StatusBar(wb, &b);
2104 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2105 ok(b == VARIANT_TRUE, "b=%x\n", b);
2107 /* ToolBar */
2109 hres = IWebBrowser2_get_ToolBar(wb, &i);
2110 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2111 ok(i, "i=%x\n", i);
2113 SET_EXPECT(Invoke_ONTOOLBAR);
2114 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
2115 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2116 CHECK_CALLED(Invoke_ONTOOLBAR);
2118 hres = IWebBrowser2_get_ToolBar(wb, &i);
2119 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2120 ok(i == VARIANT_FALSE, "b=%x\n", i);
2122 SET_EXPECT(Invoke_ONTOOLBAR);
2123 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
2124 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2125 CHECK_CALLED(Invoke_ONTOOLBAR);
2127 hres = IWebBrowser2_get_ToolBar(wb, &i);
2128 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2129 ok(i, "i=%x\n", i);
2131 SET_EXPECT(Invoke_ONTOOLBAR);
2132 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
2133 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2134 CHECK_CALLED(Invoke_ONTOOLBAR);
2136 /* FullScreen */
2138 hres = IWebBrowser2_get_FullScreen(wb, &b);
2139 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2140 ok(b == VARIANT_FALSE, "b=%x\n", b);
2142 SET_EXPECT(Invoke_ONFULLSCREEN);
2143 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
2144 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2145 CHECK_CALLED(Invoke_ONFULLSCREEN);
2147 hres = IWebBrowser2_get_FullScreen(wb, &b);
2148 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2149 ok(b == VARIANT_TRUE, "b=%x\n", b);
2151 SET_EXPECT(Invoke_ONFULLSCREEN);
2152 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
2153 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2154 CHECK_CALLED(Invoke_ONFULLSCREEN);
2156 hres = IWebBrowser2_get_FullScreen(wb, &b);
2157 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2158 ok(b == VARIANT_TRUE, "b=%x\n", b);
2160 SET_EXPECT(Invoke_ONFULLSCREEN);
2161 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
2162 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2163 CHECK_CALLED(Invoke_ONFULLSCREEN);
2165 /* TheaterMode */
2167 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2168 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2169 ok(b == VARIANT_FALSE, "b=%x\n", b);
2171 SET_EXPECT(Invoke_ONTHEATERMODE);
2172 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
2173 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2174 CHECK_CALLED(Invoke_ONTHEATERMODE);
2176 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2177 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2178 ok(b == VARIANT_TRUE, "b=%x\n", b);
2180 SET_EXPECT(Invoke_ONTHEATERMODE);
2181 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
2182 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2183 CHECK_CALLED(Invoke_ONTHEATERMODE);
2185 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2186 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2187 ok(b == VARIANT_TRUE, "b=%x\n", b);
2189 SET_EXPECT(Invoke_ONTHEATERMODE);
2190 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
2191 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2192 CHECK_CALLED(Invoke_ONTHEATERMODE);
2194 /* Resizable */
2196 b = 0x100;
2197 hres = IWebBrowser2_get_Resizable(wb, &b);
2198 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2199 ok(b == 0x100, "b=%x\n", b);
2201 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2202 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
2203 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2204 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2206 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2207 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
2208 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2209 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2211 hres = IWebBrowser2_get_Resizable(wb, &b);
2212 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2213 ok(b == 0x100, "b=%x\n", b);
2215 /* Application */
2217 disp = NULL;
2218 hres = IWebBrowser2_get_Application(wb, &disp);
2219 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
2220 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
2221 if(disp)
2222 IDispatch_Release(disp);
2224 hres = IWebBrowser2_get_Application(wb, NULL);
2225 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
2227 /* Name */
2228 hres = IWebBrowser2_get_Name(wb, &sName);
2229 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
2230 if (is_lang_english())
2231 ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
2232 else /* Non-English cannot be blank. */
2233 ok(sName!=NULL, "get_Name return a NULL string.\n");
2234 SysFreeString(sName);
2236 /* Quit */
2238 hres = IWebBrowser2_Quit(wb);
2239 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
2241 IWebBrowser2_Release(wb);
2244 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2246 VARIANT_BOOL b;
2247 HRESULT hres;
2249 b = 100;
2250 hres = IWebBrowser2_get_Silent(wb, &b);
2251 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2252 ok(b == VARIANT_FALSE, "b=%x\n", b);
2254 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2255 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2257 b = 100;
2258 hres = IWebBrowser2_get_Silent(wb, &b);
2259 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2260 ok(b == VARIANT_TRUE, "b=%x\n", b);
2262 hres = IWebBrowser2_put_Silent(wb, 100);
2263 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2265 b = 100;
2266 hres = IWebBrowser2_get_Silent(wb, &b);
2267 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2268 ok(b == VARIANT_TRUE, "b=%x\n", b);
2270 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
2271 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2273 b = 100;
2274 hres = IWebBrowser2_get_Silent(wb, &b);
2275 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2276 ok(b == VARIANT_FALSE, "b=%x\n", b);
2278 if(is_clientsite) {
2279 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2280 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2282 SET_EXPECT(Invoke_AMBIENT_SILENT);
2285 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2286 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2288 if(is_clientsite)
2289 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2291 b = 100;
2292 hres = IWebBrowser2_get_Silent(wb, &b);
2293 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2294 ok(b == VARIANT_FALSE, "b=%x\n", b);
2297 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2299 VARIANT_BOOL b;
2300 HRESULT hres;
2302 b = 100;
2303 hres = IWebBrowser2_get_Offline(wb, &b);
2304 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2305 ok(b == VARIANT_FALSE, "b=%x\n", b);
2307 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2308 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2310 b = 100;
2311 hres = IWebBrowser2_get_Offline(wb, &b);
2312 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2313 ok(b == VARIANT_TRUE, "b=%x\n", b);
2315 hres = IWebBrowser2_put_Offline(wb, 100);
2316 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2318 b = 100;
2319 hres = IWebBrowser2_get_Offline(wb, &b);
2320 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2321 ok(b == VARIANT_TRUE, "b=%x\n", b);
2323 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
2324 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2326 b = 100;
2327 hres = IWebBrowser2_get_Offline(wb, &b);
2328 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2329 ok(b == VARIANT_FALSE, "b=%x\n", b);
2331 if(is_clientsite) {
2332 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2333 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2335 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2338 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2339 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2341 if(is_clientsite)
2342 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2344 b = 100;
2345 hres = IWebBrowser2_get_Offline(wb, &b);
2346 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2347 ok(b == VARIANT_FALSE, "b=%x\n", b);
2350 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2352 HRESULT hres;
2354 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2355 SET_EXPECT(Invoke_AMBIENT_SILENT);
2356 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2357 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2358 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2359 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2361 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
2362 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2364 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2365 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
2366 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
2367 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
2368 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2369 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2371 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2372 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2373 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2374 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2375 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2376 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2379 static void test_wb_funcs(IUnknown *unk, BOOL is_clientsite)
2381 IWebBrowser2 *wb;
2382 IOleControl *control;
2383 HRESULT hres;
2385 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2386 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
2388 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2389 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2391 test_Silent(wb, control, is_clientsite);
2392 test_Offline(wb, control, is_clientsite);
2393 test_ambient_unknown(wb, control, is_clientsite);
2395 IWebBrowser_Release(wb);
2396 IOleControl_Release(control);
2399 static void test_GetControlInfo(IUnknown *unk)
2401 IOleControl *control;
2402 CONTROLINFO info;
2403 HRESULT hres;
2405 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2406 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2407 if(FAILED(hres))
2408 return;
2410 hres = IOleControl_GetControlInfo(control, &info);
2411 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2412 hres = IOleControl_GetControlInfo(control, NULL);
2413 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2415 IOleControl_Release(control);
2418 static void test_Extent(IUnknown *unk)
2420 IOleObject *oleobj;
2421 SIZE size, expected;
2422 HRESULT hres;
2423 DWORD dpi_x;
2424 DWORD dpi_y;
2425 HDC hdc;
2427 /* default aspect ratio is 96dpi / 96dpi */
2428 hdc = GetDC(0);
2429 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2430 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2431 ReleaseDC(0, hdc);
2432 if (dpi_x != 96 || dpi_y != 96)
2433 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2435 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2436 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2437 if(FAILED(hres))
2438 return;
2440 size.cx = size.cy = 0xdeadbeef;
2441 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2442 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2443 /* Default size is 50x20 pixels, in himetric units */
2444 expected.cx = MulDiv( 50, 2540, dpi_x );
2445 expected.cy = MulDiv( 20, 2540, dpi_y );
2446 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2447 size.cx, size.cy, expected.cx, expected.cy );
2449 size.cx = 800;
2450 size.cy = 700;
2451 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2452 ok(hres == S_OK, "SetExtent failed: %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 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2459 size.cx = size.cy = 0xdeadbeef;
2460 hres = IOleObject_GetExtent(oleobj, 0, &size);
2461 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2462 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2464 size.cx = 900;
2465 size.cy = 800;
2466 hres = IOleObject_SetExtent(oleobj, 0, &size);
2467 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2469 size.cx = size.cy = 0xdeadbeef;
2470 hres = IOleObject_GetExtent(oleobj, 0, &size);
2471 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2472 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2474 size.cx = size.cy = 0xdeadbeef;
2475 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2476 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2477 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2479 size.cx = 1000;
2480 size.cy = 900;
2481 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2482 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2484 size.cx = size.cy = 0xdeadbeef;
2485 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2486 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2487 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2489 size.cx = size.cy = 0xdeadbeef;
2490 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2491 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2492 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2494 IOleObject_Release(oleobj);
2497 static void test_ConnectionPoint(IUnknown *unk, BOOL init)
2499 IConnectionPointContainer *container;
2500 IConnectionPoint *point;
2501 HRESULT hres;
2503 static DWORD dw = 100;
2505 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2506 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2507 if(FAILED(hres))
2508 return;
2510 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2511 IConnectionPointContainer_Release(container);
2512 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2513 if(FAILED(hres))
2514 return;
2516 if(init) {
2517 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2518 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2519 ok(dw == 1, "dw=%d, expected 1\n", dw);
2520 }else {
2521 hres = IConnectionPoint_Unadvise(point, dw);
2522 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2525 IConnectionPoint_Release(point);
2528 static void test_Navigate2(IUnknown *unk, const char *nav_url)
2530 IWebBrowser2 *webbrowser;
2531 VARIANT url;
2532 HRESULT hres;
2534 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&webbrowser);
2535 ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
2536 if(FAILED(hres))
2537 return;
2539 test_LocationURL(unk, is_first_load ? "" : current_url);
2540 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2542 is_http = !memcmp(nav_url, "http:", 5);
2543 V_VT(&url) = VT_BSTR;
2544 V_BSTR(&url) = a2bstr(current_url = nav_url);
2546 if(is_first_load) {
2547 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2548 SET_EXPECT(Invoke_PROPERTYCHANGE);
2549 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2550 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2551 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2552 SET_EXPECT(EnableModeless_FALSE);
2553 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2554 SET_EXPECT(SetStatusText);
2555 if(use_container_dochostui)
2556 SET_EXPECT(GetHostInfo);
2557 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2558 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2559 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2560 if(use_container_dochostui) {
2561 SET_EXPECT(GetOptionKeyPath);
2562 SET_EXPECT(GetOverridesKeyPath);
2564 if (use_container_olecmd) SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2565 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSMAX);
2566 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSPOS);
2567 SET_EXPECT(Invoke_SETSECURELOCKICON);
2568 SET_EXPECT(Invoke_FILEDOWNLOAD);
2569 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2570 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2571 SET_EXPECT(EnableModeless_TRUE);
2572 if (!use_container_olecmd) SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2575 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2576 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2578 if(is_first_load) {
2579 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2580 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2581 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2582 todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2583 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2584 CHECK_CALLED(EnableModeless_FALSE);
2585 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2586 CHECK_CALLED(SetStatusText);
2587 if(use_container_dochostui)
2588 CHECK_CALLED(GetHostInfo);
2589 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2590 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2591 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* Not called by IE9 */
2592 if(use_container_dochostui) {
2593 CLEAR_CALLED(GetOptionKeyPath);
2594 CHECK_CALLED(GetOverridesKeyPath);
2596 if (use_container_olecmd) todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2597 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2598 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2599 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2600 todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
2601 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2602 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2603 CHECK_CALLED(EnableModeless_TRUE);
2606 VariantClear(&url);
2607 IWebBrowser2_Release(webbrowser);
2609 test_ready_state(READYSTATE_LOADING);
2612 static void test_QueryStatusWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2614 HRESULT hres, success_state;
2615 OLECMDF success_flags;
2616 enum OLECMDF status;
2619 * We can tell the difference between the custom container target and the built-in target
2620 * since the custom target returns OLECMDF_SUPPORTED instead of OLECMDF_ENABLED.
2622 if (use_custom_target)
2623 success_flags = OLECMDF_SUPPORTED;
2624 else
2625 success_flags = OLECMDF_ENABLED;
2627 /* When no target is available (no document or custom target) an error is returned */
2628 if (has_document)
2629 success_state = S_OK;
2630 else
2631 success_state = E_UNEXPECTED;
2634 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2635 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2636 * is enabled and IDM_STOP is not.
2638 status = 0xdeadbeef;
2639 if (use_custom_target) SET_EXPECT(QueryStatus_STOP);
2640 hres = IWebBrowser2_QueryStatusWB(webbrowser, OLECMDID_STOP, &status);
2641 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2642 if (!use_custom_target && has_document)
2643 todo_wine ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2644 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2645 else
2646 ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2647 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2648 status = 0xdeadbeef;
2649 if (use_custom_target) SET_EXPECT(QueryStatus_IDM_STOP);
2650 hres = IWebBrowser2_QueryStatusWB(webbrowser, IDM_STOP, &status);
2651 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2652 ok((has_document && status == 0) || (!has_document && status == 0xdeadbeef),
2653 "IDM_STOP is enabled/supported: %08x %d\n", status, has_document);
2656 static void test_ExecWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2658 HRESULT hres, olecmdid_state, idm_state;
2660 /* When no target is available (no document or custom target) an error is returned */
2661 if (has_document)
2663 olecmdid_state = S_OK;
2664 idm_state = OLECMDERR_E_NOTSUPPORTED;
2666 else
2668 olecmdid_state = E_UNEXPECTED;
2669 idm_state = E_UNEXPECTED;
2673 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2674 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2675 * succeeds (S_OK) and IDM_STOP does not (OLECMDERR_E_NOTSUPPORTED).
2677 if(use_custom_target) {
2678 SET_EXPECT(Exec_STOP);
2679 }else if(has_document) {
2680 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2681 SET_EXPECT(SetStatusText);
2683 hres = IWebBrowser2_ExecWB(webbrowser, OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2684 if(!use_custom_target && has_document) {
2685 todo_wine ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2686 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2687 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
2688 }else {
2689 ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2691 if (use_custom_target)
2692 SET_EXPECT(Exec_IDM_STOP);
2693 hres = IWebBrowser2_ExecWB(webbrowser, IDM_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2694 ok(hres == idm_state, "ExecWB failed: %08x %08x\n", hres, idm_state);
2697 static void test_download(DWORD flags)
2699 MSG msg;
2701 is_downloading = TRUE;
2702 dwl_flags = flags;
2704 test_ready_state((flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2706 if((is_http && !(flags & DWL_FROM_GOBACK)) || (flags & DWL_EXPECT_BEFORE_NAVIGATE))
2707 SET_EXPECT(Invoke_PROPERTYCHANGE);
2709 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2710 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2711 SET_EXPECT(TranslateUrl);
2713 SET_EXPECT(Exec_SETPROGRESSMAX);
2714 SET_EXPECT(Exec_SETPROGRESSPOS);
2715 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2716 SET_EXPECT(DocHost_EnableModeless_FALSE);
2717 SET_EXPECT(DocHost_EnableModeless_TRUE);
2718 SET_EXPECT(Invoke_SETSECURELOCKICON);
2719 SET_EXPECT(Invoke_282);
2720 SET_EXPECT(EnableModeless_FALSE);
2721 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2722 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2723 SET_EXPECT(SetStatusText);
2724 SET_EXPECT(EnableModeless_TRUE);
2725 if(!is_first_load)
2726 SET_EXPECT(GetHostInfo);
2727 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2728 SET_EXPECT(Invoke_TITLECHANGE);
2729 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2730 if(is_first_load)
2731 SET_EXPECT(GetDropTarget);
2732 SET_EXPECT(Invoke_PROGRESSCHANGE);
2733 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2735 if(flags & DWL_HTTP)
2736 SET_EXPECT(Exec_SETTITLE);
2737 SET_EXPECT(UpdateUI);
2738 SET_EXPECT(Exec_UPDATECOMMANDS);
2739 SET_EXPECT(QueryStatus_STOP);
2741 while(!called_Invoke_DOCUMENTCOMPLETE && GetMessage(&msg, NULL, 0, 0)) {
2742 TranslateMessage(&msg);
2743 DispatchMessage(&msg);
2746 if((is_http && !(flags & DWL_FROM_GOBACK)) || (flags & DWL_EXPECT_BEFORE_NAVIGATE))
2747 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2749 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2750 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2751 CHECK_CALLED(TranslateUrl);
2753 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2754 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2755 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2756 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
2757 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
2758 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2759 CLEAR_CALLED(Invoke_282); /* IE 7 */
2760 if(is_first_load)
2761 todo_wine CHECK_CALLED(EnableModeless_FALSE);
2762 else
2763 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2764 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE);
2765 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2766 todo_wine CHECK_CALLED(SetStatusText);
2767 if(is_first_load)
2768 todo_wine CHECK_CALLED(EnableModeless_TRUE);
2769 else
2770 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2771 if(!is_first_load)
2772 todo_wine CHECK_CALLED(GetHostInfo);
2773 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2774 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
2775 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
2776 if(is_first_load)
2777 todo_wine CHECK_CALLED(GetDropTarget);
2778 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2779 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
2781 is_downloading = FALSE;
2783 test_ready_state(READYSTATE_COMPLETE);
2785 while(!called_Exec_UPDATECOMMANDS && GetMessage(&msg, NULL, 0, 0)) {
2786 TranslateMessage(&msg);
2787 DispatchMessage(&msg);
2790 if(flags & DWL_HTTP)
2791 CLEAR_CALLED(Exec_SETTITLE); /* FIXME: make it more strict */
2792 CHECK_CALLED(UpdateUI);
2793 CHECK_CALLED(Exec_UPDATECOMMANDS);
2794 CLEAR_CALLED(QueryStatus_STOP);
2797 static void test_olecmd(IUnknown *unk, BOOL loaded)
2799 IOleCommandTarget *cmdtrg;
2800 OLECMD cmds[3];
2801 HRESULT hres;
2803 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2804 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
2805 if(FAILED(hres))
2806 return;
2808 cmds[0].cmdID = OLECMDID_SPELL;
2809 cmds[0].cmdf = 0xdeadbeef;
2810 cmds[1].cmdID = OLECMDID_REFRESH;
2811 cmds[1].cmdf = 0xdeadbeef;
2812 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
2813 if(loaded) {
2814 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2815 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2816 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
2817 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
2818 }else {
2819 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
2820 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2821 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
2824 IOleCommandTarget_Release(cmdtrg);
2827 static void test_IServiceProvider(IUnknown *unk)
2829 IServiceProvider *servprov = (void*)0xdeadbeef;
2830 IUnknown *iface;
2831 HRESULT hres;
2833 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
2834 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
2835 if(FAILED(hres))
2836 return;
2838 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&iface);
2839 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
2840 ok(!iface, "QueryService returned %p, expected NULL\n", iface);
2841 if(hres == S_OK)
2842 IUnknown_Release(iface);
2844 hres = IServiceProvider_QueryService(servprov, &SID_SHTMLWindow, &IID_IHTMLWindow2, (LPVOID*)&iface);
2845 ok(hres == S_OK, "QueryService returned %08x, expected S_OK\n", hres);
2846 ok(iface != NULL, "QueryService returned NULL\n");
2847 if(hres == S_OK)
2848 IUnknown_Release(iface);
2850 IServiceProvider_Release(servprov);
2853 static void test_put_href(IUnknown *unk, const char *url)
2855 IHTMLLocation *location;
2856 IHTMLDocument2 *doc;
2857 IDispatch *doc_disp;
2858 BSTR str;
2859 HRESULT hres;
2861 doc_disp = get_document(unk);
2863 hres = IDispatch_QueryInterface(doc_disp, &IID_IHTMLDocument2, (void**)&doc);
2864 IDispatch_Release(doc_disp);
2865 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2 failed: %08x\n", hres);
2867 location = NULL;
2868 hres = IHTMLDocument2_get_location(doc, &location);
2869 IHTMLDocument2_Release(doc);
2870 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2871 ok(location != NULL, "location == NULL\n");
2873 SET_EXPECT(TranslateUrl);
2874 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2875 if(!is_http)
2876 SET_EXPECT(Invoke_PROPERTYCHANGE);
2878 dwl_flags = DWL_FROM_PUT_HREF;
2880 is_http = !memcmp(url, "http:", 5);
2881 str = a2bstr(current_url = url);
2882 is_first_load = FALSE;
2883 hres = IHTMLLocation_put_href(location, str);
2885 CHECK_CALLED(TranslateUrl);
2886 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2887 if(!is_http)
2888 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2890 IHTMLLocation_Release(location);
2891 SysFreeString(str);
2892 ok(hres == S_OK, "put_href failed: %08x\n", hres);
2894 test_ready_state(READYSTATE_COMPLETE);
2897 static void test_go_back(IUnknown *unk, const char *back_url)
2899 IWebBrowser2 *wb;
2900 HRESULT hres;
2902 current_url = back_url;
2904 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2905 ok(hres == S_OK, "Could not get IWebBrowser2 iface: %08x\n", hres);
2907 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2908 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2909 hres = IWebBrowser2_GoBack(wb);
2910 ok(hres == S_OK, "GoBack failed: %08x\n", hres);
2911 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2912 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2914 IWebBrowser2_Release(wb);
2917 static void test_QueryInterface(IUnknown *unk)
2919 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
2920 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
2921 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
2922 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
2923 IOleCache *cache = (void*)0xdeadbeef;
2924 IObjectWithSite *site = (void*)0xdeadbeef;
2925 IViewObjectEx *viewex = (void*)0xdeadbeef;
2926 IOleLink *link = (void*)0xdeadbeef;
2927 IMarshal *marshal = (void*)0xdeadbeef;
2928 IStdMarshalInfo *marshalinfo = (void*)0xdeadbeef;
2929 HRESULT hres;
2931 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
2932 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2933 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
2935 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
2936 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2937 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
2939 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
2940 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2941 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
2943 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
2944 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2945 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
2947 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
2948 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2949 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
2951 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2952 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2953 ok(site == NULL, "site=%p, expected NULL\n", site);
2955 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
2956 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2957 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
2959 hres = IUnknown_QueryInterface(unk, &IID_IOleLink, (void**)&link);
2960 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2961 ok(link == NULL, "link=%p, expected NULL\n", link);
2963 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&marshal);
2964 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2965 ok(marshal == NULL, "marshal=%p, expected NULL\n", marshal);
2967 hres = IUnknown_QueryInterface(unk, &IID_IStdMarshalInfo, (void**)&marshalinfo);
2968 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2969 ok(marshalinfo == NULL, "marshalinfo=%p, expected NULL\n", marshalinfo);
2973 static void test_UIActivate(IUnknown *unk, BOOL activate)
2975 IOleDocumentView *docview;
2976 IDispatch *disp;
2977 HRESULT hres;
2979 disp = get_document(unk);
2981 hres = IDispatch_QueryInterface(disp, &IID_IOleDocumentView, (void**)&docview);
2982 ok(hres == S_OK, "Got 0x%08x\n", hres);
2983 if(SUCCEEDED(hres)) {
2984 if(activate) {
2985 SET_EXPECT(RequestUIActivate);
2986 SET_EXPECT(ShowUI);
2987 SET_EXPECT(HideUI);
2988 SET_EXPECT(OnFocus);
2991 hres = IOleDocumentView_UIActivate(docview, activate);
2992 if(activate)
2993 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
2994 else
2995 ok(hres == S_OK, "Got 0x%08x\n", hres);
2997 if(activate) {
2998 todo_wine {
2999 CHECK_CALLED(RequestUIActivate);
3000 CHECK_CALLED(ShowUI);
3001 CHECK_CALLED(HideUI);
3002 CHECK_CALLED(OnFocus);
3006 IOleDocumentView_Release(docview);
3009 IDispatch_Release(disp);
3012 static void test_external(IUnknown *unk)
3014 IDocHostUIHandler2 *dochost;
3015 IOleClientSite *client;
3016 IDispatch *disp;
3017 HRESULT hres;
3019 client = get_dochost(unk);
3021 hres = IOleClientSite_QueryInterface(client, &IID_IDocHostUIHandler2, (void**)&dochost);
3022 ok(hres == S_OK, "Could not get IDocHostUIHandler2 iface: %08x\n", hres);
3023 IOleClientSite_Release(client);
3025 if(use_container_dochostui)
3026 SET_EXPECT(GetExternal);
3027 disp = (void*)0xdeadbeef;
3028 hres = IDocHostUIHandler2_GetExternal(dochost, &disp);
3029 if(use_container_dochostui) {
3030 CHECK_CALLED(GetExternal);
3031 ok(hres == S_FALSE, "GetExternal failed: %08x\n", hres);
3032 ok(!disp, "disp = %p\n", disp);
3033 }else {
3034 IShellUIHelper *uihelper;
3036 ok(hres == S_OK, "GetExternal failed: %08x\n", hres);
3037 ok(disp != NULL, "disp == NULL\n");
3039 hres = IDispatch_QueryInterface(disp, &IID_IShellUIHelper, (void**)&uihelper);
3040 ok(hres == S_OK, "Could not get IShellUIHelper iface: %08x\n", hres);
3041 IShellUIHelper_Release(uihelper);
3044 IDocHostUIHandler2_Release(dochost);
3047 static void test_TranslateAccelerator(IUnknown *unk)
3049 IOleClientSite *doc_clientsite;
3050 IOleInPlaceActiveObject *pao;
3051 HRESULT hres;
3052 DWORD keycode;
3053 MSG msg_a = {
3054 container_hwnd,
3055 0, 0, 0,
3056 GetTickCount(),
3057 {5, 5}
3060 test_Navigate2(unk, "about:blank");
3062 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3063 ok(hres == S_OK, "Got 0x%08x\n", hres);
3064 if(SUCCEEDED(hres)) {
3065 /* One accelerator that should be handled by mshtml */
3066 msg_a.message = WM_KEYDOWN;
3067 msg_a.wParam = VK_F1;
3068 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3069 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3071 /* And one that should not */
3072 msg_a.message = WM_KEYDOWN;
3073 msg_a.wParam = VK_F5;
3074 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3075 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3077 IOleInPlaceActiveObject_Release(pao);
3080 test_UIActivate(unk, TRUE);
3082 /* Test again after UIActivate */
3083 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3084 ok(hres == S_OK, "Got 0x%08x\n", hres);
3085 if(SUCCEEDED(hres)) {
3086 /* One accelerator that should be handled by mshtml */
3087 msg_a.message = WM_KEYDOWN;
3088 msg_a.wParam = VK_F1;
3089 SET_EXPECT(DocHost_TranslateAccelerator);
3090 SET_EXPECT(ControlSite_TranslateAccelerator);
3091 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3092 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3093 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3094 todo_wine CHECK_CALLED(ControlSite_TranslateAccelerator);
3096 /* And one that should not */
3097 msg_a.message = WM_KEYDOWN;
3098 msg_a.wParam = VK_F5;
3099 SET_EXPECT(DocHost_TranslateAccelerator);
3100 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3101 todo_wine ok(hres == S_OK, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3102 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3104 IOleInPlaceActiveObject_Release(pao);
3107 doc_clientsite = get_dochost(unk);
3108 if(doc_clientsite) {
3109 IDocHostUIHandler2 *dochost;
3110 IOleControlSite *doc_controlsite;
3111 IUnknown *unk_test;
3113 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleInPlaceFrame, (void**)&unk_test);
3114 ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
3115 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3117 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostShowUI, (void**)&unk_test);
3118 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
3119 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3121 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler, (void**)&unk_test);
3122 ok(hres == S_OK, "Got 0x%08x\n", hres);
3123 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3125 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler2, (void**)&dochost);
3126 ok(hres == S_OK, "Got 0x%08x\n", hres);
3127 if(SUCCEEDED(hres)) {
3128 msg_a.message = WM_KEYDOWN;
3129 hr_dochost_TranslateAccelerator = 0xdeadbeef;
3130 for(keycode = 0; keycode <= 0x100; keycode++) {
3131 msg_a.wParam = keycode;
3132 SET_EXPECT(DocHost_TranslateAccelerator);
3133 hres = IDocHostUIHandler_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3134 ok(hres == 0xdeadbeef, "Got 0x%08x\n", hres);
3135 CHECK_CALLED(DocHost_TranslateAccelerator);
3137 hr_dochost_TranslateAccelerator = E_NOTIMPL;
3139 SET_EXPECT(DocHost_TranslateAccelerator);
3140 hres = IDocHostUIHandler_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3141 ok(hres == E_NOTIMPL, "Got 0x%08x\n", hres);
3142 CHECK_CALLED(DocHost_TranslateAccelerator);
3144 IDocHostUIHandler2_Release(dochost);
3147 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleControlSite, (void**)&doc_controlsite);
3148 ok(hres == S_OK, "Got 0x%08x\n", hres);
3149 if(SUCCEEDED(hres)) {
3150 msg_a.message = WM_KEYDOWN;
3151 hr_site_TranslateAccelerator = 0xdeadbeef;
3152 for(keycode = 0; keycode < 0x100; keycode++) {
3153 msg_a.wParam = keycode;
3154 SET_EXPECT(ControlSite_TranslateAccelerator);
3155 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3156 if(keycode == 0x9 || keycode == 0x75)
3157 todo_wine ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3158 else
3159 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3161 CHECK_CALLED(ControlSite_TranslateAccelerator);
3163 msg_a.wParam = VK_LEFT;
3164 SET_EXPECT(ControlSite_TranslateAccelerator);
3165 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3166 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3167 CHECK_CALLED(ControlSite_TranslateAccelerator);
3169 hr_site_TranslateAccelerator = S_OK;
3170 SET_EXPECT(ControlSite_TranslateAccelerator);
3171 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3172 ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3173 CHECK_CALLED(ControlSite_TranslateAccelerator);
3175 hr_site_TranslateAccelerator = E_NOTIMPL;
3176 SET_EXPECT(ControlSite_TranslateAccelerator);
3177 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3178 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3179 CHECK_CALLED(ControlSite_TranslateAccelerator);
3181 IOleControlSite_Release(doc_controlsite);
3184 IOleClientSite_Release(doc_clientsite);
3187 test_UIActivate(unk, FALSE);
3190 static void test_dochost_qs(IUnknown *unk)
3192 IOleClientSite *client_site;
3193 IServiceProvider *serv_prov;
3194 IUnknown *service;
3195 HRESULT hres;
3197 client_site = get_dochost(unk);
3198 hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
3199 IOleClientSite_Release(client_site);
3200 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
3202 hres = IServiceProvider_QueryService(serv_prov, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&service);
3203 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3204 ok(iface_cmp(service, unk), "service != unk\n");
3205 IUnknown_Release(service);
3207 hres = IServiceProvider_QueryService(serv_prov, &IID_IWebBrowserApp, &IID_IHlinkFrame, (void**)&service);
3208 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3209 ok(iface_cmp(service, unk), "service != unk\n");
3210 IUnknown_Release(service);
3212 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IShellBrowser, (void**)&service);
3213 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3214 IUnknown_Release(service);
3216 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IBrowserService, (void**)&service);
3217 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3218 IUnknown_Release(service);
3220 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IDocObjectService, (void**)&service);
3221 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3222 IUnknown_Release(service);
3224 IServiceProvider_Release(serv_prov);
3227 static void test_Close(IWebBrowser2 *wb, BOOL do_download)
3229 IOleObject *oo;
3230 IOleClientSite *ocs;
3231 HRESULT hres;
3233 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oo);
3234 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3235 if(hres != S_OK)
3236 return;
3238 test_close = TRUE;
3240 SET_EXPECT(Frame_SetActiveObject);
3241 SET_EXPECT(UIWindow_SetActiveObject);
3242 SET_EXPECT(OnUIDeactivate);
3243 SET_EXPECT(OnFocus);
3244 SET_EXPECT(OnInPlaceDeactivate);
3245 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
3246 if(!do_download) {
3247 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
3248 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3250 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3251 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3252 CHECK_CALLED(Frame_SetActiveObject);
3253 CHECK_CALLED(UIWindow_SetActiveObject);
3254 CHECK_CALLED(OnUIDeactivate);
3255 todo_wine CHECK_CALLED(OnFocus);
3256 CHECK_CALLED(OnInPlaceDeactivate);
3257 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
3258 if(!do_download) {
3259 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
3260 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3263 hres = IOleObject_GetClientSite(oo, &ocs);
3264 ok(hres == S_OK, "hres = %x\n", hres);
3265 ok(!ocs, "ocs != NULL\n");
3267 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3268 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3270 test_close = FALSE;
3271 IOleObject_Release(oo);
3274 static void test_WebBrowser(BOOL do_download, BOOL do_close)
3276 IUnknown *unk = NULL;
3277 ULONG ref;
3278 HRESULT hres;
3280 if (FAILED(create_WebBrowser(&unk)))
3281 return;
3283 is_downloading = FALSE;
3284 is_first_load = TRUE;
3285 use_container_olecmd = TRUE;
3286 use_container_dochostui = TRUE;
3288 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
3289 ok(hres == S_OK, "Could not get IWebBrowser2 iface: %08x\n", hres);
3291 test_QueryStatusWB(wb, FALSE, FALSE);
3292 test_ExecWB(wb, FALSE, FALSE);
3293 test_QueryInterface(unk);
3294 test_ready_state(READYSTATE_UNINITIALIZED);
3295 test_ClassInfo(unk);
3296 test_EnumVerbs(wb);
3297 test_LocationURL(unk, "");
3298 test_ConnectionPoint(unk, TRUE);
3299 test_ClientSite(unk, &ClientSite, !do_download);
3300 test_Extent(unk);
3301 test_wb_funcs(unk, TRUE);
3302 test_DoVerb(unk);
3303 test_olecmd(unk, FALSE);
3304 test_Navigate2(unk, "about:blank");
3305 test_QueryStatusWB(wb, TRUE, TRUE);
3306 test_ExecWB(wb, TRUE, TRUE);
3308 if(do_download) {
3309 IDispatch *doc, *doc2;
3311 test_download(0);
3312 test_olecmd(unk, TRUE);
3313 doc = get_document(unk);
3315 test_put_href(unk, "about:test");
3316 test_download(DWL_FROM_PUT_HREF);
3317 doc2 = get_document(unk);
3318 ok(doc == doc2, "doc != doc2\n");
3319 IDispatch_Release(doc2);
3321 trace("Navigate2 repeated...\n");
3322 test_Navigate2(unk, "about:blank");
3323 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3324 doc2 = get_document(unk);
3325 ok(doc == doc2, "doc != doc2\n");
3326 IDispatch_Release(doc2);
3327 IDispatch_Release(doc);
3329 if(!do_close) {
3330 trace("Navigate2 http URL...\n");
3331 test_ready_state(READYSTATE_COMPLETE);
3332 test_Navigate2(unk, "http://test.winehq.org/tests/hello.html");
3333 test_download(DWL_EXPECT_BEFORE_NAVIGATE|DWL_HTTP);
3335 trace("put_href http URL...\n");
3336 test_put_href(unk, "http://www.winehq.org/");
3337 test_download(DWL_FROM_PUT_HREF|DWL_HTTP);
3339 trace("GoBack...\n");
3340 test_go_back(unk, "http://test.winehq.org/tests/hello.html");
3341 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3344 test_EnumVerbs(wb);
3345 test_TranslateAccelerator(unk);
3347 test_dochost_qs(unk);
3350 test_external(unk);
3352 if(do_close)
3353 test_Close(wb, do_download);
3354 else
3355 test_ClientSite(unk, NULL, !do_download);
3356 test_ie_funcs(unk);
3357 test_GetControlInfo(unk);
3358 test_wb_funcs(unk, FALSE);
3359 test_ConnectionPoint(unk, FALSE);
3360 test_IServiceProvider(unk);
3362 IWebBrowser2_Release(wb);
3363 ref = IUnknown_Release(unk);
3364 ok(ref == 0 || broken(do_download && !do_close && ref == 1), "ref=%d, expected 0\n", ref);
3367 static void test_WebBrowserV1(void)
3369 IWebBrowser2 *wb;
3370 ULONG ref;
3371 HRESULT hres;
3373 wb_version = 1;
3375 hres = CoCreateInstance(&CLSID_WebBrowser_V1, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3376 &IID_IWebBrowser2, (void**)&wb);
3377 ok(hres == S_OK, "Could not get WebBrowserV1 instance: %08x\n", hres);
3379 test_QueryStatusWB(wb, FALSE, FALSE);
3380 test_ExecWB(wb, FALSE, FALSE);
3381 test_QueryInterface((IUnknown*)wb);
3382 test_ready_state(READYSTATE_UNINITIALIZED);
3383 test_ClassInfo((IUnknown*)wb);
3384 test_EnumVerbs(wb);
3386 ref = IWebBrowser2_Release(wb);
3387 ok(ref == 0, "ref=%d, expected 0\n", ref);
3390 static void test_WebBrowser_slim_container(void)
3392 IUnknown *unk = NULL;
3393 HRESULT hres;
3394 ULONG ref;
3396 is_downloading = FALSE;
3397 is_first_load = TRUE;
3398 use_container_olecmd = FALSE;
3399 use_container_dochostui = FALSE;
3401 /* Setup stage */
3402 if (FAILED(create_WebBrowser(&unk)))
3403 return;
3404 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
3405 ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
3406 if(FAILED(hres))
3407 return;
3408 test_ConnectionPoint(unk, TRUE);
3409 test_ClientSite(unk, &ClientSite, TRUE);
3410 test_DoVerb(unk);
3411 test_Navigate2(unk, "about:blank");
3413 /* Tests of interest */
3414 test_QueryStatusWB(wb, FALSE, TRUE);
3415 test_ExecWB(wb, FALSE, TRUE);
3416 test_external(unk);
3418 /* Cleanup stage */
3419 IWebBrowser2_Release(wb);
3420 test_ClientSite(unk, NULL, TRUE);
3421 test_ConnectionPoint(unk, FALSE);
3422 ref = IUnknown_Release(unk);
3423 ok(ref == 0, "ref=%d, expected 0\n", ref);
3426 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
3427 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
3428 static BOOL is_ie_hardened(void)
3430 HKEY zone_map;
3431 DWORD ie_harden, type, size;
3433 ie_harden = 0;
3434 if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
3435 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
3436 size = sizeof(DWORD);
3437 if (RegQueryValueEx(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
3438 type != REG_DWORD) {
3439 ie_harden = 0;
3441 RegCloseKey(zone_map);
3444 return ie_harden != 0;
3447 START_TEST(webbrowser)
3449 OleInitialize(NULL);
3451 container_hwnd = create_container_window();
3453 trace("Testing WebBrowser (no download)...\n");
3454 test_WebBrowser(FALSE, FALSE);
3455 test_WebBrowser(FALSE, TRUE);
3457 if(!is_ie_hardened()) {
3458 trace("Testing WebBrowser...\n");
3459 test_WebBrowser(TRUE, FALSE);
3460 }else {
3461 win_skip("Skipping http tests in hardened mode\n");
3464 trace("Testing WebBrowser (with close)...\n");
3465 test_WebBrowser(TRUE, TRUE);
3466 trace("Testing WebBrowser w/o container-based olecmd...\n");
3467 test_WebBrowser_slim_container();
3468 trace("Testing WebBrowserV1...\n");
3469 test_WebBrowserV1();
3471 OleUninitialize();