quartz: Free two assert calls from having side effects.
[wine/testsucceed.git] / dlls / ieframe / tests / webbrowser.c
blob6d414622982ab44b0b4535cc13ce4036f588be7e
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);
144 static const WCHAR wszItem[] = {'i','t','e','m',0};
145 static const WCHAR emptyW[] = {0};
147 static VARIANT_BOOL exvb;
149 static IWebBrowser2 *wb;
151 static HWND container_hwnd, shell_embedding_hwnd;
152 static BOOL is_downloading, is_first_load, use_container_olecmd, test_close;
153 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
154 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
155 static const char *current_url;
157 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
158 #define DWL_FROM_PUT_HREF 0x02
160 static DWORD dwl_flags;
163 /* Returns true if the user interface is in English. Note that this does not
164 * presume of the formatting of dates, numbers, etc.
166 static BOOL is_lang_english(void)
168 static HMODULE hkernel32 = NULL;
169 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
170 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
172 if (!hkernel32)
174 hkernel32 = GetModuleHandleA("kernel32.dll");
175 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
176 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
178 if (pGetThreadUILanguage)
179 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
180 if (pGetUserDefaultUILanguage)
181 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
183 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
186 static int strcmp_wa(LPCWSTR strw, const char *stra)
188 CHAR buf[512];
189 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
190 return lstrcmpA(stra, buf);
193 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
195 IUnknown *unk1, *unk2;
197 if(iface1 == iface2)
198 return TRUE;
200 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
201 IUnknown_Release(unk1);
202 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
203 IUnknown_Release(unk2);
205 return unk1 == unk2;
208 static const char *debugstr_guid(REFIID riid)
210 static char buf[50];
212 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
213 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
214 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
215 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
217 return buf;
220 static BSTR a2bstr(const char *str)
222 BSTR ret;
223 int len;
225 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
226 ret = SysAllocStringLen(NULL, len);
227 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
229 return ret;
232 #define create_WebBrowser(a) _create_WebBrowser(__LINE__,a)
233 static HRESULT _create_WebBrowser(unsigned line, IUnknown **unk)
235 HRESULT hres;
237 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
238 &IID_IUnknown, (void**)unk);
239 ok_(__FILE__,line)(hres == S_OK, "Creating WebBrowser object failed: %08x\n", hres);
240 return hres;
243 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
244 static void _test_LocationURL(unsigned line, IUnknown *unk, const char *exurl)
246 IWebBrowser2 *wb;
247 BSTR url = (void*)0xdeadbeef;
248 HRESULT hres;
250 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
251 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
252 if(FAILED(hres))
253 return;
255 hres = IWebBrowser2_get_LocationURL(wb, &url);
256 ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
257 if (hres == S_OK)
259 ok_(__FILE__,line) (!strcmp_wa(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
260 SysFreeString(url);
263 IWebBrowser2_Release(wb);
266 #define test_ready_state(ex) _test_ready_state(__LINE__,ex);
267 static void _test_ready_state(unsigned line, READYSTATE exstate)
269 READYSTATE state;
270 HRESULT hres;
272 hres = IWebBrowser2_get_ReadyState(wb, &state);
273 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
274 ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
277 #define get_document(u) _get_document(__LINE__,u)
278 static IDispatch *_get_document(unsigned line, IUnknown *unk)
280 IHTMLDocument2 *html_doc;
281 IWebBrowser2 *wb;
282 IDispatch *disp;
283 HRESULT hres;
285 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
286 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IWebBrowser2) failed: %08x\n", hres);
288 disp = NULL;
289 hres = IWebBrowser2_get_Document(wb, &disp);
290 IWebBrowser2_Release(wb);
291 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
292 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
294 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
295 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
296 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
297 IHTMLDocument_Release(html_doc);
299 return disp;
302 #define get_dochost(u) _get_dochost(__LINE__,u)
303 static IOleClientSite *_get_dochost(unsigned line, IUnknown *unk)
305 IOleClientSite *client_site;
306 IOleObject *oleobj;
307 IDispatch *doc;
308 HRESULT hres;
310 doc = _get_document(line, unk);
311 hres = IDispatch_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
312 IDispatch_Release(doc);
313 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
315 hres = IOleObject_GetClientSite(oleobj, &client_site);
316 IOleObject_Release(oleobj);
317 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
319 return client_site;
322 static HRESULT QueryInterface(REFIID,void**);
324 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
325 REFIID riid, void **ppv)
327 ok(0, "unexpected call\n");
328 return E_NOINTERFACE;
331 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
333 return 2;
336 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
338 return 1;
341 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
342 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
344 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
345 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
346 ok(!pCmdText, "pCmdText != NULL\n");
348 switch(prgCmds[0].cmdID) {
349 case OLECMDID_STOP:
350 CHECK_EXPECT2(QueryStatus_STOP);
351 prgCmds[0].cmdf = OLECMDF_SUPPORTED;
352 return S_OK;
353 case OLECMDID_SETPROGRESSTEXT:
354 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
355 prgCmds[0].cmdf = OLECMDF_ENABLED;
356 return S_OK;
357 case IDM_STOP:
358 /* Note:
359 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
360 * This command appears here for the ExecWB and QueryStatusWB tests in order
361 * to help demonstrate that these routines use a NULL pguidCmdGroup.
363 CHECK_EXPECT(QueryStatus_IDM_STOP);
364 prgCmds[0].cmdf = 0;
365 return S_OK;
366 default:
367 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
370 return E_FAIL;
373 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
374 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
376 if(!pguidCmdGroup) {
377 switch(nCmdID) {
378 case OLECMDID_SETPROGRESSMAX:
379 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
380 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
381 ok(pvaIn != NULL, "pvaIn == NULL\n");
382 if(pvaIn)
383 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
384 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
385 return S_OK;
386 case OLECMDID_SETPROGRESSPOS:
387 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
388 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
389 ok(pvaIn != NULL, "pvaIn == NULL\n");
390 if(pvaIn)
391 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
392 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
393 return S_OK;
394 case OLECMDID_SETDOWNLOADSTATE:
395 if(is_downloading)
396 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
397 "nCmdexecopts=%08x\n", nCmdexecopt);
398 else
399 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
400 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
401 ok(pvaIn != NULL, "pvaIn == NULL\n");
402 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
403 switch(V_I4(pvaIn)) {
404 case 0:
405 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
406 break;
407 case 1:
408 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
409 break;
410 default:
411 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
413 return S_OK;
414 case OLECMDID_UPDATECOMMANDS:
415 CHECK_EXPECT(Exec_UPDATECOMMANDS);
416 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
417 ok(!pvaIn, "pvaIn != NULL\n");
418 ok(!pvaOut, "pvaOut=%p, expected NULL\n", pvaOut);
419 return S_OK;
420 case OLECMDID_SETTITLE:
421 CHECK_EXPECT(Exec_SETTITLE);
422 /* TODO: test args */
423 return S_OK;
424 case OLECMDID_STOP:
425 CHECK_EXPECT(Exec_STOP);
426 return S_OK;
427 case IDM_STOP:
428 /* Note:
429 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
430 * This command appears here for the ExecWB and QueryStatusWB tests in order
431 * to help demonstrate that these routines use a NULL pguidCmdGroup.
433 CHECK_EXPECT(Exec_IDM_STOP);
434 return OLECMDERR_E_NOTSUPPORTED;
435 default:
436 ok(0, "unexpected nsCmdID %d\n", nCmdID);
438 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
439 switch(nCmdID) {
440 case 24: /* TODO */
441 case 25: /* IE5 */
442 case 37: /* TODO */
443 case 39: /* TODO */
444 case 66: /* TODO */
445 case 67: /* TODO */
446 case 69: /* TODO */
447 case 101: /* TODO (IE8) */
448 return E_FAIL;
449 default:
450 ok(0, "unexpected nCmdID %d\n", nCmdID);
452 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
453 switch(nCmdID) {
454 case 105: /* TODO */
455 case 140: /* TODO (Win7) */
456 return E_FAIL;
457 default:
458 ok(0, "unexpected nCmdID %d\n", nCmdID);
460 }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
461 switch(nCmdID) {
462 case 11: /* TODO */
463 break;
464 default:
465 ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
467 }else if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
468 switch(nCmdID) {
469 case 6041: /* TODO */
470 break;
471 default:
472 ok(0, "unexpected nCmdID %d of CGID_DocHostCommandHandler\n", nCmdID);
474 }else {
475 ok(0, "unexpected pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
478 return E_FAIL;
481 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
482 OleCommandTarget_QueryInterface,
483 OleCommandTarget_AddRef,
484 OleCommandTarget_Release,
485 OleCommandTarget_QueryStatus,
486 OleCommandTarget_Exec
489 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
491 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
493 if(IsEqualGUID(&IID_ITargetContainer, riid))
494 return E_NOINTERFACE; /* TODO */
496 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
497 if(use_container_olecmd)
499 *ppv = &OleCommandTarget;
500 return S_OK;
502 else
503 return E_NOINTERFACE;
506 ok(0, "unexpected call\n");
507 return E_NOINTERFACE;
510 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
512 return 2;
515 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
517 return 1;
520 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
521 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
523 ok(0, "unexpected call\n");
524 return E_NOTIMPL;
527 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
528 IEnumUnknown **ppenum)
530 ok(0, "unexpected call\n");
531 return E_NOTIMPL;
534 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
536 ok(0, "unexpected call\n");
537 return E_NOTIMPL;
540 static const IOleContainerVtbl OleContainerVtbl = {
541 OleContainer_QueryInterface,
542 OleContainer_AddRef,
543 OleContainer_Release,
544 OleContainer_ParseDisplayName,
545 OleContainer_EnumObjects,
546 OleContainer_LockContainer
549 static IOleContainer OleContainer = { &OleContainerVtbl };
551 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
553 return QueryInterface(riid, ppv);
556 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
558 return 2;
561 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
563 return 1;
566 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
568 ok(0, "unexpected call\n");
569 return E_NOTIMPL;
572 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
573 ITypeInfo **ppTInfo)
575 ok(0, "unexpected call\n");
576 return E_NOTIMPL;
579 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
580 UINT cNames, LCID lcid, DISPID *rgDispId)
582 ok(0, "unexpected call\n");
583 return E_NOTIMPL;
586 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
587 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
588 EXCEPINFO *pExcepInfo, UINT *puArgErr)
590 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
591 ok(pDispParams != NULL, "pDispParams == NULL\n");
592 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
593 ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
594 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
595 ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
596 ok(pDispParams->rgdispidNamedArgs == NULL,
597 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
598 ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
599 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
601 switch(dispIdMember) {
602 case DISPID_AMBIENT_USERMODE:
603 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
604 return E_FAIL;
605 case DISPID_AMBIENT_DLCONTROL:
606 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
607 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
608 return E_FAIL;
609 case DISPID_AMBIENT_USERAGENT:
610 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
611 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
612 return E_FAIL;
613 case DISPID_AMBIENT_PALETTE:
614 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
615 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
616 return E_FAIL;
617 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
618 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
619 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
620 V_VT(pVarResult) = VT_BOOL;
621 V_BOOL(pVarResult) = VARIANT_FALSE;
622 return S_OK;
623 case DISPID_AMBIENT_SILENT:
624 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
625 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
626 V_VT(pVarResult) = VT_BOOL;
627 V_BOOL(pVarResult) = VARIANT_FALSE;
628 return S_OK;
631 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
632 return E_NOTIMPL;
635 static IDispatchVtbl DispatchVtbl = {
636 Dispatch_QueryInterface,
637 Dispatch_AddRef,
638 Dispatch_Release,
639 Dispatch_GetTypeInfoCount,
640 Dispatch_GetTypeInfo,
641 Dispatch_GetIDsOfNames,
642 Dispatch_Invoke
645 static IDispatch Dispatch = { &DispatchVtbl };
647 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
649 *ppv = NULL;
651 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid)) {
652 *ppv = iface;
653 return S_OK;
656 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
657 return E_NOINTERFACE;
660 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
661 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
663 ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
664 ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
665 ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
666 if(strict)
667 ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
668 V_BOOL(params->rgvarg), exvb);
669 else
670 ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
671 V_BOOL(params->rgvarg), exvb);
674 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
675 const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
677 ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
678 ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
679 ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
681 ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
682 ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
683 if(V_VARIANTREF(url)) {
684 ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
685 V_VT(V_VARIANTREF(url)));
686 ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
687 ok(!strcmp_wa(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
688 wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), current_url);
691 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
692 V_VT(flags));
693 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
694 V_VT(flags));
695 ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
696 if(V_VARIANTREF(flags)) {
697 ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
698 V_VT(V_VARIANTREF(flags)));
699 if(is_first_load) {
700 ok(V_I4(V_VARIANTREF(flags)) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0\n",
701 V_I4(V_VARIANTREF(flags)));
702 }else {
703 ok((V_I4(V_VARIANTREF(flags)) & ~0x40) == 0, "V_I4(V_VARIANTREF(flags)) = %x, expected 0x40 or 0\n",
704 V_I4(V_VARIANTREF(flags)));
708 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
709 V_VT(frame));
710 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
711 V_VT(frame));
712 ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
713 if(V_VARIANTREF(frame)) {
714 ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
715 V_VT(V_VARIANTREF(frame)));
716 ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
717 V_BSTR(V_VARIANTREF(frame)));
720 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
721 V_VT(post_data));
722 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
723 V_VT(post_data));
724 ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
725 if(V_VARIANTREF(post_data)) {
726 ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
727 "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
728 V_VT(V_VARIANTREF(post_data)));
729 ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
730 "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
731 if(V_VARIANTREF(V_VARIANTREF(post_data))) {
732 ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
733 "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
734 V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
736 if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
737 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
739 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
740 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
745 ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
746 V_VT(headers));
747 ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
748 if(V_VARIANTREF(headers)) {
749 ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
750 V_VT(V_VARIANTREF(headers)));
751 ok(V_BSTR(V_VARIANTREF(headers)) == NULL, "V_BSTR(V_VARIANTREF(headers)) = %p, expected NULL\n",
752 V_BSTR(V_VARIANTREF(headers)));
755 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
756 V_VT(cancel));
757 ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
758 if(V_BOOLREF(cancel))
759 ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(cancel) = %x, expected VARIANT_FALSE\n",
760 *V_BOOLREF(cancel));
763 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
764 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
765 EXCEPINFO *pExcepInfo, UINT *puArgErr)
767 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
768 ok(pDispParams != NULL, "pDispParams == NULL\n");
769 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
770 ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
771 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
772 ok(pDispParams->rgdispidNamedArgs == NULL,
773 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
774 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
776 switch(dispIdMember) {
777 case DISPID_STATUSTEXTCHANGE:
778 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
780 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
781 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
782 ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
783 V_VT(pDispParams->rgvarg));
784 /* TODO: Check text */
785 break;
787 case DISPID_PROPERTYCHANGE:
788 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
790 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
791 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
792 /* TODO: Check args */
793 break;
795 case DISPID_DOWNLOADBEGIN:
796 CHECK_EXPECT(Invoke_DOWNLOADBEGIN);
798 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
799 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
800 test_ready_state(READYSTATE_LOADING);
801 break;
803 case DISPID_BEFORENAVIGATE2:
804 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
806 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
807 ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
808 test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
809 pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
810 pDispParams->rgvarg);
811 test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
812 break;
814 case DISPID_SETSECURELOCKICON:
815 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
817 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
818 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
819 /* TODO: Check args */
820 break;
822 case DISPID_FILEDOWNLOAD:
823 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
825 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
826 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
827 /* TODO: Check args */
828 break;
830 case DISPID_COMMANDSTATECHANGE:
831 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE);
833 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
834 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
835 /* TODO: Check args */
836 break;
838 case DISPID_DOWNLOADCOMPLETE:
839 CHECK_EXPECT(Invoke_DOWNLOADCOMPLETE);
841 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
842 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
843 test_ready_state(READYSTATE_LOADING);
844 break;
846 case DISPID_ONMENUBAR:
847 CHECK_EXPECT(Invoke_ONMENUBAR);
848 test_invoke_bool(pDispParams, TRUE);
849 break;
851 case DISPID_ONADDRESSBAR:
852 CHECK_EXPECT(Invoke_ONADDRESSBAR);
853 test_invoke_bool(pDispParams, TRUE);
854 break;
856 case DISPID_ONSTATUSBAR:
857 CHECK_EXPECT(Invoke_ONSTATUSBAR);
858 test_invoke_bool(pDispParams, TRUE);
859 break;
861 case DISPID_ONTOOLBAR:
862 CHECK_EXPECT(Invoke_ONTOOLBAR);
863 test_invoke_bool(pDispParams, FALSE);
864 break;
866 case DISPID_ONFULLSCREEN:
867 CHECK_EXPECT(Invoke_ONFULLSCREEN);
868 test_invoke_bool(pDispParams, TRUE);
869 break;
871 case DISPID_ONTHEATERMODE:
872 CHECK_EXPECT(Invoke_ONTHEATERMODE);
873 test_invoke_bool(pDispParams, TRUE);
874 break;
876 case DISPID_WINDOWSETRESIZABLE:
877 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
878 test_invoke_bool(pDispParams, TRUE);
879 break;
881 case DISPID_TITLECHANGE:
882 CHECK_EXPECT2(Invoke_TITLECHANGE);
883 /* FIXME */
884 break;
886 case DISPID_NAVIGATECOMPLETE2:
887 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
888 /* FIXME */
889 test_ready_state((dwl_flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
890 break;
892 case DISPID_PROGRESSCHANGE:
893 CHECK_EXPECT(Invoke_PROGRESSCHANGE);
894 /* FIXME */
895 break;
897 case DISPID_DOCUMENTCOMPLETE:
898 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
899 /* FIXME */
900 test_ready_state(READYSTATE_COMPLETE);
901 break;
903 case 282: /* FIXME */
904 CHECK_EXPECT2(Invoke_282);
905 break;
907 default:
908 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
911 return S_OK;
914 static IDispatchVtbl WebBrowserEvents2Vtbl = {
915 WebBrowserEvents2_QueryInterface,
916 Dispatch_AddRef,
917 Dispatch_Release,
918 Dispatch_GetTypeInfoCount,
919 Dispatch_GetTypeInfo,
920 Dispatch_GetIDsOfNames,
921 WebBrowserEvents2_Invoke
924 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
926 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
928 return QueryInterface(riid, ppv);
931 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
933 return 2;
936 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
938 return 1;
941 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
943 ok(0, "unexpected call\n");
944 return E_NOTIMPL;
947 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
948 IMoniker **ppmon)
950 ok(0, "unexpected call\n");
951 return E_NOTIMPL;
954 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
956 CHECK_EXPECT(GetContainer);
958 ok(ppContainer != NULL, "ppContainer == NULL\n");
959 if(ppContainer)
960 *ppContainer = &OleContainer;
962 return S_OK;
965 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
967 CHECK_EXPECT(ShowObject);
968 return S_OK;
971 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
973 ok(0, "unexpected call\n");
974 return E_NOTIMPL;
977 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
979 ok(0, "unexpected call\n");
980 return E_NOTIMPL;
983 static const IOleClientSiteVtbl ClientSiteVtbl = {
984 ClientSite_QueryInterface,
985 ClientSite_AddRef,
986 ClientSite_Release,
987 ClientSite_SaveObject,
988 ClientSite_GetMoniker,
989 ClientSite_GetContainer,
990 ClientSite_ShowObject,
991 ClientSite_OnShowWindow,
992 ClientSite_RequestNewObjectLayout
995 static IOleClientSite ClientSite = { &ClientSiteVtbl };
997 static HRESULT WINAPI IOleControlSite_fnQueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
999 *ppv = NULL;
1000 return E_NOINTERFACE;
1003 static ULONG WINAPI IOleControlSite_fnAddRef(IOleControlSite *iface)
1005 return 2;
1008 static ULONG WINAPI IOleControlSite_fnRelease(IOleControlSite *iface)
1010 return 1;
1013 static HRESULT WINAPI IOleControlSite_fnOnControlInfoChanged(IOleControlSite* This)
1015 ok(0, "unexpected call\n");
1016 return E_NOTIMPL;
1019 static HRESULT WINAPI IOleControlSite_fnLockInPlaceActive(IOleControlSite* This,
1020 BOOL fLock)
1022 ok(0, "unexpected call\n");
1023 return E_NOTIMPL;
1026 static HRESULT WINAPI IOleControlSite_fnGetExtendedControl(IOleControlSite* This,
1027 IDispatch **ppDisp)
1029 ok(0, "unexpected call\n");
1030 return E_NOTIMPL;
1033 static HRESULT WINAPI IOleControlSite_fnTransformCoords(IOleControlSite* This,
1034 POINTL *pPtlHimetric,
1035 POINTF *pPtfContainer,
1036 DWORD dwFlags)
1038 ok(0, "unexpected call\n");
1039 return E_NOTIMPL;
1042 static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* This, MSG *pMsg,
1043 DWORD grfModifiers)
1045 CHECK_EXPECT(ControlSite_TranslateAccelerator);
1046 return hr_site_TranslateAccelerator;
1049 static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus)
1051 CHECK_EXPECT2(OnFocus);
1052 return E_NOTIMPL;
1055 static HRESULT WINAPI IOleControlSite_fnShowPropertyFrame(IOleControlSite* This)
1057 ok(0, "unexpected call\n");
1058 return E_NOTIMPL;
1061 static IOleControlSiteVtbl ControlSiteVtbl = {
1062 IOleControlSite_fnQueryInterface,
1063 IOleControlSite_fnAddRef,
1064 IOleControlSite_fnRelease,
1065 IOleControlSite_fnOnControlInfoChanged,
1066 IOleControlSite_fnLockInPlaceActive,
1067 IOleControlSite_fnGetExtendedControl,
1068 IOleControlSite_fnTransformCoords,
1069 IOleControlSite_fnTranslateAccelerator,
1070 IOleControlSite_fnOnFocus,
1071 IOleControlSite_fnShowPropertyFrame
1074 static IOleControlSite ControlSite = { &ControlSiteVtbl };
1076 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
1077 REFIID riid, void **ppv)
1079 ok(0, "unexpected call\n");
1080 return E_NOINTERFACE;
1083 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
1085 return 2;
1088 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
1090 return 1;
1093 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1095 ok(0, "unexpected call\n");
1096 return E_NOTIMPL;
1099 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1101 CHECK_EXPECT(Frame_GetWindow);
1102 ok(phwnd != NULL, "phwnd == NULL\n");
1103 if(phwnd)
1104 *phwnd = container_hwnd;
1105 return S_OK;
1108 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1110 ok(0, "unexpected call\n");
1111 return E_NOTIMPL;
1114 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1116 ok(0, "unexpected call\n");
1117 return E_NOTIMPL;
1120 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
1121 LPCBORDERWIDTHS pborderwidths)
1123 ok(0, "unexpected call\n");
1124 return E_NOTIMPL;
1127 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
1128 LPCBORDERWIDTHS pborderwidths)
1130 ok(0, "unexpected call\n");
1131 return E_NOTIMPL;
1134 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1135 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1137 CHECK_EXPECT(UIWindow_SetActiveObject);
1138 if(!test_close) {
1139 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1140 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1141 } else {
1142 ok(!pActiveObject, "pActiveObject != NULL\n");
1143 ok(!pszObjName, "pszObjName != NULL\n");
1145 return S_OK;
1148 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1149 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1151 CHECK_EXPECT(Frame_SetActiveObject);
1152 if(!test_close) {
1153 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1154 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1155 } else {
1156 ok(!pActiveObject, "pActiveObject != NULL\n");
1157 ok(!pszObjName, "pszObjName != NULL\n");
1159 return S_OK;
1162 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1163 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1165 ok(0, "unexpected call\n");
1166 return E_NOTIMPL;
1169 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1170 HOLEMENU holemenu, HWND hwndActiveObject)
1172 CHECK_EXPECT(SetMenu);
1173 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
1174 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
1175 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
1176 hwndActiveObject, shell_embedding_hwnd);
1177 return S_OK;
1180 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1182 ok(0, "unexpected call\n");
1183 return E_NOTIMPL;
1186 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1188 CHECK_EXPECT2(SetStatusText);
1189 /* FIXME: Check pszStatusText */
1190 return S_OK;
1193 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1195 if(fEnable)
1196 CHECK_EXPECT2(EnableModeless_TRUE);
1197 else
1198 CHECK_EXPECT2(EnableModeless_FALSE);
1199 return S_OK;
1202 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1204 ok(0, "unexpected call\n");
1205 return E_NOTIMPL;
1208 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1209 InPlaceUIWindow_QueryInterface,
1210 InPlaceUIWindow_AddRef,
1211 InPlaceUIWindow_Release,
1212 InPlaceUIWindow_GetWindow,
1213 InPlaceUIWindow_ContextSensitiveHelp,
1214 InPlaceUIWindow_GetBorder,
1215 InPlaceUIWindow_RequestBorderSpace,
1216 InPlaceUIWindow_SetBorderSpace,
1217 InPlaceUIWindow_SetActiveObject,
1220 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
1222 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1223 InPlaceUIWindow_QueryInterface,
1224 InPlaceUIWindow_AddRef,
1225 InPlaceUIWindow_Release,
1226 InPlaceFrame_GetWindow,
1227 InPlaceUIWindow_ContextSensitiveHelp,
1228 InPlaceUIWindow_GetBorder,
1229 InPlaceUIWindow_RequestBorderSpace,
1230 InPlaceUIWindow_SetBorderSpace,
1231 InPlaceFrame_SetActiveObject,
1232 InPlaceFrame_InsertMenus,
1233 InPlaceFrame_SetMenu,
1234 InPlaceFrame_RemoveMenus,
1235 InPlaceFrame_SetStatusText,
1236 InPlaceFrame_EnableModeless,
1237 InPlaceFrame_TranslateAccelerator
1240 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1242 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1244 return QueryInterface(riid, ppv);
1247 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1249 return 2;
1252 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1254 return 1;
1257 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1259 CHECK_EXPECT(Site_GetWindow);
1260 ok(phwnd != NULL, "phwnd == NULL\n");
1261 if(phwnd)
1262 *phwnd = container_hwnd;
1263 return S_OK;
1266 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1268 ok(0, "unexpected call\n");
1269 return E_NOTIMPL;
1272 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1274 CHECK_EXPECT(CanInPlaceActivate);
1275 return S_OK;
1278 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1280 CHECK_EXPECT(OnInPlaceActivate);
1281 return S_OK;
1284 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1286 CHECK_EXPECT(OnUIActivate);
1287 return S_OK;
1290 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1291 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1292 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1294 static const RECT pos_rect = {2,1,1002,901};
1295 static const RECT clip_rect = {10,10,990,890};
1297 CHECK_EXPECT(GetWindowContext);
1299 ok(ppFrame != NULL, "ppFrame = NULL\n");
1300 if(ppFrame)
1301 *ppFrame = &InPlaceFrame;
1303 ok(ppDoc != NULL, "ppDoc = NULL\n");
1304 if(ppDoc)
1305 *ppDoc = &InPlaceUIWindow;
1307 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1308 if(lprcPosRect)
1309 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1311 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1312 if(lprcClipRect)
1313 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1315 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1316 if(lpFrameInfo) {
1317 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1318 lpFrameInfo->fMDIApp = FALSE;
1319 lpFrameInfo->hwndFrame = container_hwnd;
1320 lpFrameInfo->haccel = NULL;
1321 lpFrameInfo->cAccelEntries = 0;
1324 return S_OK;
1327 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1329 ok(0, "unexpected call\n");
1330 return E_NOTIMPL;
1333 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1335 CHECK_EXPECT(OnUIDeactivate);
1336 ok(!fUndoable, "fUndoable should be FALSE\n");
1337 return S_OK;
1340 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1342 CHECK_EXPECT(OnInPlaceDeactivate);
1343 return S_OK;
1346 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1348 ok(0, "unexpected call\n");
1349 return E_NOTIMPL;
1352 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1354 ok(0, "unexpected call\n");
1355 return E_NOTIMPL;
1358 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1360 ok(0, "unexpected call\n");
1361 return E_NOTIMPL;
1364 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1365 BOOL *pNoRedraw, DWORD dwFlags)
1367 ok(0, "unexpected call\n");
1368 return E_NOTIMPL;
1371 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1372 BOOL fNoRedraw)
1374 ok(0, "unexpected call\n");
1375 return E_NOTIMPL;
1378 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1380 CHECK_EXPECT2(RequestUIActivate);
1381 return S_OK;
1384 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1385 InPlaceSite_QueryInterface,
1386 InPlaceSite_AddRef,
1387 InPlaceSite_Release,
1388 InPlaceSite_GetWindow,
1389 InPlaceSite_ContextSensitiveHelp,
1390 InPlaceSite_CanInPlaceActivate,
1391 InPlaceSite_OnInPlaceActivate,
1392 InPlaceSite_OnUIActivate,
1393 InPlaceSite_GetWindowContext,
1394 InPlaceSite_Scroll,
1395 InPlaceSite_OnUIDeactivate,
1396 InPlaceSite_OnInPlaceDeactivate,
1397 InPlaceSite_DiscardUndoState,
1398 InPlaceSite_DeactivateAndUndo,
1399 InPlaceSite_OnPosRectChange,
1400 InPlaceSite_OnInPlaceActivateEx,
1401 InPlaceSite_OnInPlaceDeactivateEx,
1402 InPlaceSite_RequestUIActivate
1405 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1407 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1409 return QueryInterface(riid, ppv);
1412 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1414 return 2;
1417 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1419 return 1;
1422 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1423 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1425 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1426 return S_FALSE;
1429 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1431 CHECK_EXPECT2(GetHostInfo);
1432 ok(pInfo != NULL, "pInfo=NULL\n");
1433 if(pInfo) {
1434 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1435 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1436 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1437 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1438 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1440 return E_FAIL;
1443 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1444 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1445 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1447 CHECK_EXPECT(ShowUI);
1448 return E_NOTIMPL;
1451 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1453 CHECK_EXPECT(HideUI);
1454 return E_NOTIMPL;
1457 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1459 CHECK_EXPECT(UpdateUI);
1460 return E_NOTIMPL;
1463 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1465 if(fEnable)
1466 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1467 else
1468 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1470 return S_OK;
1473 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1475 ok(0, "unexpected call\n");
1476 return E_NOTIMPL;
1479 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1481 ok(0, "unexpected call\n");
1482 return E_NOTIMPL;
1485 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1486 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1488 ok(0, "unexpected call\n");
1489 return E_NOTIMPL;
1492 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1493 const GUID *pguidCmdGroup, DWORD nCmdID)
1495 CHECK_EXPECT(DocHost_TranslateAccelerator);
1496 ok(pguidCmdGroup != NULL, "Got NULL pguidCmdGroup.\n");
1497 if(pguidCmdGroup)
1498 ok(IsEqualGUID(pguidCmdGroup, &CGID_MSHTML), "Unexpected pguidCmdGroup\n");
1499 ok(lpMsg != NULL, "Got NULL lpMsg.\n");
1500 return hr_dochost_TranslateAccelerator;
1503 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1504 LPOLESTR *pchKey, DWORD dw)
1506 CHECK_EXPECT(GetOptionKeyPath);
1507 ok(pchKey != NULL, "pchKey==NULL\n");
1508 if(pchKey)
1509 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1510 ok(!dw, "dw=%x\n", dw);
1511 return E_NOTIMPL;
1514 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1515 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1517 CHECK_EXPECT(GetDropTarget);
1518 return E_NOTIMPL;
1521 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1523 ok(0, "unexpected call\n");
1524 return E_NOTIMPL;
1527 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1528 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1530 if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1531 todo_wine CHECK_EXPECT(TranslateUrl);
1532 else
1533 CHECK_EXPECT(TranslateUrl);
1534 return E_NOTIMPL;
1537 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1538 IDataObject **ppPORet)
1540 ok(0, "unexpected call\n");
1541 return E_NOTIMPL;
1544 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1545 LPOLESTR *pchKey, DWORD dw)
1547 CHECK_EXPECT(GetOverridesKeyPath);
1548 ok(pchKey != NULL, "pchKey==NULL\n");
1549 if(pchKey)
1550 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1551 ok(!dw, "dw=%x\n", dw);
1552 return E_NOTIMPL;
1555 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1556 DocHostUIHandler_QueryInterface,
1557 DocHostUIHandler_AddRef,
1558 DocHostUIHandler_Release,
1559 DocHostUIHandler_ShowContextMenu,
1560 DocHostUIHandler_GetHostInfo,
1561 DocHostUIHandler_ShowUI,
1562 DocHostUIHandler_HideUI,
1563 DocHostUIHandler_UpdateUI,
1564 DocHostUIHandler_EnableModeless,
1565 DocHostUIHandler_OnDocWindowActivate,
1566 DocHostUIHandler_OnFrameWindowActivate,
1567 DocHostUIHandler_ResizeBorder,
1568 DocHostUIHandler_TranslateAccelerator,
1569 DocHostUIHandler_GetOptionKeyPath,
1570 DocHostUIHandler_GetDropTarget,
1571 DocHostUIHandler_GetExternal,
1572 DocHostUIHandler_TranslateUrl,
1573 DocHostUIHandler_FilterDataObject,
1574 DocHostUIHandler_GetOverrideKeyPath
1577 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1580 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1582 return QueryInterface(riid, ppv);
1585 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1587 return 2;
1590 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1592 return 1;
1595 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1596 REFGUID guidService, REFIID riid, void **ppv)
1598 *ppv = NULL;
1600 if(!winetest_interactive)
1601 return E_NOINTERFACE;
1603 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1604 trace("Service SID_STopLevelBrowser\n");
1605 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1606 trace("Service SID_SEditCommandTarget\n");
1607 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1608 trace("Service IID_ITargetFrame2\n");
1609 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1610 trace("Service SID_SInternetSecurityManager\n");
1611 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1612 trace("Service SID_SOleUndoManager\n");
1613 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1614 trace("Service SID_IMimeInfo\n");
1615 else if (IsEqualGUID(&SID_STopWindow, guidService))
1616 trace("Service SID_STopWindow\n");
1618 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1619 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1620 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1621 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1622 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1623 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1624 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1625 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1626 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1627 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1628 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1630 else
1631 trace("Service %s not supported\n", debugstr_guid(guidService));
1633 return E_NOINTERFACE;
1637 static const IServiceProviderVtbl ServiceProviderVtbl = {
1638 ServiceProvider_QueryInterface,
1639 ServiceProvider_AddRef,
1640 ServiceProvider_Release,
1641 ServiceProvider_QueryService
1644 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1647 static HRESULT QueryInterface(REFIID riid, void **ppv)
1649 *ppv = NULL;
1651 if(IsEqualGUID(&IID_IUnknown, riid)
1652 || IsEqualGUID(&IID_IOleClientSite, riid))
1653 *ppv = &ClientSite;
1654 else if(IsEqualGUID(&IID_IOleWindow, riid)
1655 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1656 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1657 *ppv = &InPlaceSite;
1658 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1659 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1660 *ppv = &DocHostUIHandler;
1661 else if(IsEqualGUID(&IID_IDispatch, riid))
1662 *ppv = &Dispatch;
1663 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1664 *ppv = &ServiceProvider;
1665 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1666 trace("interface IID_IDocHostShowUI\n");
1667 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1668 *ppv = &ControlSite;
1669 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1670 trace("interface IID_IOleCommandTarget\n");
1672 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1674 else
1676 /* are there more interfaces, that a host can support? */
1677 trace("%s: interface not supported\n", debugstr_guid(riid));
1680 return (*ppv) ? S_OK : E_NOINTERFACE;
1683 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1685 return DefWindowProcW(hwnd, msg, wParam, lParam);
1688 static HWND create_container_window(void)
1690 static const WCHAR wszWebBrowserContainer[] =
1691 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1692 static WNDCLASSEXW wndclass = {
1693 sizeof(WNDCLASSEXW),
1695 wnd_proc,
1696 0, 0, NULL, NULL, NULL, NULL, NULL,
1697 wszWebBrowserContainer,
1698 NULL
1701 RegisterClassExW(&wndclass);
1702 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1703 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1704 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
1707 static void test_DoVerb(IUnknown *unk)
1709 IOleObject *oleobj;
1710 RECT rect = {0,0,1000,1000};
1711 HRESULT hres;
1713 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1714 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1715 if(FAILED(hres))
1716 return;
1718 SET_EXPECT(CanInPlaceActivate);
1719 SET_EXPECT(Site_GetWindow);
1720 SET_EXPECT(OnInPlaceActivate);
1721 SET_EXPECT(GetWindowContext);
1722 SET_EXPECT(ShowObject);
1723 SET_EXPECT(GetContainer);
1724 SET_EXPECT(Frame_GetWindow);
1725 SET_EXPECT(OnUIActivate);
1726 SET_EXPECT(Frame_SetActiveObject);
1727 SET_EXPECT(UIWindow_SetActiveObject);
1728 SET_EXPECT(SetMenu);
1729 SET_EXPECT(OnFocus);
1731 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1732 0, (HWND)0xdeadbeef, &rect);
1733 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1735 CHECK_CALLED(CanInPlaceActivate);
1736 CHECK_CALLED(Site_GetWindow);
1737 CHECK_CALLED(OnInPlaceActivate);
1738 CHECK_CALLED(GetWindowContext);
1739 CHECK_CALLED(ShowObject);
1740 CHECK_CALLED(GetContainer);
1741 CHECK_CALLED(Frame_GetWindow);
1742 CHECK_CALLED(OnUIActivate);
1743 CHECK_CALLED(Frame_SetActiveObject);
1744 CHECK_CALLED(UIWindow_SetActiveObject);
1745 CHECK_CALLED(SetMenu);
1746 todo_wine CHECK_CALLED(OnFocus);
1748 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1749 0, (HWND)0xdeadbeef, &rect);
1750 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1752 IOleObject_Release(oleobj);
1755 static void test_GetMiscStatus(IOleObject *oleobj)
1757 DWORD st, i;
1758 HRESULT hres;
1760 for(i=0; i<10; i++) {
1761 st = 0xdeadbeef;
1762 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1763 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1764 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1765 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1766 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1767 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1771 static void test_SetHostNames(IOleObject *oleobj)
1773 HRESULT hres;
1775 static const WCHAR test_appW[] = {'t','e','s','t',' ','a','p','p',0};
1777 hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1778 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1781 static void test_ClientSite(IUnknown *unk, IOleClientSite *client, BOOL stop_download)
1783 IOleObject *oleobj;
1784 IOleInPlaceObject *inplace;
1785 HWND hwnd;
1786 HRESULT hres;
1788 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1789 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1790 if(FAILED(hres))
1791 return;
1793 test_GetMiscStatus(oleobj);
1794 test_SetHostNames(oleobj);
1796 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1797 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1798 if(FAILED(hres)) {
1799 IOleObject_Release(oleobj);
1800 return;
1803 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1804 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1805 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1807 if(client) {
1808 SET_EXPECT(GetContainer);
1809 SET_EXPECT(Site_GetWindow);
1810 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1811 SET_EXPECT(Invoke_AMBIENT_SILENT);
1812 }else if(stop_download) {
1813 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1814 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1815 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
1818 hres = IOleObject_SetClientSite(oleobj, client);
1819 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1821 if(client) {
1822 CHECK_CALLED(GetContainer);
1823 CHECK_CALLED(Site_GetWindow);
1824 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1825 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1826 }else if(stop_download) {
1827 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
1828 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1829 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
1832 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1833 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1834 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
1836 shell_embedding_hwnd = hwnd;
1838 test_SetHostNames(oleobj);
1840 IOleInPlaceObject_Release(inplace);
1841 IOleObject_Release(oleobj);
1844 static void test_ClassInfo(IUnknown *unk)
1846 IProvideClassInfo2 *class_info;
1847 GUID guid;
1848 HRESULT hres;
1850 hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
1851 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
1852 if(FAILED(hres))
1853 return;
1855 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
1856 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
1857 ok(IsEqualGUID(&DIID_DWebBrowserEvents2, &guid), "wrong guid\n");
1859 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
1860 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1861 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1863 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
1864 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
1865 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
1867 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
1868 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1870 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
1871 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
1873 IProvideClassInfo2_Release(class_info);
1876 static void test_ie_funcs(IUnknown *unk)
1878 IWebBrowser2 *wb;
1879 IDispatch *disp;
1880 VARIANT_BOOL b;
1881 int i;
1882 LONG hwnd;
1883 HRESULT hres;
1884 BSTR sName;
1886 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
1887 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
1888 if(FAILED(hres))
1889 return;
1891 /* HWND */
1893 hwnd = 0xdeadbeef;
1894 hres = IWebBrowser2_get_HWND(wb, &hwnd);
1895 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
1896 ok(hwnd == 0, "unexpected hwnd %x\n", hwnd);
1898 /* MenuBar */
1900 hres = IWebBrowser2_get_MenuBar(wb, &b);
1901 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1902 ok(b == VARIANT_TRUE, "b=%x\n", b);
1904 SET_EXPECT(Invoke_ONMENUBAR);
1905 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
1906 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1907 CHECK_CALLED(Invoke_ONMENUBAR);
1909 hres = IWebBrowser2_get_MenuBar(wb, &b);
1910 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1911 ok(b == VARIANT_FALSE, "b=%x\n", b);
1913 SET_EXPECT(Invoke_ONMENUBAR);
1914 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
1915 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1916 CHECK_CALLED(Invoke_ONMENUBAR);
1918 hres = IWebBrowser2_get_MenuBar(wb, &b);
1919 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1920 ok(b == VARIANT_TRUE, "b=%x\n", b);
1922 /* AddressBar */
1924 hres = IWebBrowser2_get_AddressBar(wb, &b);
1925 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1926 ok(b == VARIANT_TRUE, "b=%x\n", b);
1928 SET_EXPECT(Invoke_ONADDRESSBAR);
1929 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
1930 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1931 CHECK_CALLED(Invoke_ONADDRESSBAR);
1933 hres = IWebBrowser2_get_AddressBar(wb, &b);
1934 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
1935 ok(b == VARIANT_FALSE, "b=%x\n", b);
1937 SET_EXPECT(Invoke_ONADDRESSBAR);
1938 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
1939 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
1940 CHECK_CALLED(Invoke_ONADDRESSBAR);
1942 hres = IWebBrowser2_get_AddressBar(wb, &b);
1943 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
1944 ok(b == VARIANT_TRUE, "b=%x\n", b);
1946 SET_EXPECT(Invoke_ONADDRESSBAR);
1947 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
1948 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
1949 CHECK_CALLED(Invoke_ONADDRESSBAR);
1951 /* StatusBar */
1953 hres = IWebBrowser2_get_StatusBar(wb, &b);
1954 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1955 ok(b == VARIANT_TRUE, "b=%x\n", b);
1957 SET_EXPECT(Invoke_ONSTATUSBAR);
1958 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
1959 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1960 CHECK_CALLED(Invoke_ONSTATUSBAR);
1962 hres = IWebBrowser2_get_StatusBar(wb, &b);
1963 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1964 ok(b == VARIANT_TRUE, "b=%x\n", b);
1966 SET_EXPECT(Invoke_ONSTATUSBAR);
1967 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
1968 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1969 CHECK_CALLED(Invoke_ONSTATUSBAR);
1971 hres = IWebBrowser2_get_StatusBar(wb, &b);
1972 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1973 ok(b == VARIANT_FALSE, "b=%x\n", b);
1975 SET_EXPECT(Invoke_ONSTATUSBAR);
1976 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
1977 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
1978 CHECK_CALLED(Invoke_ONSTATUSBAR);
1980 hres = IWebBrowser2_get_StatusBar(wb, &b);
1981 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
1982 ok(b == VARIANT_TRUE, "b=%x\n", b);
1984 /* ToolBar */
1986 hres = IWebBrowser2_get_ToolBar(wb, &i);
1987 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1988 ok(i, "i=%x\n", i);
1990 SET_EXPECT(Invoke_ONTOOLBAR);
1991 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
1992 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
1993 CHECK_CALLED(Invoke_ONTOOLBAR);
1995 hres = IWebBrowser2_get_ToolBar(wb, &i);
1996 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
1997 ok(i == VARIANT_FALSE, "b=%x\n", i);
1999 SET_EXPECT(Invoke_ONTOOLBAR);
2000 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
2001 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2002 CHECK_CALLED(Invoke_ONTOOLBAR);
2004 hres = IWebBrowser2_get_ToolBar(wb, &i);
2005 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2006 ok(i, "i=%x\n", i);
2008 SET_EXPECT(Invoke_ONTOOLBAR);
2009 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
2010 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2011 CHECK_CALLED(Invoke_ONTOOLBAR);
2013 /* FullScreen */
2015 hres = IWebBrowser2_get_FullScreen(wb, &b);
2016 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2017 ok(b == VARIANT_FALSE, "b=%x\n", b);
2019 SET_EXPECT(Invoke_ONFULLSCREEN);
2020 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
2021 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2022 CHECK_CALLED(Invoke_ONFULLSCREEN);
2024 hres = IWebBrowser2_get_FullScreen(wb, &b);
2025 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2026 ok(b == VARIANT_TRUE, "b=%x\n", b);
2028 SET_EXPECT(Invoke_ONFULLSCREEN);
2029 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
2030 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2031 CHECK_CALLED(Invoke_ONFULLSCREEN);
2033 hres = IWebBrowser2_get_FullScreen(wb, &b);
2034 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2035 ok(b == VARIANT_TRUE, "b=%x\n", b);
2037 SET_EXPECT(Invoke_ONFULLSCREEN);
2038 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
2039 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2040 CHECK_CALLED(Invoke_ONFULLSCREEN);
2042 /* TheaterMode */
2044 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2045 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2046 ok(b == VARIANT_FALSE, "b=%x\n", b);
2048 SET_EXPECT(Invoke_ONTHEATERMODE);
2049 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
2050 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2051 CHECK_CALLED(Invoke_ONTHEATERMODE);
2053 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2054 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2055 ok(b == VARIANT_TRUE, "b=%x\n", b);
2057 SET_EXPECT(Invoke_ONTHEATERMODE);
2058 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
2059 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2060 CHECK_CALLED(Invoke_ONTHEATERMODE);
2062 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2063 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2064 ok(b == VARIANT_TRUE, "b=%x\n", b);
2066 SET_EXPECT(Invoke_ONTHEATERMODE);
2067 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
2068 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2069 CHECK_CALLED(Invoke_ONTHEATERMODE);
2071 /* Resizable */
2073 b = 0x100;
2074 hres = IWebBrowser2_get_Resizable(wb, &b);
2075 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2076 ok(b == 0x100, "b=%x\n", b);
2078 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2079 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
2080 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2081 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2083 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2084 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
2085 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2086 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2088 hres = IWebBrowser2_get_Resizable(wb, &b);
2089 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2090 ok(b == 0x100, "b=%x\n", b);
2092 /* Application */
2094 disp = NULL;
2095 hres = IWebBrowser2_get_Application(wb, &disp);
2096 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
2097 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
2098 if(disp)
2099 IDispatch_Release(disp);
2101 hres = IWebBrowser2_get_Application(wb, NULL);
2102 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
2104 /* Name */
2105 hres = IWebBrowser2_get_Name(wb, &sName);
2106 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
2107 if (is_lang_english())
2108 ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
2109 else /* Non-English cannot be blank. */
2110 ok(sName!=NULL, "get_Name return a NULL string.\n");
2111 SysFreeString(sName);
2113 /* Quit */
2115 hres = IWebBrowser2_Quit(wb);
2116 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
2118 IWebBrowser2_Release(wb);
2121 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2123 VARIANT_BOOL b;
2124 HRESULT hres;
2126 b = 100;
2127 hres = IWebBrowser2_get_Silent(wb, &b);
2128 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2129 ok(b == VARIANT_FALSE, "b=%x\n", b);
2131 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2132 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2134 b = 100;
2135 hres = IWebBrowser2_get_Silent(wb, &b);
2136 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2137 ok(b == VARIANT_TRUE, "b=%x\n", b);
2139 hres = IWebBrowser2_put_Silent(wb, 100);
2140 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2142 b = 100;
2143 hres = IWebBrowser2_get_Silent(wb, &b);
2144 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2145 ok(b == VARIANT_TRUE, "b=%x\n", b);
2147 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
2148 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2150 b = 100;
2151 hres = IWebBrowser2_get_Silent(wb, &b);
2152 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2153 ok(b == VARIANT_FALSE, "b=%x\n", b);
2155 if(is_clientsite) {
2156 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2157 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2159 SET_EXPECT(Invoke_AMBIENT_SILENT);
2162 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2163 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2165 if(is_clientsite)
2166 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2168 b = 100;
2169 hres = IWebBrowser2_get_Silent(wb, &b);
2170 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2171 ok(b == VARIANT_FALSE, "b=%x\n", b);
2174 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2176 VARIANT_BOOL b;
2177 HRESULT hres;
2179 b = 100;
2180 hres = IWebBrowser2_get_Offline(wb, &b);
2181 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2182 ok(b == VARIANT_FALSE, "b=%x\n", b);
2184 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2185 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2187 b = 100;
2188 hres = IWebBrowser2_get_Offline(wb, &b);
2189 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2190 ok(b == VARIANT_TRUE, "b=%x\n", b);
2192 hres = IWebBrowser2_put_Offline(wb, 100);
2193 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2195 b = 100;
2196 hres = IWebBrowser2_get_Offline(wb, &b);
2197 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2198 ok(b == VARIANT_TRUE, "b=%x\n", b);
2200 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
2201 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2203 b = 100;
2204 hres = IWebBrowser2_get_Offline(wb, &b);
2205 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2206 ok(b == VARIANT_FALSE, "b=%x\n", b);
2208 if(is_clientsite) {
2209 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2210 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2212 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2215 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2216 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2218 if(is_clientsite)
2219 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2221 b = 100;
2222 hres = IWebBrowser2_get_Offline(wb, &b);
2223 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2224 ok(b == VARIANT_FALSE, "b=%x\n", b);
2227 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2229 HRESULT hres;
2231 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2232 SET_EXPECT(Invoke_AMBIENT_SILENT);
2233 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2234 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2235 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2236 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2238 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
2239 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2241 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2242 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
2243 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
2244 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
2245 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2246 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2248 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2249 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2250 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2251 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2252 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2253 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2256 static void test_wb_funcs(IUnknown *unk, BOOL is_clientsite)
2258 IWebBrowser2 *wb;
2259 IOleControl *control;
2260 HRESULT hres;
2262 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
2263 ok(hres == S_OK, "Could not get IWebBrowser2 interface: %08x\n", hres);
2265 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2266 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2268 test_Silent(wb, control, is_clientsite);
2269 test_Offline(wb, control, is_clientsite);
2270 test_ambient_unknown(wb, control, is_clientsite);
2272 IWebBrowser_Release(wb);
2273 IOleControl_Release(control);
2276 static void test_GetControlInfo(IUnknown *unk)
2278 IOleControl *control;
2279 CONTROLINFO info;
2280 HRESULT hres;
2282 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2283 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2284 if(FAILED(hres))
2285 return;
2287 hres = IOleControl_GetControlInfo(control, &info);
2288 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2289 hres = IOleControl_GetControlInfo(control, NULL);
2290 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2292 IOleControl_Release(control);
2295 static void test_Extent(IUnknown *unk)
2297 IOleObject *oleobj;
2298 SIZE size, expected;
2299 HRESULT hres;
2300 DWORD dpi_x;
2301 DWORD dpi_y;
2302 HDC hdc;
2304 /* default aspect ratio is 96dpi / 96dpi */
2305 hdc = GetDC(0);
2306 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2307 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2308 ReleaseDC(0, hdc);
2309 if (dpi_x != 96 || dpi_y != 96)
2310 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2312 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2313 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2314 if(FAILED(hres))
2315 return;
2317 size.cx = size.cy = 0xdeadbeef;
2318 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2319 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2320 /* Default size is 50x20 pixels, in himetric units */
2321 expected.cx = MulDiv( 50, 2540, dpi_x );
2322 expected.cy = MulDiv( 20, 2540, dpi_y );
2323 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2324 size.cx, size.cy, expected.cx, expected.cy );
2326 size.cx = 800;
2327 size.cy = 700;
2328 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2329 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2331 size.cx = size.cy = 0xdeadbeef;
2332 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2333 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2334 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2336 size.cx = size.cy = 0xdeadbeef;
2337 hres = IOleObject_GetExtent(oleobj, 0, &size);
2338 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2339 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2341 size.cx = 900;
2342 size.cy = 800;
2343 hres = IOleObject_SetExtent(oleobj, 0, &size);
2344 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2346 size.cx = size.cy = 0xdeadbeef;
2347 hres = IOleObject_GetExtent(oleobj, 0, &size);
2348 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2349 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2351 size.cx = size.cy = 0xdeadbeef;
2352 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2353 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2354 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2356 size.cx = 1000;
2357 size.cy = 900;
2358 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2359 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2361 size.cx = size.cy = 0xdeadbeef;
2362 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2363 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2364 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2366 size.cx = size.cy = 0xdeadbeef;
2367 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2368 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2369 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2371 IOleObject_Release(oleobj);
2374 static void test_ConnectionPoint(IUnknown *unk, BOOL init)
2376 IConnectionPointContainer *container;
2377 IConnectionPoint *point;
2378 HRESULT hres;
2380 static DWORD dw = 100;
2382 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2383 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2384 if(FAILED(hres))
2385 return;
2387 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2388 IConnectionPointContainer_Release(container);
2389 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2390 if(FAILED(hres))
2391 return;
2393 if(init) {
2394 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2395 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2396 ok(dw == 1, "dw=%d, expected 1\n", dw);
2397 }else {
2398 hres = IConnectionPoint_Unadvise(point, dw);
2399 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2402 IConnectionPoint_Release(point);
2405 static void test_Navigate2(IUnknown *unk)
2407 IWebBrowser2 *webbrowser;
2408 VARIANT url;
2409 HRESULT hres;
2411 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&webbrowser);
2412 ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
2413 if(FAILED(hres))
2414 return;
2416 test_LocationURL(unk, is_first_load ? "" : current_url);
2417 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2419 V_VT(&url) = VT_BSTR;
2420 V_BSTR(&url) = a2bstr("about:blank");
2421 current_url = "about:blank";
2423 if(is_first_load) {
2424 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2425 SET_EXPECT(Invoke_PROPERTYCHANGE);
2426 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2427 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2428 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2429 SET_EXPECT(EnableModeless_FALSE);
2430 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2431 SET_EXPECT(SetStatusText);
2432 SET_EXPECT(GetHostInfo);
2433 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2434 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2435 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2436 SET_EXPECT(GetOptionKeyPath);
2437 SET_EXPECT(GetOverridesKeyPath);
2438 if (use_container_olecmd) SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2439 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSMAX);
2440 if (use_container_olecmd) SET_EXPECT(Exec_SETPROGRESSPOS);
2441 SET_EXPECT(Invoke_SETSECURELOCKICON);
2442 SET_EXPECT(Invoke_FILEDOWNLOAD);
2443 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2444 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2445 SET_EXPECT(EnableModeless_TRUE);
2446 if (!use_container_olecmd) SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2449 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2450 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2452 if(is_first_load) {
2453 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2454 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2455 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2456 todo_wine CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2457 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2458 CHECK_CALLED(EnableModeless_FALSE);
2459 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2460 CHECK_CALLED(SetStatusText);
2461 CHECK_CALLED(GetHostInfo);
2462 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2463 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2464 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2465 CHECK_CALLED(GetOptionKeyPath);
2466 CHECK_CALLED(GetOverridesKeyPath);
2467 if (use_container_olecmd) todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2468 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2469 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2470 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2471 todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
2472 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
2473 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2474 CHECK_CALLED(EnableModeless_TRUE);
2477 VariantClear(&url);
2478 IWebBrowser2_Release(webbrowser);
2480 test_ready_state(READYSTATE_LOADING);
2483 static void test_QueryStatusWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2485 HRESULT hres, success_state;
2486 OLECMDF success_flags;
2487 enum OLECMDF status;
2490 * We can tell the difference between the custom container target and the built-in target
2491 * since the custom target returns OLECMDF_SUPPORTED instead of OLECMDF_ENABLED.
2493 if (use_custom_target)
2494 success_flags = OLECMDF_SUPPORTED;
2495 else
2496 success_flags = OLECMDF_ENABLED;
2498 /* When no target is available (no document or custom target) an error is returned */
2499 if (has_document)
2500 success_state = S_OK;
2501 else
2502 success_state = E_UNEXPECTED;
2505 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2506 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2507 * is enabled and IDM_STOP is not.
2509 status = 0xdeadbeef;
2510 if (use_custom_target) SET_EXPECT(QueryStatus_STOP);
2511 hres = IWebBrowser2_QueryStatusWB(webbrowser, OLECMDID_STOP, &status);
2512 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2513 if (!use_custom_target && has_document)
2514 todo_wine ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2515 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2516 else
2517 ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2518 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2519 status = 0xdeadbeef;
2520 if (use_custom_target) SET_EXPECT(QueryStatus_IDM_STOP);
2521 hres = IWebBrowser2_QueryStatusWB(webbrowser, IDM_STOP, &status);
2522 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2523 ok((has_document && status == 0) || (!has_document && status == 0xdeadbeef),
2524 "IDM_STOP is enabled/supported: %08x %d\n", status, has_document);
2527 static void test_ExecWB(IWebBrowser2 *webbrowser, BOOL use_custom_target, BOOL has_document)
2529 HRESULT hres, olecmdid_state, idm_state;
2531 /* When no target is available (no document or custom target) an error is returned */
2532 if (has_document)
2534 olecmdid_state = S_OK;
2535 idm_state = OLECMDERR_E_NOTSUPPORTED;
2537 else
2539 olecmdid_state = E_UNEXPECTED;
2540 idm_state = E_UNEXPECTED;
2544 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2545 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2546 * succeeds (S_OK) and IDM_STOP does not (OLECMDERR_E_NOTSUPPORTED).
2548 if (use_custom_target)
2549 SET_EXPECT(Exec_STOP);
2550 hres = IWebBrowser2_ExecWB(webbrowser, OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2551 if (!use_custom_target && has_document)
2552 todo_wine ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2553 else
2554 ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2555 if (use_custom_target)
2556 SET_EXPECT(Exec_IDM_STOP);
2557 hres = IWebBrowser2_ExecWB(webbrowser, IDM_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2558 ok(hres == idm_state, "ExecWB failed: %08x %08x\n", hres, idm_state);
2561 static void test_download(DWORD flags)
2563 MSG msg;
2565 is_downloading = TRUE;
2566 dwl_flags = flags;
2568 test_ready_state((flags & DWL_FROM_PUT_HREF) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2570 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2571 SET_EXPECT(Invoke_PROPERTYCHANGE);
2572 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2573 SET_EXPECT(TranslateUrl);
2575 SET_EXPECT(Exec_SETPROGRESSMAX);
2576 SET_EXPECT(Exec_SETPROGRESSPOS);
2577 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2578 SET_EXPECT(DocHost_EnableModeless_FALSE);
2579 SET_EXPECT(DocHost_EnableModeless_TRUE);
2580 SET_EXPECT(Invoke_SETSECURELOCKICON);
2581 SET_EXPECT(Invoke_282);
2582 SET_EXPECT(EnableModeless_FALSE);
2583 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
2584 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2585 SET_EXPECT(SetStatusText);
2586 SET_EXPECT(EnableModeless_TRUE);
2587 if(!is_first_load)
2588 SET_EXPECT(GetHostInfo);
2589 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2590 SET_EXPECT(Invoke_TITLECHANGE);
2591 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2592 if(is_first_load)
2593 SET_EXPECT(GetDropTarget);
2594 SET_EXPECT(Invoke_PROGRESSCHANGE);
2595 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2597 SET_EXPECT(UpdateUI);
2598 SET_EXPECT(Exec_UPDATECOMMANDS);
2599 SET_EXPECT(QueryStatus_STOP);
2601 while(!called_Invoke_DOCUMENTCOMPLETE && GetMessage(&msg, NULL, 0, 0)) {
2602 TranslateMessage(&msg);
2603 DispatchMessage(&msg);
2606 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2607 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2608 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2609 CHECK_CALLED(TranslateUrl);
2611 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2612 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2613 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2614 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
2615 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
2616 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2617 CLEAR_CALLED(Invoke_282); /* IE 7 */
2618 if(is_first_load)
2619 todo_wine CHECK_CALLED(EnableModeless_FALSE);
2620 else
2621 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2622 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE);
2623 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2624 todo_wine CHECK_CALLED(SetStatusText);
2625 if(is_first_load)
2626 todo_wine CHECK_CALLED(EnableModeless_TRUE);
2627 else
2628 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
2629 if(!is_first_load)
2630 todo_wine CHECK_CALLED(GetHostInfo);
2631 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2632 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
2633 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
2634 if(is_first_load)
2635 todo_wine CHECK_CALLED(GetDropTarget);
2636 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2637 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
2639 is_downloading = FALSE;
2641 test_ready_state(READYSTATE_COMPLETE);
2643 while(!called_Exec_UPDATECOMMANDS && GetMessage(&msg, NULL, 0, 0)) {
2644 TranslateMessage(&msg);
2645 DispatchMessage(&msg);
2648 CHECK_CALLED(UpdateUI);
2649 CHECK_CALLED(Exec_UPDATECOMMANDS);
2650 CLEAR_CALLED(QueryStatus_STOP);
2653 static void test_olecmd(IUnknown *unk, BOOL loaded)
2655 IOleCommandTarget *cmdtrg;
2656 OLECMD cmds[3];
2657 HRESULT hres;
2659 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2660 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
2661 if(FAILED(hres))
2662 return;
2664 cmds[0].cmdID = OLECMDID_SPELL;
2665 cmds[0].cmdf = 0xdeadbeef;
2666 cmds[1].cmdID = OLECMDID_REFRESH;
2667 cmds[1].cmdf = 0xdeadbeef;
2668 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
2669 if(loaded) {
2670 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2671 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2672 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
2673 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
2674 }else {
2675 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
2676 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
2677 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
2680 IOleCommandTarget_Release(cmdtrg);
2683 static void test_IServiceProvider(IUnknown *unk)
2685 IServiceProvider *servprov = (void*)0xdeadbeef;
2686 HRESULT hres;
2687 IUnknown *ret = NULL;
2689 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
2690 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
2691 if(FAILED(hres))
2692 return;
2694 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&ret);
2695 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
2696 ok(ret == NULL, "ret returned %p, expected NULL\n", ret);
2697 if(hres == S_OK)
2699 IUnknown_Release(ret);
2702 IServiceProvider_Release(servprov);
2705 static void test_put_href(IUnknown *unk)
2707 IHTMLLocation *location;
2708 IHTMLDocument2 *doc;
2709 IDispatch *doc_disp;
2710 BSTR str;
2711 HRESULT hres;
2713 doc_disp = get_document(unk);
2715 hres = IDispatch_QueryInterface(doc_disp, &IID_IHTMLDocument2, (void**)&doc);
2716 IDispatch_Release(doc_disp);
2717 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2 failed: %08x\n", hres);
2719 location = NULL;
2720 hres = IHTMLDocument2_get_location(doc, &location);
2721 IHTMLDocument2_Release(doc);
2722 ok(hres == S_OK, "get_location failed: %08x\n", hres);
2723 ok(location != NULL, "location == NULL\n");
2725 SET_EXPECT(TranslateUrl);
2726 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2727 SET_EXPECT(Invoke_PROPERTYCHANGE);
2729 dwl_flags = DWL_FROM_PUT_HREF;
2731 str = a2bstr("about:test");
2732 current_url = "about:test";
2733 is_first_load = FALSE;
2734 hres = IHTMLLocation_put_href(location, str);
2736 CHECK_CALLED(TranslateUrl);
2737 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2738 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2740 IHTMLLocation_Release(location);
2741 SysFreeString(str);
2742 ok(hres == S_OK, "put_href failed: %08x\n", hres);
2744 test_ready_state(READYSTATE_COMPLETE);
2747 static void test_QueryInterface(IUnknown *unk)
2749 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
2750 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
2751 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
2752 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
2753 IOleCache *cache = (void*)0xdeadbeef;
2754 IObjectWithSite *site = (void*)0xdeadbeef;
2755 IViewObjectEx *viewex = (void*)0xdeadbeef;
2756 IOleLink *link = (void*)0xdeadbeef;
2757 IMarshal *marshal = (void*)0xdeadbeef;
2758 IStdMarshalInfo *marshalinfo = (void*)0xdeadbeef;
2759 HRESULT hres;
2761 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
2762 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2763 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
2765 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
2766 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2767 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
2769 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
2770 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2771 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
2773 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
2774 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2775 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
2777 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
2778 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2779 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
2781 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
2782 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2783 ok(site == NULL, "site=%p, expected NULL\n", site);
2785 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
2786 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2787 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
2789 hres = IUnknown_QueryInterface(unk, &IID_IOleLink, (void**)&link);
2790 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2791 ok(link == NULL, "link=%p, expected NULL\n", link);
2793 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&marshal);
2794 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2795 ok(marshal == NULL, "marshal=%p, expected NULL\n", marshal);
2797 hres = IUnknown_QueryInterface(unk, &IID_IStdMarshalInfo, (void**)&marshalinfo);
2798 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
2799 ok(marshalinfo == NULL, "marshalinfo=%p, expected NULL\n", marshalinfo);
2803 static void test_UIActivate(IUnknown *unk, BOOL activate)
2805 IOleDocumentView *docview;
2806 IDispatch *disp;
2807 HRESULT hres;
2809 disp = get_document(unk);
2811 hres = IDispatch_QueryInterface(disp, &IID_IOleDocumentView, (void**)&docview);
2812 ok(hres == S_OK, "Got 0x%08x\n", hres);
2813 if(SUCCEEDED(hres)) {
2814 if(activate) {
2815 SET_EXPECT(RequestUIActivate);
2816 SET_EXPECT(ShowUI);
2817 SET_EXPECT(HideUI);
2818 SET_EXPECT(OnFocus);
2821 hres = IOleDocumentView_UIActivate(docview, activate);
2822 if(activate)
2823 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
2824 else
2825 ok(hres == S_OK, "Got 0x%08x\n", hres);
2827 if(activate) {
2828 todo_wine {
2829 CHECK_CALLED(RequestUIActivate);
2830 CHECK_CALLED(ShowUI);
2831 CHECK_CALLED(HideUI);
2832 CHECK_CALLED(OnFocus);
2836 IOleDocumentView_Release(docview);
2839 IDispatch_Release(disp);
2842 static void test_TranslateAccelerator(IUnknown *unk)
2844 IOleClientSite *doc_clientsite;
2845 IOleInPlaceActiveObject *pao;
2846 HRESULT hres;
2847 DWORD keycode;
2848 MSG msg_a = {
2849 container_hwnd,
2850 0, 0, 0,
2851 GetTickCount(),
2852 {5, 5}
2855 test_Navigate2(unk);
2857 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
2858 ok(hres == S_OK, "Got 0x%08x\n", hres);
2859 if(SUCCEEDED(hres)) {
2860 /* One accelerator that should be handled by mshtml */
2861 msg_a.message = WM_KEYDOWN;
2862 msg_a.wParam = VK_F1;
2863 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
2864 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
2866 /* And one that should not */
2867 msg_a.message = WM_KEYDOWN;
2868 msg_a.wParam = VK_F5;
2869 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
2870 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
2872 IOleInPlaceActiveObject_Release(pao);
2875 test_UIActivate(unk, TRUE);
2877 /* Test again after UIActivate */
2878 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
2879 ok(hres == S_OK, "Got 0x%08x\n", hres);
2880 if(SUCCEEDED(hres)) {
2881 /* One accelerator that should be handled by mshtml */
2882 msg_a.message = WM_KEYDOWN;
2883 msg_a.wParam = VK_F1;
2884 SET_EXPECT(DocHost_TranslateAccelerator);
2885 SET_EXPECT(ControlSite_TranslateAccelerator);
2886 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
2887 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
2888 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
2889 todo_wine CHECK_CALLED(ControlSite_TranslateAccelerator);
2891 /* And one that should not */
2892 msg_a.message = WM_KEYDOWN;
2893 msg_a.wParam = VK_F5;
2894 SET_EXPECT(DocHost_TranslateAccelerator);
2895 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
2896 todo_wine ok(hres == S_OK, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
2897 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
2899 IOleInPlaceActiveObject_Release(pao);
2902 doc_clientsite = get_dochost(unk);
2903 if(doc_clientsite) {
2904 IDocHostUIHandler2 *dochost;
2905 IOleControlSite *doc_controlsite;
2906 IUnknown *unk_test;
2908 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleInPlaceFrame, (void**)&unk_test);
2909 ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
2910 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
2912 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostShowUI, (void**)&unk_test);
2913 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
2914 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
2916 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler, (void**)&unk_test);
2917 ok(hres == S_OK, "Got 0x%08x\n", hres);
2918 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
2920 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler2, (void**)&dochost);
2921 ok(hres == S_OK, "Got 0x%08x\n", hres);
2922 if(SUCCEEDED(hres)) {
2923 msg_a.message = WM_KEYDOWN;
2924 hr_dochost_TranslateAccelerator = 0xdeadbeef;
2925 for(keycode = 0; keycode <= 0x100; keycode++) {
2926 msg_a.wParam = keycode;
2927 SET_EXPECT(DocHost_TranslateAccelerator);
2928 hres = IDocHostUIHandler_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
2929 ok(hres == 0xdeadbeef, "Got 0x%08x\n", hres);
2930 CHECK_CALLED(DocHost_TranslateAccelerator);
2932 hr_dochost_TranslateAccelerator = E_NOTIMPL;
2934 SET_EXPECT(DocHost_TranslateAccelerator);
2935 hres = IDocHostUIHandler_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
2936 ok(hres == E_NOTIMPL, "Got 0x%08x\n", hres);
2937 CHECK_CALLED(DocHost_TranslateAccelerator);
2939 IDocHostUIHandler2_Release(dochost);
2942 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleControlSite, (void**)&doc_controlsite);
2943 ok(hres == S_OK, "Got 0x%08x\n", hres);
2944 if(SUCCEEDED(hres)) {
2945 msg_a.message = WM_KEYDOWN;
2946 hr_site_TranslateAccelerator = 0xdeadbeef;
2947 for(keycode = 0; keycode < 0x100; keycode++) {
2948 msg_a.wParam = keycode;
2949 SET_EXPECT(ControlSite_TranslateAccelerator);
2950 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
2951 if(keycode == 0x9 || keycode == 0x75)
2952 todo_wine ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
2953 else
2954 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
2956 CHECK_CALLED(ControlSite_TranslateAccelerator);
2958 msg_a.wParam = VK_LEFT;
2959 SET_EXPECT(ControlSite_TranslateAccelerator);
2960 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
2961 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
2962 CHECK_CALLED(ControlSite_TranslateAccelerator);
2964 hr_site_TranslateAccelerator = S_OK;
2965 SET_EXPECT(ControlSite_TranslateAccelerator);
2966 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
2967 ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
2968 CHECK_CALLED(ControlSite_TranslateAccelerator);
2970 hr_site_TranslateAccelerator = E_NOTIMPL;
2971 SET_EXPECT(ControlSite_TranslateAccelerator);
2972 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
2973 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
2974 CHECK_CALLED(ControlSite_TranslateAccelerator);
2976 IOleControlSite_Release(doc_controlsite);
2979 IOleClientSite_Release(doc_clientsite);
2982 test_UIActivate(unk, FALSE);
2985 static void test_dochost_qs(IUnknown *unk)
2987 IOleClientSite *client_site;
2988 IServiceProvider *serv_prov;
2989 IUnknown *service;
2990 HRESULT hres;
2992 client_site = get_dochost(unk);
2993 hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
2994 IOleClientSite_Release(client_site);
2995 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
2997 hres = IServiceProvider_QueryService(serv_prov, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&service);
2998 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
2999 ok(iface_cmp(service, unk), "service != unk\n");
3000 IUnknown_Release(service);
3002 hres = IServiceProvider_QueryService(serv_prov, &IID_IWebBrowserApp, &IID_IHlinkFrame, (void**)&service);
3003 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3004 ok(iface_cmp(service, unk), "service != unk\n");
3005 IUnknown_Release(service);
3007 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IShellBrowser, (void**)&service);
3008 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3009 IUnknown_Release(service);
3011 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IBrowserService, (void**)&service);
3012 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3013 IUnknown_Release(service);
3015 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IDocObjectService, (void**)&service);
3016 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3017 IUnknown_Release(service);
3019 IServiceProvider_Release(serv_prov);
3022 static void test_Close(IWebBrowser2 *wb, BOOL do_download)
3024 IOleObject *oo;
3025 IOleClientSite *ocs;
3026 HRESULT hres;
3028 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oo);
3029 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3030 if(hres != S_OK)
3031 return;
3033 test_close = TRUE;
3035 SET_EXPECT(Frame_SetActiveObject);
3036 SET_EXPECT(UIWindow_SetActiveObject);
3037 SET_EXPECT(OnUIDeactivate);
3038 SET_EXPECT(OnFocus);
3039 SET_EXPECT(OnInPlaceDeactivate);
3040 if(!do_download) {
3041 SET_EXPECT(Invoke_COMMANDSTATECHANGE);
3042 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3044 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3045 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3046 CHECK_CALLED(Frame_SetActiveObject);
3047 CHECK_CALLED(UIWindow_SetActiveObject);
3048 CHECK_CALLED(OnUIDeactivate);
3049 todo_wine CHECK_CALLED(OnFocus);
3050 CHECK_CALLED(OnInPlaceDeactivate);
3051 if(!do_download) {
3052 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE);
3053 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3056 hres = IOleObject_GetClientSite(oo, &ocs);
3057 ok(hres == S_OK, "hres = %x\n", hres);
3058 ok(!ocs, "ocs != NULL\n");
3060 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3061 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3063 test_close = FALSE;
3064 IOleObject_Release(oo);
3067 static void test_WebBrowser(BOOL do_download, BOOL do_close)
3069 IUnknown *unk = NULL;
3070 ULONG ref;
3071 HRESULT hres;
3073 if (FAILED(create_WebBrowser(&unk)))
3074 return;
3076 is_downloading = FALSE;
3077 is_first_load = TRUE;
3078 use_container_olecmd = TRUE;
3080 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
3081 ok(hres == S_OK, "Could not get IWebBrowser2 iface: %08x\n", hres);
3083 test_QueryStatusWB(wb, FALSE, FALSE);
3084 test_ExecWB(wb, FALSE, FALSE);
3085 test_QueryInterface(unk);
3086 test_ready_state(READYSTATE_UNINITIALIZED);
3087 test_ClassInfo(unk);
3088 test_LocationURL(unk, "");
3089 test_ConnectionPoint(unk, TRUE);
3090 test_ClientSite(unk, &ClientSite, !do_download);
3091 test_Extent(unk);
3092 test_wb_funcs(unk, TRUE);
3093 test_DoVerb(unk);
3094 test_olecmd(unk, FALSE);
3095 test_Navigate2(unk);
3096 test_QueryStatusWB(wb, TRUE, TRUE);
3097 test_ExecWB(wb, TRUE, TRUE);
3099 if(do_download) {
3100 IDispatch *doc, *doc2;
3102 test_download(0);
3103 test_olecmd(unk, TRUE);
3104 doc = get_document(unk);
3106 test_put_href(unk);
3107 test_download(DWL_FROM_PUT_HREF);
3108 doc2 = get_document(unk);
3109 ok(doc == doc2, "doc != doc2\n");
3110 IDispatch_Release(doc2);
3112 test_Navigate2(unk);
3113 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3114 test_TranslateAccelerator(unk);
3115 doc2 = get_document(unk);
3116 ok(doc == doc2, "doc != doc2\n");
3117 IDispatch_Release(doc2);
3118 IDispatch_Release(doc2);
3120 test_dochost_qs(unk);
3123 if(do_close)
3124 test_Close(wb, do_download);
3125 else
3126 test_ClientSite(unk, NULL, !do_download);
3127 test_ie_funcs(unk);
3128 test_GetControlInfo(unk);
3129 test_wb_funcs(unk, FALSE);
3130 test_ConnectionPoint(unk, FALSE);
3131 test_IServiceProvider(unk);
3133 IWebBrowser2_Release(wb);
3134 ref = IUnknown_Release(unk);
3135 ok(ref == 0, "ref=%d, expected 0\n", ref);
3138 static void test_WebBrowser_NoContainerOlecmd(void)
3140 IUnknown *unk = NULL;
3141 HRESULT hres;
3142 ULONG ref;
3144 is_downloading = FALSE;
3145 is_first_load = TRUE;
3146 use_container_olecmd = FALSE;
3148 /* Setup stage */
3149 if (FAILED(create_WebBrowser(&unk)))
3150 return;
3151 hres = IUnknown_QueryInterface(unk, &IID_IWebBrowser2, (void**)&wb);
3152 ok(hres == S_OK, "QueryInterface(IID_IWebBrowser) failed: %08x\n", hres);
3153 if(FAILED(hres))
3154 return;
3155 test_ConnectionPoint(unk, TRUE);
3156 test_ClientSite(unk, &ClientSite, TRUE);
3157 test_DoVerb(unk);
3158 test_Navigate2(unk);
3160 /* Tests of interest */
3161 test_QueryStatusWB(wb, FALSE, TRUE);
3162 test_ExecWB(wb, FALSE, TRUE);
3164 /* Cleanup stage */
3165 IWebBrowser2_Release(wb);
3166 test_ClientSite(unk, NULL, TRUE);
3167 test_ConnectionPoint(unk, FALSE);
3168 ref = IUnknown_Release(unk);
3169 ok(ref == 0, "ref=%d, expected 0\n", ref);
3172 START_TEST(webbrowser)
3174 OleInitialize(NULL);
3176 container_hwnd = create_container_window();
3178 trace("Testing WebBrowser (no download)...\n");
3179 test_WebBrowser(FALSE, FALSE);
3180 test_WebBrowser(FALSE, TRUE);
3181 trace("Testing WebBrowser...\n");
3182 test_WebBrowser(TRUE, FALSE);
3183 test_WebBrowser(TRUE, TRUE);
3184 trace("Testing WebBrowser w/o container-based olecmd...\n");
3185 test_WebBrowser_NoContainerOlecmd();
3187 OleUninitialize();