winemac.drv: Don't filter non active displays out.
[wine/zf.git] / dlls / ieframe / tests / webbrowser.c
blobab0345b79b57497edf5180ac527647a852cdc96e
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 "htiface.h"
33 #include "mshtmhst.h"
34 #include "mshtmcid.h"
35 #include "mshtml.h"
36 #include "idispids.h"
37 #include "olectl.h"
38 #include "mshtmdid.h"
39 #include "shobjidl.h"
40 #include "shdeprecated.h"
41 #include "shlguid.h"
42 #include "exdispid.h"
43 #include "mimeinfo.h"
44 #include "hlink.h"
45 #include "docobjectservice.h"
47 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
48 DEFINE_GUID(outer_test_iid,0x06d4cd6c,0x18dd,0x11ea,0x8e,0x76,0xfc,0xaa,0x14,0x72,0x2d,0xac);
49 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
50 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
52 #define DEFINE_EXPECT(func) \
53 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
55 #define SET_EXPECT(func) \
56 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
58 #define CHECK_EXPECT2(func) \
59 do { \
60 ok(expect_ ##func, "unexpected call " #func "\n"); \
61 called_ ## func = TRUE; \
62 }while(0)
64 #define CHECK_EXPECT(func) \
65 do { \
66 CHECK_EXPECT2(func); \
67 expect_ ## func = FALSE; \
68 }while(0)
70 #define CHECK_CALLED(func) \
71 do { \
72 ok(called_ ## func, "expected " #func "\n"); \
73 expect_ ## func = called_ ## func = FALSE; \
74 }while(0)
76 #define CHECK_NOT_CALLED(func) \
77 do { \
78 ok(!called_ ## func, "unexpected " #func "\n"); \
79 expect_ ## func = called_ ## func = FALSE; \
80 }while(0)
82 #define CLEAR_CALLED(func) \
83 expect_ ## func = called_ ## func = FALSE
85 DEFINE_EXPECT(GetContainer);
86 DEFINE_EXPECT(Site_GetWindow);
87 DEFINE_EXPECT(ShowObject);
88 DEFINE_EXPECT(CanInPlaceActivate);
89 DEFINE_EXPECT(OnInPlaceActivate);
90 DEFINE_EXPECT(OnUIActivate);
91 DEFINE_EXPECT(GetWindowContext);
92 DEFINE_EXPECT(Frame_GetWindow);
93 DEFINE_EXPECT(Frame_SetActiveObject);
94 DEFINE_EXPECT(UIWindow_SetActiveObject);
95 DEFINE_EXPECT(SetMenu);
96 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
97 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
98 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
99 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
100 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
101 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
102 DEFINE_EXPECT(Invoke_STATUSTEXTCHANGE);
103 DEFINE_EXPECT(Invoke_PROPERTYCHANGE);
104 DEFINE_EXPECT(Invoke_DOWNLOADBEGIN);
105 DEFINE_EXPECT(Invoke_BEFORENAVIGATE2);
106 DEFINE_EXPECT(Invoke_SETSECURELOCKICON);
107 DEFINE_EXPECT(Invoke_FILEDOWNLOAD);
108 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
109 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
110 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
111 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
112 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
113 DEFINE_EXPECT(Invoke_DOWNLOADCOMPLETE);
114 DEFINE_EXPECT(Invoke_ONMENUBAR);
115 DEFINE_EXPECT(Invoke_ONADDRESSBAR);
116 DEFINE_EXPECT(Invoke_ONSTATUSBAR);
117 DEFINE_EXPECT(Invoke_ONTOOLBAR);
118 DEFINE_EXPECT(Invoke_ONFULLSCREEN);
119 DEFINE_EXPECT(Invoke_ONTHEATERMODE);
120 DEFINE_EXPECT(Invoke_WINDOWSETRESIZABLE);
121 DEFINE_EXPECT(Invoke_TITLECHANGE);
122 DEFINE_EXPECT(Invoke_NAVIGATECOMPLETE2);
123 DEFINE_EXPECT(Invoke_PROGRESSCHANGE);
124 DEFINE_EXPECT(Invoke_DOCUMENTCOMPLETE);
125 DEFINE_EXPECT(Invoke_WINDOWCLOSING);
126 DEFINE_EXPECT(Invoke_SETPHISHINGFILTERSTATUS);
127 DEFINE_EXPECT(EnableModeless_TRUE);
128 DEFINE_EXPECT(EnableModeless_FALSE);
129 DEFINE_EXPECT(GetHostInfo);
130 DEFINE_EXPECT(GetOptionKeyPath);
131 DEFINE_EXPECT(GetOverridesKeyPath);
132 DEFINE_EXPECT(SetStatusText);
133 DEFINE_EXPECT(UpdateUI);
134 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
135 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
136 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
137 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
138 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
139 DEFINE_EXPECT(Exec_SETTITLE);
140 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
141 DEFINE_EXPECT(Exec_STOP);
142 DEFINE_EXPECT(Exec_IDM_STOP);
143 DEFINE_EXPECT(Exec_DocHostCommandHandler_2300);
144 DEFINE_EXPECT(QueryStatus_STOP);
145 DEFINE_EXPECT(QueryStatus_IDM_STOP);
146 DEFINE_EXPECT(DocHost_EnableModeless_TRUE);
147 DEFINE_EXPECT(DocHost_EnableModeless_FALSE);
148 DEFINE_EXPECT(DocHost_TranslateAccelerator);
149 DEFINE_EXPECT(GetDropTarget);
150 DEFINE_EXPECT(TranslateUrl);
151 DEFINE_EXPECT(ShowUI);
152 DEFINE_EXPECT(HideUI);
153 DEFINE_EXPECT(OnUIDeactivate);
154 DEFINE_EXPECT(OnInPlaceDeactivate);
155 DEFINE_EXPECT(RequestUIActivate);
156 DEFINE_EXPECT(ControlSite_TranslateAccelerator);
157 DEFINE_EXPECT(OnFocus_TRUE);
158 DEFINE_EXPECT(OnFocus_FALSE);
159 DEFINE_EXPECT(GetExternal);
160 DEFINE_EXPECT(outer_QI_test);
161 DEFINE_EXPECT(Advise_OnClose);
163 static VARIANT_BOOL exvb;
165 static IWebBrowser2 *wb;
167 static HWND container_hwnd, shell_embedding_hwnd;
168 static BOOL is_downloading, do_download, is_first_load, use_container_olecmd;
169 static BOOL test_close, test_hide, is_http, use_container_dochostui;
170 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
171 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
172 static const WCHAR *current_url;
173 static int wb_version, expect_update_commands_enable, set_update_commands_enable;
174 static BOOL nav_back_todo, nav_forward_todo; /* FIXME */
176 enum SessionOp
178 SESSION_QUERY,
179 SESSION_INCREMENT,
180 SESSION_DECREMENT
183 static LONG (WINAPI *pSetQueryNetSessionCount)(DWORD);
185 #define BUSY_FAIL 2
187 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
188 #define DWL_FROM_PUT_HREF 0x02
189 #define DWL_FROM_GOBACK 0x04
190 #define DWL_FROM_GOFORWARD 0x08
191 #define DWL_HTTP 0x10
192 #define DWL_REFRESH 0x20
193 #define DWL_BACK_ENABLE 0x40
195 static DWORD dwl_flags;
197 static IAdviseSink test_sink;
199 /* Returns true if the user interface is in English. Note that this does not
200 * presume of the formatting of dates, numbers, etc.
202 static BOOL is_lang_english(void)
204 static HMODULE hkernel32 = NULL;
205 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
206 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
208 if (!hkernel32)
210 hkernel32 = GetModuleHandleA("kernel32.dll");
211 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
212 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
214 if (pGetThreadUILanguage)
215 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
216 if (pGetUserDefaultUILanguage)
217 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
219 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
222 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
224 IUnknown *unk1, *unk2;
226 if(iface1 == iface2)
227 return TRUE;
229 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
230 IUnknown_Release(unk1);
231 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
232 IUnknown_Release(unk2);
234 return unk1 == unk2;
237 #define create_webbrowser() _create_webbrowser(__LINE__)
238 static IWebBrowser2 *_create_webbrowser(unsigned line)
240 IWebBrowser2 *ret;
241 HRESULT hres;
243 wb_version = 2;
245 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
246 &IID_IWebBrowser2, (void**)&ret);
247 ok_(__FILE__,line)(hres == S_OK, "Creating WebBrowser object failed: %08x\n", hres);
248 return ret;
251 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
252 static void _test_LocationURL(unsigned line, IWebBrowser2 *wb, const WCHAR *exurl)
254 BSTR url = (void*)0xdeadbeef;
255 HRESULT hres;
257 hres = IWebBrowser2_get_LocationURL(wb, &url);
258 ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
259 if (SUCCEEDED(hres))
261 ok_(__FILE__,line) (!lstrcmpW(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
262 SysFreeString(url);
266 #define test_ready_state(a,b) _test_ready_state(__LINE__,a,b)
267 static void _test_ready_state(unsigned line, READYSTATE exstate, VARIANT_BOOL expect_busy)
269 READYSTATE state;
270 VARIANT_BOOL busy;
271 HRESULT hres;
273 hres = IWebBrowser2_get_ReadyState(wb, &state);
274 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
275 ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
277 hres = IWebBrowser2_get_Busy(wb, &busy);
278 if(expect_busy != BUSY_FAIL) {
279 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
280 ok_(__FILE__,line)(busy == expect_busy, "Busy = %x, expected %x for ready state %d\n",
281 busy, expect_busy, state);
282 }else {
283 todo_wine
284 ok_(__FILE__,line)(hres == E_FAIL, "get_ReadyState returned: %08x\n", hres);
288 #define get_document(u) _get_document(__LINE__,u)
289 static IHTMLDocument2 *_get_document(unsigned line, IWebBrowser2 *wb)
291 IHTMLDocument2 *html_doc;
292 IDispatch *disp;
293 HRESULT hres;
295 disp = NULL;
296 hres = IWebBrowser2_get_Document(wb, &disp);
297 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
298 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
300 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
301 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
302 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
303 IDispatch_Release(disp);
305 return html_doc;
308 #define get_dochost(u) _get_dochost(__LINE__,u)
309 static IOleClientSite *_get_dochost(unsigned line, IWebBrowser2 *unk)
311 IOleClientSite *client_site;
312 IHTMLDocument2 *doc;
313 IOleObject *oleobj;
314 HRESULT hres;
316 doc = _get_document(line, unk);
317 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
318 IHTMLDocument2_Release(doc);
319 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
321 hres = IOleObject_GetClientSite(oleobj, &client_site);
322 IOleObject_Release(oleobj);
323 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
325 return client_site;
328 static HRESULT QueryInterface(REFIID,void**);
330 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
331 REFIID riid, void **ppv)
333 ok(0, "unexpected call\n");
334 return E_NOINTERFACE;
337 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
339 return 2;
342 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
344 return 1;
347 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
348 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
350 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
351 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
352 ok(!pCmdText, "pCmdText != NULL\n");
354 switch(prgCmds[0].cmdID) {
355 case OLECMDID_STOP:
356 CHECK_EXPECT2(QueryStatus_STOP);
357 prgCmds[0].cmdf = OLECMDF_SUPPORTED;
358 return S_OK;
359 case OLECMDID_SETPROGRESSTEXT:
360 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
361 prgCmds[0].cmdf = OLECMDF_ENABLED;
362 return S_OK;
363 case IDM_STOP:
364 /* Note:
365 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
366 * This command appears here for the ExecWB and QueryStatusWB tests in order
367 * to help demonstrate that these routines use a NULL pguidCmdGroup.
369 CHECK_EXPECT(QueryStatus_IDM_STOP);
370 prgCmds[0].cmdf = 0;
371 return S_OK;
372 default:
373 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
376 return E_FAIL;
379 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
380 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
382 if(!pguidCmdGroup) {
383 switch(nCmdID) {
384 case OLECMDID_SETPROGRESSMAX:
385 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
386 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
387 ok(pvaIn != NULL, "pvaIn == NULL\n");
388 if(pvaIn)
389 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
390 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
391 return S_OK;
392 case OLECMDID_SETPROGRESSPOS:
393 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
394 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
395 ok(pvaIn != NULL, "pvaIn == NULL\n");
396 if(pvaIn)
397 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
398 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
399 return S_OK;
400 case OLECMDID_SETDOWNLOADSTATE:
401 if(is_downloading)
402 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
403 "nCmdexecopts=%08x\n", nCmdexecopt);
404 else
405 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
406 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
407 ok(pvaIn != NULL, "pvaIn == NULL\n");
408 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
409 switch(V_I4(pvaIn)) {
410 case 0:
411 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
412 break;
413 case 1:
414 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
415 break;
416 default:
417 ok(0, "unexpected V_I4(pvaIn)=%d\n", V_I4(pvaIn));
419 return S_OK;
420 case OLECMDID_UPDATECOMMANDS:
421 CHECK_EXPECT2(Exec_UPDATECOMMANDS);
422 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
423 ok(!pvaIn, "pvaIn != NULL\n");
424 ok(!pvaOut, "pvaOut=%p, expected NULL\n", pvaOut);
425 return S_OK;
426 case OLECMDID_SETTITLE:
427 CHECK_EXPECT(Exec_SETTITLE);
428 /* TODO: test args */
429 return S_OK;
430 case OLECMDID_STOP:
431 CHECK_EXPECT(Exec_STOP);
432 return S_OK;
433 case IDM_STOP:
434 /* Note:
435 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
436 * This command appears here for the ExecWB and QueryStatusWB tests in order
437 * to help demonstrate that these routines use a NULL pguidCmdGroup.
439 CHECK_EXPECT(Exec_IDM_STOP);
440 return OLECMDERR_E_NOTSUPPORTED;
441 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
442 case OLECMDID_PAGEAVAILABLE: /* TODO (IE11) */
443 return E_NOTIMPL;
444 case 6058: /* TODO */
445 return E_NOTIMPL;
446 default:
447 ok(0, "unexpected nCmdID %d\n", nCmdID);
449 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
450 switch(nCmdID) {
451 case 20: /* TODO */
452 case 24: /* TODO */
453 case 25: /* IE5 */
454 case 37: /* TODO */
455 case 39: /* TODO */
456 case 66: /* TODO */
457 case 67: /* TODO */
458 case 69: /* TODO */
459 case 101: /* TODO (IE8) */
460 case 109: /* TODO (IE9) */
461 case 113: /* TODO (IE10) */
462 case 119: /* IE11 */
463 return E_FAIL;
464 default:
465 ok(0, "unexpected nCmdID %d\n", nCmdID);
467 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
468 switch(nCmdID) {
469 case 63: /* win10 */
470 case 105: /* TODO */
471 case 132: /* win10 */
472 case 133: /* IE11 */
473 case 134: /* TODO (IE10) */
474 case 135: /* IE11 */
475 case 136: /* TODO (IE10) */
476 case 137: /* win10 */
477 case 138: /* TODO */
478 case 140: /* TODO (Win7) */
479 case 144: /* TODO */
480 case 178: /* IE11 */
481 case 179: /* IE11 */
482 case 180: /* IE11 */
483 case 181: /* IE11 */
484 case 182: /* win10 */
485 return E_FAIL;
486 default:
487 ok(0, "unexpected nCmdID %d\n", nCmdID);
489 }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
490 switch(nCmdID) {
491 case 11: /* TODO */
492 break;
493 default:
494 ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
496 }else if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
497 switch(nCmdID) {
498 case 6041: /* TODO */
499 break;
500 case 2300:
501 CHECK_EXPECT(Exec_DocHostCommandHandler_2300);
502 return E_NOTIMPL;
503 default:
504 ok(0, "unexpected nCmdID %d of CGID_DocHostCommandHandler\n", nCmdID);
506 }else {
507 ok(0, "unexpected pguidCmdGroup %s\n", wine_dbgstr_guid(pguidCmdGroup));
510 return E_FAIL;
513 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
514 OleCommandTarget_QueryInterface,
515 OleCommandTarget_AddRef,
516 OleCommandTarget_Release,
517 OleCommandTarget_QueryStatus,
518 OleCommandTarget_Exec
521 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
523 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
525 if(IsEqualGUID(&IID_ITargetContainer, riid))
526 return E_NOINTERFACE; /* TODO */
528 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
529 if(use_container_olecmd)
531 *ppv = &OleCommandTarget;
532 return S_OK;
534 else
535 return E_NOINTERFACE;
538 ok(0, "unexpected call\n");
539 return E_NOINTERFACE;
542 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
544 return 2;
547 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
549 return 1;
552 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
553 LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
555 ok(0, "unexpected call\n");
556 return E_NOTIMPL;
559 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
560 IEnumUnknown **ppenum)
562 ok(0, "unexpected call\n");
563 return E_NOTIMPL;
566 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
568 ok(0, "unexpected call\n");
569 return E_NOTIMPL;
572 static const IOleContainerVtbl OleContainerVtbl = {
573 OleContainer_QueryInterface,
574 OleContainer_AddRef,
575 OleContainer_Release,
576 OleContainer_ParseDisplayName,
577 OleContainer_EnumObjects,
578 OleContainer_LockContainer
581 static IOleContainer OleContainer = { &OleContainerVtbl };
583 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
585 return QueryInterface(riid, ppv);
588 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
590 return 2;
593 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
595 return 1;
598 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
600 ok(0, "unexpected call\n");
601 return E_NOTIMPL;
604 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
605 ITypeInfo **ppTInfo)
607 ok(0, "unexpected call\n");
608 return E_NOTIMPL;
611 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
612 UINT cNames, LCID lcid, DISPID *rgDispId)
614 ok(0, "unexpected call\n");
615 return E_NOTIMPL;
618 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
619 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
620 EXCEPINFO *pExcepInfo, UINT *puArgErr)
622 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
623 ok(pDispParams != NULL, "pDispParams == NULL\n");
624 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
625 ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
626 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
627 ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
628 ok(pDispParams->rgdispidNamedArgs == NULL,
629 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
630 ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
631 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
633 switch(dispIdMember) {
634 case DISPID_AMBIENT_USERMODE:
635 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
636 return E_FAIL;
637 case DISPID_AMBIENT_DLCONTROL:
638 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
639 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
640 return E_FAIL;
641 case DISPID_AMBIENT_USERAGENT:
642 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
643 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
644 return E_FAIL;
645 case DISPID_AMBIENT_PALETTE:
646 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
647 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
648 return E_FAIL;
649 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
650 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
651 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
652 V_VT(pVarResult) = VT_BOOL;
653 V_BOOL(pVarResult) = VARIANT_FALSE;
654 return S_OK;
655 case DISPID_AMBIENT_SILENT:
656 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
657 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
658 V_VT(pVarResult) = VT_BOOL;
659 V_BOOL(pVarResult) = VARIANT_FALSE;
660 return S_OK;
663 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
664 return E_NOTIMPL;
667 static IDispatchVtbl DispatchVtbl = {
668 Dispatch_QueryInterface,
669 Dispatch_AddRef,
670 Dispatch_Release,
671 Dispatch_GetTypeInfoCount,
672 Dispatch_GetTypeInfo,
673 Dispatch_GetIDsOfNames,
674 Dispatch_Invoke
677 static IDispatch Dispatch = { &DispatchVtbl };
679 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
681 *ppv = NULL;
683 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
684 *ppv = iface;
685 return S_OK;
688 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
689 return E_NOINTERFACE;
692 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
693 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
695 ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
696 ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
697 ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
698 if(strict)
699 ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
700 V_BOOL(params->rgvarg), exvb);
701 else
702 ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
703 V_BOOL(params->rgvarg), exvb);
706 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
707 const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
709 BSTR str;
711 ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
712 ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
713 ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
715 ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
716 ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
717 if(V_VARIANTREF(url)) {
718 ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
719 V_VT(V_VARIANTREF(url)));
720 ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
721 ok(!lstrcmpW(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
722 wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), wine_dbgstr_w(current_url));
725 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
726 V_VT(flags));
727 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
728 V_VT(flags));
729 ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
730 if(V_VARIANTREF(flags)) {
731 int f;
733 ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
734 V_VT(V_VARIANTREF(flags)));
735 f = V_I4(V_VARIANTREF(flags));
736 f &= ~0x100; /* IE11 sets this flag */
737 if(is_first_load)
738 ok(!f, "flags = %x, expected 0\n", V_I4(V_VARIANTREF(flags)));
739 else
740 ok(!(f & ~0x40), "flags = %x, expected 0x40 or 0\n", V_I4(V_VARIANTREF(flags)));
743 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
744 V_VT(frame));
745 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
746 V_VT(frame));
747 ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
748 if(V_VARIANTREF(frame)) {
749 ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
750 V_VT(V_VARIANTREF(frame)));
751 ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
752 V_BSTR(V_VARIANTREF(frame)));
755 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
756 V_VT(post_data));
757 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
758 V_VT(post_data));
759 ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
760 if(V_VARIANTREF(post_data)) {
761 ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
762 "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
763 V_VT(V_VARIANTREF(post_data)));
764 ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
765 "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
766 if(V_VARIANTREF(V_VARIANTREF(post_data))) {
767 ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
768 "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
769 V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
771 if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
772 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
774 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
775 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
780 ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
781 V_VT(headers));
782 ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
783 if(V_VARIANTREF(headers)) {
784 ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
785 V_VT(V_VARIANTREF(headers)));
786 str = V_BSTR(V_VARIANTREF(headers));
787 ok(!str || !lstrcmpW(str, L"Referer: http://test.winehq.org/tests/hello.html\r\n"),
788 "V_BSTR(V_VARIANTREF(headers)) = %s, expected NULL\n", wine_dbgstr_w(str));
791 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
792 V_VT(cancel));
793 ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
794 if(V_BOOLREF(cancel))
795 ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(cancel) = %x, expected VARIANT_FALSE\n",
796 *V_BOOLREF(cancel));
799 static void test_navigatecomplete2(DISPPARAMS *dp)
801 VARIANT *v;
803 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
805 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
806 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
808 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
809 v = V_VARIANTREF(dp->rgvarg);
810 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
811 ok(!lstrcmpW(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)),
812 wine_dbgstr_w(current_url));
814 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
815 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
817 if(dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK|DWL_FROM_GOFORWARD))
818 test_ready_state(READYSTATE_COMPLETE, VARIANT_TRUE);
819 else
820 test_ready_state(READYSTATE_LOADING, VARIANT_TRUE);
823 static void test_documentcomplete(DISPPARAMS *dp)
825 VARIANT *v;
827 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
829 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
830 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
832 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
833 v = V_VARIANTREF(dp->rgvarg);
834 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
835 ok(!lstrcmpW(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)),
836 wine_dbgstr_w(current_url));
838 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
839 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
841 test_ready_state(READYSTATE_COMPLETE, VARIANT_FALSE);
844 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
845 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
846 EXCEPINFO *pExcepInfo, UINT *puArgErr)
848 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
849 ok(pDispParams != NULL, "pDispParams == NULL\n");
850 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
851 ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
852 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
853 ok(pDispParams->rgdispidNamedArgs == NULL,
854 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
855 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
857 switch(dispIdMember) {
858 case DISPID_STATUSTEXTCHANGE:
859 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
861 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
862 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
863 ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
864 V_VT(pDispParams->rgvarg));
865 ok(V_BSTR(pDispParams->rgvarg) != NULL, "V_BSTR(pDispParams->rgvarg) is NULL\n");
866 /* TODO: Check text */
867 break;
869 case DISPID_PROPERTYCHANGE:
870 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
872 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
873 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
874 /* TODO: Check args */
875 break;
877 case DISPID_DOWNLOADBEGIN:
878 CHECK_EXPECT2(Invoke_DOWNLOADBEGIN);
880 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
881 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
882 if(dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOFORWARD|DWL_FROM_GOBACK))
883 test_ready_state(READYSTATE_COMPLETE, VARIANT_TRUE);
884 else if(!(dwl_flags & DWL_REFRESH)) /* todo_wine */
885 test_ready_state(READYSTATE_LOADING, VARIANT_TRUE);
886 break;
888 case DISPID_BEFORENAVIGATE2:
889 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
891 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
892 ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
893 test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
894 pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
895 pDispParams->rgvarg);
896 if(dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOFORWARD))
897 test_ready_state(READYSTATE_COMPLETE, VARIANT_FALSE);
898 else
899 test_ready_state(READYSTATE_LOADING, VARIANT_FALSE);
900 break;
902 case DISPID_SETSECURELOCKICON:
903 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
905 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
906 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
907 /* TODO: Check args */
908 break;
910 case DISPID_FILEDOWNLOAD:
911 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
913 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
914 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
915 /* TODO: Check args */
916 break;
918 case DISPID_COMMANDSTATECHANGE:
919 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
920 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
922 ok(V_VT(pDispParams->rgvarg) == VT_BOOL, "V_VT(pDispParams->rgvarg) = %d\n", V_VT(pDispParams->rgvarg));
923 ok(V_VT(pDispParams->rgvarg+1) == VT_I4, "V_VT(pDispParams->rgvarg+1) = %d\n", V_VT(pDispParams->rgvarg+1));
924 ok(V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEFORWARD ||
925 V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEBACK ||
926 V_I4(pDispParams->rgvarg+1) == CSC_UPDATECOMMANDS,
927 "V_I4(pDispParams->rgvarg+1) = %x\n", V_I4(pDispParams->rgvarg+1));
929 if (V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEFORWARD)
931 todo_wine_if(nav_forward_todo) {
932 if(V_BOOL(pDispParams->rgvarg))
933 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
934 else
935 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
938 else if (V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEBACK)
940 todo_wine_if(nav_back_todo) {
941 if(V_BOOL(pDispParams->rgvarg))
942 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
943 else
944 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
947 else if (V_I4(pDispParams->rgvarg+1) == CSC_UPDATECOMMANDS)
949 todo_wine CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
950 set_update_commands_enable = V_BOOL(pDispParams->rgvarg);
952 break;
954 case DISPID_DOWNLOADCOMPLETE:
955 CHECK_EXPECT2(Invoke_DOWNLOADCOMPLETE);
957 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
958 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
959 if(use_container_olecmd)
960 test_ready_state(READYSTATE_LOADING, VARIANT_FALSE);
961 break;
963 case DISPID_ONMENUBAR:
964 CHECK_EXPECT(Invoke_ONMENUBAR);
965 test_invoke_bool(pDispParams, TRUE);
966 break;
968 case DISPID_ONADDRESSBAR:
969 CHECK_EXPECT(Invoke_ONADDRESSBAR);
970 test_invoke_bool(pDispParams, TRUE);
971 break;
973 case DISPID_ONSTATUSBAR:
974 CHECK_EXPECT(Invoke_ONSTATUSBAR);
975 test_invoke_bool(pDispParams, TRUE);
976 break;
978 case DISPID_ONTOOLBAR:
979 CHECK_EXPECT(Invoke_ONTOOLBAR);
980 test_invoke_bool(pDispParams, FALSE);
981 break;
983 case DISPID_ONFULLSCREEN:
984 CHECK_EXPECT(Invoke_ONFULLSCREEN);
985 test_invoke_bool(pDispParams, TRUE);
986 break;
988 case DISPID_ONTHEATERMODE:
989 CHECK_EXPECT(Invoke_ONTHEATERMODE);
990 test_invoke_bool(pDispParams, TRUE);
991 break;
993 case DISPID_WINDOWSETRESIZABLE:
994 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
995 test_invoke_bool(pDispParams, TRUE);
996 break;
998 case DISPID_TITLECHANGE:
999 CHECK_EXPECT2(Invoke_TITLECHANGE);
1000 /* FIXME */
1001 break;
1003 case DISPID_NAVIGATECOMPLETE2:
1004 test_navigatecomplete2(pDispParams);
1005 break;
1007 case DISPID_PROGRESSCHANGE:
1008 CHECK_EXPECT2(Invoke_PROGRESSCHANGE);
1009 /* FIXME */
1010 break;
1012 case DISPID_DOCUMENTCOMPLETE:
1013 test_documentcomplete(pDispParams);
1014 break;
1016 case DISPID_WINDOWCLOSING: {
1017 VARIANT *is_child = pDispParams->rgvarg+1, *cancel = pDispParams->rgvarg;
1019 CHECK_EXPECT(Invoke_WINDOWCLOSING);
1021 ok(pDispParams->cArgs == 2, "pdp->cArgs = %d\n", pDispParams->cArgs);
1022 ok(V_VT(is_child) == VT_BOOL, "V_VT(is_child) = %d\n", V_VT(is_child));
1023 ok(!V_BOOL(is_child), "V_BOOL(is_child) = %x\n", V_BOOL(is_child));
1024 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel) = %d\n", V_VT(cancel));
1025 ok(!*V_BOOLREF(cancel), "*V_BOOLREF(cancel) = %x\n", *V_BOOLREF(cancel));
1027 *V_BOOLREF(cancel) = VARIANT_TRUE;
1028 return S_OK;
1031 case DISPID_SETPHISHINGFILTERSTATUS: /* FIXME */
1032 CHECK_EXPECT2(Invoke_SETPHISHINGFILTERSTATUS);
1033 break;
1035 case DISPID_BEFORESCRIPTEXECUTE: /* FIXME: IE10 */
1036 break;
1038 case DISPID_PRIVACYIMPACTEDSTATECHANGE:
1039 break;
1041 default:
1042 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
1045 return S_OK;
1048 static IDispatchVtbl WebBrowserEvents2Vtbl = {
1049 WebBrowserEvents2_QueryInterface,
1050 Dispatch_AddRef,
1051 Dispatch_Release,
1052 Dispatch_GetTypeInfoCount,
1053 Dispatch_GetTypeInfo,
1054 Dispatch_GetIDsOfNames,
1055 WebBrowserEvents2_Invoke
1058 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
1060 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1062 return QueryInterface(riid, ppv);
1065 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1067 return 2;
1070 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1072 return 1;
1075 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1077 ok(0, "unexpected call\n");
1078 return E_NOTIMPL;
1081 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1082 IMoniker **ppmon)
1084 ok(0, "unexpected call\n");
1085 return E_NOTIMPL;
1088 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1090 CHECK_EXPECT(GetContainer);
1092 ok(ppContainer != NULL, "ppContainer == NULL\n");
1093 if(ppContainer)
1094 *ppContainer = &OleContainer;
1096 return S_OK;
1099 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1101 CHECK_EXPECT(ShowObject);
1102 return S_OK;
1105 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1107 ok(0, "unexpected call\n");
1108 return E_NOTIMPL;
1111 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1113 ok(0, "unexpected call\n");
1114 return E_NOTIMPL;
1117 static const IOleClientSiteVtbl ClientSiteVtbl = {
1118 ClientSite_QueryInterface,
1119 ClientSite_AddRef,
1120 ClientSite_Release,
1121 ClientSite_SaveObject,
1122 ClientSite_GetMoniker,
1123 ClientSite_GetContainer,
1124 ClientSite_ShowObject,
1125 ClientSite_OnShowWindow,
1126 ClientSite_RequestNewObjectLayout
1129 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1130 static IOleClientSite ClientSite2 = { &ClientSiteVtbl };
1132 static HRESULT WINAPI IOleControlSite_fnQueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1134 *ppv = NULL;
1135 return E_NOINTERFACE;
1138 static ULONG WINAPI IOleControlSite_fnAddRef(IOleControlSite *iface)
1140 return 2;
1143 static ULONG WINAPI IOleControlSite_fnRelease(IOleControlSite *iface)
1145 return 1;
1148 static HRESULT WINAPI IOleControlSite_fnOnControlInfoChanged(IOleControlSite* This)
1150 ok(0, "unexpected call\n");
1151 return E_NOTIMPL;
1154 static HRESULT WINAPI IOleControlSite_fnLockInPlaceActive(IOleControlSite* This,
1155 BOOL fLock)
1157 ok(0, "unexpected call\n");
1158 return E_NOTIMPL;
1161 static HRESULT WINAPI IOleControlSite_fnGetExtendedControl(IOleControlSite* This,
1162 IDispatch **ppDisp)
1164 ok(0, "unexpected call\n");
1165 return E_NOTIMPL;
1168 static HRESULT WINAPI IOleControlSite_fnTransformCoords(IOleControlSite* This,
1169 POINTL *pPtlHimetric,
1170 POINTF *pPtfContainer,
1171 DWORD dwFlags)
1173 ok(0, "unexpected call\n");
1174 return E_NOTIMPL;
1177 static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* This, MSG *pMsg,
1178 DWORD grfModifiers)
1180 CHECK_EXPECT(ControlSite_TranslateAccelerator);
1181 return hr_site_TranslateAccelerator;
1184 static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus)
1186 if(fGotFocus)
1187 CHECK_EXPECT2(OnFocus_TRUE);
1188 else
1189 CHECK_EXPECT2(OnFocus_FALSE);
1190 return E_NOTIMPL;
1193 static HRESULT WINAPI IOleControlSite_fnShowPropertyFrame(IOleControlSite* This)
1195 ok(0, "unexpected call\n");
1196 return E_NOTIMPL;
1199 static IOleControlSiteVtbl ControlSiteVtbl = {
1200 IOleControlSite_fnQueryInterface,
1201 IOleControlSite_fnAddRef,
1202 IOleControlSite_fnRelease,
1203 IOleControlSite_fnOnControlInfoChanged,
1204 IOleControlSite_fnLockInPlaceActive,
1205 IOleControlSite_fnGetExtendedControl,
1206 IOleControlSite_fnTransformCoords,
1207 IOleControlSite_fnTranslateAccelerator,
1208 IOleControlSite_fnOnFocus,
1209 IOleControlSite_fnShowPropertyFrame
1212 static IOleControlSite ControlSite = { &ControlSiteVtbl };
1214 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
1215 REFIID riid, void **ppv)
1217 ok(0, "unexpected call\n");
1218 return E_NOINTERFACE;
1221 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
1223 return 2;
1226 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
1228 return 1;
1231 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1233 ok(0, "unexpected call\n");
1234 return E_NOTIMPL;
1237 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1239 CHECK_EXPECT(Frame_GetWindow);
1240 ok(phwnd != NULL, "phwnd == NULL\n");
1241 if(phwnd)
1242 *phwnd = container_hwnd;
1243 return S_OK;
1246 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1248 ok(0, "unexpected call\n");
1249 return E_NOTIMPL;
1252 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1254 ok(0, "unexpected call\n");
1255 return E_NOTIMPL;
1258 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
1259 LPCBORDERWIDTHS pborderwidths)
1261 ok(0, "unexpected call\n");
1262 return E_NOTIMPL;
1265 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
1266 LPCBORDERWIDTHS pborderwidths)
1268 ok(0, "unexpected call\n");
1269 return E_NOTIMPL;
1272 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1273 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1275 CHECK_EXPECT(UIWindow_SetActiveObject);
1276 if(!test_close && !test_hide) {
1277 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1278 ok(!lstrcmpW(pszObjName, L"item"), "unexpected pszObjName\n");
1279 } else {
1280 ok(!pActiveObject, "pActiveObject != NULL\n");
1281 ok(!pszObjName, "pszObjName != NULL\n");
1283 return S_OK;
1286 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1287 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1289 CHECK_EXPECT(Frame_SetActiveObject);
1290 if(!test_close && !test_hide) {
1291 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1292 ok(!lstrcmpW(pszObjName, L"item"), "unexpected pszObjName\n");
1293 } else {
1294 ok(!pActiveObject, "pActiveObject != NULL\n");
1295 ok(!pszObjName, "pszObjName != NULL\n");
1297 return S_OK;
1300 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1301 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1303 ok(0, "unexpected call\n");
1304 return E_NOTIMPL;
1307 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1308 HOLEMENU holemenu, HWND hwndActiveObject)
1310 CHECK_EXPECT(SetMenu);
1311 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
1312 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
1313 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
1314 hwndActiveObject, shell_embedding_hwnd);
1315 return S_OK;
1318 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1320 ok(0, "unexpected call\n");
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1326 CHECK_EXPECT2(SetStatusText);
1327 /* FIXME: Check pszStatusText */
1328 return S_OK;
1331 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1333 if(fEnable)
1334 CHECK_EXPECT2(EnableModeless_TRUE);
1335 else
1336 CHECK_EXPECT2(EnableModeless_FALSE);
1337 return S_OK;
1340 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1342 ok(0, "unexpected call\n");
1343 return E_NOTIMPL;
1346 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1347 InPlaceUIWindow_QueryInterface,
1348 InPlaceUIWindow_AddRef,
1349 InPlaceUIWindow_Release,
1350 InPlaceUIWindow_GetWindow,
1351 InPlaceUIWindow_ContextSensitiveHelp,
1352 InPlaceUIWindow_GetBorder,
1353 InPlaceUIWindow_RequestBorderSpace,
1354 InPlaceUIWindow_SetBorderSpace,
1355 InPlaceUIWindow_SetActiveObject,
1358 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
1360 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1361 InPlaceUIWindow_QueryInterface,
1362 InPlaceUIWindow_AddRef,
1363 InPlaceUIWindow_Release,
1364 InPlaceFrame_GetWindow,
1365 InPlaceUIWindow_ContextSensitiveHelp,
1366 InPlaceUIWindow_GetBorder,
1367 InPlaceUIWindow_RequestBorderSpace,
1368 InPlaceUIWindow_SetBorderSpace,
1369 InPlaceFrame_SetActiveObject,
1370 InPlaceFrame_InsertMenus,
1371 InPlaceFrame_SetMenu,
1372 InPlaceFrame_RemoveMenus,
1373 InPlaceFrame_SetStatusText,
1374 InPlaceFrame_EnableModeless,
1375 InPlaceFrame_TranslateAccelerator
1378 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1380 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1382 return QueryInterface(riid, ppv);
1385 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1387 return 2;
1390 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1392 return 1;
1395 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1397 CHECK_EXPECT(Site_GetWindow);
1398 ok(phwnd != NULL, "phwnd == NULL\n");
1399 if(phwnd)
1400 *phwnd = container_hwnd;
1401 return S_OK;
1404 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1406 ok(0, "unexpected call\n");
1407 return E_NOTIMPL;
1410 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1412 CHECK_EXPECT(CanInPlaceActivate);
1413 return S_OK;
1416 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1418 CHECK_EXPECT(OnInPlaceActivate);
1419 return S_OK;
1422 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1424 CHECK_EXPECT(OnUIActivate);
1425 return S_OK;
1428 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1429 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1430 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1432 static const RECT pos_rect = {2,1,1002,901};
1433 static const RECT clip_rect = {10,10,990,890};
1435 CHECK_EXPECT(GetWindowContext);
1437 ok(ppFrame != NULL, "ppFrame = NULL\n");
1438 if(ppFrame)
1439 *ppFrame = &InPlaceFrame;
1441 ok(ppDoc != NULL, "ppDoc = NULL\n");
1442 if(ppDoc)
1443 *ppDoc = &InPlaceUIWindow;
1445 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1446 if(lprcPosRect)
1447 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1449 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1450 if(lprcClipRect)
1451 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1453 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1454 if(lpFrameInfo) {
1455 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1456 lpFrameInfo->fMDIApp = FALSE;
1457 lpFrameInfo->hwndFrame = container_hwnd;
1458 lpFrameInfo->haccel = NULL;
1459 lpFrameInfo->cAccelEntries = 0;
1462 return S_OK;
1465 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1467 ok(0, "unexpected call\n");
1468 return E_NOTIMPL;
1471 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1473 CHECK_EXPECT(OnUIDeactivate);
1474 ok(!fUndoable, "fUndoable should be FALSE\n");
1475 return S_OK;
1478 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1480 CHECK_EXPECT(OnInPlaceDeactivate);
1481 return S_OK;
1484 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1486 ok(0, "unexpected call\n");
1487 return E_NOTIMPL;
1490 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1492 ok(0, "unexpected call\n");
1493 return E_NOTIMPL;
1496 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1498 ok(0, "unexpected call\n");
1499 return E_NOTIMPL;
1502 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1503 BOOL *pNoRedraw, DWORD dwFlags)
1505 ok(0, "unexpected call\n");
1506 return E_NOTIMPL;
1509 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1510 BOOL fNoRedraw)
1512 ok(0, "unexpected call\n");
1513 return E_NOTIMPL;
1516 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1518 CHECK_EXPECT2(RequestUIActivate);
1519 return S_OK;
1522 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1523 InPlaceSite_QueryInterface,
1524 InPlaceSite_AddRef,
1525 InPlaceSite_Release,
1526 InPlaceSite_GetWindow,
1527 InPlaceSite_ContextSensitiveHelp,
1528 InPlaceSite_CanInPlaceActivate,
1529 InPlaceSite_OnInPlaceActivate,
1530 InPlaceSite_OnUIActivate,
1531 InPlaceSite_GetWindowContext,
1532 InPlaceSite_Scroll,
1533 InPlaceSite_OnUIDeactivate,
1534 InPlaceSite_OnInPlaceDeactivate,
1535 InPlaceSite_DiscardUndoState,
1536 InPlaceSite_DeactivateAndUndo,
1537 InPlaceSite_OnPosRectChange,
1538 InPlaceSite_OnInPlaceActivateEx,
1539 InPlaceSite_OnInPlaceDeactivateEx,
1540 InPlaceSite_RequestUIActivate
1543 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1545 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1547 return QueryInterface(riid, ppv);
1550 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1552 return 2;
1555 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1557 return 1;
1560 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1561 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1563 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1564 return S_FALSE;
1567 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1569 CHECK_EXPECT2(GetHostInfo);
1570 ok(pInfo != NULL, "pInfo=NULL\n");
1571 if(pInfo) {
1572 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1573 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1574 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1575 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1576 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1578 return E_FAIL;
1581 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1582 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1583 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1585 CHECK_EXPECT(ShowUI);
1586 return E_NOTIMPL;
1589 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1591 CHECK_EXPECT(HideUI);
1592 return E_NOTIMPL;
1595 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1597 CHECK_EXPECT2(UpdateUI);
1598 return E_NOTIMPL;
1601 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1603 if(fEnable)
1604 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1605 else
1606 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1608 return S_OK;
1611 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1613 ok(0, "unexpected call\n");
1614 return E_NOTIMPL;
1617 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1619 ok(0, "unexpected call\n");
1620 return E_NOTIMPL;
1623 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1624 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1626 ok(0, "unexpected call\n");
1627 return E_NOTIMPL;
1630 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1631 const GUID *pguidCmdGroup, DWORD nCmdID)
1633 CHECK_EXPECT(DocHost_TranslateAccelerator);
1634 ok(pguidCmdGroup != NULL, "Got NULL pguidCmdGroup.\n");
1635 if(pguidCmdGroup)
1636 ok(IsEqualGUID(pguidCmdGroup, &CGID_MSHTML), "Unexpected pguidCmdGroup\n");
1637 ok(lpMsg != NULL, "Got NULL lpMsg.\n");
1638 return hr_dochost_TranslateAccelerator;
1641 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1642 LPOLESTR *pchKey, DWORD dw)
1644 CHECK_EXPECT(GetOptionKeyPath);
1645 ok(pchKey != NULL, "pchKey==NULL\n");
1646 if(pchKey)
1647 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1648 ok(!dw, "dw=%x\n", dw);
1649 return E_NOTIMPL;
1652 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1653 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1655 CHECK_EXPECT(GetDropTarget);
1656 return E_NOTIMPL;
1659 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1661 CHECK_EXPECT(GetExternal);
1662 *ppDispatch = NULL;
1663 return S_FALSE;
1666 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1667 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1669 todo_wine_if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1670 CHECK_EXPECT(TranslateUrl);
1671 return E_NOTIMPL;
1674 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1675 IDataObject **ppPORet)
1677 ok(0, "unexpected call\n");
1678 return E_NOTIMPL;
1681 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1682 LPOLESTR *pchKey, DWORD dw)
1684 CHECK_EXPECT(GetOverridesKeyPath);
1685 ok(pchKey != NULL, "pchKey==NULL\n");
1686 if(pchKey)
1687 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1688 ok(!dw, "dw=%x\n", dw);
1689 return E_NOTIMPL;
1692 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1693 DocHostUIHandler_QueryInterface,
1694 DocHostUIHandler_AddRef,
1695 DocHostUIHandler_Release,
1696 DocHostUIHandler_ShowContextMenu,
1697 DocHostUIHandler_GetHostInfo,
1698 DocHostUIHandler_ShowUI,
1699 DocHostUIHandler_HideUI,
1700 DocHostUIHandler_UpdateUI,
1701 DocHostUIHandler_EnableModeless,
1702 DocHostUIHandler_OnDocWindowActivate,
1703 DocHostUIHandler_OnFrameWindowActivate,
1704 DocHostUIHandler_ResizeBorder,
1705 DocHostUIHandler_TranslateAccelerator,
1706 DocHostUIHandler_GetOptionKeyPath,
1707 DocHostUIHandler_GetDropTarget,
1708 DocHostUIHandler_GetExternal,
1709 DocHostUIHandler_TranslateUrl,
1710 DocHostUIHandler_FilterDataObject,
1711 DocHostUIHandler_GetOverrideKeyPath
1714 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1717 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1719 return QueryInterface(riid, ppv);
1722 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1724 return 2;
1727 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1729 return 1;
1732 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1733 REFGUID guidService, REFIID riid, void **ppv)
1735 *ppv = NULL;
1737 if(!winetest_interactive)
1738 return E_NOINTERFACE;
1740 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1741 trace("Service SID_STopLevelBrowser\n");
1742 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1743 trace("Service SID_SEditCommandTarget\n");
1744 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1745 trace("Service IID_ITargetFrame2\n");
1746 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1747 trace("Service SID_SInternetSecurityManager\n");
1748 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1749 trace("Service SID_SOleUndoManager\n");
1750 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1751 trace("Service SID_IMimeInfo\n");
1752 else if (IsEqualGUID(&SID_STopWindow, guidService))
1753 trace("Service SID_STopWindow\n");
1755 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1756 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1757 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1758 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1759 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1760 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1761 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1762 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1763 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1764 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1765 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1767 else
1768 trace("Service %s not supported\n", wine_dbgstr_guid(guidService));
1770 return E_NOINTERFACE;
1774 static const IServiceProviderVtbl ServiceProviderVtbl = {
1775 ServiceProvider_QueryInterface,
1776 ServiceProvider_AddRef,
1777 ServiceProvider_Release,
1778 ServiceProvider_QueryService
1781 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1784 static HRESULT QueryInterface(REFIID riid, void **ppv)
1786 *ppv = NULL;
1788 if(IsEqualGUID(&IID_IUnknown, riid)
1789 || IsEqualGUID(&IID_IOleClientSite, riid))
1790 *ppv = &ClientSite;
1791 else if(IsEqualGUID(&IID_IOleWindow, riid)
1792 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1793 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1794 *ppv = &InPlaceSite;
1795 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1796 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1797 *ppv = use_container_dochostui ? &DocHostUIHandler : NULL;
1798 else if(IsEqualGUID(&IID_IDispatch, riid))
1799 *ppv = &Dispatch;
1800 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1801 *ppv = &ServiceProvider;
1802 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1803 trace("interface IID_IDocHostShowUI\n");
1804 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1805 *ppv = &ControlSite;
1806 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1807 trace("interface IID_IOleCommandTarget\n");
1809 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1811 else
1813 /* are there more interfaces, that a host can support? */
1814 trace("%s: interface not supported\n", wine_dbgstr_guid(riid));
1817 return (*ppv) ? S_OK : E_NOINTERFACE;
1820 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1822 return DefWindowProcW(hwnd, msg, wParam, lParam);
1825 static HWND create_container_window(void)
1827 static WNDCLASSEXW wndclass = {
1828 sizeof(WNDCLASSEXW),
1830 wnd_proc,
1831 0, 0, NULL, NULL, NULL, NULL, NULL,
1832 L"WebBrowserContainer",
1833 NULL
1836 RegisterClassExW(&wndclass);
1837 return CreateWindowW(L"WebBrowserContainer", L"WebBrowserContainer",
1838 WS_OVERLAPPEDWINDOW, 10, 10, 600, 600, NULL, NULL, NULL, NULL);
1841 static void test_DoVerb(IWebBrowser2 *unk)
1843 IOleObject *oleobj;
1844 RECT rect = {0,0,1000,1000};
1845 HRESULT hres;
1846 DWORD connection;
1848 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1849 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1850 if(FAILED(hres))
1851 return;
1853 hres = IOleObject_Advise(oleobj, &test_sink, &connection);
1854 ok(hres == S_OK, "Advise failed: %08x\n", hres);
1856 SET_EXPECT(CanInPlaceActivate);
1857 SET_EXPECT(Site_GetWindow);
1858 SET_EXPECT(OnInPlaceActivate);
1859 SET_EXPECT(GetWindowContext);
1860 SET_EXPECT(ShowObject);
1861 SET_EXPECT(GetContainer);
1862 SET_EXPECT(Frame_GetWindow);
1863 SET_EXPECT(OnUIActivate);
1864 SET_EXPECT(Frame_SetActiveObject);
1865 SET_EXPECT(UIWindow_SetActiveObject);
1866 SET_EXPECT(SetMenu);
1867 SET_EXPECT(OnFocus_TRUE);
1869 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1870 0, (HWND)0xdeadbeef, &rect);
1871 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1873 CHECK_CALLED(CanInPlaceActivate);
1874 CHECK_CALLED(Site_GetWindow);
1875 CHECK_CALLED(OnInPlaceActivate);
1876 CHECK_CALLED(GetWindowContext);
1877 CHECK_CALLED(ShowObject);
1878 CHECK_CALLED(GetContainer);
1879 CHECK_CALLED(Frame_GetWindow);
1880 CHECK_CALLED(OnUIActivate);
1881 CHECK_CALLED(Frame_SetActiveObject);
1882 CHECK_CALLED(UIWindow_SetActiveObject);
1883 CHECK_CALLED(SetMenu);
1884 CHECK_CALLED(OnFocus_TRUE);
1886 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1887 0, (HWND)0xdeadbeef, &rect);
1888 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1890 hres = IOleObject_Unadvise(oleobj, connection);
1891 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
1893 IOleObject_Release(oleobj);
1896 static void call_DoVerb(IWebBrowser2 *unk, LONG verb)
1898 IOleObject *oleobj;
1899 RECT rect = {60,60,600,600};
1900 HRESULT hres;
1902 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1903 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1904 if(FAILED(hres))
1905 return;
1907 hres = IOleObject_DoVerb(oleobj, verb, NULL, &ClientSite,
1908 -1, container_hwnd, &rect);
1909 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1911 IOleObject_Release(oleobj);
1914 static HWND get_hwnd(IWebBrowser2 *unk)
1916 IOleInPlaceObject *inplace;
1917 HWND hwnd;
1918 HRESULT hres;
1920 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1921 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1923 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1924 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1926 IOleInPlaceObject_Release(inplace);
1927 return hwnd;
1930 static void test_GetMiscStatus(IOleObject *oleobj)
1932 DWORD st, i;
1933 HRESULT hres;
1935 for(i=0; i<10; i++) {
1936 st = 0xdeadbeef;
1937 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1938 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1939 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1940 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1941 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1942 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1946 static void test_SetHostNames(IOleObject *oleobj)
1948 HRESULT hres;
1950 hres = IOleObject_SetHostNames(oleobj, L"test app", (void*)0xdeadbeef);
1951 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1954 static void test_ClientSite(IWebBrowser2 *unk, IOleClientSite *client, BOOL stop_download)
1956 IOleObject *oleobj;
1957 IOleInPlaceObject *inplace;
1958 DWORD session_count;
1959 HWND hwnd;
1960 HRESULT hres;
1962 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1963 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1964 if(FAILED(hres))
1965 return;
1967 test_GetMiscStatus(oleobj);
1968 test_SetHostNames(oleobj);
1970 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1971 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1972 if(FAILED(hres)) {
1973 IOleObject_Release(oleobj);
1974 return;
1977 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1978 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1979 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1981 if(client) {
1982 session_count = pSetQueryNetSessionCount(SESSION_QUERY);
1984 SET_EXPECT(GetContainer);
1985 SET_EXPECT(Site_GetWindow);
1986 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1987 SET_EXPECT(Invoke_AMBIENT_SILENT);
1988 }else if(stop_download) {
1989 if (use_container_olecmd) {
1990 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1991 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1994 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
1995 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
1997 expect_update_commands_enable = 0;
1998 set_update_commands_enable = 0xdead;
1999 SET_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
2000 }else {
2001 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2002 SET_EXPECT(Invoke_PROGRESSCHANGE);
2003 nav_back_todo = nav_forward_todo = TRUE;
2006 hres = IOleObject_SetClientSite(oleobj, client);
2007 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2009 if(client) {
2010 DWORD count = pSetQueryNetSessionCount(SESSION_QUERY);
2011 ok(count == session_count + 1, "count = %u expected %u\n", count, session_count + 1);
2013 CHECK_CALLED(GetContainer);
2014 CHECK_CALLED(Site_GetWindow);
2015 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2016 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2017 }else if(stop_download) {
2018 if (use_container_olecmd) {
2019 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2020 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
2023 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2024 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2026 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
2027 todo_wine ok(expect_update_commands_enable == set_update_commands_enable,
2028 "got %d\n", set_update_commands_enable);
2029 }else {
2030 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2031 CLEAR_CALLED(Invoke_PROGRESSCHANGE);
2032 nav_back_todo = nav_forward_todo = FALSE;
2035 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
2036 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2037 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
2039 shell_embedding_hwnd = hwnd;
2041 test_SetHostNames(oleobj);
2043 IOleInPlaceObject_Release(inplace);
2044 IOleObject_Release(oleobj);
2047 static void test_change_ClientSite(IWebBrowser2 *unk)
2049 BOOL old_use_container_olecmd = use_container_olecmd;
2050 IOleClientSite *doc_clientsite;
2051 IOleInPlaceObject *inplace;
2052 IOleCommandTarget *olecmd;
2053 IOleObject *oleobj;
2054 HRESULT hres;
2055 HWND hwnd;
2057 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2058 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
2059 if(FAILED(hres))
2060 return;
2062 use_container_olecmd = FALSE;
2064 SET_EXPECT(Site_GetWindow);
2065 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2066 SET_EXPECT(Invoke_AMBIENT_SILENT);
2068 hres = IOleObject_SetClientSite(oleobj, &ClientSite2);
2069 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2070 IOleObject_Release(oleobj);
2072 CHECK_CALLED(Site_GetWindow);
2073 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2074 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2076 doc_clientsite = get_dochost(unk);
2077 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleCommandTarget, (void**)&olecmd);
2078 ok(hres == S_OK, "QueryInterface(IOleCommandTarget) failed: %08x\n", hres);
2079 IOleClientSite_Release(doc_clientsite);
2081 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
2082 ok(hres == S_OK, "QueryInterface(OleInPlaceObject) failed: %08x\n", hres);
2083 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
2084 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2085 ok(hwnd == shell_embedding_hwnd, "unexpected hwnd %p\n", hwnd);
2086 IOleInPlaceObject_Release(inplace);
2088 if(old_use_container_olecmd) {
2089 SET_EXPECT(Exec_UPDATECOMMANDS);
2091 hres = IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_UPDATECOMMANDS,
2092 OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
2093 ok(hres == S_OK, "Exec(OLECMDID_UPDATECOMMAND) failed: %08x\n", hres);
2095 CHECK_CALLED(Exec_UPDATECOMMANDS);
2096 use_container_olecmd = TRUE;
2099 IOleCommandTarget_Release(olecmd);
2102 static void test_ClassInfo(IWebBrowser2 *unk)
2104 IProvideClassInfo2 *class_info;
2105 TYPEATTR *type_attr;
2106 ITypeInfo *typeinfo;
2107 GUID guid;
2108 HRESULT hres;
2110 hres = IWebBrowser2_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
2111 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
2112 if(FAILED(hres))
2113 return;
2115 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
2116 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
2117 ok(IsEqualGUID(wb_version > 1 ? &DIID_DWebBrowserEvents2 : &DIID_DWebBrowserEvents, &guid), "wrong guid\n");
2119 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
2120 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
2121 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
2123 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
2124 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
2125 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
2127 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
2128 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
2130 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
2131 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
2133 typeinfo = NULL;
2134 hres = IProvideClassInfo2_GetClassInfo(class_info, &typeinfo);
2135 ok(hres == S_OK, "GetClassInfo failed: %08x\n", hres);
2136 ok(typeinfo != NULL, "typeinfo == NULL\n");
2138 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
2139 ok(hres == S_OK, "GetTypeAtr failed: %08x\n", hres);
2141 ok(IsEqualGUID(&type_attr->guid, wb_version > 1 ? &CLSID_WebBrowser : &CLSID_WebBrowser_V1),
2142 "guid = %s\n", wine_dbgstr_guid(&type_attr->guid));
2144 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
2145 ITypeInfo_Release(typeinfo);
2147 IProvideClassInfo2_Release(class_info);
2150 #define expect_oleverb(a,b) _expect_oleverb(__LINE__,a,b)
2151 static void _expect_oleverb(unsigned line, const OLEVERB *verb, LONG exverb)
2153 ok_(__FILE__,line)(verb->lVerb == exverb, "verb->lVerb = %d, expected %d\n", verb->lVerb, exverb);
2154 ok_(__FILE__,line)(!verb->lpszVerbName, "verb->lpszVerbName = %s\n", wine_dbgstr_w(verb->lpszVerbName));
2155 ok_(__FILE__,line)(!verb->fuFlags, "verb->fuFlags = %x\n", verb->fuFlags);
2156 ok_(__FILE__,line)(!verb->grfAttribs, "verb->grfAttribs = %x\n", verb->grfAttribs);
2159 #define test_next_oleverb(a,b) _test_next_oleverb(__LINE__,a,b)
2160 static void _test_next_oleverb(unsigned line, IEnumOLEVERB *enum_verbs, LONG exverb)
2162 ULONG fetched = 0xdeadbeef;
2163 OLEVERB verb;
2164 HRESULT hres;
2166 fetched = 0xdeadbeef;
2167 memset(&verb, 0xa, sizeof(verb));
2168 hres = IEnumOLEVERB_Next(enum_verbs, 1, &verb, &fetched);
2169 ok_(__FILE__,line)(hres == S_OK, "Next failed: %08x\n", hres);
2170 ok_(__FILE__,line)(!fetched, "fetched = %d\n", fetched);
2171 _expect_oleverb(line, &verb, exverb);
2174 static void test_EnumVerbs(IWebBrowser2 *wb)
2176 IEnumOLEVERB *enum_verbs;
2177 IOleObject *oleobj;
2178 OLEVERB verbs[20];
2179 ULONG fetched;
2180 HRESULT hres;
2182 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oleobj);
2183 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
2185 hres = IOleObject_EnumVerbs(oleobj, &enum_verbs);
2186 IOleObject_Release(oleobj);
2187 ok(hres == S_OK, "EnumVerbs failed: %08x\n", hres);
2188 ok(enum_verbs != NULL, "enum_verbs == NULL\n");
2190 fetched = 0xdeadbeef;
2191 memset(verbs, 0xa, sizeof(verbs));
2192 verbs[1].lVerb = 0xdeadbeef;
2193 hres = IEnumOLEVERB_Next(enum_verbs, ARRAY_SIZE(verbs), verbs, &fetched);
2194 ok(hres == S_OK, "Next failed: %08x\n", hres);
2195 ok(!fetched, "fetched = %d\n", fetched);
2196 /* Although fetched==0, an element is returned. */
2197 expect_oleverb(verbs, OLEIVERB_PRIMARY);
2198 /* The first argument is ignored and always one element is returned. */
2199 ok(verbs[1].lVerb == 0xdeadbeef, "verbs[1].lVerb = %x\n", verbs[1].lVerb);
2201 test_next_oleverb(enum_verbs, OLEIVERB_INPLACEACTIVATE);
2202 test_next_oleverb(enum_verbs, OLEIVERB_UIACTIVATE);
2203 test_next_oleverb(enum_verbs, OLEIVERB_SHOW);
2204 test_next_oleverb(enum_verbs, OLEIVERB_HIDE);
2206 /* There is anouther verb, returned correctly. */
2207 fetched = 0xdeadbeef;
2208 memset(verbs, 0xa, sizeof(verbs));
2209 verbs[0].lVerb = 0xdeadbeef;
2210 hres = IEnumOLEVERB_Next(enum_verbs, ARRAY_SIZE(verbs), verbs, &fetched);
2211 todo_wine ok(hres == S_OK, "Next failed: %08x\n", hres);
2212 todo_wine ok(fetched == 1, "fetched = %d\n", fetched);
2213 todo_wine ok(verbs[0].lVerb != 0xdeadbeef, "verbs[0].lVerb = %x\n", verbs[0].lVerb);
2215 hres = IEnumOLEVERB_Next(enum_verbs, ARRAY_SIZE(verbs), verbs, &fetched);
2216 ok(hres == S_FALSE, "Next failed: %08x\n", hres);
2217 ok(!fetched, "fetched = %d\n", fetched);
2219 hres = IEnumOLEVERB_Reset(enum_verbs);
2220 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2222 fetched = 0xdeadbeef;
2223 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2224 ok(hres == S_OK, "Next failed: %08x\n", hres);
2225 ok(!fetched, "fetched = %d\n", fetched);
2227 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, NULL);
2228 ok(hres == S_OK, "Next failed: %08x\n", hres);
2230 hres = IEnumOLEVERB_Skip(enum_verbs, 20);
2231 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2233 fetched = 0xdeadbeef;
2234 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2235 ok(hres == S_OK, "Next failed: %08x\n", hres);
2236 ok(!fetched, "fetched = %d\n", fetched);
2238 test_next_oleverb(enum_verbs, OLEIVERB_SHOW);
2240 IEnumOLEVERB_Release(enum_verbs);
2243 static void test_Persist(IWebBrowser2 *wb, int version)
2245 IPersist *persist;
2246 GUID guid;
2247 HRESULT hr;
2249 hr = IWebBrowser2_QueryInterface(wb, &IID_IPersist, (void **)&persist);
2250 ok(hr == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hr);
2252 hr = IPersist_GetClassID(persist, &guid);
2253 ok(hr == S_OK, "GetClassID failed: %08x\n", hr);
2254 if (version == 1)
2255 ok(IsEqualGUID(&guid, &CLSID_WebBrowser_V1), "got wrong CLSID: %s\n", wine_dbgstr_guid(&guid));
2256 else
2257 ok(IsEqualGUID(&guid, &CLSID_WebBrowser), "got wrong CLSID: %s\n", wine_dbgstr_guid(&guid));
2259 IPersist_Release(persist);
2262 static void test_OleObject(IWebBrowser2 *wb, int version)
2264 IOleObject *oleobj;
2265 CLSID clsid;
2266 HRESULT hr;
2268 hr = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void **)&oleobj);
2269 ok(hr == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hr);
2271 hr = IOleObject_GetUserClassID(oleobj, &clsid);
2272 ok(hr == S_OK, "GetUserClassID failed: %08x\n", hr);
2273 if (version == 1)
2274 ok(IsEqualGUID(&clsid, &CLSID_WebBrowser_V1), "got wrong CLSID: %s\n", wine_dbgstr_guid(&clsid));
2275 else
2276 ok(IsEqualGUID(&clsid, &CLSID_WebBrowser), "got wrong CLSID: %s\n", wine_dbgstr_guid(&clsid));
2278 IOleObject_Release(oleobj);
2281 static void test_ie_funcs(IWebBrowser2 *wb)
2283 IDispatch *disp;
2284 VARIANT_BOOL b;
2285 int i;
2286 SHANDLE_PTR hwnd;
2287 HRESULT hres;
2288 BSTR sName;
2290 /* HWND */
2292 hwnd = 0xdeadbeef;
2293 hres = IWebBrowser2_get_HWND(wb, &hwnd);
2294 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
2295 ok(hwnd == 0, "unexpected hwnd %p\n", (PVOID)hwnd);
2297 /* MenuBar */
2299 hres = IWebBrowser2_get_MenuBar(wb, &b);
2300 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2301 ok(b == VARIANT_TRUE, "b=%x\n", b);
2303 SET_EXPECT(Invoke_ONMENUBAR);
2304 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
2305 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2306 CHECK_CALLED(Invoke_ONMENUBAR);
2308 hres = IWebBrowser2_get_MenuBar(wb, &b);
2309 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2310 ok(b == VARIANT_FALSE, "b=%x\n", b);
2312 SET_EXPECT(Invoke_ONMENUBAR);
2313 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
2314 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2315 CHECK_CALLED(Invoke_ONMENUBAR);
2317 hres = IWebBrowser2_get_MenuBar(wb, &b);
2318 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2319 ok(b == VARIANT_TRUE, "b=%x\n", b);
2321 /* AddressBar */
2323 hres = IWebBrowser2_get_AddressBar(wb, &b);
2324 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2325 ok(b == VARIANT_TRUE, "b=%x\n", b);
2327 SET_EXPECT(Invoke_ONADDRESSBAR);
2328 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
2329 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2330 CHECK_CALLED(Invoke_ONADDRESSBAR);
2332 hres = IWebBrowser2_get_AddressBar(wb, &b);
2333 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2334 ok(b == VARIANT_FALSE, "b=%x\n", b);
2336 SET_EXPECT(Invoke_ONADDRESSBAR);
2337 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
2338 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2339 CHECK_CALLED(Invoke_ONADDRESSBAR);
2341 hres = IWebBrowser2_get_AddressBar(wb, &b);
2342 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2343 ok(b == VARIANT_TRUE, "b=%x\n", b);
2345 SET_EXPECT(Invoke_ONADDRESSBAR);
2346 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
2347 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2348 CHECK_CALLED(Invoke_ONADDRESSBAR);
2350 /* StatusBar */
2352 hres = IWebBrowser2_get_StatusBar(wb, &b);
2353 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2354 ok(b == VARIANT_TRUE, "b=%x\n", b);
2356 SET_EXPECT(Invoke_ONSTATUSBAR);
2357 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
2358 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2359 CHECK_CALLED(Invoke_ONSTATUSBAR);
2361 hres = IWebBrowser2_get_StatusBar(wb, &b);
2362 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2363 ok(b == VARIANT_TRUE, "b=%x\n", b);
2365 SET_EXPECT(Invoke_ONSTATUSBAR);
2366 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
2367 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2368 CHECK_CALLED(Invoke_ONSTATUSBAR);
2370 hres = IWebBrowser2_get_StatusBar(wb, &b);
2371 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2372 ok(b == VARIANT_FALSE, "b=%x\n", b);
2374 SET_EXPECT(Invoke_ONSTATUSBAR);
2375 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
2376 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2377 CHECK_CALLED(Invoke_ONSTATUSBAR);
2379 hres = IWebBrowser2_get_StatusBar(wb, &b);
2380 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2381 ok(b == VARIANT_TRUE, "b=%x\n", b);
2383 /* ToolBar */
2385 hres = IWebBrowser2_get_ToolBar(wb, &i);
2386 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2387 ok(i, "i=%x\n", i);
2389 SET_EXPECT(Invoke_ONTOOLBAR);
2390 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
2391 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2392 CHECK_CALLED(Invoke_ONTOOLBAR);
2394 hres = IWebBrowser2_get_ToolBar(wb, &i);
2395 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2396 ok(i == VARIANT_FALSE, "b=%x\n", i);
2398 SET_EXPECT(Invoke_ONTOOLBAR);
2399 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
2400 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2401 CHECK_CALLED(Invoke_ONTOOLBAR);
2403 hres = IWebBrowser2_get_ToolBar(wb, &i);
2404 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2405 ok(i, "i=%x\n", i);
2407 SET_EXPECT(Invoke_ONTOOLBAR);
2408 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
2409 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2410 CHECK_CALLED(Invoke_ONTOOLBAR);
2412 /* FullScreen */
2414 hres = IWebBrowser2_get_FullScreen(wb, &b);
2415 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2416 ok(b == VARIANT_FALSE, "b=%x\n", b);
2418 SET_EXPECT(Invoke_ONFULLSCREEN);
2419 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
2420 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2421 CHECK_CALLED(Invoke_ONFULLSCREEN);
2423 hres = IWebBrowser2_get_FullScreen(wb, &b);
2424 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2425 ok(b == VARIANT_TRUE, "b=%x\n", b);
2427 SET_EXPECT(Invoke_ONFULLSCREEN);
2428 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
2429 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2430 CHECK_CALLED(Invoke_ONFULLSCREEN);
2432 hres = IWebBrowser2_get_FullScreen(wb, &b);
2433 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2434 ok(b == VARIANT_TRUE, "b=%x\n", b);
2436 SET_EXPECT(Invoke_ONFULLSCREEN);
2437 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
2438 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2439 CHECK_CALLED(Invoke_ONFULLSCREEN);
2441 /* TheaterMode */
2443 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2444 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2445 ok(b == VARIANT_FALSE, "b=%x\n", b);
2447 SET_EXPECT(Invoke_ONTHEATERMODE);
2448 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
2449 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2450 CHECK_CALLED(Invoke_ONTHEATERMODE);
2452 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2453 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2454 ok(b == VARIANT_TRUE, "b=%x\n", b);
2456 SET_EXPECT(Invoke_ONTHEATERMODE);
2457 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
2458 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2459 CHECK_CALLED(Invoke_ONTHEATERMODE);
2461 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2462 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2463 ok(b == VARIANT_TRUE, "b=%x\n", b);
2465 SET_EXPECT(Invoke_ONTHEATERMODE);
2466 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
2467 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2468 CHECK_CALLED(Invoke_ONTHEATERMODE);
2470 /* Resizable */
2472 b = 0x100;
2473 hres = IWebBrowser2_get_Resizable(wb, &b);
2474 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2475 ok(b == 0x100, "b=%x\n", b);
2477 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2478 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
2479 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2480 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2482 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2483 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
2484 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2485 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2487 hres = IWebBrowser2_get_Resizable(wb, &b);
2488 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2489 ok(b == 0x100, "b=%x\n", b);
2491 /* Application */
2493 disp = NULL;
2494 hres = IWebBrowser2_get_Application(wb, &disp);
2495 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
2496 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
2497 if(disp)
2498 IDispatch_Release(disp);
2500 hres = IWebBrowser2_get_Application(wb, NULL);
2501 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
2503 /* Name */
2504 hres = IWebBrowser2_get_Name(wb, &sName);
2505 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
2506 if (is_lang_english())
2507 ok(!lstrcmpW(sName, L"Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
2508 else /* Non-English cannot be blank. */
2509 ok(sName!=NULL, "get_Name return a NULL string.\n");
2510 SysFreeString(sName);
2512 /* RegisterAsDropTarget */
2513 hres = IWebBrowser2_get_RegisterAsDropTarget(wb, NULL);
2514 ok(hres == E_INVALIDARG, "get_RegisterAsDropTarget returned: %08x\n", hres);
2516 /* Quit */
2518 hres = IWebBrowser2_Quit(wb);
2519 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
2522 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2524 VARIANT_BOOL b;
2525 HRESULT hres;
2527 b = 100;
2528 hres = IWebBrowser2_get_Silent(wb, &b);
2529 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2530 ok(b == VARIANT_FALSE, "b=%x\n", b);
2532 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2533 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2535 b = 100;
2536 hres = IWebBrowser2_get_Silent(wb, &b);
2537 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2538 ok(b == VARIANT_TRUE, "b=%x\n", b);
2540 hres = IWebBrowser2_put_Silent(wb, 100);
2541 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2543 b = 100;
2544 hres = IWebBrowser2_get_Silent(wb, &b);
2545 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2546 ok(b == VARIANT_TRUE, "b=%x\n", b);
2548 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
2549 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2551 b = 100;
2552 hres = IWebBrowser2_get_Silent(wb, &b);
2553 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2554 ok(b == VARIANT_FALSE, "b=%x\n", b);
2556 if(is_clientsite) {
2557 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2558 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2560 SET_EXPECT(Invoke_AMBIENT_SILENT);
2563 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2564 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2566 if(is_clientsite)
2567 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2569 b = 100;
2570 hres = IWebBrowser2_get_Silent(wb, &b);
2571 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2572 ok(b == VARIANT_FALSE, "b=%x\n", b);
2575 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2577 VARIANT_BOOL b;
2578 HRESULT hres;
2580 b = 100;
2581 hres = IWebBrowser2_get_Offline(wb, &b);
2582 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2583 ok(b == VARIANT_FALSE, "b=%x\n", b);
2585 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2586 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2588 b = 100;
2589 hres = IWebBrowser2_get_Offline(wb, &b);
2590 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2591 ok(b == VARIANT_TRUE, "b=%x\n", b);
2593 hres = IWebBrowser2_put_Offline(wb, 100);
2594 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2596 b = 100;
2597 hres = IWebBrowser2_get_Offline(wb, &b);
2598 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2599 ok(b == VARIANT_TRUE, "b=%x\n", b);
2601 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
2602 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2604 b = 100;
2605 hres = IWebBrowser2_get_Offline(wb, &b);
2606 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2607 ok(b == VARIANT_FALSE, "b=%x\n", b);
2609 if(is_clientsite) {
2610 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2611 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2613 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2616 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2617 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2619 if(is_clientsite)
2620 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2622 b = 100;
2623 hres = IWebBrowser2_get_Offline(wb, &b);
2624 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2625 ok(b == VARIANT_FALSE, "b=%x\n", b);
2628 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2630 HRESULT hres;
2632 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2633 SET_EXPECT(Invoke_AMBIENT_SILENT);
2634 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2635 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2636 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2637 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2639 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
2640 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2642 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2643 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
2644 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
2645 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
2646 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2647 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2649 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2650 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2651 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2652 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2653 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2654 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2657 static void test_wb_funcs(IWebBrowser2 *wb, BOOL is_clientsite)
2659 IOleControl *control;
2660 HRESULT hres;
2662 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleControl, (void**)&control);
2663 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2665 test_Silent(wb, control, is_clientsite);
2666 test_Offline(wb, control, is_clientsite);
2667 test_ambient_unknown(wb, control, is_clientsite);
2669 IOleControl_Release(control);
2672 static void test_GetControlInfo(IWebBrowser2 *unk)
2674 IOleControl *control;
2675 CONTROLINFO info;
2676 HRESULT hres;
2678 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2679 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2680 if(FAILED(hres))
2681 return;
2683 hres = IOleControl_GetControlInfo(control, &info);
2684 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2685 hres = IOleControl_GetControlInfo(control, NULL);
2686 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2688 IOleControl_Release(control);
2691 static void test_Extent(IWebBrowser2 *unk)
2693 IOleObject *oleobj;
2694 SIZE size, expected;
2695 HRESULT hres;
2696 DWORD dpi_x;
2697 DWORD dpi_y;
2698 HDC hdc;
2700 /* default aspect ratio is 96dpi / 96dpi */
2701 hdc = GetDC(0);
2702 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2703 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2704 ReleaseDC(0, hdc);
2705 if (dpi_x != 96 || dpi_y != 96)
2706 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2708 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2709 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
2710 if(FAILED(hres))
2711 return;
2713 size.cx = size.cy = 0xdeadbeef;
2714 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2715 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2716 /* Default size is 50x20 pixels, in himetric units */
2717 expected.cx = MulDiv( 50, 2540, dpi_x );
2718 expected.cy = MulDiv( 20, 2540, dpi_y );
2719 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2720 size.cx, size.cy, expected.cx, expected.cy );
2722 size.cx = 800;
2723 size.cy = 700;
2724 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2725 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2727 size.cx = size.cy = 0xdeadbeef;
2728 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2729 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2730 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2732 size.cx = size.cy = 0xdeadbeef;
2733 hres = IOleObject_GetExtent(oleobj, 0, &size);
2734 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2735 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2737 size.cx = 900;
2738 size.cy = 800;
2739 hres = IOleObject_SetExtent(oleobj, 0, &size);
2740 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2742 size.cx = size.cy = 0xdeadbeef;
2743 hres = IOleObject_GetExtent(oleobj, 0, &size);
2744 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2745 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2747 size.cx = size.cy = 0xdeadbeef;
2748 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2749 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2750 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2752 size.cx = 1000;
2753 size.cy = 900;
2754 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2755 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2757 size.cx = size.cy = 0xdeadbeef;
2758 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2759 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2760 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2762 size.cx = size.cy = 0xdeadbeef;
2763 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2764 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2765 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2767 IOleObject_Release(oleobj);
2770 static void test_ConnectionPoint(IWebBrowser2 *unk, BOOL init)
2772 IConnectionPointContainer *container;
2773 IConnectionPoint *point;
2774 HRESULT hres;
2776 static DWORD dw = 100;
2778 hres = IWebBrowser2_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2779 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2780 if(FAILED(hres))
2781 return;
2783 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2784 IConnectionPointContainer_Release(container);
2785 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2786 if(FAILED(hres))
2787 return;
2789 if(init) {
2790 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2791 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2792 ok(dw == 1, "dw=%d, expected 1\n", dw);
2793 }else {
2794 hres = IConnectionPoint_Unadvise(point, dw);
2795 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2798 IConnectionPoint_Release(point);
2801 static void test_Navigate2(IWebBrowser2 *webbrowser, const WCHAR *nav_url)
2803 VARIANT url;
2804 BOOL is_file;
2805 HRESULT hres;
2807 test_LocationURL(webbrowser, is_first_load ? L"" : current_url);
2808 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE, VARIANT_FALSE);
2810 is_http = !memcmp(nav_url, "http:", 5);
2811 V_VT(&url) = VT_BSTR;
2812 V_BSTR(&url) = SysAllocString(current_url = nav_url);
2814 if((is_file = !wcsnicmp(nav_url, L"file://", 7)))
2815 current_url = nav_url + 7;
2817 if(is_first_load) {
2818 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2819 SET_EXPECT(Invoke_PROPERTYCHANGE);
2820 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2821 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2822 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2823 SET_EXPECT(EnableModeless_FALSE);
2824 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2825 SET_EXPECT(SetStatusText);
2826 if(use_container_dochostui)
2827 SET_EXPECT(GetHostInfo);
2828 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2829 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2830 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2831 if(use_container_dochostui) {
2832 SET_EXPECT(GetOptionKeyPath);
2833 SET_EXPECT(GetOverridesKeyPath);
2835 if (use_container_olecmd) {
2836 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2837 SET_EXPECT(Exec_SETPROGRESSMAX);
2838 SET_EXPECT(Exec_SETPROGRESSPOS);
2840 SET_EXPECT(Invoke_SETSECURELOCKICON);
2841 SET_EXPECT(Invoke_FILEDOWNLOAD);
2842 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2843 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2844 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2845 SET_EXPECT(EnableModeless_TRUE);
2846 if (!use_container_olecmd) SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2847 if (is_file) SET_EXPECT(Invoke_PROGRESSCHANGE);
2850 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2851 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2853 if(is_first_load) {
2854 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2855 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2856 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2857 CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2858 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2859 CHECK_CALLED(EnableModeless_FALSE);
2860 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2861 CHECK_CALLED(SetStatusText);
2862 if(use_container_dochostui)
2863 CHECK_CALLED(GetHostInfo);
2864 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2865 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2866 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* Not called by IE9 */
2867 if(use_container_dochostui) {
2868 CLEAR_CALLED(GetOptionKeyPath);
2869 CHECK_CALLED(GetOverridesKeyPath);
2871 if (use_container_olecmd) {
2872 todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2873 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2874 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2876 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2877 todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
2878 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2879 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2880 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2881 CHECK_CALLED(EnableModeless_TRUE);
2882 if (!use_container_olecmd) CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
2883 if (is_file) todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2886 VariantClear(&url);
2888 test_ready_state(READYSTATE_LOADING, VARIANT_FALSE);
2891 static void test_QueryStatusWB(IWebBrowser2 *webbrowser, BOOL has_document)
2893 HRESULT hres, success_state;
2894 OLECMDF success_flags;
2895 enum OLECMDF status;
2898 * We can tell the difference between the custom container target and the built-in target
2899 * since the custom target returns OLECMDF_SUPPORTED instead of OLECMDF_ENABLED.
2901 if (use_container_olecmd)
2902 success_flags = OLECMDF_SUPPORTED;
2903 else
2904 success_flags = OLECMDF_ENABLED;
2906 /* When no target is available (no document or custom target) an error is returned */
2907 if (has_document)
2908 success_state = S_OK;
2909 else
2910 success_state = E_UNEXPECTED;
2913 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2914 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2915 * is enabled and IDM_STOP is not.
2917 status = 0xdeadbeef;
2918 if (use_container_olecmd) SET_EXPECT(QueryStatus_STOP);
2919 hres = IWebBrowser2_QueryStatusWB(webbrowser, OLECMDID_STOP, &status);
2920 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2921 todo_wine_if (!use_container_olecmd && has_document)
2922 ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2923 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2924 status = 0xdeadbeef;
2925 if (use_container_olecmd) SET_EXPECT(QueryStatus_IDM_STOP);
2926 hres = IWebBrowser2_QueryStatusWB(webbrowser, IDM_STOP, &status);
2927 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2928 ok((has_document && status == 0) || (!has_document && status == 0xdeadbeef),
2929 "IDM_STOP is enabled/supported: %08x %d\n", status, has_document);
2932 static void test_ExecWB(IWebBrowser2 *webbrowser, BOOL has_document)
2934 HRESULT hres, olecmdid_state, idm_state;
2936 /* When no target is available (no document or custom target) an error is returned */
2937 if (has_document)
2939 olecmdid_state = S_OK;
2940 idm_state = OLECMDERR_E_NOTSUPPORTED;
2942 else
2944 olecmdid_state = E_UNEXPECTED;
2945 idm_state = E_UNEXPECTED;
2949 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2950 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2951 * succeeds (S_OK) and IDM_STOP does not (OLECMDERR_E_NOTSUPPORTED).
2953 if(use_container_olecmd) {
2954 SET_EXPECT(Exec_STOP);
2955 }else if(has_document) {
2956 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2957 SET_EXPECT(SetStatusText);
2959 hres = IWebBrowser2_ExecWB(webbrowser, OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2960 if(!use_container_olecmd && has_document) {
2961 todo_wine ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2962 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2963 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
2964 }else {
2965 ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2967 if (use_container_olecmd)
2968 SET_EXPECT(Exec_IDM_STOP);
2969 hres = IWebBrowser2_ExecWB(webbrowser, IDM_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2970 ok(hres == idm_state, "ExecWB failed: %08x %08x\n", hres, idm_state);
2973 static void test_download(DWORD flags)
2975 BOOL *b = &called_Invoke_DOCUMENTCOMPLETE;
2976 MSG msg;
2978 if(flags & DWL_REFRESH)
2979 b = use_container_olecmd ? &called_Exec_SETDOWNLOADSTATE_0 : &called_Invoke_DOWNLOADCOMPLETE;
2980 else if((flags & DWL_FROM_PUT_HREF) && !use_container_olecmd && 0)
2981 b = &called_Invoke_DOWNLOADCOMPLETE;
2983 is_downloading = TRUE;
2984 dwl_flags = flags;
2986 if(flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK|DWL_FROM_GOFORWARD|DWL_REFRESH))
2987 test_ready_state(READYSTATE_COMPLETE, VARIANT_FALSE);
2988 else
2989 test_ready_state(READYSTATE_LOADING, VARIANT_FALSE);
2991 if(flags & (DWL_EXPECT_BEFORE_NAVIGATE|(is_http ? DWL_FROM_PUT_HREF : 0)|DWL_FROM_GOFORWARD|DWL_REFRESH))
2992 SET_EXPECT(Invoke_PROPERTYCHANGE);
2994 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2995 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2996 SET_EXPECT(TranslateUrl);
2998 if(use_container_olecmd) {
2999 SET_EXPECT(Exec_SETPROGRESSMAX);
3000 SET_EXPECT(Exec_SETPROGRESSPOS);
3001 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
3002 }else {
3003 SET_EXPECT(Invoke_DOWNLOADBEGIN);
3005 SET_EXPECT(DocHost_EnableModeless_FALSE);
3006 SET_EXPECT(DocHost_EnableModeless_TRUE);
3007 SET_EXPECT(Invoke_SETSECURELOCKICON);
3008 SET_EXPECT(Invoke_SETPHISHINGFILTERSTATUS);
3009 SET_EXPECT(EnableModeless_FALSE);
3011 if(!(flags & DWL_REFRESH)) {
3012 if(flags & (DWL_FROM_GOFORWARD|DWL_BACK_ENABLE))
3013 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3014 else
3015 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3016 if(flags & DWL_FROM_GOBACK)
3017 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3018 else
3019 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3022 expect_update_commands_enable = 0;
3023 set_update_commands_enable = 0xdead;
3024 SET_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3026 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
3027 SET_EXPECT(SetStatusText);
3028 SET_EXPECT(EnableModeless_TRUE);
3029 if(!is_first_load)
3030 SET_EXPECT(GetHostInfo);
3031 if(use_container_olecmd)
3032 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
3033 else
3034 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3035 SET_EXPECT(Invoke_TITLECHANGE);
3036 if(!(flags & DWL_REFRESH))
3037 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
3038 if(is_first_load)
3039 SET_EXPECT(GetDropTarget);
3040 SET_EXPECT(Invoke_PROGRESSCHANGE);
3041 if(!(flags & DWL_REFRESH))
3042 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
3044 if(flags & DWL_HTTP)
3045 SET_EXPECT(Exec_SETTITLE);
3046 SET_EXPECT(UpdateUI);
3047 if(use_container_olecmd)
3048 SET_EXPECT(Exec_UPDATECOMMANDS);
3049 SET_EXPECT(QueryStatus_STOP);
3050 SET_EXPECT(GetOverridesKeyPath); /* Called randomly on some VMs. */
3052 trace("Downloading...\n");
3053 while(!*b && GetMessageW(&msg, NULL, 0, 0)) {
3054 TranslateMessage(&msg);
3055 DispatchMessageW(&msg);
3058 if(flags & (DWL_EXPECT_BEFORE_NAVIGATE|(is_http ? DWL_FROM_PUT_HREF : 0)))
3059 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
3060 else if(flags & (DWL_FROM_GOFORWARD|DWL_REFRESH))
3061 CLEAR_CALLED(Invoke_PROPERTYCHANGE); /* called by IE11 */
3063 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
3064 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3065 CHECK_CALLED(TranslateUrl);
3067 if(use_container_olecmd) {
3068 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
3069 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
3070 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
3071 }else {
3072 SET_EXPECT(Invoke_DOWNLOADBEGIN);
3074 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
3075 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
3076 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
3077 CLEAR_CALLED(Invoke_SETPHISHINGFILTERSTATUS); /* IE 7 */
3078 if(is_first_load)
3079 todo_wine CHECK_CALLED(EnableModeless_FALSE);
3080 else
3081 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
3083 if(!(flags & DWL_REFRESH)) {
3084 todo_wine_if(nav_back_todo) {
3085 if(flags & (DWL_FROM_GOFORWARD|DWL_BACK_ENABLE))
3086 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3087 else
3088 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3090 if(flags & DWL_FROM_GOBACK)
3091 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3092 else
3093 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3095 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3096 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
3097 todo_wine CHECK_CALLED(SetStatusText);
3098 if(is_first_load)
3099 todo_wine CHECK_CALLED(EnableModeless_TRUE);
3100 else
3101 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
3102 if(!is_first_load)
3103 todo_wine CHECK_CALLED(GetHostInfo);
3104 if(use_container_olecmd)
3105 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
3106 else
3107 CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3108 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
3109 if(!(flags & DWL_REFRESH))
3110 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
3111 if(is_first_load)
3112 todo_wine CHECK_CALLED(GetDropTarget);
3113 if(!(flags & DWL_REFRESH))
3114 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
3116 is_downloading = FALSE;
3118 test_ready_state(READYSTATE_COMPLETE, VARIANT_FALSE);
3120 while(use_container_olecmd && !called_Exec_UPDATECOMMANDS && GetMessageA(&msg, NULL, 0, 0)) {
3121 TranslateMessage(&msg);
3122 DispatchMessageA(&msg);
3125 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
3126 if(flags & DWL_HTTP)
3127 CLEAR_CALLED(Exec_SETTITLE); /* FIXME: make it more strict */
3128 if(use_container_olecmd)
3129 CHECK_CALLED(UpdateUI);
3130 else
3131 CLEAR_CALLED(UpdateUI);
3132 if(use_container_olecmd)
3133 CHECK_CALLED(Exec_UPDATECOMMANDS);
3134 CLEAR_CALLED(QueryStatus_STOP);
3135 CLEAR_CALLED(GetOverridesKeyPath);
3138 static void test_Refresh(IWebBrowser2 *webbrowser, BOOL use_refresh2)
3140 HRESULT hres;
3142 trace("Refresh...\n");
3144 if(use_container_olecmd)
3145 SET_EXPECT(Exec_DocHostCommandHandler_2300);
3147 if(use_refresh2) {
3148 VARIANT v;
3150 V_VT(&v) = VT_I4;
3151 V_I4(&v) = REFRESH_NORMAL;
3153 hres = IWebBrowser2_Refresh2(webbrowser, &v);
3154 ok(hres == S_OK, "Refresh failed: %08x\n", hres);
3155 }else {
3156 hres = IWebBrowser2_Refresh(webbrowser);
3157 ok(hres == S_OK, "Refresh failed: %08x\n", hres);
3160 if(use_container_olecmd)
3161 CHECK_CALLED(Exec_DocHostCommandHandler_2300);
3163 test_download(DWL_REFRESH);
3166 static void test_olecmd(IWebBrowser2 *unk, BOOL loaded)
3168 IOleCommandTarget *cmdtrg;
3169 OLECMD cmds[3];
3170 HRESULT hres;
3172 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3173 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
3174 if(FAILED(hres))
3175 return;
3177 cmds[0].cmdID = OLECMDID_SPELL;
3178 cmds[0].cmdf = 0xdeadbeef;
3179 cmds[1].cmdID = OLECMDID_REFRESH;
3180 cmds[1].cmdf = 0xdeadbeef;
3181 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
3182 if(loaded) {
3183 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3184 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
3185 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
3186 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
3187 }else {
3188 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
3189 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
3190 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
3193 IOleCommandTarget_Release(cmdtrg);
3196 static void test_IServiceProvider(IWebBrowser2 *unk)
3198 IServiceProvider *servprov = (void*)0xdeadbeef;
3199 IUnknown *iface;
3200 HRESULT hres;
3202 hres = IWebBrowser2_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
3203 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
3204 if(FAILED(hres))
3205 return;
3207 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&iface);
3208 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
3209 ok(!iface, "QueryService returned %p, expected NULL\n", iface);
3210 if(hres == S_OK)
3211 IUnknown_Release(iface);
3213 hres = IServiceProvider_QueryService(servprov, &SID_SHTMLWindow, &IID_IHTMLWindow2, (LPVOID*)&iface);
3214 ok(hres == S_OK, "QueryService returned %08x, expected S_OK\n", hres);
3215 ok(iface != NULL, "QueryService returned NULL\n");
3216 if(hres == S_OK)
3217 IUnknown_Release(iface);
3219 IServiceProvider_Release(servprov);
3222 static void test_put_href(IWebBrowser2 *unk, const WCHAR *url)
3224 IHTMLLocation *location;
3225 IHTMLDocument2 *doc;
3226 BSTR str;
3227 HRESULT hres;
3229 trace("put_href(%s)...\n", wine_dbgstr_w(url));
3231 doc = get_document(unk);
3233 location = NULL;
3234 hres = IHTMLDocument2_get_location(doc, &location);
3235 IHTMLDocument2_Release(doc);
3236 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3237 ok(location != NULL, "location == NULL\n");
3239 is_http = !wcsncmp(url, L"http:", 5);
3241 SET_EXPECT(TranslateUrl);
3242 SET_EXPECT(Invoke_BEFORENAVIGATE2);
3243 if(!is_http)
3244 SET_EXPECT(Invoke_PROPERTYCHANGE);
3246 dwl_flags = DWL_FROM_PUT_HREF;
3248 str = SysAllocString(current_url = url);
3249 is_first_load = FALSE;
3250 hres = IHTMLLocation_put_href(location, str);
3252 CHECK_CALLED(TranslateUrl);
3253 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3254 if(!is_http)
3255 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
3257 IHTMLLocation_Release(location);
3258 SysFreeString(str);
3259 ok(hres == S_OK, "put_href failed: %08x\n", hres);
3261 test_ready_state(READYSTATE_COMPLETE, VARIANT_FALSE);
3264 static void test_go_back(IWebBrowser2 *wb, const WCHAR *back_url, int back_enable, int forward_enable, int forward_todo)
3266 HRESULT hres;
3268 current_url = back_url;
3270 SET_EXPECT(Invoke_BEFORENAVIGATE2);
3272 if(back_enable)
3273 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3274 else
3275 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3277 if(forward_enable)
3278 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3279 else
3280 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3282 nav_forward_todo = forward_todo;
3283 SET_EXPECT(Invoke_PROPERTYCHANGE);
3284 hres = IWebBrowser2_GoBack(wb);
3285 ok(hres == S_OK, "GoBack failed: %08x\n", hres);
3286 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3287 nav_forward_todo = FALSE;
3289 todo_wine_if(nav_back_todo) {
3290 if(back_enable)
3291 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3292 else
3293 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3296 todo_wine_if(forward_todo) {
3297 if(forward_enable)
3298 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3299 else
3300 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3303 CLEAR_CALLED(Invoke_PROPERTYCHANGE); /* called by IE11 */
3306 static void test_go_forward(IWebBrowser2 *wb, const WCHAR *forward_url, int back_enable, int forward_enable)
3308 HRESULT hres;
3310 current_url = forward_url;
3311 dwl_flags |= DWL_FROM_GOFORWARD;
3313 SET_EXPECT(Invoke_BEFORENAVIGATE2);
3315 if(back_enable)
3316 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3317 else
3318 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3320 if(forward_enable)
3321 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3322 else
3323 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3325 hres = IWebBrowser2_GoForward(wb);
3326 ok(hres == S_OK, "GoForward failed: %08x\n", hres);
3327 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3329 if(back_enable)
3330 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3331 else
3332 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3334 if(forward_enable)
3335 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3336 else
3337 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3340 static void test_QueryInterface(IWebBrowser2 *wb)
3342 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
3343 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
3344 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
3345 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
3346 IOleCache *cache = (void*)0xdeadbeef;
3347 IObjectWithSite *site = (void*)0xdeadbeef;
3348 IViewObjectEx *viewex = (void*)0xdeadbeef;
3349 IOleLink *link = (void*)0xdeadbeef;
3350 IMarshal *marshal = (void*)0xdeadbeef;
3351 IUnknown *unk = (IUnknown*)wb;
3352 HRESULT hres;
3354 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
3355 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3356 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
3358 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
3359 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3360 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
3362 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
3363 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3364 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
3366 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
3367 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3368 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
3370 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
3371 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3372 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
3374 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
3375 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3376 ok(site == NULL, "site=%p, expected NULL\n", site);
3378 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
3379 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3380 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
3382 hres = IUnknown_QueryInterface(unk, &IID_IOleLink, (void**)&link);
3383 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3384 ok(link == NULL, "link=%p, expected NULL\n", link);
3386 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&marshal);
3387 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3388 ok(marshal == NULL, "marshal=%p, expected NULL\n", marshal);
3392 static void test_UIActivate(IWebBrowser2 *unk, BOOL activate)
3394 IOleDocumentView *docview;
3395 IHTMLDocument2 *doc;
3396 HRESULT hres;
3398 doc = get_document(unk);
3400 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleDocumentView, (void**)&docview);
3401 ok(hres == S_OK, "Got 0x%08x\n", hres);
3402 if(SUCCEEDED(hres)) {
3403 if(activate) {
3404 SET_EXPECT(RequestUIActivate);
3405 SET_EXPECT(ShowUI);
3406 SET_EXPECT(HideUI);
3407 SET_EXPECT(OnFocus_FALSE);
3410 hres = IOleDocumentView_UIActivate(docview, activate);
3411 todo_wine_if(activate)
3412 ok(hres == S_OK, "Got 0x%08x\n", hres);
3414 if(activate) {
3415 todo_wine {
3416 CHECK_CALLED(RequestUIActivate);
3417 CHECK_CALLED(ShowUI);
3418 CHECK_CALLED(HideUI);
3419 CHECK_CALLED(OnFocus_FALSE);
3423 IOleDocumentView_Release(docview);
3426 IHTMLDocument2_Release(doc);
3429 static void test_external(IWebBrowser2 *unk)
3431 IDocHostUIHandler2 *dochost;
3432 IOleClientSite *client;
3433 IDispatch *disp;
3434 HRESULT hres;
3436 client = get_dochost(unk);
3438 hres = IOleClientSite_QueryInterface(client, &IID_IDocHostUIHandler2, (void**)&dochost);
3439 ok(hres == S_OK, "Could not get IDocHostUIHandler2 iface: %08x\n", hres);
3440 IOleClientSite_Release(client);
3442 if(use_container_dochostui)
3443 SET_EXPECT(GetExternal);
3444 disp = (void*)0xdeadbeef;
3445 hres = IDocHostUIHandler2_GetExternal(dochost, &disp);
3446 if(use_container_dochostui) {
3447 CHECK_CALLED(GetExternal);
3448 ok(hres == S_FALSE, "GetExternal failed: %08x\n", hres);
3449 ok(!disp, "disp = %p\n", disp);
3450 }else {
3451 IShellUIHelper *uihelper;
3453 ok(hres == S_OK, "GetExternal failed: %08x\n", hres);
3454 ok(disp != NULL, "disp == NULL\n");
3456 hres = IDispatch_QueryInterface(disp, &IID_IShellUIHelper, (void**)&uihelper);
3457 ok(hres == S_OK, "Could not get IShellUIHelper iface: %08x\n", hres);
3458 IShellUIHelper_Release(uihelper);
3459 IDispatch_Release(disp);
3462 IDocHostUIHandler2_Release(dochost);
3465 static void test_htmlwindow_close(IWebBrowser2 *wb)
3467 IHTMLWindow2 *window;
3468 IHTMLDocument2 *doc;
3469 HRESULT hres;
3471 doc = get_document(wb);
3473 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3474 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3475 IHTMLDocument2_Release(doc);
3477 SET_EXPECT(Invoke_WINDOWCLOSING);
3479 hres = IHTMLWindow2_close(window);
3480 ok(hres == S_OK, "close failed: %08x\n", hres);
3482 CHECK_CALLED(Invoke_WINDOWCLOSING);
3484 IHTMLWindow2_Release(window);
3487 static void test_TranslateAccelerator(IWebBrowser2 *unk)
3489 IOleClientSite *doc_clientsite;
3490 IOleInPlaceActiveObject *pao;
3491 HRESULT hres;
3492 DWORD keycode;
3493 MSG msg_a = {
3494 container_hwnd,
3495 0, 0, 0,
3496 GetTickCount(),
3497 {5, 5}
3500 test_Navigate2(unk, L"about:blank");
3502 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3503 ok(hres == S_OK, "Got 0x%08x\n", hres);
3504 if(SUCCEEDED(hres)) {
3505 /* One accelerator that should be handled by mshtml */
3506 msg_a.message = WM_KEYDOWN;
3507 msg_a.wParam = VK_F1;
3508 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3509 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3511 /* And one that should not */
3512 msg_a.message = WM_KEYDOWN;
3513 msg_a.wParam = VK_F5;
3514 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3515 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3517 IOleInPlaceActiveObject_Release(pao);
3520 test_UIActivate(unk, TRUE);
3522 /* Test again after UIActivate */
3523 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3524 ok(hres == S_OK, "Got 0x%08x\n", hres);
3525 if(SUCCEEDED(hres)) {
3526 /* One accelerator that should be handled by mshtml */
3527 msg_a.message = WM_KEYDOWN;
3528 msg_a.wParam = VK_F1;
3529 SET_EXPECT(DocHost_TranslateAccelerator);
3530 SET_EXPECT(ControlSite_TranslateAccelerator);
3531 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3532 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3533 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3534 todo_wine CHECK_CALLED(ControlSite_TranslateAccelerator);
3536 /* And one that should not */
3537 msg_a.message = WM_KEYDOWN;
3538 msg_a.wParam = VK_F5;
3539 SET_EXPECT(DocHost_TranslateAccelerator);
3540 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3541 todo_wine ok(hres == S_OK, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3542 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3544 IOleInPlaceActiveObject_Release(pao);
3547 doc_clientsite = get_dochost(unk);
3548 if(doc_clientsite) {
3549 IDocHostUIHandler2 *dochost;
3550 IOleControlSite *doc_controlsite;
3551 IUnknown *unk_test;
3553 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleInPlaceFrame, (void**)&unk_test);
3554 ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
3555 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3557 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostShowUI, (void**)&unk_test);
3558 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
3559 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3561 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler, (void**)&unk_test);
3562 ok(hres == S_OK, "Got 0x%08x\n", hres);
3563 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3565 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler2, (void**)&dochost);
3566 ok(hres == S_OK, "Got 0x%08x\n", hres);
3567 if(SUCCEEDED(hres)) {
3568 msg_a.message = WM_KEYDOWN;
3569 hr_dochost_TranslateAccelerator = 0xdeadbeef;
3570 for(keycode = 0; keycode <= 0x100; keycode++) {
3571 msg_a.wParam = keycode;
3572 SET_EXPECT(DocHost_TranslateAccelerator);
3573 hres = IDocHostUIHandler2_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3574 ok(hres == 0xdeadbeef, "Got 0x%08x\n", hres);
3575 CHECK_CALLED(DocHost_TranslateAccelerator);
3577 hr_dochost_TranslateAccelerator = E_NOTIMPL;
3579 SET_EXPECT(DocHost_TranslateAccelerator);
3580 hres = IDocHostUIHandler2_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3581 ok(hres == E_NOTIMPL, "Got 0x%08x\n", hres);
3582 CHECK_CALLED(DocHost_TranslateAccelerator);
3584 IDocHostUIHandler2_Release(dochost);
3587 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleControlSite, (void**)&doc_controlsite);
3588 ok(hres == S_OK, "Got 0x%08x\n", hres);
3589 if(SUCCEEDED(hres)) {
3590 msg_a.message = WM_KEYDOWN;
3591 hr_site_TranslateAccelerator = 0xdeadbeef;
3592 for(keycode = 0; keycode < 0x100; keycode++) {
3593 msg_a.wParam = keycode;
3594 SET_EXPECT(ControlSite_TranslateAccelerator);
3595 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3596 if(keycode == 0x9 || keycode == 0x75)
3597 todo_wine ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3598 else
3599 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3601 CHECK_CALLED(ControlSite_TranslateAccelerator);
3603 msg_a.wParam = VK_LEFT;
3604 SET_EXPECT(ControlSite_TranslateAccelerator);
3605 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3606 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3607 CHECK_CALLED(ControlSite_TranslateAccelerator);
3609 hr_site_TranslateAccelerator = S_OK;
3610 SET_EXPECT(ControlSite_TranslateAccelerator);
3611 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3612 ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3613 CHECK_CALLED(ControlSite_TranslateAccelerator);
3615 hr_site_TranslateAccelerator = E_NOTIMPL;
3616 SET_EXPECT(ControlSite_TranslateAccelerator);
3617 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3618 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3619 CHECK_CALLED(ControlSite_TranslateAccelerator);
3621 IOleControlSite_Release(doc_controlsite);
3624 IOleClientSite_Release(doc_clientsite);
3627 test_UIActivate(unk, FALSE);
3630 static void test_dochost_qs(IWebBrowser2 *webbrowser)
3632 IOleClientSite *client_site;
3633 IServiceProvider *serv_prov;
3634 IUnknown *service;
3635 HRESULT hres;
3637 client_site = get_dochost(webbrowser);
3638 hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
3639 IOleClientSite_Release(client_site);
3640 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
3642 hres = IServiceProvider_QueryService(serv_prov, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&service);
3643 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3644 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3645 IUnknown_Release(service);
3647 hres = IServiceProvider_QueryService(serv_prov, &IID_IWebBrowserApp, &IID_IHlinkFrame, (void**)&service);
3648 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3649 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3650 IUnknown_Release(service);
3652 hres = IServiceProvider_QueryService(serv_prov, &IID_ITargetFrame, &IID_ITargetFrame, (void**)&service);
3653 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3654 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3655 IUnknown_Release(service);
3657 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IShellBrowser, (void**)&service);
3658 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3659 IUnknown_Release(service);
3661 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IBrowserService, (void**)&service);
3662 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3663 IUnknown_Release(service);
3665 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IDocObjectService, (void**)&service);
3666 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3667 IUnknown_Release(service);
3669 IServiceProvider_Release(serv_prov);
3672 static void test_Close(IWebBrowser2 *wb, BOOL do_download)
3674 IOleObject *oo;
3675 IOleClientSite *ocs;
3676 HRESULT hres;
3678 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oo);
3679 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3680 if(hres != S_OK)
3681 return;
3683 test_close = TRUE;
3685 SET_EXPECT(Frame_SetActiveObject);
3686 SET_EXPECT(UIWindow_SetActiveObject);
3687 SET_EXPECT(OnUIDeactivate);
3688 SET_EXPECT(OnFocus_FALSE);
3689 SET_EXPECT(OnInPlaceDeactivate);
3690 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
3691 if(!do_download) {
3692 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3693 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3695 expect_update_commands_enable = 0;
3696 set_update_commands_enable = 0xdead;
3697 SET_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3699 if(use_container_olecmd)
3700 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3701 }else {
3702 nav_back_todo = nav_forward_todo = TRUE;
3704 SET_EXPECT(Advise_OnClose);
3705 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3706 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3707 CHECK_CALLED(Frame_SetActiveObject);
3708 CHECK_CALLED(UIWindow_SetActiveObject);
3709 CHECK_CALLED(OnUIDeactivate);
3710 CHECK_CALLED(OnFocus_FALSE);
3711 CHECK_CALLED(OnInPlaceDeactivate);
3712 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
3713 if(!do_download) {
3714 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3715 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3717 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3718 todo_wine ok(expect_update_commands_enable == set_update_commands_enable,
3719 "got %d\n", set_update_commands_enable);
3721 if(use_container_olecmd)
3722 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3723 }else {
3724 nav_back_todo = nav_forward_todo = FALSE;
3726 CHECK_CALLED(Advise_OnClose);
3728 hres = IOleObject_GetClientSite(oo, &ocs);
3729 ok(hres == S_OK, "hres = %x\n", hres);
3730 ok(!ocs, "ocs != NULL\n");
3732 SET_EXPECT(GetContainer);
3733 SET_EXPECT(Site_GetWindow);
3734 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3735 SET_EXPECT(Invoke_AMBIENT_SILENT);
3736 hres = IOleObject_DoVerb(oo, OLEIVERB_HIDE, NULL, (IOleClientSite*)0xdeadbeef,
3737 0, (HWND)0xdeadbeef, NULL);
3738 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3739 CHECK_CALLED(GetContainer);
3740 CHECK_CALLED(Site_GetWindow);
3741 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3742 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3744 hres = IOleObject_GetClientSite(oo, &ocs);
3745 ok(hres == S_OK, "hres = %x\n", hres);
3746 ok(ocs == &ClientSite, "ocs != &ClientSite\n");
3747 if(ocs)
3748 IOleClientSite_Release(ocs);
3750 SET_EXPECT(OnFocus_FALSE);
3751 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3752 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3753 SET_EXPECT(Advise_OnClose);
3754 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3755 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3756 CHECK_NOT_CALLED(OnFocus_FALSE);
3757 todo_wine CHECK_NOT_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3758 todo_wine CHECK_NOT_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3759 CHECK_CALLED(Advise_OnClose);
3761 test_close = FALSE;
3762 IOleObject_Release(oo);
3765 static void test_Advise(IWebBrowser2 *wb)
3767 IOleObject *oleobj;
3768 IEnumSTATDATA *data;
3769 DWORD connection[2];
3770 HRESULT hres;
3772 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void **)&oleobj);
3773 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3775 hres = IOleObject_Unadvise(oleobj, 0);
3776 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
3778 data = (void *)0xdeadbeef;
3779 hres = IOleObject_EnumAdvise(oleobj, &data);
3780 ok(hres == E_NOTIMPL, "EnumAdvise returned: %08x\n", hres);
3781 ok(data == NULL, "got data %p\n", data);
3783 connection[0] = 0xdeadbeef;
3784 hres = IOleObject_Advise(oleobj, NULL, &connection[0]);
3785 ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
3786 ok(connection[0] == 0, "got connection %u\n", connection[0]);
3788 hres = IOleObject_Advise(oleobj, &test_sink, NULL);
3789 ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
3791 connection[0] = 0xdeadbeef;
3792 hres = IOleObject_Advise(oleobj, &test_sink, &connection[0]);
3793 ok(hres == S_OK, "Advise returned: %08x\n", hres);
3794 ok(connection[0] != 0xdeadbeef, "got connection %u\n", connection[0]);
3796 connection[1] = 0xdeadbeef;
3797 hres = IOleObject_Advise(oleobj, &test_sink, &connection[1]);
3798 ok(hres == S_OK, "Advise returned: %08x\n", hres);
3799 ok(connection[1] == connection[0] + 1, "got connection %u\n", connection[1]);
3801 hres = IOleObject_Unadvise(oleobj, connection[1]);
3802 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
3804 hres = IOleObject_Unadvise(oleobj, connection[1]);
3805 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
3807 hres = IOleObject_Unadvise(oleobj, connection[0]);
3808 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
3810 IOleObject_Release(oleobj);
3813 #define TEST_DOWNLOAD 0x0001
3814 #define TEST_NOOLECMD 0x0002
3815 #define TEST_NODOCHOST 0x0004
3817 static void init_test(IWebBrowser2 *webbrowser, DWORD flags)
3819 wb = webbrowser;
3821 do_download = is_downloading = (flags & TEST_DOWNLOAD) != 0;
3822 is_first_load = TRUE;
3823 dwl_flags = 0;
3824 use_container_olecmd = !(flags & TEST_NOOLECMD);
3825 use_container_dochostui = !(flags & TEST_NODOCHOST);
3828 static void test_WebBrowser(DWORD flags, BOOL do_close)
3830 IWebBrowser2 *webbrowser;
3831 IOleObject *oleobj;
3832 HRESULT hres;
3833 ULONG ref, connection;
3835 webbrowser = create_webbrowser();
3836 if(!webbrowser)
3837 return;
3839 init_test(webbrowser, flags);
3841 hres = IWebBrowser2_QueryInterface(webbrowser, &IID_IOleObject, (void **)&oleobj);
3842 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
3844 hres = IOleObject_Advise(oleobj, &test_sink, &connection);
3845 ok(hres == S_OK, "Advise failed: %08x\n", hres);
3847 test_QueryStatusWB(webbrowser, FALSE);
3848 test_ExecWB(webbrowser, FALSE);
3849 test_QueryInterface(webbrowser);
3850 test_ready_state(READYSTATE_UNINITIALIZED, BUSY_FAIL);
3851 test_ClassInfo(webbrowser);
3852 test_EnumVerbs(webbrowser);
3853 test_LocationURL(webbrowser, L"");
3854 test_ConnectionPoint(webbrowser, TRUE);
3856 test_ClientSite(webbrowser, &ClientSite, !do_download);
3857 test_Extent(webbrowser);
3858 test_wb_funcs(webbrowser, TRUE);
3859 test_DoVerb(webbrowser);
3860 test_olecmd(webbrowser, FALSE);
3861 test_Navigate2(webbrowser, L"about:blank");
3862 test_QueryStatusWB(webbrowser, TRUE);
3863 test_Persist(webbrowser, 2);
3864 test_OleObject(webbrowser, 2);
3865 test_Advise(webbrowser);
3867 if(do_download) {
3868 IHTMLDocument2 *doc, *doc2;
3870 test_download(0);
3871 test_olecmd(webbrowser, TRUE);
3872 doc = get_document(webbrowser);
3874 test_put_href(webbrowser, L"about:test");
3875 test_download(DWL_FROM_PUT_HREF);
3876 doc2 = get_document(webbrowser);
3877 ok(doc == doc2, "doc != doc2\n");
3878 IHTMLDocument2_Release(doc2);
3880 trace("Navigate2 repeated...\n");
3881 test_Navigate2(webbrowser, L"about:blank");
3882 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3883 doc2 = get_document(webbrowser);
3884 ok(doc == doc2, "doc != doc2\n");
3885 IHTMLDocument2_Release(doc2);
3886 IHTMLDocument2_Release(doc);
3888 if(!do_close) {
3889 trace("Navigate2 http URL...\n");
3890 test_ready_state(READYSTATE_COMPLETE, VARIANT_FALSE);
3891 test_Navigate2(webbrowser, L"http://test.winehq.org/tests/hello.html");
3892 nav_back_todo = TRUE;
3893 test_download(DWL_EXPECT_BEFORE_NAVIGATE|DWL_HTTP);
3894 nav_back_todo = FALSE;
3896 test_Refresh(webbrowser, FALSE);
3897 test_Refresh(webbrowser, TRUE);
3899 trace("put_href http URL...\n");
3900 test_put_href(webbrowser, L"http://test.winehq.org/tests/winehq_snapshot/");
3901 test_download(DWL_FROM_PUT_HREF|DWL_HTTP|DWL_BACK_ENABLE);
3903 trace("GoBack...\n");
3904 nav_back_todo = TRUE;
3905 test_go_back(webbrowser, L"http://test.winehq.org/tests/hello.html", 0, 0, 1);
3906 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3907 nav_back_todo = FALSE;
3909 trace("GoForward...\n");
3910 test_go_forward(webbrowser, L"http://test.winehq.org/tests/winehq_snapshot/", -1, 0);
3911 test_download(DWL_FROM_GOFORWARD|DWL_HTTP);
3913 trace("GoBack...\n");
3914 nav_back_todo = TRUE;
3915 test_go_back(webbrowser, L"http://test.winehq.org/tests/hello.html", 0, -1, 0);
3916 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3917 nav_back_todo = FALSE;
3919 trace("GoForward...\n");
3920 test_go_forward(webbrowser, L"http://test.winehq.org/tests/winehq_snapshot/", -1, 0);
3921 test_download(DWL_FROM_GOFORWARD|DWL_HTTP);
3922 }else {
3923 trace("Navigate2 repeated with the same URL...\n");
3924 test_Navigate2(webbrowser, L"about:blank");
3925 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3928 test_EnumVerbs(webbrowser);
3929 test_TranslateAccelerator(webbrowser);
3931 test_dochost_qs(webbrowser);
3932 }else {
3933 test_ExecWB(webbrowser, TRUE);
3936 test_external(webbrowser);
3937 test_htmlwindow_close(webbrowser);
3939 if(do_close) {
3940 test_Close(webbrowser, do_download);
3941 }else {
3942 test_change_ClientSite(webbrowser);
3943 test_ClientSite(webbrowser, NULL, !do_download);
3945 test_ie_funcs(webbrowser);
3946 test_GetControlInfo(webbrowser);
3947 test_wb_funcs(webbrowser, FALSE);
3948 test_ConnectionPoint(webbrowser, FALSE);
3949 test_IServiceProvider(webbrowser);
3951 hres = IOleObject_Unadvise(oleobj, connection);
3952 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
3954 IOleObject_Release(oleobj);
3956 ref = IWebBrowser2_Release(webbrowser);
3957 ok(ref == 0 || broken(do_download && !do_close), "ref=%d, expected 0\n", ref);
3960 static void test_WebBrowserV1(void)
3962 IWebBrowser2 *wb;
3963 IOleObject *oleobj;
3964 ULONG ref, connection;
3965 HRESULT hres;
3967 hres = CoCreateInstance(&CLSID_WebBrowser_V1, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3968 &IID_IWebBrowser2, (void**)&wb);
3969 ok(hres == S_OK, "Could not get WebBrowserV1 instance: %08x\n", hres);
3971 init_test(wb, 0);
3972 wb_version = 1;
3974 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void **)&oleobj);
3975 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
3977 hres = IOleObject_Advise(oleobj, &test_sink, &connection);
3978 ok(hres == S_OK, "Advise failed: %08x\n", hres);
3980 test_QueryStatusWB(wb, FALSE);
3981 test_ExecWB(wb, FALSE);
3982 test_QueryInterface(wb);
3983 test_ready_state(READYSTATE_UNINITIALIZED, BUSY_FAIL);
3984 test_ClassInfo(wb);
3985 test_EnumVerbs(wb);
3986 test_Persist(wb, 1);
3987 test_OleObject(wb, 1);
3988 test_Advise(wb);
3990 hres = IOleObject_Unadvise(oleobj, connection);
3991 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
3993 IOleObject_Release(oleobj);
3995 ref = IWebBrowser2_Release(wb);
3996 ok(ref == 0, "ref=%d, expected 0\n", ref);
3999 static void test_WebBrowser_slim_container(void)
4001 IWebBrowser2 *webbrowser;
4002 ULONG ref;
4004 webbrowser = create_webbrowser();
4005 init_test(webbrowser, TEST_NOOLECMD|TEST_NODOCHOST);
4007 test_ConnectionPoint(webbrowser, TRUE);
4008 test_ClientSite(webbrowser, &ClientSite, TRUE);
4009 test_DoVerb(webbrowser);
4010 test_Navigate2(webbrowser, L"about:blank");
4012 /* Tests of interest */
4013 test_QueryStatusWB(webbrowser, TRUE);
4014 test_ExecWB(webbrowser, TRUE);
4015 test_external(webbrowser);
4017 /* Cleanup stage */
4018 test_ClientSite(webbrowser, NULL, TRUE);
4019 test_ConnectionPoint(webbrowser, FALSE);
4021 ref = IWebBrowser2_Release(webbrowser);
4022 ok(ref == 0, "ref=%d, expected 0\n", ref);
4025 static void test_WebBrowser_DoVerb(void)
4027 IWebBrowser2 *webbrowser;
4028 RECT rect;
4029 HWND hwnd;
4030 ULONG ref;
4031 BOOL res;
4032 HRESULT hres;
4033 VARIANT_BOOL b;
4035 webbrowser = create_webbrowser();
4036 init_test(webbrowser, 0);
4038 test_ClientSite(webbrowser, &ClientSite, FALSE);
4040 SET_EXPECT(CanInPlaceActivate);
4041 SET_EXPECT(Site_GetWindow);
4042 SET_EXPECT(OnInPlaceActivate);
4043 SET_EXPECT(GetWindowContext);
4044 SET_EXPECT(ShowObject);
4045 SET_EXPECT(GetContainer);
4046 SET_EXPECT(Frame_GetWindow);
4047 call_DoVerb(webbrowser, OLEIVERB_INPLACEACTIVATE);
4048 CHECK_CALLED(CanInPlaceActivate);
4049 CHECK_CALLED(Site_GetWindow);
4050 CHECK_CALLED(OnInPlaceActivate);
4051 CHECK_CALLED(GetWindowContext);
4052 CHECK_CALLED(ShowObject);
4053 CHECK_CALLED(GetContainer);
4054 CHECK_CALLED(Frame_GetWindow);
4056 hwnd = get_hwnd(webbrowser);
4058 memset(&rect, 0xa, sizeof(rect));
4059 res = GetWindowRect(hwnd, &rect);
4060 ok(res, "GetWindowRect failed: %u\n", GetLastError());
4062 SET_EXPECT(OnInPlaceDeactivate);
4063 call_DoVerb(webbrowser, OLEIVERB_HIDE);
4064 CHECK_CALLED(OnInPlaceDeactivate);
4066 b = 0x100;
4067 hres = IWebBrowser2_get_Visible(webbrowser, &b);
4068 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
4069 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
4071 SET_EXPECT(CanInPlaceActivate);
4072 SET_EXPECT(Site_GetWindow);
4073 SET_EXPECT(OnInPlaceActivate);
4074 SET_EXPECT(GetWindowContext);
4075 SET_EXPECT(ShowObject);
4076 SET_EXPECT(GetContainer);
4077 SET_EXPECT(Frame_GetWindow);
4078 SET_EXPECT(OnUIActivate);
4079 SET_EXPECT(Frame_SetActiveObject);
4080 SET_EXPECT(UIWindow_SetActiveObject);
4081 SET_EXPECT(SetMenu);
4082 SET_EXPECT(OnFocus_TRUE);
4083 call_DoVerb(webbrowser, OLEIVERB_SHOW);
4084 CHECK_CALLED(CanInPlaceActivate);
4085 CHECK_CALLED(Site_GetWindow);
4086 CHECK_CALLED(OnInPlaceActivate);
4087 CHECK_CALLED(GetWindowContext);
4088 CHECK_CALLED(ShowObject);
4089 CHECK_CALLED(GetContainer);
4090 CHECK_CALLED(Frame_GetWindow);
4091 CHECK_CALLED(OnUIActivate);
4092 CHECK_CALLED(Frame_SetActiveObject);
4093 CHECK_CALLED(UIWindow_SetActiveObject);
4094 CHECK_CALLED(SetMenu);
4095 CHECK_CALLED(OnFocus_TRUE);
4097 b = 0x100;
4098 hres = IWebBrowser2_get_Visible(webbrowser, &b);
4099 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
4100 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
4102 call_DoVerb(webbrowser, OLEIVERB_SHOW);
4103 call_DoVerb(webbrowser, OLEIVERB_UIACTIVATE);
4105 SET_EXPECT(Frame_SetActiveObject);
4106 SET_EXPECT(UIWindow_SetActiveObject);
4107 SET_EXPECT(OnUIDeactivate);
4108 SET_EXPECT(OnFocus_FALSE);
4109 SET_EXPECT(OnInPlaceDeactivate);
4110 test_hide = TRUE;
4111 call_DoVerb(webbrowser, OLEIVERB_HIDE);
4112 test_hide = FALSE;
4113 CHECK_CALLED(Frame_SetActiveObject);
4114 CHECK_CALLED(UIWindow_SetActiveObject);
4115 CHECK_CALLED(OnUIDeactivate);
4116 CHECK_CALLED(OnFocus_FALSE);
4117 CHECK_CALLED(OnInPlaceDeactivate);
4119 b = 0x100;
4120 hres = IWebBrowser2_get_Visible(webbrowser, &b);
4121 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
4122 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
4124 SET_EXPECT(CanInPlaceActivate);
4125 SET_EXPECT(Site_GetWindow);
4126 SET_EXPECT(OnInPlaceActivate);
4127 SET_EXPECT(GetWindowContext);
4128 SET_EXPECT(ShowObject);
4129 SET_EXPECT(GetContainer);
4130 SET_EXPECT(Frame_GetWindow);
4131 SET_EXPECT(OnUIActivate);
4132 SET_EXPECT(Frame_SetActiveObject);
4133 SET_EXPECT(UIWindow_SetActiveObject);
4134 SET_EXPECT(SetMenu);
4135 SET_EXPECT(OnFocus_TRUE);
4136 call_DoVerb(webbrowser, OLEIVERB_SHOW);
4137 CHECK_CALLED(CanInPlaceActivate);
4138 CHECK_CALLED(Site_GetWindow);
4139 CHECK_CALLED(OnInPlaceActivate);
4140 CHECK_CALLED(GetWindowContext);
4141 CHECK_CALLED(ShowObject);
4142 CHECK_CALLED(GetContainer);
4143 CHECK_CALLED(Frame_GetWindow);
4144 CHECK_CALLED(OnUIActivate);
4145 CHECK_CALLED(Frame_SetActiveObject);
4146 CHECK_CALLED(UIWindow_SetActiveObject);
4147 CHECK_CALLED(SetMenu);
4148 CHECK_CALLED(OnFocus_TRUE);
4150 b = 0x100;
4151 hres = IWebBrowser2_get_Visible(webbrowser, &b);
4152 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
4153 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
4155 SET_EXPECT(Frame_SetActiveObject);
4156 SET_EXPECT(UIWindow_SetActiveObject);
4157 SET_EXPECT(OnUIDeactivate);
4158 SET_EXPECT(OnFocus_FALSE);
4159 SET_EXPECT(OnInPlaceDeactivate);
4160 test_hide = TRUE;
4161 call_DoVerb(webbrowser, OLEIVERB_HIDE);
4162 CHECK_CALLED(Frame_SetActiveObject);
4163 CHECK_CALLED(UIWindow_SetActiveObject);
4164 CHECK_CALLED(OnUIDeactivate);
4165 CHECK_CALLED(OnFocus_FALSE);
4166 CHECK_CALLED(OnInPlaceDeactivate);
4168 call_DoVerb(webbrowser, OLEIVERB_HIDE);
4169 test_hide = FALSE;
4171 b = 0x100;
4172 hres = IWebBrowser2_get_Visible(webbrowser, &b);
4173 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
4174 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
4176 SET_EXPECT(CanInPlaceActivate);
4177 SET_EXPECT(Site_GetWindow);
4178 SET_EXPECT(OnInPlaceActivate);
4179 SET_EXPECT(GetWindowContext);
4180 SET_EXPECT(ShowObject);
4181 SET_EXPECT(GetContainer);
4182 SET_EXPECT(Frame_GetWindow);
4183 SET_EXPECT(OnUIActivate);
4184 SET_EXPECT(Frame_SetActiveObject);
4185 SET_EXPECT(UIWindow_SetActiveObject);
4186 SET_EXPECT(SetMenu);
4187 SET_EXPECT(OnFocus_TRUE);
4188 call_DoVerb(webbrowser, OLEIVERB_UIACTIVATE);
4189 CHECK_CALLED(CanInPlaceActivate);
4190 CHECK_CALLED(Site_GetWindow);
4191 CHECK_CALLED(OnInPlaceActivate);
4192 CHECK_CALLED(GetWindowContext);
4193 CHECK_CALLED(ShowObject);
4194 CHECK_CALLED(GetContainer);
4195 CHECK_CALLED(Frame_GetWindow);
4196 CHECK_CALLED(OnUIActivate);
4197 CHECK_CALLED(Frame_SetActiveObject);
4198 CHECK_CALLED(UIWindow_SetActiveObject);
4199 CHECK_CALLED(SetMenu);
4200 CHECK_CALLED(OnFocus_TRUE);
4202 b = 0x100;
4203 hres = IWebBrowser2_get_Visible(webbrowser, &b);
4204 ok(hres == S_OK, "get_Visible failed: %08x\n", hres);
4205 ok(b == VARIANT_TRUE, "Visible = %x\n", b);
4207 call_DoVerb(webbrowser, OLEIVERB_SHOW);
4209 test_ClientSite(webbrowser, NULL, FALSE);
4211 ref = IWebBrowser2_Release(webbrowser);
4212 ok(ref == 0, "ref=%d, expected 0\n", ref);
4216 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
4217 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
4218 static BOOL is_ie_hardened(void)
4220 HKEY zone_map;
4221 DWORD ie_harden, type, size;
4223 ie_harden = 0;
4224 if(RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
4225 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
4226 size = sizeof(DWORD);
4227 if (RegQueryValueExA(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
4228 type != REG_DWORD) {
4229 ie_harden = 0;
4231 RegCloseKey(zone_map);
4234 return ie_harden != 0;
4237 static void test_FileProtocol(void)
4239 IWebBrowser2 *webbrowser;
4240 HANDLE file;
4241 ULONG ref;
4242 WCHAR file_path[MAX_PATH];
4243 WCHAR file_url[MAX_PATH] = L"File://";
4245 static const WCHAR test_file[] = L"wine_test.html";
4247 GetTempPathW(MAX_PATH, file_path);
4248 lstrcatW(file_path, test_file);
4250 webbrowser = create_webbrowser();
4251 if(!webbrowser)
4252 return;
4254 init_test(webbrowser, 0);
4256 file = CreateFileW(file_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
4257 if(file == INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_EXISTS){
4258 ok(0, "CreateFile failed\n");
4259 return;
4261 CloseHandle(file);
4263 GetLongPathNameW(file_path, file_path, ARRAY_SIZE(file_path));
4264 lstrcatW(file_url, file_path);
4266 test_ConnectionPoint(webbrowser, TRUE);
4267 test_ClientSite(webbrowser, &ClientSite, TRUE);
4268 test_DoVerb(webbrowser);
4269 test_Navigate2(webbrowser, file_url);
4270 test_ClientSite(webbrowser, NULL, TRUE);
4272 ref = IWebBrowser2_Release(webbrowser);
4273 ok(ref == 0, "ref=%u, expected 0\n", ref);
4275 if(file != INVALID_HANDLE_VALUE)
4276 DeleteFileW(file_path);
4279 static HRESULT WINAPI sink_QueryInterface( IAdviseSink *iface, REFIID riid, void **obj)
4281 if (IsEqualGUID(riid, &IID_IAdviseSink) || IsEqualGUID(riid, &IID_IUnknown)) {
4282 *obj = iface;
4283 return S_OK;
4286 if (IsEqualGUID(riid, &IID_IProxyManager))
4287 return E_NOINTERFACE;
4289 ok(0, "unexpected call QI(%s)\n", wine_dbgstr_guid(riid));
4290 return E_NOINTERFACE;
4293 static ULONG WINAPI sink_AddRef(IAdviseSink *iface)
4295 return 2;
4298 static ULONG WINAPI sink_Release(IAdviseSink *iface)
4300 return 1;
4303 static void WINAPI sink_OnDataChange(IAdviseSink *iface, FORMATETC *format, STGMEDIUM *medium)
4305 trace("OnDataChange(%p, %p, %p)\n", iface, format, medium);
4308 static void WINAPI sink_OnViewChange(IAdviseSink *iface, DWORD aspect, LONG index)
4310 trace("OnViewChange(%p, %08x, %d)\n", iface, aspect, index);
4313 static void WINAPI sink_OnRename(IAdviseSink *iface, IMoniker *moniker)
4315 trace("OnRename(%p, %p) \n", iface, moniker);
4318 static void WINAPI sink_OnSave(IAdviseSink *iface)
4320 trace("OnSave(%p)\n", iface);
4323 static void WINAPI sink_OnClose(IAdviseSink *iface)
4325 trace("OnClose(%p)\n", iface);
4326 CHECK_EXPECT(Advise_OnClose);
4329 static const IAdviseSinkVtbl sink_vtbl =
4331 sink_QueryInterface,
4332 sink_AddRef,
4333 sink_Release,
4334 sink_OnDataChange,
4335 sink_OnViewChange,
4336 sink_OnRename,
4337 sink_OnSave,
4338 sink_OnClose
4341 static IAdviseSink test_sink = { &sink_vtbl };
4343 static void test_SetAdvise(void)
4345 HRESULT hr;
4346 IWebBrowser2 *browser;
4347 IViewObject2 *view;
4348 IAdviseSink *sink;
4349 IOleObject *oleobj;
4350 IDispatch *doc;
4351 DWORD aspects, flags;
4353 if (!(browser = create_webbrowser())) return;
4354 init_test(browser, 0);
4356 hr = IWebBrowser2_QueryInterface(browser, &IID_IViewObject2, (void **)&view);
4357 ok(hr == S_OK, "got %08x\n", hr);
4358 if (FAILED(hr)) return;
4360 aspects = flags = 0xdeadbeef;
4361 sink = (IAdviseSink *)0xdeadbeef;
4362 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4363 ok(hr == S_OK, "got %08x\n", hr);
4364 ok(!aspects, "got %08x\n", aspects);
4365 ok(!flags, "got %08x\n", aspects);
4366 ok(sink == NULL, "got %p\n", sink);
4368 hr = IViewObject2_SetAdvise(view, DVASPECT_CONTENT, 0, &test_sink);
4369 ok(hr == S_OK, "got %08x\n", hr);
4371 aspects = flags = 0xdeadbeef;
4372 sink = (IAdviseSink *)0xdeadbeef;
4373 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4374 ok(hr == S_OK, "got %08x\n", hr);
4375 ok(aspects == DVASPECT_CONTENT, "got %08x\n", aspects);
4376 ok(!flags, "got %08x\n", aspects);
4377 ok(sink == &test_sink, "got %p\n", sink);
4379 hr = IWebBrowser2_QueryInterface(browser, &IID_IOleObject, (void **)&oleobj);
4380 ok(hr == S_OK, "got %08x\n", hr);
4382 SET_EXPECT(GetContainer);
4383 SET_EXPECT(Site_GetWindow);
4384 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4385 SET_EXPECT(Invoke_AMBIENT_SILENT);
4386 hr = IOleObject_SetClientSite(oleobj, &ClientSite);
4387 ok(hr == S_OK, "got %08x\n", hr);
4388 CHECK_CALLED(GetContainer);
4389 CHECK_CALLED(Site_GetWindow);
4390 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4391 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4393 sink = (IAdviseSink *)0xdeadbeef;
4394 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4395 ok(hr == S_OK, "got %08x\n", hr);
4396 ok(sink == &test_sink, "got %p\n", sink);
4398 hr = IOleObject_SetClientSite(oleobj, NULL);
4399 ok(hr == S_OK, "got %08x\n", hr);
4401 aspects = flags = 0xdeadbeef;
4402 sink = (IAdviseSink *)0xdeadbeef;
4403 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4404 ok(hr == S_OK, "got %08x\n", hr);
4405 ok(sink == &test_sink, "got %p\n", sink);
4407 hr = IViewObject2_SetAdvise(view, 0, 0, NULL);
4408 ok(hr == S_OK, "got %08x\n", hr);
4410 doc = (void*)0xdeadbeef;
4411 hr = IWebBrowser2_get_Document(browser, &doc);
4412 ok(hr == S_FALSE, "get_Document failed: %08x\n", hr);
4413 ok(!doc, "doc = %p\n", doc);
4415 IOleObject_Release(oleobj);
4416 IViewObject2_Release(view);
4417 IWebBrowser2_Release(browser);
4420 static void test_SetQueryNetSessionCount(void)
4422 LONG count, init_count;
4424 init_count = pSetQueryNetSessionCount(SESSION_QUERY);
4425 trace("init_count %d\n", init_count);
4427 count = pSetQueryNetSessionCount(SESSION_INCREMENT);
4428 ok(count == init_count + 1, "count = %d\n", count);
4430 count = pSetQueryNetSessionCount(SESSION_QUERY);
4431 ok(count == init_count + 1, "count = %d\n", count);
4433 count = pSetQueryNetSessionCount(SESSION_DECREMENT);
4434 ok(count == init_count, "count = %d\n", count);
4436 count = pSetQueryNetSessionCount(SESSION_QUERY);
4437 ok(count == init_count, "count = %d\n", count);
4440 static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
4442 if(IsEqualGUID(riid, &outer_test_iid)) {
4443 CHECK_EXPECT(outer_QI_test);
4444 *ppv = (IUnknown*)0xdeadbeef;
4445 return S_OK;
4447 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
4448 return E_NOINTERFACE;
4451 static ULONG WINAPI outer_AddRef(IUnknown *iface)
4453 return 2;
4456 static ULONG WINAPI outer_Release(IUnknown *iface)
4458 return 1;
4461 static IUnknownVtbl outer_vtbl = {
4462 outer_QueryInterface,
4463 outer_AddRef,
4464 outer_Release
4467 static void test_com_aggregation(void)
4469 HRESULT hr;
4470 IClassFactory *class_factory;
4471 IUnknown outer = { &outer_vtbl };
4472 IUnknown *unk = NULL;
4473 IWebBrowser *web_browser = NULL;
4474 IUnknown *unk2 = NULL;
4476 hr = CoGetClassObject(&CLSID_WebBrowser, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&class_factory);
4477 ok(hr == S_OK, "CoGetClassObject failed: %08x\n", hr);
4479 hr = IClassFactory_CreateInstance(class_factory, &outer, &IID_IUnknown, (void**)&unk);
4480 ok(hr == S_OK, "CreateInstance returned hr = %08x\n", hr);
4481 ok(unk != NULL, "result NULL, hr = %08x\n", hr);
4483 hr = IUnknown_QueryInterface(unk, &IID_IWebBrowser, (void**)&web_browser);
4484 ok(hr == S_OK, "QI to IWebBrowser failed, hr=%08x\n", hr);
4486 SET_EXPECT(outer_QI_test);
4487 hr = IWebBrowser_QueryInterface(web_browser, &outer_test_iid, (void**)&unk2);
4488 CHECK_CALLED(outer_QI_test);
4489 ok(hr == S_OK, "Could not get test iface: %08x\n", hr);
4490 ok(unk2 == (IUnknown*)0xdeadbeef, "unexpected unk2\n");
4492 IWebBrowser_Release(web_browser);
4493 IUnknown_Release(unk);
4494 IClassFactory_Release(class_factory);
4497 START_TEST(webbrowser)
4499 HMODULE ieframe = LoadLibraryW(L"ieframe.dll");
4501 pSetQueryNetSessionCount = (void*)GetProcAddress(ieframe, "SetQueryNetSessionCount");
4503 OleInitialize(NULL);
4505 test_SetQueryNetSessionCount();
4507 container_hwnd = create_container_window();
4509 trace("Testing WebBrowser (no download)...\n");
4510 test_WebBrowser(0, FALSE);
4511 test_WebBrowser(0, TRUE);
4513 if(!is_ie_hardened()) {
4514 trace("Testing WebBrowser...\n");
4515 test_WebBrowser(TEST_DOWNLOAD, FALSE);
4516 trace("Testing WebBrowser(no olecmd)...\n");
4517 test_WebBrowser(TEST_DOWNLOAD|TEST_NOOLECMD, FALSE);
4518 }else {
4519 win_skip("Skipping http tests in hardened mode\n");
4522 trace("Testing WebBrowser DoVerb\n");
4523 test_WebBrowser_DoVerb();
4524 trace("Testing WebBrowser (with close)...\n");
4525 test_WebBrowser(TEST_DOWNLOAD, TRUE);
4526 trace("Testing WebBrowser w/o container-based olecmd...\n");
4527 test_WebBrowser_slim_container();
4528 trace("Testing WebBrowserV1...\n");
4529 test_WebBrowserV1();
4530 trace("Testing file protocol...\n");
4531 test_FileProtocol();
4532 trace("Testing SetAdvise...\n");
4533 test_SetAdvise();
4534 test_com_aggregation();
4536 OleUninitialize();