gdiplus/metafile: Support playback for EmfPlusRecordTypeSetAntiAliasMode.
[wine.git] / dlls / ieframe / tests / webbrowser.c
blobca2a13162bb4a7996d967aed7aaf9f0f5ad7313b
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_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
50 #define DEFINE_EXPECT(func) \
51 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
53 #define SET_EXPECT(func) \
54 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
56 #define CHECK_EXPECT2(func) \
57 do { \
58 ok(expect_ ##func, "unexpected call " #func "\n"); \
59 called_ ## func = TRUE; \
60 }while(0)
62 #define CHECK_EXPECT(func) \
63 do { \
64 CHECK_EXPECT2(func); \
65 expect_ ## func = FALSE; \
66 }while(0)
68 #define CHECK_CALLED(func) \
69 do { \
70 ok(called_ ## func, "expected " #func "\n"); \
71 expect_ ## func = called_ ## func = FALSE; \
72 }while(0)
74 #define CHECK_NOT_CALLED(func) \
75 do { \
76 ok(!called_ ## func, "unexpected " #func "\n"); \
77 expect_ ## func = called_ ## func = FALSE; \
78 }while(0)
80 #define CLEAR_CALLED(func) \
81 expect_ ## func = called_ ## func = FALSE
83 DEFINE_EXPECT(GetContainer);
84 DEFINE_EXPECT(Site_GetWindow);
85 DEFINE_EXPECT(ShowObject);
86 DEFINE_EXPECT(CanInPlaceActivate);
87 DEFINE_EXPECT(OnInPlaceActivate);
88 DEFINE_EXPECT(OnUIActivate);
89 DEFINE_EXPECT(GetWindowContext);
90 DEFINE_EXPECT(Frame_GetWindow);
91 DEFINE_EXPECT(Frame_SetActiveObject);
92 DEFINE_EXPECT(UIWindow_SetActiveObject);
93 DEFINE_EXPECT(SetMenu);
94 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
95 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
96 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
97 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
98 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
99 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
100 DEFINE_EXPECT(Invoke_STATUSTEXTCHANGE);
101 DEFINE_EXPECT(Invoke_PROPERTYCHANGE);
102 DEFINE_EXPECT(Invoke_DOWNLOADBEGIN);
103 DEFINE_EXPECT(Invoke_BEFORENAVIGATE2);
104 DEFINE_EXPECT(Invoke_SETSECURELOCKICON);
105 DEFINE_EXPECT(Invoke_FILEDOWNLOAD);
106 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
107 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
108 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
109 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
110 DEFINE_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
111 DEFINE_EXPECT(Invoke_DOWNLOADCOMPLETE);
112 DEFINE_EXPECT(Invoke_ONMENUBAR);
113 DEFINE_EXPECT(Invoke_ONADDRESSBAR);
114 DEFINE_EXPECT(Invoke_ONSTATUSBAR);
115 DEFINE_EXPECT(Invoke_ONTOOLBAR);
116 DEFINE_EXPECT(Invoke_ONFULLSCREEN);
117 DEFINE_EXPECT(Invoke_ONTHEATERMODE);
118 DEFINE_EXPECT(Invoke_WINDOWSETRESIZABLE);
119 DEFINE_EXPECT(Invoke_TITLECHANGE);
120 DEFINE_EXPECT(Invoke_NAVIGATECOMPLETE2);
121 DEFINE_EXPECT(Invoke_PROGRESSCHANGE);
122 DEFINE_EXPECT(Invoke_DOCUMENTCOMPLETE);
123 DEFINE_EXPECT(Invoke_WINDOWCLOSING);
124 DEFINE_EXPECT(Invoke_SETPHISHINGFILTERSTATUS);
125 DEFINE_EXPECT(EnableModeless_TRUE);
126 DEFINE_EXPECT(EnableModeless_FALSE);
127 DEFINE_EXPECT(GetHostInfo);
128 DEFINE_EXPECT(GetOptionKeyPath);
129 DEFINE_EXPECT(GetOverridesKeyPath);
130 DEFINE_EXPECT(SetStatusText);
131 DEFINE_EXPECT(UpdateUI);
132 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
133 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
134 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
135 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
136 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
137 DEFINE_EXPECT(Exec_SETTITLE);
138 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
139 DEFINE_EXPECT(Exec_STOP);
140 DEFINE_EXPECT(Exec_IDM_STOP);
141 DEFINE_EXPECT(Exec_DocHostCommandHandler_2300);
142 DEFINE_EXPECT(QueryStatus_STOP);
143 DEFINE_EXPECT(QueryStatus_IDM_STOP);
144 DEFINE_EXPECT(DocHost_EnableModeless_TRUE);
145 DEFINE_EXPECT(DocHost_EnableModeless_FALSE);
146 DEFINE_EXPECT(DocHost_TranslateAccelerator);
147 DEFINE_EXPECT(GetDropTarget);
148 DEFINE_EXPECT(TranslateUrl);
149 DEFINE_EXPECT(ShowUI);
150 DEFINE_EXPECT(HideUI);
151 DEFINE_EXPECT(OnUIDeactivate);
152 DEFINE_EXPECT(OnInPlaceDeactivate);
153 DEFINE_EXPECT(RequestUIActivate);
154 DEFINE_EXPECT(ControlSite_TranslateAccelerator);
155 DEFINE_EXPECT(OnFocus_TRUE);
156 DEFINE_EXPECT(OnFocus_FALSE);
157 DEFINE_EXPECT(GetExternal);
159 static const WCHAR wszItem[] = {'i','t','e','m',0};
161 static VARIANT_BOOL exvb;
163 static IWebBrowser2 *wb;
165 static HWND container_hwnd, shell_embedding_hwnd;
166 static BOOL is_downloading, do_download, is_first_load, use_container_olecmd, test_close, is_http, use_container_dochostui;
167 static HRESULT hr_dochost_TranslateAccelerator = E_NOTIMPL;
168 static HRESULT hr_site_TranslateAccelerator = E_NOTIMPL;
169 static const char *current_url;
170 static int wb_version, expect_update_commands_enable, set_update_commands_enable;
171 static BOOL nav_back_todo, nav_forward_todo; /* FIXME */
173 #define DWL_EXPECT_BEFORE_NAVIGATE 0x01
174 #define DWL_FROM_PUT_HREF 0x02
175 #define DWL_FROM_GOBACK 0x04
176 #define DWL_FROM_GOFORWARD 0x08
177 #define DWL_HTTP 0x10
178 #define DWL_REFRESH 0x20
179 #define DWL_BACK_ENABLE 0x40
181 static DWORD dwl_flags;
184 /* Returns true if the user interface is in English. Note that this does not
185 * presume of the formatting of dates, numbers, etc.
187 static BOOL is_lang_english(void)
189 static HMODULE hkernel32 = NULL;
190 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
191 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
193 if (!hkernel32)
195 hkernel32 = GetModuleHandleA("kernel32.dll");
196 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
197 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
199 if (pGetThreadUILanguage)
200 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
201 if (pGetUserDefaultUILanguage)
202 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
204 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
207 static int strcmp_wa(LPCWSTR strw, const char *stra)
209 CHAR buf[512];
210 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
211 return lstrcmpA(stra, buf);
214 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
216 IUnknown *unk1, *unk2;
218 if(iface1 == iface2)
219 return TRUE;
221 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
222 IUnknown_Release(unk1);
223 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
224 IUnknown_Release(unk2);
226 return unk1 == unk2;
229 static BSTR a2bstr(const char *str)
231 BSTR ret;
232 int len;
234 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
235 ret = SysAllocStringLen(NULL, len);
236 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
238 return ret;
241 #define create_webbrowser() _create_webbrowser(__LINE__)
242 static IWebBrowser2 *_create_webbrowser(unsigned line)
244 IWebBrowser2 *ret;
245 HRESULT hres;
247 wb_version = 2;
249 hres = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
250 &IID_IWebBrowser2, (void**)&ret);
251 ok_(__FILE__,line)(hres == S_OK, "Creating WebBrowser object failed: %08x\n", hres);
252 return ret;
255 #define test_LocationURL(a,b) _test_LocationURL(__LINE__,a,b)
256 static void _test_LocationURL(unsigned line, IWebBrowser2 *wb, const char *exurl)
258 BSTR url = (void*)0xdeadbeef;
259 HRESULT hres;
261 hres = IWebBrowser2_get_LocationURL(wb, &url);
262 ok_(__FILE__,line) (hres == (*exurl ? S_OK : S_FALSE), "get_LocationURL failed: %08x\n", hres);
263 if (SUCCEEDED(hres))
265 ok_(__FILE__,line) (!strcmp_wa(url, exurl), "unexpected URL: %s\n", wine_dbgstr_w(url));
266 SysFreeString(url);
270 #define test_ready_state(ex) _test_ready_state(__LINE__,ex)
271 static void _test_ready_state(unsigned line, READYSTATE exstate)
273 READYSTATE state;
274 HRESULT hres;
276 hres = IWebBrowser2_get_ReadyState(wb, &state);
277 ok_(__FILE__,line)(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
278 ok_(__FILE__,line)(state == exstate, "ReadyState = %d, expected %d\n", state, exstate);
281 #define get_document(u) _get_document(__LINE__,u)
282 static IHTMLDocument2 *_get_document(unsigned line, IWebBrowser2 *wb)
284 IHTMLDocument2 *html_doc;
285 IDispatch *disp;
286 HRESULT hres;
288 disp = NULL;
289 hres = IWebBrowser2_get_Document(wb, &disp);
290 ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
291 ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
293 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
294 ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
295 ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
296 IDispatch_Release(disp);
298 return html_doc;
301 #define get_dochost(u) _get_dochost(__LINE__,u)
302 static IOleClientSite *_get_dochost(unsigned line, IWebBrowser2 *unk)
304 IOleClientSite *client_site;
305 IHTMLDocument2 *doc;
306 IOleObject *oleobj;
307 HRESULT hres;
309 doc = _get_document(line, unk);
310 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
311 IHTMLDocument2_Release(doc);
312 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
314 hres = IOleObject_GetClientSite(oleobj, &client_site);
315 IOleObject_Release(oleobj);
316 ok_(__FILE__,line)(hres == S_OK, "Got 0x%08x\n", hres);
318 return client_site;
321 static HRESULT QueryInterface(REFIID,void**);
323 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
324 REFIID riid, void **ppv)
326 ok(0, "unexpected call\n");
327 return E_NOINTERFACE;
330 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
332 return 2;
335 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
337 return 1;
340 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
341 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
343 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
344 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
345 ok(!pCmdText, "pCmdText != NULL\n");
347 switch(prgCmds[0].cmdID) {
348 case OLECMDID_STOP:
349 CHECK_EXPECT2(QueryStatus_STOP);
350 prgCmds[0].cmdf = OLECMDF_SUPPORTED;
351 return S_OK;
352 case OLECMDID_SETPROGRESSTEXT:
353 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
354 prgCmds[0].cmdf = OLECMDF_ENABLED;
355 return S_OK;
356 case IDM_STOP:
357 /* Note:
358 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
359 * This command appears here for the ExecWB and QueryStatusWB tests in order
360 * to help demonstrate that these routines use a NULL pguidCmdGroup.
362 CHECK_EXPECT(QueryStatus_IDM_STOP);
363 prgCmds[0].cmdf = 0;
364 return S_OK;
365 default:
366 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
369 return E_FAIL;
372 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
373 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
375 if(!pguidCmdGroup) {
376 switch(nCmdID) {
377 case OLECMDID_SETPROGRESSMAX:
378 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
379 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
380 ok(pvaIn != NULL, "pvaIn == NULL\n");
381 if(pvaIn)
382 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
383 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
384 return S_OK;
385 case OLECMDID_SETPROGRESSPOS:
386 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
387 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
388 ok(pvaIn != NULL, "pvaIn == NULL\n");
389 if(pvaIn)
390 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
391 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
392 return S_OK;
393 case OLECMDID_SETDOWNLOADSTATE:
394 if(is_downloading)
395 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER || !nCmdexecopt,
396 "nCmdexecopts=%08x\n", nCmdexecopt);
397 else
398 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
399 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
400 ok(pvaIn != NULL, "pvaIn == NULL\n");
401 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
402 switch(V_I4(pvaIn)) {
403 case 0:
404 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_0);
405 break;
406 case 1:
407 CHECK_EXPECT2(Exec_SETDOWNLOADSTATE_1);
408 break;
409 default:
410 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
412 return S_OK;
413 case OLECMDID_UPDATECOMMANDS:
414 CHECK_EXPECT2(Exec_UPDATECOMMANDS);
415 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
416 ok(!pvaIn, "pvaIn != NULL\n");
417 ok(!pvaOut, "pvaOut=%p, expected NULL\n", pvaOut);
418 return S_OK;
419 case OLECMDID_SETTITLE:
420 CHECK_EXPECT(Exec_SETTITLE);
421 /* TODO: test args */
422 return S_OK;
423 case OLECMDID_STOP:
424 CHECK_EXPECT(Exec_STOP);
425 return S_OK;
426 case IDM_STOP:
427 /* Note:
428 * IDM_STOP is a command specific to CGID_MSHTML (not an OLECMDID command).
429 * This command appears here for the ExecWB and QueryStatusWB tests in order
430 * to help demonstrate that these routines use a NULL pguidCmdGroup.
432 CHECK_EXPECT(Exec_IDM_STOP);
433 return OLECMDERR_E_NOTSUPPORTED;
434 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
435 case OLECMDID_PAGEAVAILABLE: /* TODO (IE11) */
436 return E_NOTIMPL;
437 case 6058: /* TODO */
438 return E_NOTIMPL;
439 default:
440 ok(0, "unexpected nCmdID %d\n", nCmdID);
442 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
443 switch(nCmdID) {
444 case 20: /* TODO */
445 case 24: /* TODO */
446 case 25: /* IE5 */
447 case 37: /* TODO */
448 case 39: /* TODO */
449 case 66: /* TODO */
450 case 67: /* TODO */
451 case 69: /* TODO */
452 case 101: /* TODO (IE8) */
453 case 109: /* TODO (IE9) */
454 case 113: /* TODO (IE10) */
455 case 119: /* IE11 */
456 return E_FAIL;
457 default:
458 ok(0, "unexpected nCmdID %d\n", nCmdID);
460 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
461 switch(nCmdID) {
462 case 63: /* win10 */
463 case 105: /* TODO */
464 case 132: /* win10 */
465 case 133: /* IE11 */
466 case 134: /* TODO (IE10) */
467 case 135: /* IE11 */
468 case 136: /* TODO (IE10) */
469 case 137: /* win10 */
470 case 138: /* TODO */
471 case 140: /* TODO (Win7) */
472 case 144: /* TODO */
473 case 178: /* IE11 */
474 case 179: /* IE11 */
475 case 180: /* IE11 */
476 case 181: /* IE11 */
477 case 182: /* win10 */
478 return E_FAIL;
479 default:
480 ok(0, "unexpected nCmdID %d\n", nCmdID);
482 }else if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
483 switch(nCmdID) {
484 case 11: /* TODO */
485 break;
486 default:
487 ok(0, "unexpected nCmdID %d of CGID_DocHostCmdPriv\n", nCmdID);
489 }else if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
490 switch(nCmdID) {
491 case 6041: /* TODO */
492 break;
493 case 2300:
494 CHECK_EXPECT(Exec_DocHostCommandHandler_2300);
495 return E_NOTIMPL;
496 default:
497 ok(0, "unexpected nCmdID %d of CGID_DocHostCommandHandler\n", nCmdID);
499 }else {
500 ok(0, "unexpected pguidCmdGroup %s\n", wine_dbgstr_guid(pguidCmdGroup));
503 return E_FAIL;
506 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
507 OleCommandTarget_QueryInterface,
508 OleCommandTarget_AddRef,
509 OleCommandTarget_Release,
510 OleCommandTarget_QueryStatus,
511 OleCommandTarget_Exec
514 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
516 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
518 if(IsEqualGUID(&IID_ITargetContainer, riid))
519 return E_NOINTERFACE; /* TODO */
521 if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
522 if(use_container_olecmd)
524 *ppv = &OleCommandTarget;
525 return S_OK;
527 else
528 return E_NOINTERFACE;
531 ok(0, "unexpected call\n");
532 return E_NOINTERFACE;
535 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
537 return 2;
540 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
542 return 1;
545 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
546 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
548 ok(0, "unexpected call\n");
549 return E_NOTIMPL;
552 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
553 IEnumUnknown **ppenum)
555 ok(0, "unexpected call\n");
556 return E_NOTIMPL;
559 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
561 ok(0, "unexpected call\n");
562 return E_NOTIMPL;
565 static const IOleContainerVtbl OleContainerVtbl = {
566 OleContainer_QueryInterface,
567 OleContainer_AddRef,
568 OleContainer_Release,
569 OleContainer_ParseDisplayName,
570 OleContainer_EnumObjects,
571 OleContainer_LockContainer
574 static IOleContainer OleContainer = { &OleContainerVtbl };
576 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
578 return QueryInterface(riid, ppv);
581 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
583 return 2;
586 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
588 return 1;
591 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
593 ok(0, "unexpected call\n");
594 return E_NOTIMPL;
597 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
598 ITypeInfo **ppTInfo)
600 ok(0, "unexpected call\n");
601 return E_NOTIMPL;
604 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
605 UINT cNames, LCID lcid, DISPID *rgDispId)
607 ok(0, "unexpected call\n");
608 return E_NOTIMPL;
611 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
612 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
613 EXCEPINFO *pExcepInfo, UINT *puArgErr)
615 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
616 ok(pDispParams != NULL, "pDispParams == NULL\n");
617 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
618 ok(V_VT(pVarResult) == VT_EMPTY, "V_VT(pVarResult)=%d\n", V_VT(pVarResult));
619 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
620 ok(pDispParams->rgvarg == NULL, "pDispParams->rgvarg = %p\n", pDispParams->rgvarg);
621 ok(pDispParams->rgdispidNamedArgs == NULL,
622 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
623 ok(pDispParams->cArgs == 0, "pDispParams->cArgs = %d\n", pDispParams->cArgs);
624 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
626 switch(dispIdMember) {
627 case DISPID_AMBIENT_USERMODE:
628 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
629 return E_FAIL;
630 case DISPID_AMBIENT_DLCONTROL:
631 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
632 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
633 return E_FAIL;
634 case DISPID_AMBIENT_USERAGENT:
635 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
636 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
637 return E_FAIL;
638 case DISPID_AMBIENT_PALETTE:
639 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
640 ok(puArgErr != NULL, "puArgErr=%p\n", puArgErr);
641 return E_FAIL;
642 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
643 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
644 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
645 V_VT(pVarResult) = VT_BOOL;
646 V_BOOL(pVarResult) = VARIANT_FALSE;
647 return S_OK;
648 case DISPID_AMBIENT_SILENT:
649 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
650 ok(puArgErr == NULL, "puArgErr=%p\n", puArgErr);
651 V_VT(pVarResult) = VT_BOOL;
652 V_BOOL(pVarResult) = VARIANT_FALSE;
653 return S_OK;
656 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
657 return E_NOTIMPL;
660 static IDispatchVtbl DispatchVtbl = {
661 Dispatch_QueryInterface,
662 Dispatch_AddRef,
663 Dispatch_Release,
664 Dispatch_GetTypeInfoCount,
665 Dispatch_GetTypeInfo,
666 Dispatch_GetIDsOfNames,
667 Dispatch_Invoke
670 static IDispatch Dispatch = { &DispatchVtbl };
672 static HRESULT WINAPI WebBrowserEvents2_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
674 *ppv = NULL;
676 if(IsEqualGUID(&DIID_DWebBrowserEvents2, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
677 *ppv = iface;
678 return S_OK;
681 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
682 return E_NOINTERFACE;
685 #define test_invoke_bool(p,s) _test_invoke_bool(__LINE__,p,s)
686 static void _test_invoke_bool(unsigned line, const DISPPARAMS *params, BOOL strict)
688 ok_(__FILE__,line) (params->rgvarg != NULL, "rgvarg == NULL\n");
689 ok_(__FILE__,line) (params->cArgs == 1, "cArgs=%d, expected 1\n", params->cArgs);
690 ok_(__FILE__,line) (V_VT(params->rgvarg) == VT_BOOL, "V_VT(arg)=%d\n", V_VT(params->rgvarg));
691 if(strict)
692 ok_(__FILE__,line) (V_BOOL(params->rgvarg) == exvb, "V_VT(arg)=%x, expected %x\n",
693 V_BOOL(params->rgvarg), exvb);
694 else
695 ok_(__FILE__,line) (!V_BOOL(params->rgvarg) == !exvb, "V_VT(arg)=%x, expected %x\n",
696 V_BOOL(params->rgvarg), exvb);
699 static void test_OnBeforeNavigate(const VARIANT *disp, const VARIANT *url, const VARIANT *flags,
700 const VARIANT *frame, const VARIANT *post_data, const VARIANT *headers, const VARIANT *cancel)
702 BSTR str;
704 ok(V_VT(disp) == VT_DISPATCH, "V_VT(disp)=%d, expected VT_DISPATCH\n", V_VT(disp));
705 ok(V_DISPATCH(disp) != NULL, "V_DISPATCH(disp) == NULL\n");
706 ok(V_DISPATCH(disp) == (IDispatch*)wb, "V_DISPATCH(disp)=%p, wb=%p\n", V_DISPATCH(disp), wb);
708 ok(V_VT(url) == (VT_BYREF|VT_VARIANT), "V_VT(url)=%x, expected VT_BYREF|VT_VARIANT\n", V_VT(url));
709 ok(V_VARIANTREF(url) != NULL, "V_VARIANTREF(url) == NULL)\n");
710 if(V_VARIANTREF(url)) {
711 ok(V_VT(V_VARIANTREF(url)) == VT_BSTR, "V_VT(V_VARIANTREF(url))=%d, expected VT_BSTR\n",
712 V_VT(V_VARIANTREF(url)));
713 ok(V_BSTR(V_VARIANTREF(url)) != NULL, "V_BSTR(V_VARIANTREF(url)) == NULL\n");
714 ok(!strcmp_wa(V_BSTR(V_VARIANTREF(url)), current_url), "unexpected url %s, expected %s\n",
715 wine_dbgstr_w(V_BSTR(V_VARIANTREF(url))), current_url);
718 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
719 V_VT(flags));
720 ok(V_VT(flags) == (VT_BYREF|VT_VARIANT), "V_VT(flags)=%x, expected VT_BYREF|VT_VARIANT\n",
721 V_VT(flags));
722 ok(V_VARIANTREF(flags) != NULL, "V_VARIANTREF(flags) == NULL)\n");
723 if(V_VARIANTREF(flags)) {
724 int f;
726 ok(V_VT(V_VARIANTREF(flags)) == VT_I4, "V_VT(V_VARIANTREF(flags))=%d, expected VT_I4\n",
727 V_VT(V_VARIANTREF(flags)));
728 f = V_I4(V_VARIANTREF(flags));
729 f &= ~0x100; /* IE11 sets this flag */
730 if(is_first_load)
731 ok(!f, "flags = %x, expected 0\n", V_I4(V_VARIANTREF(flags)));
732 else
733 ok(!(f & ~0x40), "flags = %x, expected 0x40 or 0\n", V_I4(V_VARIANTREF(flags)));
736 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
737 V_VT(frame));
738 ok(V_VT(frame) == (VT_BYREF|VT_VARIANT), "V_VT(frame)=%x, expected VT_BYREF|VT_VARIANT\n",
739 V_VT(frame));
740 ok(V_VARIANTREF(frame) != NULL, "V_VARIANTREF(frame) == NULL)\n");
741 if(V_VARIANTREF(frame)) {
742 ok(V_VT(V_VARIANTREF(frame)) == VT_BSTR, "V_VT(V_VARIANTREF(frame))=%d, expected VT_BSTR\n",
743 V_VT(V_VARIANTREF(frame)));
744 ok(V_BSTR(V_VARIANTREF(frame)) == NULL, "V_BSTR(V_VARIANTREF(frame)) = %p, expected NULL\n",
745 V_BSTR(V_VARIANTREF(frame)));
748 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
749 V_VT(post_data));
750 ok(V_VT(post_data) == (VT_BYREF|VT_VARIANT), "V_VT(post_data)=%x, expected VT_BYREF|VT_VARIANT\n",
751 V_VT(post_data));
752 ok(V_VARIANTREF(post_data) != NULL, "V_VARIANTREF(post_data) == NULL)\n");
753 if(V_VARIANTREF(post_data)) {
754 ok(V_VT(V_VARIANTREF(post_data)) == (VT_VARIANT|VT_BYREF),
755 "V_VT(V_VARIANTREF(post_data))=%d, expected VT_VARIANT|VT_BYREF\n",
756 V_VT(V_VARIANTREF(post_data)));
757 ok(V_VARIANTREF(V_VARIANTREF(post_data)) != NULL,
758 "V_VARIANTREF(V_VARIANTREF(post_data)) == NULL\n");
759 if(V_VARIANTREF(V_VARIANTREF(post_data))) {
760 ok(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == VT_EMPTY,
761 "V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) = %d, expected VT_EMPTY\n",
762 V_VT(V_VARIANTREF(V_VARIANTREF(post_data))));
764 if(V_VT(V_VARIANTREF(V_VARIANTREF(post_data))) == (VT_UI1|VT_ARRAY)) {
765 const SAFEARRAY *sa = V_ARRAY(V_VARIANTREF(V_VARIANTREF(post_data)));
767 ok(sa->cDims == 1, "sa->cDims = %d, expected 1\n", sa->cDims);
768 ok(sa->fFeatures == 0, "sa->fFeatures = %d, expected 0\n", sa->fFeatures);
773 ok(V_VT(headers) == (VT_BYREF|VT_VARIANT), "V_VT(headers)=%x, expected VT_BYREF|VT_VARIANT\n",
774 V_VT(headers));
775 ok(V_VARIANTREF(headers) != NULL, "V_VARIANTREF(headers) == NULL)\n");
776 if(V_VARIANTREF(headers)) {
777 ok(V_VT(V_VARIANTREF(headers)) == VT_BSTR, "V_VT(V_VARIANTREF(headers))=%d, expected VT_BSTR\n",
778 V_VT(V_VARIANTREF(headers)));
779 str = V_BSTR(V_VARIANTREF(headers));
780 ok(!str || !strcmp_wa(str, "Referer: http://test.winehq.org/tests/hello.html\r\n"),
781 "V_BSTR(V_VARIANTREF(headers)) = %s, expected NULL\n", wine_dbgstr_w(str));
784 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel)=%x, expected VT_BYREF|VT_BOOL\n",
785 V_VT(cancel));
786 ok(V_BOOLREF(cancel) != NULL, "V_BOOLREF(pDispParams->rgvarg[0] == NULL)\n");
787 if(V_BOOLREF(cancel))
788 ok(*V_BOOLREF(cancel) == VARIANT_FALSE, "*V_BOOLREF(cancel) = %x, expected VARIANT_FALSE\n",
789 *V_BOOLREF(cancel));
792 static void test_navigatecomplete2(DISPPARAMS *dp)
794 VARIANT *v;
796 CHECK_EXPECT(Invoke_NAVIGATECOMPLETE2);
798 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
799 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
801 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
802 v = V_VARIANTREF(dp->rgvarg);
803 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
804 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
806 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
807 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
809 test_ready_state((dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK|DWL_FROM_GOFORWARD))
810 ? READYSTATE_COMPLETE : READYSTATE_LOADING);
813 static void test_documentcomplete(DISPPARAMS *dp)
815 VARIANT *v;
817 CHECK_EXPECT(Invoke_DOCUMENTCOMPLETE);
819 ok(dp->rgvarg != NULL, "rgvarg == NULL\n");
820 ok(dp->cArgs == 2, "cArgs=%d, expected 2\n", dp->cArgs);
822 ok(V_VT(dp->rgvarg) == (VT_BYREF|VT_VARIANT), "V_VT(dp->rgvarg) = %d\n", V_VT(dp->rgvarg));
823 v = V_VARIANTREF(dp->rgvarg);
824 ok(V_VT(v) == VT_BSTR, "V_VT(url) = %d\n", V_VT(v));
825 ok(!strcmp_wa(V_BSTR(v), current_url), "url=%s, expected %s\n", wine_dbgstr_w(V_BSTR(v)), current_url);
827 ok(V_VT(dp->rgvarg+1) == VT_DISPATCH, "V_VT(dp->rgvarg+1) = %d\n", V_VT(dp->rgvarg+1));
828 ok(V_DISPATCH(dp->rgvarg+1) == (IDispatch*)wb, "V_DISPATCH=%p, wb=%p\n", V_DISPATCH(dp->rgvarg+1), wb);
830 test_ready_state(READYSTATE_COMPLETE);
833 static HRESULT WINAPI WebBrowserEvents2_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
834 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
835 EXCEPINFO *pExcepInfo, UINT *puArgErr)
837 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
838 ok(pDispParams != NULL, "pDispParams == NULL\n");
839 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
840 ok(pVarResult == NULL, "pVarResult=%p\n", pVarResult);
841 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
842 ok(pDispParams->rgdispidNamedArgs == NULL,
843 "pDispParams->rgdispidNamedArgs = %p\n", pDispParams->rgdispidNamedArgs);
844 ok(pDispParams->cNamedArgs == 0, "pDispParams->cNamedArgs = %d\n", pDispParams->cNamedArgs);
846 switch(dispIdMember) {
847 case DISPID_STATUSTEXTCHANGE:
848 CHECK_EXPECT2(Invoke_STATUSTEXTCHANGE);
850 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
851 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
852 ok(V_VT(pDispParams->rgvarg) == VT_BSTR, "V_VT(pDispParams->rgvarg)=%d, expected VT_BSTR\n",
853 V_VT(pDispParams->rgvarg));
854 ok(V_BSTR(pDispParams->rgvarg) != NULL, "V_BSTR(pDispParams->rgvarg) is NULL\n");
855 /* TODO: Check text */
856 break;
858 case DISPID_PROPERTYCHANGE:
859 CHECK_EXPECT2(Invoke_PROPERTYCHANGE);
861 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
862 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
863 /* TODO: Check args */
864 break;
866 case DISPID_DOWNLOADBEGIN:
867 CHECK_EXPECT2(Invoke_DOWNLOADBEGIN);
869 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
870 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
871 if(dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOFORWARD|DWL_FROM_GOBACK))
872 test_ready_state(READYSTATE_COMPLETE);
873 else if(!(dwl_flags & DWL_REFRESH)) /* todo_wine */
874 test_ready_state(READYSTATE_LOADING);
875 break;
877 case DISPID_BEFORENAVIGATE2:
878 CHECK_EXPECT(Invoke_BEFORENAVIGATE2);
880 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
881 ok(pDispParams->cArgs == 7, "cArgs=%d, expected 7\n", pDispParams->cArgs);
882 test_OnBeforeNavigate(pDispParams->rgvarg+6, pDispParams->rgvarg+5, pDispParams->rgvarg+4,
883 pDispParams->rgvarg+3, pDispParams->rgvarg+2, pDispParams->rgvarg+1,
884 pDispParams->rgvarg);
885 test_ready_state((dwl_flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOFORWARD)) ? READYSTATE_COMPLETE : READYSTATE_LOADING);
886 break;
888 case DISPID_SETSECURELOCKICON:
889 CHECK_EXPECT2(Invoke_SETSECURELOCKICON);
891 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
892 ok(pDispParams->cArgs == 1, "cArgs=%d, expected 1\n", pDispParams->cArgs);
893 /* TODO: Check args */
894 break;
896 case DISPID_FILEDOWNLOAD:
897 CHECK_EXPECT(Invoke_FILEDOWNLOAD);
899 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
900 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
901 /* TODO: Check args */
902 break;
904 case DISPID_COMMANDSTATECHANGE:
905 ok(pDispParams->rgvarg != NULL, "rgvarg == NULL\n");
906 ok(pDispParams->cArgs == 2, "cArgs=%d, expected 2\n", pDispParams->cArgs);
908 ok(V_VT(pDispParams->rgvarg) == VT_BOOL, "V_VT(pDispParams->rgvarg) = %d\n", V_VT(pDispParams->rgvarg));
909 ok(V_VT(pDispParams->rgvarg+1) == VT_I4, "V_VT(pDispParams->rgvarg+1) = %d\n", V_VT(pDispParams->rgvarg+1));
910 ok(V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEFORWARD ||
911 V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEBACK ||
912 V_I4(pDispParams->rgvarg+1) == CSC_UPDATECOMMANDS,
913 "V_I4(pDispParams->rgvarg+1) = %x\n", V_I4(pDispParams->rgvarg+1));
915 if (V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEFORWARD)
917 todo_wine_if(nav_forward_todo) {
918 if(V_BOOL(pDispParams->rgvarg))
919 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
920 else
921 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
924 else if (V_I4(pDispParams->rgvarg+1) == CSC_NAVIGATEBACK)
926 todo_wine_if(nav_back_todo) {
927 if(V_BOOL(pDispParams->rgvarg))
928 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
929 else
930 CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
933 else if (V_I4(pDispParams->rgvarg+1) == CSC_UPDATECOMMANDS)
935 todo_wine CHECK_EXPECT2(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
936 set_update_commands_enable = V_BOOL(pDispParams->rgvarg);
938 break;
940 case DISPID_DOWNLOADCOMPLETE:
941 CHECK_EXPECT2(Invoke_DOWNLOADCOMPLETE);
943 ok(pDispParams->rgvarg == NULL, "rgvarg=%p, expected NULL\n", pDispParams->rgvarg);
944 ok(pDispParams->cArgs == 0, "cArgs=%d, expected 0\n", pDispParams->cArgs);
945 if(use_container_olecmd)
946 test_ready_state(READYSTATE_LOADING);
947 break;
949 case DISPID_ONMENUBAR:
950 CHECK_EXPECT(Invoke_ONMENUBAR);
951 test_invoke_bool(pDispParams, TRUE);
952 break;
954 case DISPID_ONADDRESSBAR:
955 CHECK_EXPECT(Invoke_ONADDRESSBAR);
956 test_invoke_bool(pDispParams, TRUE);
957 break;
959 case DISPID_ONSTATUSBAR:
960 CHECK_EXPECT(Invoke_ONSTATUSBAR);
961 test_invoke_bool(pDispParams, TRUE);
962 break;
964 case DISPID_ONTOOLBAR:
965 CHECK_EXPECT(Invoke_ONTOOLBAR);
966 test_invoke_bool(pDispParams, FALSE);
967 break;
969 case DISPID_ONFULLSCREEN:
970 CHECK_EXPECT(Invoke_ONFULLSCREEN);
971 test_invoke_bool(pDispParams, TRUE);
972 break;
974 case DISPID_ONTHEATERMODE:
975 CHECK_EXPECT(Invoke_ONTHEATERMODE);
976 test_invoke_bool(pDispParams, TRUE);
977 break;
979 case DISPID_WINDOWSETRESIZABLE:
980 CHECK_EXPECT(Invoke_WINDOWSETRESIZABLE);
981 test_invoke_bool(pDispParams, TRUE);
982 break;
984 case DISPID_TITLECHANGE:
985 CHECK_EXPECT2(Invoke_TITLECHANGE);
986 /* FIXME */
987 break;
989 case DISPID_NAVIGATECOMPLETE2:
990 test_navigatecomplete2(pDispParams);
991 break;
993 case DISPID_PROGRESSCHANGE:
994 CHECK_EXPECT2(Invoke_PROGRESSCHANGE);
995 /* FIXME */
996 break;
998 case DISPID_DOCUMENTCOMPLETE:
999 test_documentcomplete(pDispParams);
1000 break;
1002 case DISPID_WINDOWCLOSING: {
1003 VARIANT *is_child = pDispParams->rgvarg+1, *cancel = pDispParams->rgvarg;
1005 CHECK_EXPECT(Invoke_WINDOWCLOSING);
1007 ok(pDispParams->cArgs == 2, "pdp->cArgs = %d\n", pDispParams->cArgs);
1008 ok(V_VT(is_child) == VT_BOOL, "V_VT(is_child) = %d\n", V_VT(is_child));
1009 ok(!V_BOOL(is_child), "V_BOOL(is_child) = %x\n", V_BOOL(is_child));
1010 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel) = %d\n", V_VT(cancel));
1011 ok(!*V_BOOLREF(cancel), "*V_BOOLREF(cancel) = %x\n", *V_BOOLREF(cancel));
1013 *V_BOOLREF(cancel) = VARIANT_TRUE;
1014 return S_OK;
1017 case DISPID_SETPHISHINGFILTERSTATUS: /* FIXME */
1018 CHECK_EXPECT2(Invoke_SETPHISHINGFILTERSTATUS);
1019 break;
1021 case DISPID_BEFORESCRIPTEXECUTE: /* FIXME: IE10 */
1022 break;
1024 case DISPID_PRIVACYIMPACTEDSTATECHANGE:
1025 break;
1027 default:
1028 ok(0, "unexpected dispIdMember %d\n", dispIdMember);
1031 return S_OK;
1034 static IDispatchVtbl WebBrowserEvents2Vtbl = {
1035 WebBrowserEvents2_QueryInterface,
1036 Dispatch_AddRef,
1037 Dispatch_Release,
1038 Dispatch_GetTypeInfoCount,
1039 Dispatch_GetTypeInfo,
1040 Dispatch_GetIDsOfNames,
1041 WebBrowserEvents2_Invoke
1044 static IDispatch WebBrowserEvents2 = { &WebBrowserEvents2Vtbl };
1046 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1048 return QueryInterface(riid, ppv);
1051 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1053 return 2;
1056 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1058 return 1;
1061 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1063 ok(0, "unexpected call\n");
1064 return E_NOTIMPL;
1067 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1068 IMoniker **ppmon)
1070 ok(0, "unexpected call\n");
1071 return E_NOTIMPL;
1074 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1076 CHECK_EXPECT(GetContainer);
1078 ok(ppContainer != NULL, "ppContainer == NULL\n");
1079 if(ppContainer)
1080 *ppContainer = &OleContainer;
1082 return S_OK;
1085 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1087 CHECK_EXPECT(ShowObject);
1088 return S_OK;
1091 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1093 ok(0, "unexpected call\n");
1094 return E_NOTIMPL;
1097 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1099 ok(0, "unexpected call\n");
1100 return E_NOTIMPL;
1103 static const IOleClientSiteVtbl ClientSiteVtbl = {
1104 ClientSite_QueryInterface,
1105 ClientSite_AddRef,
1106 ClientSite_Release,
1107 ClientSite_SaveObject,
1108 ClientSite_GetMoniker,
1109 ClientSite_GetContainer,
1110 ClientSite_ShowObject,
1111 ClientSite_OnShowWindow,
1112 ClientSite_RequestNewObjectLayout
1115 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1116 static IOleClientSite ClientSite2 = { &ClientSiteVtbl };
1118 static HRESULT WINAPI IOleControlSite_fnQueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1120 *ppv = NULL;
1121 return E_NOINTERFACE;
1124 static ULONG WINAPI IOleControlSite_fnAddRef(IOleControlSite *iface)
1126 return 2;
1129 static ULONG WINAPI IOleControlSite_fnRelease(IOleControlSite *iface)
1131 return 1;
1134 static HRESULT WINAPI IOleControlSite_fnOnControlInfoChanged(IOleControlSite* This)
1136 ok(0, "unexpected call\n");
1137 return E_NOTIMPL;
1140 static HRESULT WINAPI IOleControlSite_fnLockInPlaceActive(IOleControlSite* This,
1141 BOOL fLock)
1143 ok(0, "unexpected call\n");
1144 return E_NOTIMPL;
1147 static HRESULT WINAPI IOleControlSite_fnGetExtendedControl(IOleControlSite* This,
1148 IDispatch **ppDisp)
1150 ok(0, "unexpected call\n");
1151 return E_NOTIMPL;
1154 static HRESULT WINAPI IOleControlSite_fnTransformCoords(IOleControlSite* This,
1155 POINTL *pPtlHimetric,
1156 POINTF *pPtfContainer,
1157 DWORD dwFlags)
1159 ok(0, "unexpected call\n");
1160 return E_NOTIMPL;
1163 static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* This, MSG *pMsg,
1164 DWORD grfModifiers)
1166 CHECK_EXPECT(ControlSite_TranslateAccelerator);
1167 return hr_site_TranslateAccelerator;
1170 static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus)
1172 if(fGotFocus)
1173 CHECK_EXPECT2(OnFocus_TRUE);
1174 else
1175 CHECK_EXPECT2(OnFocus_FALSE);
1176 return E_NOTIMPL;
1179 static HRESULT WINAPI IOleControlSite_fnShowPropertyFrame(IOleControlSite* This)
1181 ok(0, "unexpected call\n");
1182 return E_NOTIMPL;
1185 static IOleControlSiteVtbl ControlSiteVtbl = {
1186 IOleControlSite_fnQueryInterface,
1187 IOleControlSite_fnAddRef,
1188 IOleControlSite_fnRelease,
1189 IOleControlSite_fnOnControlInfoChanged,
1190 IOleControlSite_fnLockInPlaceActive,
1191 IOleControlSite_fnGetExtendedControl,
1192 IOleControlSite_fnTransformCoords,
1193 IOleControlSite_fnTranslateAccelerator,
1194 IOleControlSite_fnOnFocus,
1195 IOleControlSite_fnShowPropertyFrame
1198 static IOleControlSite ControlSite = { &ControlSiteVtbl };
1200 static HRESULT WINAPI InPlaceUIWindow_QueryInterface(IOleInPlaceFrame *iface,
1201 REFIID riid, void **ppv)
1203 ok(0, "unexpected call\n");
1204 return E_NOINTERFACE;
1207 static ULONG WINAPI InPlaceUIWindow_AddRef(IOleInPlaceFrame *iface)
1209 return 2;
1212 static ULONG WINAPI InPlaceUIWindow_Release(IOleInPlaceFrame *iface)
1214 return 1;
1217 static HRESULT WINAPI InPlaceUIWindow_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1219 ok(0, "unexpected call\n");
1220 return E_NOTIMPL;
1223 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1225 CHECK_EXPECT(Frame_GetWindow);
1226 ok(phwnd != NULL, "phwnd == NULL\n");
1227 if(phwnd)
1228 *phwnd = container_hwnd;
1229 return S_OK;
1232 static HRESULT WINAPI InPlaceUIWindow_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1234 ok(0, "unexpected call\n");
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI InPlaceUIWindow_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1240 ok(0, "unexpected call\n");
1241 return E_NOTIMPL;
1244 static HRESULT WINAPI InPlaceUIWindow_RequestBorderSpace(IOleInPlaceFrame *iface,
1245 LPCBORDERWIDTHS pborderwidths)
1247 ok(0, "unexpected call\n");
1248 return E_NOTIMPL;
1251 static HRESULT WINAPI InPlaceUIWindow_SetBorderSpace(IOleInPlaceFrame *iface,
1252 LPCBORDERWIDTHS pborderwidths)
1254 ok(0, "unexpected call\n");
1255 return E_NOTIMPL;
1258 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1259 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1261 CHECK_EXPECT(UIWindow_SetActiveObject);
1262 if(!test_close) {
1263 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1264 ok(!lstrcmpW(pszObjName, wszItem), "unexpected pszObjName\n");
1265 } else {
1266 ok(!pActiveObject, "pActiveObject != NULL\n");
1267 ok(!pszObjName, "pszObjName != NULL\n");
1269 return S_OK;
1272 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1273 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1275 CHECK_EXPECT(Frame_SetActiveObject);
1276 if(!test_close) {
1277 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1278 ok(!lstrcmpW(pszObjName, wszItem), "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_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1287 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1289 ok(0, "unexpected call\n");
1290 return E_NOTIMPL;
1293 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1294 HOLEMENU holemenu, HWND hwndActiveObject)
1296 CHECK_EXPECT(SetMenu);
1297 ok(hmenuShared == NULL, "hmenuShared=%p\n", hmenuShared);
1298 ok(holemenu == NULL, "holemenu=%p\n", holemenu);
1299 ok(hwndActiveObject == shell_embedding_hwnd, "hwndActiveObject=%p, expected %p\n",
1300 hwndActiveObject, shell_embedding_hwnd);
1301 return S_OK;
1304 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1306 ok(0, "unexpected call\n");
1307 return E_NOTIMPL;
1310 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1312 CHECK_EXPECT2(SetStatusText);
1313 /* FIXME: Check pszStatusText */
1314 return S_OK;
1317 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1319 if(fEnable)
1320 CHECK_EXPECT2(EnableModeless_TRUE);
1321 else
1322 CHECK_EXPECT2(EnableModeless_FALSE);
1323 return S_OK;
1326 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1328 ok(0, "unexpected call\n");
1329 return E_NOTIMPL;
1332 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1333 InPlaceUIWindow_QueryInterface,
1334 InPlaceUIWindow_AddRef,
1335 InPlaceUIWindow_Release,
1336 InPlaceUIWindow_GetWindow,
1337 InPlaceUIWindow_ContextSensitiveHelp,
1338 InPlaceUIWindow_GetBorder,
1339 InPlaceUIWindow_RequestBorderSpace,
1340 InPlaceUIWindow_SetBorderSpace,
1341 InPlaceUIWindow_SetActiveObject,
1344 static IOleInPlaceUIWindow InPlaceUIWindow = { (IOleInPlaceUIWindowVtbl*)&InPlaceUIWindowVtbl };
1346 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1347 InPlaceUIWindow_QueryInterface,
1348 InPlaceUIWindow_AddRef,
1349 InPlaceUIWindow_Release,
1350 InPlaceFrame_GetWindow,
1351 InPlaceUIWindow_ContextSensitiveHelp,
1352 InPlaceUIWindow_GetBorder,
1353 InPlaceUIWindow_RequestBorderSpace,
1354 InPlaceUIWindow_SetBorderSpace,
1355 InPlaceFrame_SetActiveObject,
1356 InPlaceFrame_InsertMenus,
1357 InPlaceFrame_SetMenu,
1358 InPlaceFrame_RemoveMenus,
1359 InPlaceFrame_SetStatusText,
1360 InPlaceFrame_EnableModeless,
1361 InPlaceFrame_TranslateAccelerator
1364 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1366 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1368 return QueryInterface(riid, ppv);
1371 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1373 return 2;
1376 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1378 return 1;
1381 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1383 CHECK_EXPECT(Site_GetWindow);
1384 ok(phwnd != NULL, "phwnd == NULL\n");
1385 if(phwnd)
1386 *phwnd = container_hwnd;
1387 return S_OK;
1390 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1392 ok(0, "unexpected call\n");
1393 return E_NOTIMPL;
1396 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1398 CHECK_EXPECT(CanInPlaceActivate);
1399 return S_OK;
1402 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1404 CHECK_EXPECT(OnInPlaceActivate);
1405 return S_OK;
1408 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1410 CHECK_EXPECT(OnUIActivate);
1411 return S_OK;
1414 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1415 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1416 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1418 static const RECT pos_rect = {2,1,1002,901};
1419 static const RECT clip_rect = {10,10,990,890};
1421 CHECK_EXPECT(GetWindowContext);
1423 ok(ppFrame != NULL, "ppFrame = NULL\n");
1424 if(ppFrame)
1425 *ppFrame = &InPlaceFrame;
1427 ok(ppDoc != NULL, "ppDoc = NULL\n");
1428 if(ppDoc)
1429 *ppDoc = &InPlaceUIWindow;
1431 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1432 if(lprcPosRect)
1433 memcpy(lprcPosRect, &pos_rect, sizeof(RECT));
1435 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1436 if(lprcClipRect)
1437 memcpy(lprcClipRect, &clip_rect, sizeof(RECT));
1439 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1440 if(lpFrameInfo) {
1441 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1442 lpFrameInfo->fMDIApp = FALSE;
1443 lpFrameInfo->hwndFrame = container_hwnd;
1444 lpFrameInfo->haccel = NULL;
1445 lpFrameInfo->cAccelEntries = 0;
1448 return S_OK;
1451 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1453 ok(0, "unexpected call\n");
1454 return E_NOTIMPL;
1457 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1459 CHECK_EXPECT(OnUIDeactivate);
1460 ok(!fUndoable, "fUndoable should be FALSE\n");
1461 return S_OK;
1464 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1466 CHECK_EXPECT(OnInPlaceDeactivate);
1467 return S_OK;
1470 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1472 ok(0, "unexpected call\n");
1473 return E_NOTIMPL;
1476 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1478 ok(0, "unexpected call\n");
1479 return E_NOTIMPL;
1482 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1484 ok(0, "unexpected call\n");
1485 return E_NOTIMPL;
1488 static HRESULT WINAPI InPlaceSite_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface,
1489 BOOL *pNoRedraw, DWORD dwFlags)
1491 ok(0, "unexpected call\n");
1492 return E_NOTIMPL;
1495 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface,
1496 BOOL fNoRedraw)
1498 ok(0, "unexpected call\n");
1499 return E_NOTIMPL;
1502 static HRESULT WINAPI InPlaceSite_RequestUIActivate(IOleInPlaceSiteEx *iface)
1504 CHECK_EXPECT2(RequestUIActivate);
1505 return S_OK;
1508 static const IOleInPlaceSiteExVtbl InPlaceSiteExVtbl = {
1509 InPlaceSite_QueryInterface,
1510 InPlaceSite_AddRef,
1511 InPlaceSite_Release,
1512 InPlaceSite_GetWindow,
1513 InPlaceSite_ContextSensitiveHelp,
1514 InPlaceSite_CanInPlaceActivate,
1515 InPlaceSite_OnInPlaceActivate,
1516 InPlaceSite_OnUIActivate,
1517 InPlaceSite_GetWindowContext,
1518 InPlaceSite_Scroll,
1519 InPlaceSite_OnUIDeactivate,
1520 InPlaceSite_OnInPlaceDeactivate,
1521 InPlaceSite_DiscardUndoState,
1522 InPlaceSite_DeactivateAndUndo,
1523 InPlaceSite_OnPosRectChange,
1524 InPlaceSite_OnInPlaceActivateEx,
1525 InPlaceSite_OnInPlaceDeactivateEx,
1526 InPlaceSite_RequestUIActivate
1529 static IOleInPlaceSiteEx InPlaceSite = { &InPlaceSiteExVtbl };
1531 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1533 return QueryInterface(riid, ppv);
1536 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1538 return 2;
1541 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1543 return 1;
1546 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1547 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1549 ok(0, "unexpected call %d %p %p %p\n", dwID, ppt, pcmdtReserved, pdicpReserved);
1550 return S_FALSE;
1553 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1555 CHECK_EXPECT2(GetHostInfo);
1556 ok(pInfo != NULL, "pInfo=NULL\n");
1557 if(pInfo) {
1558 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO) || broken(!pInfo->cbSize), "pInfo->cbSize=%u\n", pInfo->cbSize);
1559 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1560 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1561 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1562 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1564 return E_FAIL;
1567 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1568 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1569 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1571 CHECK_EXPECT(ShowUI);
1572 return E_NOTIMPL;
1575 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1577 CHECK_EXPECT(HideUI);
1578 return E_NOTIMPL;
1581 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1583 CHECK_EXPECT2(UpdateUI);
1584 return E_NOTIMPL;
1587 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1589 if(fEnable)
1590 CHECK_EXPECT(DocHost_EnableModeless_TRUE);
1591 else
1592 CHECK_EXPECT(DocHost_EnableModeless_FALSE);
1594 return S_OK;
1597 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1599 ok(0, "unexpected call\n");
1600 return E_NOTIMPL;
1603 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1605 ok(0, "unexpected call\n");
1606 return E_NOTIMPL;
1609 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1610 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1612 ok(0, "unexpected call\n");
1613 return E_NOTIMPL;
1616 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1617 const GUID *pguidCmdGroup, DWORD nCmdID)
1619 CHECK_EXPECT(DocHost_TranslateAccelerator);
1620 ok(pguidCmdGroup != NULL, "Got NULL pguidCmdGroup.\n");
1621 if(pguidCmdGroup)
1622 ok(IsEqualGUID(pguidCmdGroup, &CGID_MSHTML), "Unexpected pguidCmdGroup\n");
1623 ok(lpMsg != NULL, "Got NULL lpMsg.\n");
1624 return hr_dochost_TranslateAccelerator;
1627 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1628 LPOLESTR *pchKey, DWORD dw)
1630 CHECK_EXPECT(GetOptionKeyPath);
1631 ok(pchKey != NULL, "pchKey==NULL\n");
1632 if(pchKey)
1633 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1634 ok(!dw, "dw=%x\n", dw);
1635 return E_NOTIMPL;
1638 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1639 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1641 CHECK_EXPECT(GetDropTarget);
1642 return E_NOTIMPL;
1645 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1647 CHECK_EXPECT(GetExternal);
1648 *ppDispatch = NULL;
1649 return S_FALSE;
1652 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1653 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1655 todo_wine_if(is_downloading && !(dwl_flags & DWL_EXPECT_BEFORE_NAVIGATE))
1656 CHECK_EXPECT(TranslateUrl);
1657 return E_NOTIMPL;
1660 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1661 IDataObject **ppPORet)
1663 ok(0, "unexpected call\n");
1664 return E_NOTIMPL;
1667 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1668 LPOLESTR *pchKey, DWORD dw)
1670 CHECK_EXPECT(GetOverridesKeyPath);
1671 ok(pchKey != NULL, "pchKey==NULL\n");
1672 if(pchKey)
1673 ok(*pchKey == NULL, "*pchKey=%p\n", *pchKey);
1674 ok(!dw, "dw=%x\n", dw);
1675 return E_NOTIMPL;
1678 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
1679 DocHostUIHandler_QueryInterface,
1680 DocHostUIHandler_AddRef,
1681 DocHostUIHandler_Release,
1682 DocHostUIHandler_ShowContextMenu,
1683 DocHostUIHandler_GetHostInfo,
1684 DocHostUIHandler_ShowUI,
1685 DocHostUIHandler_HideUI,
1686 DocHostUIHandler_UpdateUI,
1687 DocHostUIHandler_EnableModeless,
1688 DocHostUIHandler_OnDocWindowActivate,
1689 DocHostUIHandler_OnFrameWindowActivate,
1690 DocHostUIHandler_ResizeBorder,
1691 DocHostUIHandler_TranslateAccelerator,
1692 DocHostUIHandler_GetOptionKeyPath,
1693 DocHostUIHandler_GetDropTarget,
1694 DocHostUIHandler_GetExternal,
1695 DocHostUIHandler_TranslateUrl,
1696 DocHostUIHandler_FilterDataObject,
1697 DocHostUIHandler_GetOverrideKeyPath
1700 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
1703 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1705 return QueryInterface(riid, ppv);
1708 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1710 return 2;
1713 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1715 return 1;
1718 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1719 REFGUID guidService, REFIID riid, void **ppv)
1721 *ppv = NULL;
1723 if(!winetest_interactive)
1724 return E_NOINTERFACE;
1726 if (IsEqualGUID(&SID_STopLevelBrowser, guidService))
1727 trace("Service SID_STopLevelBrowser\n");
1728 else if (IsEqualGUID(&SID_SEditCommandTarget, guidService))
1729 trace("Service SID_SEditCommandTarget\n");
1730 else if (IsEqualGUID(&IID_ITargetFrame2, guidService))
1731 trace("Service IID_ITargetFrame2\n");
1732 else if (IsEqualGUID(&SID_SInternetSecurityManager, guidService))
1733 trace("Service SID_SInternetSecurityManager\n");
1734 else if (IsEqualGUID(&SID_SOleUndoManager, guidService))
1735 trace("Service SID_SOleUndoManager\n");
1736 else if (IsEqualGUID(&SID_IMimeInfo, guidService))
1737 trace("Service SID_IMimeInfo\n");
1738 else if (IsEqualGUID(&SID_STopWindow, guidService))
1739 trace("Service SID_STopWindow\n");
1741 /* 30D02401-6A81-11D0-8274-00C04FD5AE38 Explorer Bar: Search */
1742 /* D1E7AFEC-6A2E-11D0-8C78-00C04FD918B4 no info */
1743 /* A9227C3C-7F8E-11D0-8CB0-00A0C92DBFE8 no info */
1744 /* 371EA634-DC5C-11D1-BA57-00C04FC2040E one reference to IVersionHost */
1745 /* 3050F429-98B5-11CF-BB82-00AA00BDCE0B IID_IElementBehaviorFactory */
1746 /* 6D12FE80-7911-11CF-9534-0000C05BAE0B SID_DefView */
1747 /* AD7F6C62-F6BD-11D2-959B-006097C553C8 no info */
1748 /* 53A2D5B1-D2FC-11D0-84E0-006097C9987D no info */
1749 /* 3050F312-98B5-11CF-BB82-00AA00BDCE0B HTMLFrameBaseClass */
1750 /* 639447BD-B2D3-44B9-9FB0-510F23CB45E4 no info */
1751 /* 20C46561-8491-11CF-960C-0080C7F4EE85 no info */
1753 else
1754 trace("Service %s not supported\n", wine_dbgstr_guid(guidService));
1756 return E_NOINTERFACE;
1760 static const IServiceProviderVtbl ServiceProviderVtbl = {
1761 ServiceProvider_QueryInterface,
1762 ServiceProvider_AddRef,
1763 ServiceProvider_Release,
1764 ServiceProvider_QueryService
1767 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1770 static HRESULT QueryInterface(REFIID riid, void **ppv)
1772 *ppv = NULL;
1774 if(IsEqualGUID(&IID_IUnknown, riid)
1775 || IsEqualGUID(&IID_IOleClientSite, riid))
1776 *ppv = &ClientSite;
1777 else if(IsEqualGUID(&IID_IOleWindow, riid)
1778 || IsEqualGUID(&IID_IOleInPlaceSite, riid)
1779 || IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
1780 *ppv = &InPlaceSite;
1781 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid)
1782 || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
1783 *ppv = use_container_dochostui ? &DocHostUIHandler : NULL;
1784 else if(IsEqualGUID(&IID_IDispatch, riid))
1785 *ppv = &Dispatch;
1786 else if(IsEqualGUID(&IID_IServiceProvider, riid))
1787 *ppv = &ServiceProvider;
1788 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
1789 trace("interface IID_IDocHostShowUI\n");
1790 else if(IsEqualGUID(&IID_IOleControlSite, riid))
1791 *ppv = &ControlSite;
1792 else if(IsEqualGUID(&IID_IOleCommandTarget, riid))
1793 trace("interface IID_IOleCommandTarget\n");
1795 /* B6EA2050-048A-11D1-82B9-00C04FB9942E IAxWinHostWindow */
1797 else
1799 /* are there more interfaces, that a host can support? */
1800 trace("%s: interface not supported\n", wine_dbgstr_guid(riid));
1803 return (*ppv) ? S_OK : E_NOINTERFACE;
1806 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1808 return DefWindowProcW(hwnd, msg, wParam, lParam);
1811 static HWND create_container_window(void)
1813 static const WCHAR wszWebBrowserContainer[] =
1814 {'W','e','b','B','r','o','w','s','e','r','C','o','n','t','a','i','n','e','r',0};
1815 static WNDCLASSEXW wndclass = {
1816 sizeof(WNDCLASSEXW),
1818 wnd_proc,
1819 0, 0, NULL, NULL, NULL, NULL, NULL,
1820 wszWebBrowserContainer,
1821 NULL
1824 RegisterClassExW(&wndclass);
1825 return CreateWindowW(wszWebBrowserContainer, wszWebBrowserContainer,
1826 WS_OVERLAPPEDWINDOW, 10, 10, 600, 600, NULL, NULL, NULL, NULL);
1829 static void test_DoVerb(IWebBrowser2 *unk)
1831 IOleObject *oleobj;
1832 RECT rect = {0,0,1000,1000};
1833 HRESULT hres;
1835 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1836 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1837 if(FAILED(hres))
1838 return;
1840 SET_EXPECT(CanInPlaceActivate);
1841 SET_EXPECT(Site_GetWindow);
1842 SET_EXPECT(OnInPlaceActivate);
1843 SET_EXPECT(GetWindowContext);
1844 SET_EXPECT(ShowObject);
1845 SET_EXPECT(GetContainer);
1846 SET_EXPECT(Frame_GetWindow);
1847 SET_EXPECT(OnUIActivate);
1848 SET_EXPECT(Frame_SetActiveObject);
1849 SET_EXPECT(UIWindow_SetActiveObject);
1850 SET_EXPECT(SetMenu);
1851 SET_EXPECT(OnFocus_TRUE);
1853 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1854 0, (HWND)0xdeadbeef, &rect);
1855 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1857 CHECK_CALLED(CanInPlaceActivate);
1858 CHECK_CALLED(Site_GetWindow);
1859 CHECK_CALLED(OnInPlaceActivate);
1860 CHECK_CALLED(GetWindowContext);
1861 CHECK_CALLED(ShowObject);
1862 CHECK_CALLED(GetContainer);
1863 CHECK_CALLED(Frame_GetWindow);
1864 CHECK_CALLED(OnUIActivate);
1865 CHECK_CALLED(Frame_SetActiveObject);
1866 CHECK_CALLED(UIWindow_SetActiveObject);
1867 CHECK_CALLED(SetMenu);
1868 CHECK_CALLED(OnFocus_TRUE);
1870 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite,
1871 0, (HWND)0xdeadbeef, &rect);
1872 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1874 IOleObject_Release(oleobj);
1877 static void call_DoVerb(IWebBrowser2 *unk, LONG verb)
1879 IOleObject *oleobj;
1880 RECT rect = {60,60,600,600};
1881 HRESULT hres;
1883 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1884 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1885 if(FAILED(hres))
1886 return;
1888 hres = IOleObject_DoVerb(oleobj, verb, NULL, &ClientSite,
1889 -1, container_hwnd, &rect);
1890 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
1892 IOleObject_Release(oleobj);
1895 static HWND get_hwnd(IWebBrowser2 *unk)
1897 IOleInPlaceObject *inplace;
1898 HWND hwnd;
1899 HRESULT hres;
1901 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1902 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1904 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1905 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1907 IOleInPlaceObject_Release(inplace);
1908 return hwnd;
1911 static void test_GetMiscStatus(IOleObject *oleobj)
1913 DWORD st, i;
1914 HRESULT hres;
1916 for(i=0; i<10; i++) {
1917 st = 0xdeadbeef;
1918 hres = IOleObject_GetMiscStatus(oleobj, i, &st);
1919 ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres);
1920 ok(st == (OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_INSIDEOUT
1921 |OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE),
1922 "st=%08x, expected OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|"
1923 "OLEMISC_INSIDEOUT|OLEMISC_CANTLINKINSIDE|OLEMISC_RECOMPOSEONRESIZE)\n", st);
1927 static void test_SetHostNames(IOleObject *oleobj)
1929 HRESULT hres;
1931 static const WCHAR test_appW[] = {'t','e','s','t',' ','a','p','p',0};
1933 hres = IOleObject_SetHostNames(oleobj, test_appW, (void*)0xdeadbeef);
1934 ok(hres == S_OK, "SetHostNames failed: %08x\n", hres);
1937 static void test_ClientSite(IWebBrowser2 *unk, IOleClientSite *client, BOOL stop_download)
1939 IOleObject *oleobj;
1940 IOleInPlaceObject *inplace;
1941 HWND hwnd;
1942 HRESULT hres;
1944 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
1945 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
1946 if(FAILED(hres))
1947 return;
1949 test_GetMiscStatus(oleobj);
1950 test_SetHostNames(oleobj);
1952 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
1953 ok(hres == S_OK, "QueryInterface(IID_OleInPlaceObject) failed: %08x\n", hres);
1954 if(FAILED(hres)) {
1955 IOleObject_Release(oleobj);
1956 return;
1959 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
1960 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1961 ok((hwnd == NULL) ^ (client == NULL), "unexpected hwnd %p\n", hwnd);
1963 if(client) {
1964 SET_EXPECT(GetContainer);
1965 SET_EXPECT(Site_GetWindow);
1966 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1967 SET_EXPECT(Invoke_AMBIENT_SILENT);
1968 }else if(stop_download) {
1969 if (use_container_olecmd) {
1970 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
1971 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
1974 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
1975 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
1977 expect_update_commands_enable = 0;
1978 set_update_commands_enable = 0xdead;
1979 SET_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
1980 }else {
1981 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
1982 SET_EXPECT(Invoke_PROGRESSCHANGE);
1983 nav_back_todo = nav_forward_todo = TRUE;
1986 hres = IOleObject_SetClientSite(oleobj, client);
1987 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
1989 if(client) {
1990 CHECK_CALLED(GetContainer);
1991 CHECK_CALLED(Site_GetWindow);
1992 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
1993 CHECK_CALLED(Invoke_AMBIENT_SILENT);
1994 }else if(stop_download) {
1995 if (use_container_olecmd) {
1996 todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
1997 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
2000 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2001 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2003 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
2004 todo_wine ok(expect_update_commands_enable == set_update_commands_enable,
2005 "got %d\n", set_update_commands_enable);
2006 }else {
2007 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2008 CLEAR_CALLED(Invoke_PROGRESSCHANGE);
2009 nav_back_todo = nav_forward_todo = FALSE;
2012 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
2013 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2014 ok((hwnd == NULL) == (client == NULL), "unexpected hwnd %p\n", hwnd);
2016 shell_embedding_hwnd = hwnd;
2018 test_SetHostNames(oleobj);
2020 IOleInPlaceObject_Release(inplace);
2021 IOleObject_Release(oleobj);
2024 static void test_change_ClientSite(IWebBrowser2 *unk)
2026 BOOL old_use_container_olecmd = use_container_olecmd;
2027 IOleClientSite *doc_clientsite;
2028 IOleInPlaceObject *inplace;
2029 IOleCommandTarget *olecmd;
2030 IOleObject *oleobj;
2031 HRESULT hres;
2032 HWND hwnd;
2034 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2035 ok(hres == S_OK, "QueryInterface(IID_OleObject) failed: %08x\n", hres);
2036 if(FAILED(hres))
2037 return;
2039 use_container_olecmd = FALSE;
2041 SET_EXPECT(Site_GetWindow);
2042 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2043 SET_EXPECT(Invoke_AMBIENT_SILENT);
2045 hres = IOleObject_SetClientSite(oleobj, &ClientSite2);
2046 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
2047 IOleObject_Release(oleobj);
2049 CHECK_CALLED(Site_GetWindow);
2050 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2051 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2053 doc_clientsite = get_dochost(unk);
2054 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleCommandTarget, (void**)&olecmd);
2055 ok(hres == S_OK, "QueryInterface(IOleCommandTarget) failed: %08x\n", hres);
2056 IOleClientSite_Release(doc_clientsite);
2058 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceObject, (void**)&inplace);
2059 ok(hres == S_OK, "QueryInterface(OleInPlaceObject) failed: %08x\n", hres);
2060 hres = IOleInPlaceObject_GetWindow(inplace, &hwnd);
2061 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2062 ok(hwnd == shell_embedding_hwnd, "unexpected hwnd %p\n", hwnd);
2063 IOleInPlaceObject_Release(inplace);
2065 if(old_use_container_olecmd) {
2066 SET_EXPECT(Exec_UPDATECOMMANDS);
2068 hres = IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_UPDATECOMMANDS,
2069 OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL);
2070 ok(hres == S_OK, "Exec(OLECMDID_UPDATECOMMAND) failed: %08x\n", hres);
2072 CHECK_CALLED(Exec_UPDATECOMMANDS);
2073 use_container_olecmd = TRUE;
2076 IOleCommandTarget_Release(olecmd);
2079 static void test_ClassInfo(IWebBrowser2 *unk)
2081 IProvideClassInfo2 *class_info;
2082 TYPEATTR *type_attr;
2083 ITypeInfo *typeinfo;
2084 GUID guid;
2085 HRESULT hres;
2087 hres = IWebBrowser2_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&class_info);
2088 ok(hres == S_OK, "QueryInterface(IID_IProvideClassInfo) failed: %08x\n", hres);
2089 if(FAILED(hres))
2090 return;
2092 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &guid);
2093 ok(hres == S_OK, "GetGUID failed: %08x\n", hres);
2094 ok(IsEqualGUID(wb_version > 1 ? &DIID_DWebBrowserEvents2 : &DIID_DWebBrowserEvents, &guid), "wrong guid\n");
2096 hres = IProvideClassInfo2_GetGUID(class_info, 0, &guid);
2097 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
2098 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
2100 hres = IProvideClassInfo2_GetGUID(class_info, 2, &guid);
2101 ok(hres == E_FAIL, "GetGUID failed: %08x, expected E_FAIL\n", hres);
2102 ok(IsEqualGUID(&IID_NULL, &guid), "wrong guid\n");
2104 hres = IProvideClassInfo2_GetGUID(class_info, GUIDKIND_DEFAULT_SOURCE_DISP_IID, NULL);
2105 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
2107 hres = IProvideClassInfo2_GetGUID(class_info, 0, NULL);
2108 ok(hres == E_POINTER, "GetGUID failed: %08x, expected E_POINTER\n", hres);
2110 typeinfo = NULL;
2111 hres = IProvideClassInfo2_GetClassInfo(class_info, &typeinfo);
2112 ok(hres == S_OK, "GetClassInfo failed: %08x\n", hres);
2113 ok(typeinfo != NULL, "typeinfo == NULL\n");
2115 hres = ITypeInfo_GetTypeAttr(typeinfo, &type_attr);
2116 ok(hres == S_OK, "GetTypeAtr failed: %08x\n", hres);
2118 ok(IsEqualGUID(&type_attr->guid, wb_version > 1 ? &CLSID_WebBrowser : &CLSID_WebBrowser_V1),
2119 "guid = %s\n", wine_dbgstr_guid(&type_attr->guid));
2121 ITypeInfo_ReleaseTypeAttr(typeinfo, type_attr);
2122 ITypeInfo_Release(typeinfo);
2124 IProvideClassInfo2_Release(class_info);
2127 #define expect_oleverb(a,b) _expect_oleverb(__LINE__,a,b)
2128 static void _expect_oleverb(unsigned line, const OLEVERB *verb, LONG exverb)
2130 ok_(__FILE__,line)(verb->lVerb == exverb, "verb->lVerb = %d, expected %d\n", verb->lVerb, exverb);
2131 ok_(__FILE__,line)(!verb->lpszVerbName, "verb->lpszVerbName = %s\n", wine_dbgstr_w(verb->lpszVerbName));
2132 ok_(__FILE__,line)(!verb->fuFlags, "verb->fuFlags = %x\n", verb->fuFlags);
2133 ok_(__FILE__,line)(!verb->grfAttribs, "verb->grfAttribs = %x\n", verb->grfAttribs);
2136 #define test_next_oleverb(a,b) _test_next_oleverb(__LINE__,a,b)
2137 static void _test_next_oleverb(unsigned line, IEnumOLEVERB *enum_verbs, LONG exverb)
2139 ULONG fetched = 0xdeadbeef;
2140 OLEVERB verb;
2141 HRESULT hres;
2143 fetched = 0xdeadbeef;
2144 memset(&verb, 0xa, sizeof(verb));
2145 hres = IEnumOLEVERB_Next(enum_verbs, 1, &verb, &fetched);
2146 ok_(__FILE__,line)(hres == S_OK, "Next failed: %08x\n", hres);
2147 ok_(__FILE__,line)(!fetched, "fetched = %d\n", fetched);
2148 _expect_oleverb(line, &verb, exverb);
2151 static void test_EnumVerbs(IWebBrowser2 *wb)
2153 IEnumOLEVERB *enum_verbs;
2154 IOleObject *oleobj;
2155 OLEVERB verbs[20];
2156 ULONG fetched;
2157 HRESULT hres;
2159 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oleobj);
2160 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
2162 hres = IOleObject_EnumVerbs(oleobj, &enum_verbs);
2163 IOleObject_Release(oleobj);
2164 ok(hres == S_OK, "EnumVerbs failed: %08x\n", hres);
2165 ok(enum_verbs != NULL, "enum_verbs == NULL\n");
2167 fetched = 0xdeadbeef;
2168 memset(verbs, 0xa, sizeof(verbs));
2169 verbs[1].lVerb = 0xdeadbeef;
2170 hres = IEnumOLEVERB_Next(enum_verbs, sizeof(verbs)/sizeof(*verbs), verbs, &fetched);
2171 ok(hres == S_OK, "Next failed: %08x\n", hres);
2172 ok(!fetched, "fetched = %d\n", fetched);
2173 /* Although fetched==0, an element is returned. */
2174 expect_oleverb(verbs, OLEIVERB_PRIMARY);
2175 /* The first argument is ignored and always one element is returned. */
2176 ok(verbs[1].lVerb == 0xdeadbeef, "verbs[1].lVerb = %x\n", verbs[1].lVerb);
2178 test_next_oleverb(enum_verbs, OLEIVERB_INPLACEACTIVATE);
2179 test_next_oleverb(enum_verbs, OLEIVERB_UIACTIVATE);
2180 test_next_oleverb(enum_verbs, OLEIVERB_SHOW);
2181 test_next_oleverb(enum_verbs, OLEIVERB_HIDE);
2183 /* There is anouther verb, returned correctly. */
2184 fetched = 0xdeadbeef;
2185 memset(verbs, 0xa, sizeof(verbs));
2186 verbs[0].lVerb = 0xdeadbeef;
2187 hres = IEnumOLEVERB_Next(enum_verbs, sizeof(verbs)/sizeof(*verbs), verbs, &fetched);
2188 todo_wine ok(hres == S_OK, "Next failed: %08x\n", hres);
2189 todo_wine ok(fetched == 1, "fetched = %d\n", fetched);
2190 todo_wine ok(verbs[0].lVerb != 0xdeadbeef, "verbs[0].lVerb = %x\n", verbs[0].lVerb);
2192 hres = IEnumOLEVERB_Next(enum_verbs, sizeof(verbs)/sizeof(*verbs), verbs, &fetched);
2193 ok(hres == S_FALSE, "Next failed: %08x\n", hres);
2194 ok(!fetched, "fetched = %d\n", fetched);
2196 hres = IEnumOLEVERB_Reset(enum_verbs);
2197 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2199 fetched = 0xdeadbeef;
2200 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2201 ok(hres == S_OK, "Next failed: %08x\n", hres);
2202 ok(!fetched, "fetched = %d\n", fetched);
2204 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, NULL);
2205 ok(hres == S_OK, "Next failed: %08x\n", hres);
2207 hres = IEnumOLEVERB_Skip(enum_verbs, 20);
2208 ok(hres == S_OK, "Reset failed: %08x\n", hres);
2210 fetched = 0xdeadbeef;
2211 hres = IEnumOLEVERB_Next(enum_verbs, 1, verbs, &fetched);
2212 ok(hres == S_OK, "Next failed: %08x\n", hres);
2213 ok(!fetched, "fetched = %d\n", fetched);
2215 test_next_oleverb(enum_verbs, OLEIVERB_SHOW);
2217 IEnumOLEVERB_Release(enum_verbs);
2220 static void test_ie_funcs(IWebBrowser2 *wb)
2222 IDispatch *disp;
2223 VARIANT_BOOL b;
2224 int i;
2225 SHANDLE_PTR hwnd;
2226 HRESULT hres;
2227 BSTR sName;
2229 /* HWND */
2231 hwnd = 0xdeadbeef;
2232 hres = IWebBrowser2_get_HWND(wb, &hwnd);
2233 ok(hres == E_FAIL, "get_HWND failed: %08x, expected E_FAIL\n", hres);
2234 ok(hwnd == 0, "unexpected hwnd %p\n", (PVOID)hwnd);
2236 /* MenuBar */
2238 hres = IWebBrowser2_get_MenuBar(wb, &b);
2239 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2240 ok(b == VARIANT_TRUE, "b=%x\n", b);
2242 SET_EXPECT(Invoke_ONMENUBAR);
2243 hres = IWebBrowser2_put_MenuBar(wb, (exvb = VARIANT_FALSE));
2244 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2245 CHECK_CALLED(Invoke_ONMENUBAR);
2247 hres = IWebBrowser2_get_MenuBar(wb, &b);
2248 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2249 ok(b == VARIANT_FALSE, "b=%x\n", b);
2251 SET_EXPECT(Invoke_ONMENUBAR);
2252 hres = IWebBrowser2_put_MenuBar(wb, (exvb = 100));
2253 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2254 CHECK_CALLED(Invoke_ONMENUBAR);
2256 hres = IWebBrowser2_get_MenuBar(wb, &b);
2257 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2258 ok(b == VARIANT_TRUE, "b=%x\n", b);
2260 /* AddressBar */
2262 hres = IWebBrowser2_get_AddressBar(wb, &b);
2263 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2264 ok(b == VARIANT_TRUE, "b=%x\n", b);
2266 SET_EXPECT(Invoke_ONADDRESSBAR);
2267 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_FALSE));
2268 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2269 CHECK_CALLED(Invoke_ONADDRESSBAR);
2271 hres = IWebBrowser2_get_AddressBar(wb, &b);
2272 ok(hres == S_OK, "get_MenuBar failed: %08x\n", hres);
2273 ok(b == VARIANT_FALSE, "b=%x\n", b);
2275 SET_EXPECT(Invoke_ONADDRESSBAR);
2276 hres = IWebBrowser2_put_AddressBar(wb, (exvb = 100));
2277 ok(hres == S_OK, "put_AddressBar failed: %08x\n", hres);
2278 CHECK_CALLED(Invoke_ONADDRESSBAR);
2280 hres = IWebBrowser2_get_AddressBar(wb, &b);
2281 ok(hres == S_OK, "get_AddressBar failed: %08x\n", hres);
2282 ok(b == VARIANT_TRUE, "b=%x\n", b);
2284 SET_EXPECT(Invoke_ONADDRESSBAR);
2285 hres = IWebBrowser2_put_AddressBar(wb, (exvb = VARIANT_TRUE));
2286 ok(hres == S_OK, "put_MenuBar failed: %08x\n", hres);
2287 CHECK_CALLED(Invoke_ONADDRESSBAR);
2289 /* StatusBar */
2291 hres = IWebBrowser2_get_StatusBar(wb, &b);
2292 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2293 ok(b == VARIANT_TRUE, "b=%x\n", b);
2295 SET_EXPECT(Invoke_ONSTATUSBAR);
2296 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_TRUE));
2297 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2298 CHECK_CALLED(Invoke_ONSTATUSBAR);
2300 hres = IWebBrowser2_get_StatusBar(wb, &b);
2301 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2302 ok(b == VARIANT_TRUE, "b=%x\n", b);
2304 SET_EXPECT(Invoke_ONSTATUSBAR);
2305 hres = IWebBrowser2_put_StatusBar(wb, (exvb = VARIANT_FALSE));
2306 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2307 CHECK_CALLED(Invoke_ONSTATUSBAR);
2309 hres = IWebBrowser2_get_StatusBar(wb, &b);
2310 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2311 ok(b == VARIANT_FALSE, "b=%x\n", b);
2313 SET_EXPECT(Invoke_ONSTATUSBAR);
2314 hres = IWebBrowser2_put_StatusBar(wb, (exvb = 100));
2315 ok(hres == S_OK, "put_StatusBar failed: %08x\n", hres);
2316 CHECK_CALLED(Invoke_ONSTATUSBAR);
2318 hres = IWebBrowser2_get_StatusBar(wb, &b);
2319 ok(hres == S_OK, "get_StatusBar failed: %08x\n", hres);
2320 ok(b == VARIANT_TRUE, "b=%x\n", b);
2322 /* ToolBar */
2324 hres = IWebBrowser2_get_ToolBar(wb, &i);
2325 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2326 ok(i, "i=%x\n", i);
2328 SET_EXPECT(Invoke_ONTOOLBAR);
2329 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_FALSE));
2330 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2331 CHECK_CALLED(Invoke_ONTOOLBAR);
2333 hres = IWebBrowser2_get_ToolBar(wb, &i);
2334 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2335 ok(i == VARIANT_FALSE, "b=%x\n", i);
2337 SET_EXPECT(Invoke_ONTOOLBAR);
2338 hres = IWebBrowser2_put_ToolBar(wb, (exvb = 100));
2339 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2340 CHECK_CALLED(Invoke_ONTOOLBAR);
2342 hres = IWebBrowser2_get_ToolBar(wb, &i);
2343 ok(hres == S_OK, "get_ToolBar failed: %08x\n", hres);
2344 ok(i, "i=%x\n", i);
2346 SET_EXPECT(Invoke_ONTOOLBAR);
2347 hres = IWebBrowser2_put_ToolBar(wb, (exvb = VARIANT_TRUE));
2348 ok(hres == S_OK, "put_ToolBar failed: %08x\n", hres);
2349 CHECK_CALLED(Invoke_ONTOOLBAR);
2351 /* FullScreen */
2353 hres = IWebBrowser2_get_FullScreen(wb, &b);
2354 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2355 ok(b == VARIANT_FALSE, "b=%x\n", b);
2357 SET_EXPECT(Invoke_ONFULLSCREEN);
2358 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_TRUE));
2359 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2360 CHECK_CALLED(Invoke_ONFULLSCREEN);
2362 hres = IWebBrowser2_get_FullScreen(wb, &b);
2363 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2364 ok(b == VARIANT_TRUE, "b=%x\n", b);
2366 SET_EXPECT(Invoke_ONFULLSCREEN);
2367 hres = IWebBrowser2_put_FullScreen(wb, (exvb = 100));
2368 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2369 CHECK_CALLED(Invoke_ONFULLSCREEN);
2371 hres = IWebBrowser2_get_FullScreen(wb, &b);
2372 ok(hres == S_OK, "get_FullScreen failed: %08x\n", hres);
2373 ok(b == VARIANT_TRUE, "b=%x\n", b);
2375 SET_EXPECT(Invoke_ONFULLSCREEN);
2376 hres = IWebBrowser2_put_FullScreen(wb, (exvb = VARIANT_FALSE));
2377 ok(hres == S_OK, "put_FullScreen failed: %08x\n", hres);
2378 CHECK_CALLED(Invoke_ONFULLSCREEN);
2380 /* TheaterMode */
2382 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2383 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2384 ok(b == VARIANT_FALSE, "b=%x\n", b);
2386 SET_EXPECT(Invoke_ONTHEATERMODE);
2387 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_TRUE));
2388 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2389 CHECK_CALLED(Invoke_ONTHEATERMODE);
2391 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2392 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2393 ok(b == VARIANT_TRUE, "b=%x\n", b);
2395 SET_EXPECT(Invoke_ONTHEATERMODE);
2396 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = 100));
2397 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2398 CHECK_CALLED(Invoke_ONTHEATERMODE);
2400 hres = IWebBrowser2_get_TheaterMode(wb, &b);
2401 ok(hres == S_OK, "get_TheaterMode failed: %08x\n", hres);
2402 ok(b == VARIANT_TRUE, "b=%x\n", b);
2404 SET_EXPECT(Invoke_ONTHEATERMODE);
2405 hres = IWebBrowser2_put_TheaterMode(wb, (exvb = VARIANT_FALSE));
2406 ok(hres == S_OK, "put_TheaterMode failed: %08x\n", hres);
2407 CHECK_CALLED(Invoke_ONTHEATERMODE);
2409 /* Resizable */
2411 b = 0x100;
2412 hres = IWebBrowser2_get_Resizable(wb, &b);
2413 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2414 ok(b == 0x100, "b=%x\n", b);
2416 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2417 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_TRUE));
2418 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2419 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2421 SET_EXPECT(Invoke_WINDOWSETRESIZABLE);
2422 hres = IWebBrowser2_put_Resizable(wb, (exvb = VARIANT_FALSE));
2423 ok(hres == S_OK, "put_Resizable failed: %08x\n", hres);
2424 CHECK_CALLED(Invoke_WINDOWSETRESIZABLE);
2426 hres = IWebBrowser2_get_Resizable(wb, &b);
2427 ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres);
2428 ok(b == 0x100, "b=%x\n", b);
2430 /* Application */
2432 disp = NULL;
2433 hres = IWebBrowser2_get_Application(wb, &disp);
2434 ok(hres == S_OK, "get_Application failed: %08x\n", hres);
2435 ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb);
2436 if(disp)
2437 IDispatch_Release(disp);
2439 hres = IWebBrowser2_get_Application(wb, NULL);
2440 ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres);
2442 /* Name */
2443 hres = IWebBrowser2_get_Name(wb, &sName);
2444 ok(hres == S_OK, "getName failed: %08x, expected S_OK\n", hres);
2445 if (is_lang_english())
2446 ok(!strcmp_wa(sName, "Microsoft Web Browser Control"), "got '%s', expected 'Microsoft Web Browser Control'\n", wine_dbgstr_w(sName));
2447 else /* Non-English cannot be blank. */
2448 ok(sName!=NULL, "get_Name return a NULL string.\n");
2449 SysFreeString(sName);
2451 /* RegisterAsDropTarget */
2452 hres = IWebBrowser2_get_RegisterAsDropTarget(wb, NULL);
2453 ok(hres == E_INVALIDARG, "get_RegisterAsDropTarget returned: %08x\n", hres);
2455 /* Quit */
2457 hres = IWebBrowser2_Quit(wb);
2458 ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres);
2461 static void test_Silent(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2463 VARIANT_BOOL b;
2464 HRESULT hres;
2466 b = 100;
2467 hres = IWebBrowser2_get_Silent(wb, &b);
2468 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2469 ok(b == VARIANT_FALSE, "b=%x\n", b);
2471 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2472 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2474 b = 100;
2475 hres = IWebBrowser2_get_Silent(wb, &b);
2476 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2477 ok(b == VARIANT_TRUE, "b=%x\n", b);
2479 hres = IWebBrowser2_put_Silent(wb, 100);
2480 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2482 b = 100;
2483 hres = IWebBrowser2_get_Silent(wb, &b);
2484 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2485 ok(b == VARIANT_TRUE, "b=%x\n", b);
2487 hres = IWebBrowser2_put_Silent(wb, VARIANT_FALSE);
2488 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2490 b = 100;
2491 hres = IWebBrowser2_get_Silent(wb, &b);
2492 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2493 ok(b == VARIANT_FALSE, "b=%x\n", b);
2495 if(is_clientsite) {
2496 hres = IWebBrowser2_put_Silent(wb, VARIANT_TRUE);
2497 ok(hres == S_OK, "set_Silent failed: %08x\n", hres);
2499 SET_EXPECT(Invoke_AMBIENT_SILENT);
2502 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
2503 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2505 if(is_clientsite)
2506 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2508 b = 100;
2509 hres = IWebBrowser2_get_Silent(wb, &b);
2510 ok(hres == S_OK, "get_Silent failed: %08x\n", hres);
2511 ok(b == VARIANT_FALSE, "b=%x\n", b);
2514 static void test_Offline(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2516 VARIANT_BOOL b;
2517 HRESULT hres;
2519 b = 100;
2520 hres = IWebBrowser2_get_Offline(wb, &b);
2521 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2522 ok(b == VARIANT_FALSE, "b=%x\n", b);
2524 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2525 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2527 b = 100;
2528 hres = IWebBrowser2_get_Offline(wb, &b);
2529 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2530 ok(b == VARIANT_TRUE, "b=%x\n", b);
2532 hres = IWebBrowser2_put_Offline(wb, 100);
2533 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2535 b = 100;
2536 hres = IWebBrowser2_get_Offline(wb, &b);
2537 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2538 ok(b == VARIANT_TRUE, "b=%x\n", b);
2540 hres = IWebBrowser2_put_Offline(wb, VARIANT_FALSE);
2541 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2543 b = 100;
2544 hres = IWebBrowser2_get_Offline(wb, &b);
2545 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2546 ok(b == VARIANT_FALSE, "b=%x\n", b);
2548 if(is_clientsite) {
2549 hres = IWebBrowser2_put_Offline(wb, VARIANT_TRUE);
2550 ok(hres == S_OK, "set_Offline failed: %08x\n", hres);
2552 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2555 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
2556 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2558 if(is_clientsite)
2559 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2561 b = 100;
2562 hres = IWebBrowser2_get_Offline(wb, &b);
2563 ok(hres == S_OK, "get_Offline failed: %08x\n", hres);
2564 ok(b == VARIANT_FALSE, "b=%x\n", b);
2567 static void test_ambient_unknown(IWebBrowser2 *wb, IOleControl *control, BOOL is_clientsite)
2569 HRESULT hres;
2571 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2572 SET_EXPECT(Invoke_AMBIENT_SILENT);
2573 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2574 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2575 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2576 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2578 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_UNKNOWN);
2579 ok(hres == S_OK, "OnAmbientPropertyChange failed %08x\n", hres);
2581 CHECK_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2582 CHECK_EXPECT(Invoke_AMBIENT_SILENT);
2583 CHECK_EXPECT(Invoke_AMBIENT_USERMODE);
2584 CHECK_EXPECT(Invoke_AMBIENT_DLCONTROL);
2585 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2586 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2588 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2589 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
2590 CLEAR_CALLED(Invoke_AMBIENT_USERMODE);
2591 CLEAR_CALLED(Invoke_AMBIENT_DLCONTROL);
2592 CLEAR_CALLED(Invoke_AMBIENT_USERAGENT);
2593 CLEAR_CALLED(Invoke_AMBIENT_PALETTE);
2596 static void test_wb_funcs(IWebBrowser2 *wb, BOOL is_clientsite)
2598 IOleControl *control;
2599 HRESULT hres;
2601 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleControl, (void**)&control);
2602 ok(hres == S_OK, "Could not get IOleControl interface: %08x\n", hres);
2604 test_Silent(wb, control, is_clientsite);
2605 test_Offline(wb, control, is_clientsite);
2606 test_ambient_unknown(wb, control, is_clientsite);
2608 IOleControl_Release(control);
2611 static void test_GetControlInfo(IWebBrowser2 *unk)
2613 IOleControl *control;
2614 CONTROLINFO info;
2615 HRESULT hres;
2617 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleControl, (void**)&control);
2618 ok(hres == S_OK, "Could not get IOleControl: %08x\n", hres);
2619 if(FAILED(hres))
2620 return;
2622 hres = IOleControl_GetControlInfo(control, &info);
2623 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2624 hres = IOleControl_GetControlInfo(control, NULL);
2625 ok(hres == E_NOTIMPL, "GetControlInfo failed: %08x, expected E_NOTIMPL\n", hres);
2627 IOleControl_Release(control);
2630 static void test_Extent(IWebBrowser2 *unk)
2632 IOleObject *oleobj;
2633 SIZE size, expected;
2634 HRESULT hres;
2635 DWORD dpi_x;
2636 DWORD dpi_y;
2637 HDC hdc;
2639 /* default aspect ratio is 96dpi / 96dpi */
2640 hdc = GetDC(0);
2641 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2642 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2643 ReleaseDC(0, hdc);
2644 if (dpi_x != 96 || dpi_y != 96)
2645 trace("dpi: %d / %d\n", dpi_y, dpi_y);
2647 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
2648 ok(hres == S_OK, "Could not get IOleObkect: %08x\n", hres);
2649 if(FAILED(hres))
2650 return;
2652 size.cx = size.cy = 0xdeadbeef;
2653 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2654 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2655 /* Default size is 50x20 pixels, in himetric units */
2656 expected.cx = MulDiv( 50, 2540, dpi_x );
2657 expected.cy = MulDiv( 20, 2540, dpi_y );
2658 ok(size.cx == expected.cx && size.cy == expected.cy, "size = {%d %d} (expected %d %d)\n",
2659 size.cx, size.cy, expected.cx, expected.cy );
2661 size.cx = 800;
2662 size.cy = 700;
2663 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &size);
2664 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2666 size.cx = size.cy = 0xdeadbeef;
2667 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2668 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2669 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2671 size.cx = size.cy = 0xdeadbeef;
2672 hres = IOleObject_GetExtent(oleobj, 0, &size);
2673 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2674 ok(size.cx == 800 && size.cy == 700, "size = {%d %d}\n", size.cx, size.cy);
2676 size.cx = 900;
2677 size.cy = 800;
2678 hres = IOleObject_SetExtent(oleobj, 0, &size);
2679 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2681 size.cx = size.cy = 0xdeadbeef;
2682 hres = IOleObject_GetExtent(oleobj, 0, &size);
2683 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2684 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2686 size.cx = size.cy = 0xdeadbeef;
2687 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2688 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2689 ok(size.cx == 900 && size.cy == 800, "size = {%d %d}\n", size.cx, size.cy);
2691 size.cx = 1000;
2692 size.cy = 900;
2693 hres = IOleObject_SetExtent(oleobj, 0xdeadbeef, &size);
2694 ok(hres == S_OK, "SetExtent failed: %08x\n", hres);
2696 size.cx = size.cy = 0xdeadbeef;
2697 hres = IOleObject_GetExtent(oleobj, 0xdeadbeef, &size);
2698 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2699 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2701 size.cx = size.cy = 0xdeadbeef;
2702 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &size);
2703 ok(hres == S_OK, "GetExtent failed: %08x\n", hres);
2704 ok(size.cx == 1000 && size.cy == 900, "size = {%d %d}\n", size.cx, size.cy);
2706 IOleObject_Release(oleobj);
2709 static void test_ConnectionPoint(IWebBrowser2 *unk, BOOL init)
2711 IConnectionPointContainer *container;
2712 IConnectionPoint *point;
2713 HRESULT hres;
2715 static DWORD dw = 100;
2717 hres = IWebBrowser2_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2718 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2719 if(FAILED(hres))
2720 return;
2722 hres = IConnectionPointContainer_FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point);
2723 IConnectionPointContainer_Release(container);
2724 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2725 if(FAILED(hres))
2726 return;
2728 if(init) {
2729 hres = IConnectionPoint_Advise(point, (IUnknown*)&WebBrowserEvents2, &dw);
2730 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2731 ok(dw == 1, "dw=%d, expected 1\n", dw);
2732 }else {
2733 hres = IConnectionPoint_Unadvise(point, dw);
2734 ok(hres == S_OK, "Unadvise failed: %08x\n", hres);
2737 IConnectionPoint_Release(point);
2740 static void test_Navigate2(IWebBrowser2 *webbrowser, const char *nav_url)
2742 VARIANT url;
2743 BOOL is_file;
2744 HRESULT hres;
2746 test_LocationURL(webbrowser, is_first_load ? "" : current_url);
2747 test_ready_state(is_first_load ? READYSTATE_UNINITIALIZED : READYSTATE_COMPLETE);
2749 is_http = !memcmp(nav_url, "http:", 5);
2750 V_VT(&url) = VT_BSTR;
2751 V_BSTR(&url) = a2bstr(current_url = nav_url);
2753 if((is_file = !strncasecmp(nav_url, "file://", 7)))
2754 current_url = nav_url + 7;
2756 if(is_first_load) {
2757 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2758 SET_EXPECT(Invoke_PROPERTYCHANGE);
2759 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2760 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2761 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2762 SET_EXPECT(EnableModeless_FALSE);
2763 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2764 SET_EXPECT(SetStatusText);
2765 if(use_container_dochostui)
2766 SET_EXPECT(GetHostInfo);
2767 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2768 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2769 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2770 if(use_container_dochostui) {
2771 SET_EXPECT(GetOptionKeyPath);
2772 SET_EXPECT(GetOverridesKeyPath);
2774 if (use_container_olecmd) {
2775 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2776 SET_EXPECT(Exec_SETPROGRESSMAX);
2777 SET_EXPECT(Exec_SETPROGRESSPOS);
2779 SET_EXPECT(Invoke_SETSECURELOCKICON);
2780 SET_EXPECT(Invoke_FILEDOWNLOAD);
2781 if (use_container_olecmd) SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2782 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2783 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2784 SET_EXPECT(EnableModeless_TRUE);
2785 if (!use_container_olecmd) SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2786 if (is_file) SET_EXPECT(Invoke_PROGRESSCHANGE);
2789 hres = IWebBrowser2_Navigate2(webbrowser, &url, NULL, NULL, NULL, NULL);
2790 ok(hres == S_OK, "Navigate2 failed: %08x\n", hres);
2792 if(is_first_load) {
2793 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2794 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2795 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
2796 CHECK_CALLED(Invoke_DOWNLOADBEGIN);
2797 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2798 CHECK_CALLED(EnableModeless_FALSE);
2799 CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
2800 CHECK_CALLED(SetStatusText);
2801 if(use_container_dochostui)
2802 CHECK_CALLED(GetHostInfo);
2803 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2804 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2805 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* Not called by IE9 */
2806 if(use_container_dochostui) {
2807 CLEAR_CALLED(GetOptionKeyPath);
2808 CHECK_CALLED(GetOverridesKeyPath);
2810 if (use_container_olecmd) {
2811 todo_wine CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2812 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
2813 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
2815 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
2816 todo_wine CHECK_CALLED(Invoke_FILEDOWNLOAD);
2817 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2818 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2819 if (use_container_olecmd) todo_wine CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2820 CHECK_CALLED(EnableModeless_TRUE);
2821 if (!use_container_olecmd) CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
2822 if (is_file) todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
2825 VariantClear(&url);
2827 test_ready_state(READYSTATE_LOADING);
2830 static void test_QueryStatusWB(IWebBrowser2 *webbrowser, BOOL has_document)
2832 HRESULT hres, success_state;
2833 OLECMDF success_flags;
2834 enum OLECMDF status;
2837 * We can tell the difference between the custom container target and the built-in target
2838 * since the custom target returns OLECMDF_SUPPORTED instead of OLECMDF_ENABLED.
2840 if (use_container_olecmd)
2841 success_flags = OLECMDF_SUPPORTED;
2842 else
2843 success_flags = OLECMDF_ENABLED;
2845 /* When no target is available (no document or custom target) an error is returned */
2846 if (has_document)
2847 success_state = S_OK;
2848 else
2849 success_state = E_UNEXPECTED;
2852 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2853 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2854 * is enabled and IDM_STOP is not.
2856 status = 0xdeadbeef;
2857 if (use_container_olecmd) SET_EXPECT(QueryStatus_STOP);
2858 hres = IWebBrowser2_QueryStatusWB(webbrowser, OLECMDID_STOP, &status);
2859 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2860 todo_wine_if (!use_container_olecmd && has_document)
2861 ok((has_document && status == success_flags) || (!has_document && status == 0xdeadbeef),
2862 "OLECMDID_STOP not enabled/supported: %08x %08x\n", status, success_flags);
2863 status = 0xdeadbeef;
2864 if (use_container_olecmd) SET_EXPECT(QueryStatus_IDM_STOP);
2865 hres = IWebBrowser2_QueryStatusWB(webbrowser, IDM_STOP, &status);
2866 ok(hres == success_state, "QueryStatusWB failed: %08x %08x\n", hres, success_state);
2867 ok((has_document && status == 0) || (!has_document && status == 0xdeadbeef),
2868 "IDM_STOP is enabled/supported: %08x %d\n", status, has_document);
2871 static void test_ExecWB(IWebBrowser2 *webbrowser, BOOL has_document)
2873 HRESULT hres, olecmdid_state, idm_state;
2875 /* When no target is available (no document or custom target) an error is returned */
2876 if (has_document)
2878 olecmdid_state = S_OK;
2879 idm_state = OLECMDERR_E_NOTSUPPORTED;
2881 else
2883 olecmdid_state = E_UNEXPECTED;
2884 idm_state = E_UNEXPECTED;
2888 * Test a safe operation that exists as both a high-numbered MSHTML id and an OLECMDID.
2889 * These tests show that QueryStatusWB uses a NULL pguidCmdGroup, since OLECMDID_STOP
2890 * succeeds (S_OK) and IDM_STOP does not (OLECMDERR_E_NOTSUPPORTED).
2892 if(use_container_olecmd) {
2893 SET_EXPECT(Exec_STOP);
2894 }else if(has_document) {
2895 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2896 SET_EXPECT(SetStatusText);
2898 hres = IWebBrowser2_ExecWB(webbrowser, OLECMDID_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2899 if(!use_container_olecmd && has_document) {
2900 todo_wine ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2901 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
2902 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
2903 }else {
2904 ok(hres == olecmdid_state, "ExecWB failed: %08x %08x\n", hres, olecmdid_state);
2906 if (use_container_olecmd)
2907 SET_EXPECT(Exec_IDM_STOP);
2908 hres = IWebBrowser2_ExecWB(webbrowser, IDM_STOP, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
2909 ok(hres == idm_state, "ExecWB failed: %08x %08x\n", hres, idm_state);
2912 static void test_download(DWORD flags)
2914 BOOL *b = &called_Invoke_DOCUMENTCOMPLETE;
2915 MSG msg;
2917 if(flags & DWL_REFRESH)
2918 b = use_container_olecmd ? &called_Exec_SETDOWNLOADSTATE_0 : &called_Invoke_DOWNLOADCOMPLETE;
2919 else if((flags & DWL_FROM_PUT_HREF) && !use_container_olecmd && 0)
2920 b = &called_Invoke_DOWNLOADCOMPLETE;
2922 is_downloading = TRUE;
2923 dwl_flags = flags;
2925 test_ready_state((flags & (DWL_FROM_PUT_HREF|DWL_FROM_GOBACK|DWL_FROM_GOFORWARD|DWL_REFRESH))
2926 ? READYSTATE_COMPLETE : READYSTATE_LOADING);
2928 if(flags & (DWL_EXPECT_BEFORE_NAVIGATE|(is_http ? DWL_FROM_PUT_HREF : 0)|DWL_FROM_GOFORWARD|DWL_REFRESH))
2929 SET_EXPECT(Invoke_PROPERTYCHANGE);
2931 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
2932 SET_EXPECT(Invoke_BEFORENAVIGATE2);
2933 SET_EXPECT(TranslateUrl);
2935 if(use_container_olecmd) {
2936 SET_EXPECT(Exec_SETPROGRESSMAX);
2937 SET_EXPECT(Exec_SETPROGRESSPOS);
2938 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2939 }else {
2940 SET_EXPECT(Invoke_DOWNLOADBEGIN);
2942 SET_EXPECT(DocHost_EnableModeless_FALSE);
2943 SET_EXPECT(DocHost_EnableModeless_TRUE);
2944 SET_EXPECT(Invoke_SETSECURELOCKICON);
2945 SET_EXPECT(Invoke_SETPHISHINGFILTERSTATUS);
2946 SET_EXPECT(EnableModeless_FALSE);
2948 if(!(flags & DWL_REFRESH)) {
2949 if(flags & (DWL_FROM_GOFORWARD|DWL_BACK_ENABLE))
2950 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
2951 else
2952 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
2953 if(flags & DWL_FROM_GOBACK)
2954 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
2955 else
2956 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
2959 expect_update_commands_enable = 0;
2960 set_update_commands_enable = 0xdead;
2961 SET_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
2963 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
2964 SET_EXPECT(SetStatusText);
2965 SET_EXPECT(EnableModeless_TRUE);
2966 if(!is_first_load)
2967 SET_EXPECT(GetHostInfo);
2968 if(use_container_olecmd)
2969 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2970 else
2971 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
2972 SET_EXPECT(Invoke_TITLECHANGE);
2973 if(!(flags & DWL_REFRESH))
2974 SET_EXPECT(Invoke_NAVIGATECOMPLETE2);
2975 if(is_first_load)
2976 SET_EXPECT(GetDropTarget);
2977 SET_EXPECT(Invoke_PROGRESSCHANGE);
2978 if(!(flags & DWL_REFRESH))
2979 SET_EXPECT(Invoke_DOCUMENTCOMPLETE);
2981 if(flags & DWL_HTTP)
2982 SET_EXPECT(Exec_SETTITLE);
2983 SET_EXPECT(UpdateUI);
2984 if(use_container_olecmd)
2985 SET_EXPECT(Exec_UPDATECOMMANDS);
2986 SET_EXPECT(QueryStatus_STOP);
2987 SET_EXPECT(GetOverridesKeyPath); /* Called randomly on some VMs. */
2989 trace("Downloading...\n");
2990 while(!*b && GetMessageW(&msg, NULL, 0, 0)) {
2991 TranslateMessage(&msg);
2992 DispatchMessageW(&msg);
2995 if(flags & (DWL_EXPECT_BEFORE_NAVIGATE|(is_http ? DWL_FROM_PUT_HREF : 0)))
2996 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
2997 else if(flags & (DWL_FROM_GOFORWARD|DWL_REFRESH))
2998 CLEAR_CALLED(Invoke_PROPERTYCHANGE); /* called by IE11 */
3000 if(flags & DWL_EXPECT_BEFORE_NAVIGATE) {
3001 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3002 CHECK_CALLED(TranslateUrl);
3004 if(use_container_olecmd) {
3005 todo_wine CHECK_CALLED(Exec_SETPROGRESSMAX);
3006 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
3007 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
3008 }else {
3009 SET_EXPECT(Invoke_DOWNLOADBEGIN);
3011 CLEAR_CALLED(DocHost_EnableModeless_FALSE); /* IE 7 */
3012 CLEAR_CALLED(DocHost_EnableModeless_TRUE); /* IE 7 */
3013 todo_wine CHECK_CALLED(Invoke_SETSECURELOCKICON);
3014 CLEAR_CALLED(Invoke_SETPHISHINGFILTERSTATUS); /* IE 7 */
3015 if(is_first_load)
3016 todo_wine CHECK_CALLED(EnableModeless_FALSE);
3017 else
3018 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
3020 if(!(flags & DWL_REFRESH)) {
3021 todo_wine_if(nav_back_todo) {
3022 if(flags & (DWL_FROM_GOFORWARD|DWL_BACK_ENABLE))
3023 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3024 else
3025 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3027 if(flags & DWL_FROM_GOBACK)
3028 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3029 else
3030 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3032 CLEAR_CALLED(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3033 todo_wine CHECK_CALLED(Invoke_STATUSTEXTCHANGE);
3034 todo_wine CHECK_CALLED(SetStatusText);
3035 if(is_first_load)
3036 todo_wine CHECK_CALLED(EnableModeless_TRUE);
3037 else
3038 CLEAR_CALLED(EnableModeless_FALSE); /* IE 8 */
3039 if(!is_first_load)
3040 todo_wine CHECK_CALLED(GetHostInfo);
3041 if(use_container_olecmd)
3042 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
3043 else
3044 CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3045 todo_wine CHECK_CALLED(Invoke_TITLECHANGE);
3046 if(!(flags & DWL_REFRESH))
3047 CHECK_CALLED(Invoke_NAVIGATECOMPLETE2);
3048 if(is_first_load)
3049 todo_wine CHECK_CALLED(GetDropTarget);
3050 if(!(flags & DWL_REFRESH))
3051 CHECK_CALLED(Invoke_DOCUMENTCOMPLETE);
3053 is_downloading = FALSE;
3055 test_ready_state(READYSTATE_COMPLETE);
3057 while(use_container_olecmd && !called_Exec_UPDATECOMMANDS && GetMessageA(&msg, NULL, 0, 0)) {
3058 TranslateMessage(&msg);
3059 DispatchMessageA(&msg);
3062 todo_wine CHECK_CALLED(Invoke_PROGRESSCHANGE);
3063 if(flags & DWL_HTTP)
3064 CLEAR_CALLED(Exec_SETTITLE); /* FIXME: make it more strict */
3065 if(use_container_olecmd)
3066 CHECK_CALLED(UpdateUI);
3067 else
3068 CLEAR_CALLED(UpdateUI);
3069 if(use_container_olecmd)
3070 CHECK_CALLED(Exec_UPDATECOMMANDS);
3071 CLEAR_CALLED(QueryStatus_STOP);
3072 CLEAR_CALLED(GetOverridesKeyPath);
3075 static void test_Refresh(IWebBrowser2 *webbrowser, BOOL use_refresh2)
3077 HRESULT hres;
3079 trace("Refresh...\n");
3081 if(use_container_olecmd)
3082 SET_EXPECT(Exec_DocHostCommandHandler_2300);
3084 if(use_refresh2) {
3085 VARIANT v;
3087 V_VT(&v) = VT_I4;
3088 V_I4(&v) = REFRESH_NORMAL;
3090 hres = IWebBrowser2_Refresh2(webbrowser, &v);
3091 ok(hres == S_OK, "Refresh failed: %08x\n", hres);
3092 }else {
3093 hres = IWebBrowser2_Refresh(webbrowser);
3094 ok(hres == S_OK, "Refresh failed: %08x\n", hres);
3097 if(use_container_olecmd)
3098 CHECK_CALLED(Exec_DocHostCommandHandler_2300);
3100 test_download(DWL_REFRESH);
3103 static void test_olecmd(IWebBrowser2 *unk, BOOL loaded)
3105 IOleCommandTarget *cmdtrg;
3106 OLECMD cmds[3];
3107 HRESULT hres;
3109 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3110 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08x\n", hres);
3111 if(FAILED(hres))
3112 return;
3114 cmds[0].cmdID = OLECMDID_SPELL;
3115 cmds[0].cmdf = 0xdeadbeef;
3116 cmds[1].cmdID = OLECMDID_REFRESH;
3117 cmds[1].cmdf = 0xdeadbeef;
3118 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmds, NULL);
3119 if(loaded) {
3120 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3121 ok(cmds[0].cmdf == OLECMDF_SUPPORTED, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
3122 ok(cmds[1].cmdf == (OLECMDF_ENABLED|OLECMDF_SUPPORTED),
3123 "OLECMDID_REFRESH cmdf = %x\n", cmds[1].cmdf);
3124 }else {
3125 ok(hres == 0x80040104, "QueryStatus failed: %08x\n", hres);
3126 ok(cmds[0].cmdf == 0xdeadbeef, "OLECMDID_SPELL cmdf = %x\n", cmds[0].cmdf);
3127 ok(cmds[1].cmdf == 0xdeadbeef, "OLECMDID_REFRESH cmdf = %x\n", cmds[0].cmdf);
3130 IOleCommandTarget_Release(cmdtrg);
3133 static void test_IServiceProvider(IWebBrowser2 *unk)
3135 IServiceProvider *servprov = (void*)0xdeadbeef;
3136 IUnknown *iface;
3137 HRESULT hres;
3139 hres = IWebBrowser2_QueryInterface(unk, &IID_IServiceProvider, (void**)&servprov);
3140 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
3141 if(FAILED(hres))
3142 return;
3144 hres = IServiceProvider_QueryService(servprov, &SID_STopLevelBrowser, &IID_IBrowserService2, (LPVOID*)&iface);
3145 ok(hres == E_FAIL, "QueryService returned %08x, expected E_FAIL\n", hres);
3146 ok(!iface, "QueryService returned %p, expected NULL\n", iface);
3147 if(hres == S_OK)
3148 IUnknown_Release(iface);
3150 hres = IServiceProvider_QueryService(servprov, &SID_SHTMLWindow, &IID_IHTMLWindow2, (LPVOID*)&iface);
3151 ok(hres == S_OK, "QueryService returned %08x, expected S_OK\n", hres);
3152 ok(iface != NULL, "QueryService returned NULL\n");
3153 if(hres == S_OK)
3154 IUnknown_Release(iface);
3156 IServiceProvider_Release(servprov);
3159 static void test_put_href(IWebBrowser2 *unk, const char *url)
3161 IHTMLLocation *location;
3162 IHTMLDocument2 *doc;
3163 BSTR str;
3164 HRESULT hres;
3166 trace("put_href(%s)...\n", url);
3168 doc = get_document(unk);
3170 location = NULL;
3171 hres = IHTMLDocument2_get_location(doc, &location);
3172 IHTMLDocument2_Release(doc);
3173 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3174 ok(location != NULL, "location == NULL\n");
3176 is_http = !memcmp(url, "http:", 5);
3178 SET_EXPECT(TranslateUrl);
3179 SET_EXPECT(Invoke_BEFORENAVIGATE2);
3180 if(!is_http)
3181 SET_EXPECT(Invoke_PROPERTYCHANGE);
3183 dwl_flags = DWL_FROM_PUT_HREF;
3185 str = a2bstr(current_url = url);
3186 is_first_load = FALSE;
3187 hres = IHTMLLocation_put_href(location, str);
3189 CHECK_CALLED(TranslateUrl);
3190 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3191 if(!is_http)
3192 todo_wine CHECK_CALLED(Invoke_PROPERTYCHANGE);
3194 IHTMLLocation_Release(location);
3195 SysFreeString(str);
3196 ok(hres == S_OK, "put_href failed: %08x\n", hres);
3198 test_ready_state(READYSTATE_COMPLETE);
3201 static void test_go_back(IWebBrowser2 *wb, const char *back_url, int back_enable, int forward_enable, int forward_todo)
3203 HRESULT hres;
3205 current_url = back_url;
3207 SET_EXPECT(Invoke_BEFORENAVIGATE2);
3209 if(back_enable)
3210 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3211 else
3212 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3214 if(forward_enable)
3215 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3216 else
3217 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3219 nav_forward_todo = forward_todo;
3220 SET_EXPECT(Invoke_PROPERTYCHANGE);
3221 hres = IWebBrowser2_GoBack(wb);
3222 ok(hres == S_OK, "GoBack failed: %08x\n", hres);
3223 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3224 nav_forward_todo = FALSE;
3226 todo_wine_if(nav_back_todo) {
3227 if(back_enable)
3228 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3229 else
3230 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3233 todo_wine_if(forward_todo) {
3234 if(forward_enable)
3235 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3236 else
3237 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3240 CLEAR_CALLED(Invoke_PROPERTYCHANGE); /* called by IE11 */
3243 static void test_go_forward(IWebBrowser2 *wb, const char *forward_url, int back_enable, int forward_enable)
3245 HRESULT hres;
3247 current_url = forward_url;
3248 dwl_flags |= DWL_FROM_GOFORWARD;
3250 SET_EXPECT(Invoke_BEFORENAVIGATE2);
3252 if(back_enable)
3253 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3254 else
3255 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3257 if(forward_enable)
3258 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3259 else
3260 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3262 hres = IWebBrowser2_GoForward(wb);
3263 ok(hres == S_OK, "GoForward failed: %08x\n", hres);
3264 CHECK_CALLED(Invoke_BEFORENAVIGATE2);
3266 if(back_enable)
3267 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_TRUE);
3268 else
3269 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3271 if(forward_enable)
3272 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_TRUE);
3273 else
3274 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3277 static void test_QueryInterface(IWebBrowser2 *wb)
3279 IQuickActivate *qa = (IQuickActivate*)0xdeadbeef;
3280 IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef;
3281 IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef;
3282 IOleInPlaceSite *inplace = (void*)0xdeadbeef;
3283 IOleCache *cache = (void*)0xdeadbeef;
3284 IObjectWithSite *site = (void*)0xdeadbeef;
3285 IViewObjectEx *viewex = (void*)0xdeadbeef;
3286 IOleLink *link = (void*)0xdeadbeef;
3287 IMarshal *marshal = (void*)0xdeadbeef;
3288 IUnknown *unk = (IUnknown*)wb;
3289 HRESULT hres;
3291 hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa);
3292 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3293 ok(qa == NULL, "qa=%p, expected NULL\n", qa);
3295 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable);
3296 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3297 ok(runnable == NULL, "runnable=%p, expected NULL\n", runnable);
3299 hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse);
3300 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3301 ok(propbrowse == NULL, "propbrowse=%p, expected NULL\n", propbrowse);
3303 hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache);
3304 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3305 ok(cache == NULL, "cache=%p, expected NULL\n", cache);
3307 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceSite, (void**)&inplace);
3308 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3309 ok(inplace == NULL, "inplace=%p, expected NULL\n", inplace);
3311 hres = IUnknown_QueryInterface(unk, &IID_IObjectWithSite, (void**)&site);
3312 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3313 ok(site == NULL, "site=%p, expected NULL\n", site);
3315 hres = IUnknown_QueryInterface(unk, &IID_IViewObjectEx, (void**)&viewex);
3316 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3317 ok(viewex == NULL, "viewex=%p, expected NULL\n", viewex);
3319 hres = IUnknown_QueryInterface(unk, &IID_IOleLink, (void**)&link);
3320 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3321 ok(link == NULL, "link=%p, expected NULL\n", link);
3323 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&marshal);
3324 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3325 ok(marshal == NULL, "marshal=%p, expected NULL\n", marshal);
3329 static void test_UIActivate(IWebBrowser2 *unk, BOOL activate)
3331 IOleDocumentView *docview;
3332 IHTMLDocument2 *doc;
3333 HRESULT hres;
3335 doc = get_document(unk);
3337 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleDocumentView, (void**)&docview);
3338 ok(hres == S_OK, "Got 0x%08x\n", hres);
3339 if(SUCCEEDED(hres)) {
3340 if(activate) {
3341 SET_EXPECT(RequestUIActivate);
3342 SET_EXPECT(ShowUI);
3343 SET_EXPECT(HideUI);
3344 SET_EXPECT(OnFocus_FALSE);
3347 hres = IOleDocumentView_UIActivate(docview, activate);
3348 todo_wine_if(activate)
3349 ok(hres == S_OK, "Got 0x%08x\n", hres);
3351 if(activate) {
3352 todo_wine {
3353 CHECK_CALLED(RequestUIActivate);
3354 CHECK_CALLED(ShowUI);
3355 CHECK_CALLED(HideUI);
3356 CHECK_CALLED(OnFocus_FALSE);
3360 IOleDocumentView_Release(docview);
3363 IHTMLDocument2_Release(doc);
3366 static void test_external(IWebBrowser2 *unk)
3368 IDocHostUIHandler2 *dochost;
3369 IOleClientSite *client;
3370 IDispatch *disp;
3371 HRESULT hres;
3373 client = get_dochost(unk);
3375 hres = IOleClientSite_QueryInterface(client, &IID_IDocHostUIHandler2, (void**)&dochost);
3376 ok(hres == S_OK, "Could not get IDocHostUIHandler2 iface: %08x\n", hres);
3377 IOleClientSite_Release(client);
3379 if(use_container_dochostui)
3380 SET_EXPECT(GetExternal);
3381 disp = (void*)0xdeadbeef;
3382 hres = IDocHostUIHandler2_GetExternal(dochost, &disp);
3383 if(use_container_dochostui) {
3384 CHECK_CALLED(GetExternal);
3385 ok(hres == S_FALSE, "GetExternal failed: %08x\n", hres);
3386 ok(!disp, "disp = %p\n", disp);
3387 }else {
3388 IShellUIHelper *uihelper;
3390 ok(hres == S_OK, "GetExternal failed: %08x\n", hres);
3391 ok(disp != NULL, "disp == NULL\n");
3393 hres = IDispatch_QueryInterface(disp, &IID_IShellUIHelper, (void**)&uihelper);
3394 ok(hres == S_OK, "Could not get IShellUIHelper iface: %08x\n", hres);
3395 IShellUIHelper_Release(uihelper);
3396 IDispatch_Release(disp);
3399 IDocHostUIHandler2_Release(dochost);
3402 static void test_htmlwindow_close(IWebBrowser2 *wb)
3404 IHTMLWindow2 *window;
3405 IHTMLDocument2 *doc;
3406 HRESULT hres;
3408 doc = get_document(wb);
3410 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3411 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3412 IHTMLDocument2_Release(doc);
3414 SET_EXPECT(Invoke_WINDOWCLOSING);
3416 hres = IHTMLWindow2_close(window);
3417 ok(hres == S_OK, "close failed: %08x\n", hres);
3419 CHECK_CALLED(Invoke_WINDOWCLOSING);
3421 IHTMLWindow2_Release(window);
3424 static void test_TranslateAccelerator(IWebBrowser2 *unk)
3426 IOleClientSite *doc_clientsite;
3427 IOleInPlaceActiveObject *pao;
3428 HRESULT hres;
3429 DWORD keycode;
3430 MSG msg_a = {
3431 container_hwnd,
3432 0, 0, 0,
3433 GetTickCount(),
3434 {5, 5}
3437 test_Navigate2(unk, "about:blank");
3439 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3440 ok(hres == S_OK, "Got 0x%08x\n", hres);
3441 if(SUCCEEDED(hres)) {
3442 /* One accelerator that should be handled by mshtml */
3443 msg_a.message = WM_KEYDOWN;
3444 msg_a.wParam = VK_F1;
3445 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3446 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3448 /* And one that should not */
3449 msg_a.message = WM_KEYDOWN;
3450 msg_a.wParam = VK_F5;
3451 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3452 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3454 IOleInPlaceActiveObject_Release(pao);
3457 test_UIActivate(unk, TRUE);
3459 /* Test again after UIActivate */
3460 hres = IWebBrowser2_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&pao);
3461 ok(hres == S_OK, "Got 0x%08x\n", hres);
3462 if(SUCCEEDED(hres)) {
3463 /* One accelerator that should be handled by mshtml */
3464 msg_a.message = WM_KEYDOWN;
3465 msg_a.wParam = VK_F1;
3466 SET_EXPECT(DocHost_TranslateAccelerator);
3467 SET_EXPECT(ControlSite_TranslateAccelerator);
3468 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3469 ok(hres == S_FALSE, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3470 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3471 todo_wine CHECK_CALLED(ControlSite_TranslateAccelerator);
3473 /* And one that should not */
3474 msg_a.message = WM_KEYDOWN;
3475 msg_a.wParam = VK_F5;
3476 SET_EXPECT(DocHost_TranslateAccelerator);
3477 hres = IOleInPlaceActiveObject_TranslateAccelerator(pao, &msg_a);
3478 todo_wine ok(hres == S_OK, "Got 0x%08x (%04x::%02lx)\n", hres, msg_a.message, msg_a.wParam);
3479 todo_wine CHECK_CALLED(DocHost_TranslateAccelerator);
3481 IOleInPlaceActiveObject_Release(pao);
3484 doc_clientsite = get_dochost(unk);
3485 if(doc_clientsite) {
3486 IDocHostUIHandler2 *dochost;
3487 IOleControlSite *doc_controlsite;
3488 IUnknown *unk_test;
3490 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleInPlaceFrame, (void**)&unk_test);
3491 ok(hres == E_NOINTERFACE, "Got 0x%08x\n", hres);
3492 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3494 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostShowUI, (void**)&unk_test);
3495 todo_wine ok(hres == S_OK, "Got 0x%08x\n", hres);
3496 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3498 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler, (void**)&unk_test);
3499 ok(hres == S_OK, "Got 0x%08x\n", hres);
3500 if(SUCCEEDED(hres)) IUnknown_Release(unk_test);
3502 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IDocHostUIHandler2, (void**)&dochost);
3503 ok(hres == S_OK, "Got 0x%08x\n", hres);
3504 if(SUCCEEDED(hres)) {
3505 msg_a.message = WM_KEYDOWN;
3506 hr_dochost_TranslateAccelerator = 0xdeadbeef;
3507 for(keycode = 0; keycode <= 0x100; keycode++) {
3508 msg_a.wParam = keycode;
3509 SET_EXPECT(DocHost_TranslateAccelerator);
3510 hres = IDocHostUIHandler2_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3511 ok(hres == 0xdeadbeef, "Got 0x%08x\n", hres);
3512 CHECK_CALLED(DocHost_TranslateAccelerator);
3514 hr_dochost_TranslateAccelerator = E_NOTIMPL;
3516 SET_EXPECT(DocHost_TranslateAccelerator);
3517 hres = IDocHostUIHandler2_TranslateAccelerator(dochost, &msg_a, &CGID_MSHTML, 1234);
3518 ok(hres == E_NOTIMPL, "Got 0x%08x\n", hres);
3519 CHECK_CALLED(DocHost_TranslateAccelerator);
3521 IDocHostUIHandler2_Release(dochost);
3524 hres = IOleClientSite_QueryInterface(doc_clientsite, &IID_IOleControlSite, (void**)&doc_controlsite);
3525 ok(hres == S_OK, "Got 0x%08x\n", hres);
3526 if(SUCCEEDED(hres)) {
3527 msg_a.message = WM_KEYDOWN;
3528 hr_site_TranslateAccelerator = 0xdeadbeef;
3529 for(keycode = 0; keycode < 0x100; keycode++) {
3530 msg_a.wParam = keycode;
3531 SET_EXPECT(ControlSite_TranslateAccelerator);
3532 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3533 if(keycode == 0x9 || keycode == 0x75)
3534 todo_wine ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3535 else
3536 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3538 CHECK_CALLED(ControlSite_TranslateAccelerator);
3540 msg_a.wParam = VK_LEFT;
3541 SET_EXPECT(ControlSite_TranslateAccelerator);
3542 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3543 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3544 CHECK_CALLED(ControlSite_TranslateAccelerator);
3546 hr_site_TranslateAccelerator = S_OK;
3547 SET_EXPECT(ControlSite_TranslateAccelerator);
3548 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3549 ok(hres == S_OK, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3550 CHECK_CALLED(ControlSite_TranslateAccelerator);
3552 hr_site_TranslateAccelerator = E_NOTIMPL;
3553 SET_EXPECT(ControlSite_TranslateAccelerator);
3554 hres = IOleControlSite_TranslateAccelerator(doc_controlsite, &msg_a, 0);
3555 ok(hres == S_FALSE, "Got 0x%08x (keycode: %04x)\n", hres, keycode);
3556 CHECK_CALLED(ControlSite_TranslateAccelerator);
3558 IOleControlSite_Release(doc_controlsite);
3561 IOleClientSite_Release(doc_clientsite);
3564 test_UIActivate(unk, FALSE);
3567 static void test_dochost_qs(IWebBrowser2 *webbrowser)
3569 IOleClientSite *client_site;
3570 IServiceProvider *serv_prov;
3571 IUnknown *service;
3572 HRESULT hres;
3574 client_site = get_dochost(webbrowser);
3575 hres = IOleClientSite_QueryInterface(client_site, &IID_IServiceProvider, (void**)&serv_prov);
3576 IOleClientSite_Release(client_site);
3577 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
3579 hres = IServiceProvider_QueryService(serv_prov, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&service);
3580 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3581 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3582 IUnknown_Release(service);
3584 hres = IServiceProvider_QueryService(serv_prov, &IID_IWebBrowserApp, &IID_IHlinkFrame, (void**)&service);
3585 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3586 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3587 IUnknown_Release(service);
3589 hres = IServiceProvider_QueryService(serv_prov, &IID_ITargetFrame, &IID_ITargetFrame, (void**)&service);
3590 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3591 ok(iface_cmp(service, (IUnknown*)webbrowser), "service != unk\n");
3592 IUnknown_Release(service);
3594 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IShellBrowser, (void**)&service);
3595 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3596 IUnknown_Release(service);
3598 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IBrowserService, (void**)&service);
3599 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3600 IUnknown_Release(service);
3602 hres = IServiceProvider_QueryService(serv_prov, &IID_IShellBrowser, &IID_IDocObjectService, (void**)&service);
3603 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
3604 IUnknown_Release(service);
3606 IServiceProvider_Release(serv_prov);
3609 static void test_Close(IWebBrowser2 *wb, BOOL do_download)
3611 IOleObject *oo;
3612 IOleClientSite *ocs;
3613 HRESULT hres;
3615 hres = IWebBrowser2_QueryInterface(wb, &IID_IOleObject, (void**)&oo);
3616 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
3617 if(hres != S_OK)
3618 return;
3620 test_close = TRUE;
3622 SET_EXPECT(Frame_SetActiveObject);
3623 SET_EXPECT(UIWindow_SetActiveObject);
3624 SET_EXPECT(OnUIDeactivate);
3625 SET_EXPECT(OnFocus_FALSE);
3626 SET_EXPECT(OnInPlaceDeactivate);
3627 SET_EXPECT(Invoke_STATUSTEXTCHANGE);
3628 if(!do_download) {
3629 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3630 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3632 expect_update_commands_enable = 0;
3633 set_update_commands_enable = 0xdead;
3634 SET_EXPECT(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3636 if(use_container_olecmd)
3637 SET_EXPECT(Invoke_DOWNLOADCOMPLETE);
3638 }else {
3639 nav_back_todo = nav_forward_todo = TRUE;
3641 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3642 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3643 CHECK_CALLED(Frame_SetActiveObject);
3644 CHECK_CALLED(UIWindow_SetActiveObject);
3645 CHECK_CALLED(OnUIDeactivate);
3646 CHECK_CALLED(OnFocus_FALSE);
3647 CHECK_CALLED(OnInPlaceDeactivate);
3648 CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */
3649 if(!do_download) {
3650 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3651 CHECK_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3653 todo_wine CHECK_CALLED(Invoke_COMMANDSTATECHANGE_UPDATECOMMANDS);
3654 todo_wine ok(expect_update_commands_enable == set_update_commands_enable,
3655 "got %d\n", set_update_commands_enable);
3657 if(use_container_olecmd)
3658 todo_wine CHECK_CALLED(Invoke_DOWNLOADCOMPLETE);
3659 }else {
3660 nav_back_todo = nav_forward_todo = FALSE;
3663 hres = IOleObject_GetClientSite(oo, &ocs);
3664 ok(hres == S_OK, "hres = %x\n", hres);
3665 ok(!ocs, "ocs != NULL\n");
3667 SET_EXPECT(GetContainer);
3668 SET_EXPECT(Site_GetWindow);
3669 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3670 SET_EXPECT(Invoke_AMBIENT_SILENT);
3671 hres = IOleObject_DoVerb(oo, OLEIVERB_HIDE, NULL, (IOleClientSite*)0xdeadbeef,
3672 0, (HWND)0xdeadbeef, NULL);
3673 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3674 CHECK_CALLED(GetContainer);
3675 CHECK_CALLED(Site_GetWindow);
3676 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3677 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3679 hres = IOleObject_GetClientSite(oo, &ocs);
3680 ok(hres == S_OK, "hres = %x\n", hres);
3681 ok(ocs == &ClientSite, "ocs != &ClientSite\n");
3682 if(ocs)
3683 IOleClientSite_Release(ocs);
3685 SET_EXPECT(OnFocus_FALSE);
3686 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3687 SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3688 hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
3689 ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
3690 todo_wine CHECK_NOT_CALLED(OnFocus_FALSE);
3691 todo_wine CHECK_NOT_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
3692 todo_wine CHECK_NOT_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
3694 test_close = FALSE;
3695 IOleObject_Release(oo);
3698 #define TEST_DOWNLOAD 0x0001
3699 #define TEST_NOOLECMD 0x0002
3700 #define TEST_NODOCHOST 0x0004
3702 static void init_test(IWebBrowser2 *webbrowser, DWORD flags)
3704 wb = webbrowser;
3706 do_download = is_downloading = (flags & TEST_DOWNLOAD) != 0;
3707 is_first_load = TRUE;
3708 dwl_flags = 0;
3709 use_container_olecmd = !(flags & TEST_NOOLECMD);
3710 use_container_dochostui = !(flags & TEST_NODOCHOST);
3713 static void test_WebBrowser(DWORD flags, BOOL do_close)
3715 IWebBrowser2 *webbrowser;
3716 ULONG ref;
3718 webbrowser = create_webbrowser();
3719 if(!webbrowser)
3720 return;
3722 init_test(webbrowser, flags);
3724 test_QueryStatusWB(webbrowser, FALSE);
3725 test_ExecWB(webbrowser, FALSE);
3726 test_QueryInterface(webbrowser);
3727 test_ready_state(READYSTATE_UNINITIALIZED);
3728 test_ClassInfo(webbrowser);
3729 test_EnumVerbs(webbrowser);
3730 test_LocationURL(webbrowser, "");
3731 test_ConnectionPoint(webbrowser, TRUE);
3732 test_ClientSite(webbrowser, &ClientSite, !do_download);
3733 test_Extent(webbrowser);
3734 test_wb_funcs(webbrowser, TRUE);
3735 test_DoVerb(webbrowser);
3736 test_olecmd(webbrowser, FALSE);
3737 test_Navigate2(webbrowser, "about:blank");
3738 test_QueryStatusWB(webbrowser, TRUE);
3740 if(do_download) {
3741 IHTMLDocument2 *doc, *doc2;
3743 test_download(0);
3744 test_olecmd(webbrowser, TRUE);
3745 doc = get_document(webbrowser);
3747 test_put_href(webbrowser, "about:test");
3748 test_download(DWL_FROM_PUT_HREF);
3749 doc2 = get_document(webbrowser);
3750 ok(doc == doc2, "doc != doc2\n");
3751 IHTMLDocument2_Release(doc2);
3753 trace("Navigate2 repeated...\n");
3754 test_Navigate2(webbrowser, "about:blank");
3755 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3756 doc2 = get_document(webbrowser);
3757 ok(doc == doc2, "doc != doc2\n");
3758 IHTMLDocument2_Release(doc2);
3759 IHTMLDocument2_Release(doc);
3761 if(!do_close) {
3762 trace("Navigate2 http URL...\n");
3763 test_ready_state(READYSTATE_COMPLETE);
3764 test_Navigate2(webbrowser, "http://test.winehq.org/tests/hello.html");
3765 nav_back_todo = TRUE;
3766 test_download(DWL_EXPECT_BEFORE_NAVIGATE|DWL_HTTP);
3767 nav_back_todo = FALSE;
3769 test_Refresh(webbrowser, FALSE);
3770 test_Refresh(webbrowser, TRUE);
3772 trace("put_href http URL...\n");
3773 test_put_href(webbrowser, "http://test.winehq.org/tests/winehq_snapshot/");
3774 test_download(DWL_FROM_PUT_HREF|DWL_HTTP|DWL_BACK_ENABLE);
3776 trace("GoBack...\n");
3777 nav_back_todo = TRUE;
3778 test_go_back(webbrowser, "http://test.winehq.org/tests/hello.html", 0, 0, 1);
3779 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3780 nav_back_todo = FALSE;
3782 trace("GoForward...\n");
3783 test_go_forward(webbrowser, "http://test.winehq.org/tests/winehq_snapshot/", -1, 0);
3784 test_download(DWL_FROM_GOFORWARD|DWL_HTTP);
3786 trace("GoBack...\n");
3787 nav_back_todo = TRUE;
3788 test_go_back(webbrowser, "http://test.winehq.org/tests/hello.html", 0, -1, 0);
3789 test_download(DWL_FROM_GOBACK|DWL_HTTP);
3790 nav_back_todo = FALSE;
3792 trace("GoForward...\n");
3793 test_go_forward(webbrowser, "http://test.winehq.org/tests/winehq_snapshot/", -1, 0);
3794 test_download(DWL_FROM_GOFORWARD|DWL_HTTP);
3795 }else {
3796 trace("Navigate2 repeated with the same URL...\n");
3797 test_Navigate2(webbrowser, "about:blank");
3798 test_download(DWL_EXPECT_BEFORE_NAVIGATE);
3801 test_EnumVerbs(webbrowser);
3802 test_TranslateAccelerator(webbrowser);
3804 test_dochost_qs(webbrowser);
3805 }else {
3806 test_ExecWB(webbrowser, TRUE);
3809 test_external(webbrowser);
3810 test_htmlwindow_close(webbrowser);
3812 if(do_close) {
3813 test_Close(webbrowser, do_download);
3814 }else {
3815 test_change_ClientSite(webbrowser);
3816 test_ClientSite(webbrowser, NULL, !do_download);
3818 test_ie_funcs(webbrowser);
3819 test_GetControlInfo(webbrowser);
3820 test_wb_funcs(webbrowser, FALSE);
3821 test_ConnectionPoint(webbrowser, FALSE);
3822 test_IServiceProvider(webbrowser);
3824 ref = IWebBrowser2_Release(webbrowser);
3825 ok(ref == 0 || broken(do_download && !do_close), "ref=%d, expected 0\n", ref);
3828 static void test_WebBrowserV1(void)
3830 IWebBrowser2 *wb;
3831 ULONG ref;
3832 HRESULT hres;
3834 hres = CoCreateInstance(&CLSID_WebBrowser_V1, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3835 &IID_IWebBrowser2, (void**)&wb);
3836 ok(hres == S_OK, "Could not get WebBrowserV1 instance: %08x\n", hres);
3838 init_test(wb, 0);
3839 wb_version = 1;
3841 test_QueryStatusWB(wb, FALSE);
3842 test_ExecWB(wb, FALSE);
3843 test_QueryInterface(wb);
3844 test_ready_state(READYSTATE_UNINITIALIZED);
3845 test_ClassInfo(wb);
3846 test_EnumVerbs(wb);
3848 ref = IWebBrowser2_Release(wb);
3849 ok(ref == 0, "ref=%d, expected 0\n", ref);
3852 static void test_WebBrowser_slim_container(void)
3854 IWebBrowser2 *webbrowser;
3855 ULONG ref;
3857 webbrowser = create_webbrowser();
3858 init_test(webbrowser, TEST_NOOLECMD|TEST_NODOCHOST);
3860 test_ConnectionPoint(webbrowser, TRUE);
3861 test_ClientSite(webbrowser, &ClientSite, TRUE);
3862 test_DoVerb(webbrowser);
3863 test_Navigate2(webbrowser, "about:blank");
3865 /* Tests of interest */
3866 test_QueryStatusWB(webbrowser, TRUE);
3867 test_ExecWB(webbrowser, TRUE);
3868 test_external(webbrowser);
3870 /* Cleanup stage */
3871 test_ClientSite(webbrowser, NULL, TRUE);
3872 test_ConnectionPoint(webbrowser, FALSE);
3874 ref = IWebBrowser2_Release(webbrowser);
3875 ok(ref == 0, "ref=%d, expected 0\n", ref);
3878 static void test_WebBrowser_DoVerb(void)
3880 IWebBrowser2 *webbrowser;
3881 RECT rect;
3882 HWND hwnd;
3883 ULONG ref;
3884 BOOL res;
3886 webbrowser = create_webbrowser();
3887 init_test(webbrowser, 0);
3889 test_ClientSite(webbrowser, &ClientSite, FALSE);
3891 SET_EXPECT(CanInPlaceActivate);
3892 SET_EXPECT(Site_GetWindow);
3893 SET_EXPECT(OnInPlaceActivate);
3894 SET_EXPECT(GetWindowContext);
3895 SET_EXPECT(ShowObject);
3896 SET_EXPECT(GetContainer);
3897 SET_EXPECT(Frame_GetWindow);
3898 call_DoVerb(webbrowser, OLEIVERB_INPLACEACTIVATE);
3899 CHECK_CALLED(CanInPlaceActivate);
3900 CHECK_CALLED(Site_GetWindow);
3901 CHECK_CALLED(OnInPlaceActivate);
3902 CHECK_CALLED(GetWindowContext);
3903 CHECK_CALLED(ShowObject);
3904 CHECK_CALLED(GetContainer);
3905 CHECK_CALLED(Frame_GetWindow);
3907 hwnd = get_hwnd(webbrowser);
3909 memset(&rect, 0xa, sizeof(rect));
3910 res = GetWindowRect(hwnd, &rect);
3911 ok(res, "GetWindowRect failed: %u\n", GetLastError());
3913 SET_EXPECT(OnInPlaceDeactivate);
3914 call_DoVerb(webbrowser, OLEIVERB_HIDE);
3915 CHECK_CALLED(OnInPlaceDeactivate);
3917 test_ClientSite(webbrowser, NULL, FALSE);
3919 ref = IWebBrowser2_Release(webbrowser);
3920 ok(ref == 0, "ref=%d, expected 0\n", ref);
3924 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
3925 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
3926 static BOOL is_ie_hardened(void)
3928 HKEY zone_map;
3929 DWORD ie_harden, type, size;
3931 ie_harden = 0;
3932 if(RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
3933 0, KEY_QUERY_VALUE, &zone_map) == ERROR_SUCCESS) {
3934 size = sizeof(DWORD);
3935 if (RegQueryValueExA(zone_map, "IEHarden", NULL, &type, (LPBYTE) &ie_harden, &size) != ERROR_SUCCESS ||
3936 type != REG_DWORD) {
3937 ie_harden = 0;
3939 RegCloseKey(zone_map);
3942 return ie_harden != 0;
3945 static void test_FileProtocol(void)
3947 IWebBrowser2 *webbrowser;
3948 HANDLE file;
3949 ULONG ref;
3950 char file_path[MAX_PATH];
3951 char file_url[MAX_PATH] = "File://";
3953 static const char test_file[] = "wine_test.html";
3955 GetTempPathA(MAX_PATH, file_path);
3956 strcat(file_path, test_file);
3958 webbrowser = create_webbrowser();
3959 if(!webbrowser)
3960 return;
3962 init_test(webbrowser, 0);
3964 file = CreateFileA(file_path, GENERIC_WRITE, 0, NULL,
3965 CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
3966 if(file == INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_EXISTS){
3967 ok(0, "CreateFile failed\n");
3968 return;
3970 CloseHandle(file);
3972 GetLongPathNameA(file_path, file_path, sizeof(file_path));
3973 strcat(file_url, file_path);
3975 test_ConnectionPoint(webbrowser, TRUE);
3976 test_ClientSite(webbrowser, &ClientSite, TRUE);
3977 test_DoVerb(webbrowser);
3978 test_Navigate2(webbrowser, file_url);
3979 test_ClientSite(webbrowser, NULL, TRUE);
3981 ref = IWebBrowser2_Release(webbrowser);
3982 ok(ref == 0, "ref=%u, expected 0\n", ref);
3984 if(file != INVALID_HANDLE_VALUE)
3985 DeleteFileA(file_path);
3988 static HRESULT WINAPI sink_QueryInterface( IAdviseSink *iface, REFIID riid, void **obj)
3990 if (IsEqualGUID(riid, &IID_IAdviseSink) || IsEqualGUID(riid, &IID_IUnknown)) {
3991 *obj = iface;
3992 return S_OK;
3995 ok(0, "unexpected call QI(%s)\n", wine_dbgstr_guid(riid));
3996 return E_NOINTERFACE;
3999 static ULONG WINAPI sink_AddRef(IAdviseSink *iface)
4001 return 2;
4004 static ULONG WINAPI sink_Release(IAdviseSink *iface)
4006 return 1;
4009 static void WINAPI sink_OnDataChange(IAdviseSink *iface, FORMATETC *format, STGMEDIUM *medium)
4011 trace("%p, %p, %p\n", iface, format, medium);
4014 static void WINAPI sink_OnViewChange(IAdviseSink *iface, DWORD aspect, LONG index)
4016 trace("%p, %08x, %d\n", iface, aspect, index);
4019 static void WINAPI sink_OnRename(IAdviseSink *iface, IMoniker *moniker)
4021 trace("%p, %p\n", iface, moniker);
4024 static void WINAPI sink_OnSave(IAdviseSink *iface)
4026 trace("%p\n", iface);
4029 static void WINAPI sink_OnClose(IAdviseSink *iface)
4031 trace("%p\n", iface);
4034 static const IAdviseSinkVtbl sink_vtbl =
4036 sink_QueryInterface,
4037 sink_AddRef,
4038 sink_Release,
4039 sink_OnDataChange,
4040 sink_OnViewChange,
4041 sink_OnRename,
4042 sink_OnSave,
4043 sink_OnClose
4046 static IAdviseSink test_sink = { &sink_vtbl };
4048 static void test_SetAdvise(void)
4050 HRESULT hr;
4051 IWebBrowser2 *browser;
4052 IViewObject2 *view;
4053 IAdviseSink *sink;
4054 IOleObject *oleobj;
4055 DWORD aspects, flags;
4057 if (!(browser = create_webbrowser())) return;
4058 init_test(browser, 0);
4060 hr = IWebBrowser2_QueryInterface(browser, &IID_IViewObject2, (void **)&view);
4061 ok(hr == S_OK, "got %08x\n", hr);
4062 if (FAILED(hr)) return;
4064 aspects = flags = 0xdeadbeef;
4065 sink = (IAdviseSink *)0xdeadbeef;
4066 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4067 ok(hr == S_OK, "got %08x\n", hr);
4068 ok(!aspects, "got %08x\n", aspects);
4069 ok(!flags, "got %08x\n", aspects);
4070 ok(sink == NULL, "got %p\n", sink);
4072 hr = IViewObject2_SetAdvise(view, DVASPECT_CONTENT, 0, (IAdviseSink *)&test_sink);
4073 ok(hr == S_OK, "got %08x\n", hr);
4075 aspects = flags = 0xdeadbeef;
4076 sink = (IAdviseSink *)0xdeadbeef;
4077 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4078 ok(hr == S_OK, "got %08x\n", hr);
4079 ok(aspects == DVASPECT_CONTENT, "got %08x\n", aspects);
4080 ok(!flags, "got %08x\n", aspects);
4081 ok(sink == &test_sink, "got %p\n", sink);
4083 hr = IWebBrowser2_QueryInterface(browser, &IID_IOleObject, (void **)&oleobj);
4084 ok(hr == S_OK, "got %08x\n", hr);
4086 SET_EXPECT(GetContainer);
4087 SET_EXPECT(Site_GetWindow);
4088 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4089 SET_EXPECT(Invoke_AMBIENT_SILENT);
4090 hr = IOleObject_SetClientSite(oleobj, &ClientSite);
4091 ok(hr == S_OK, "got %08x\n", hr);
4092 CHECK_CALLED(GetContainer);
4093 CHECK_CALLED(Site_GetWindow);
4094 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4095 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4097 sink = (IAdviseSink *)0xdeadbeef;
4098 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4099 ok(hr == S_OK, "got %08x\n", hr);
4100 ok(sink == &test_sink, "got %p\n", sink);
4102 hr = IOleObject_SetClientSite(oleobj, NULL);
4103 ok(hr == S_OK, "got %08x\n", hr);
4105 aspects = flags = 0xdeadbeef;
4106 sink = (IAdviseSink *)0xdeadbeef;
4107 hr = IViewObject2_GetAdvise(view, &aspects, &flags, &sink);
4108 ok(hr == S_OK, "got %08x\n", hr);
4109 ok(sink == &test_sink, "got %p\n", sink);
4111 hr = IViewObject2_SetAdvise(view, 0, 0, NULL);
4112 ok(hr == S_OK, "got %08x\n", hr);
4114 IOleObject_Release(oleobj);
4115 IViewObject2_Release(view);
4116 IWebBrowser2_Release(browser);
4119 START_TEST(webbrowser)
4121 OleInitialize(NULL);
4123 container_hwnd = create_container_window();
4125 trace("Testing WebBrowser (no download)...\n");
4126 test_WebBrowser(0, FALSE);
4127 test_WebBrowser(0, TRUE);
4129 if(!is_ie_hardened()) {
4130 trace("Testing WebBrowser...\n");
4131 test_WebBrowser(TEST_DOWNLOAD, FALSE);
4132 trace("Testing WebBrowser(no olecmd)...\n");
4133 test_WebBrowser(TEST_DOWNLOAD|TEST_NOOLECMD, FALSE);
4134 }else {
4135 win_skip("Skipping http tests in hardened mode\n");
4138 trace("Testing WebBrowser DoVerb\n");
4139 test_WebBrowser_DoVerb();
4140 trace("Testing WebBrowser (with close)...\n");
4141 test_WebBrowser(TEST_DOWNLOAD, TRUE);
4142 trace("Testing WebBrowser w/o container-based olecmd...\n");
4143 test_WebBrowser_slim_container();
4144 trace("Testing WebBrowserV1...\n");
4145 test_WebBrowserV1();
4146 trace("Testing file protocol...\n");
4147 test_FileProtocol();
4148 trace("Testing SetAdvise...\n");
4149 test_SetAdvise();
4151 OleUninitialize();