2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
42 #include "mshtml_test.h"
44 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
45 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
46 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
48 #define DEFINE_EXPECT(func) \
49 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
51 #define SET_EXPECT(func) \
52 expect_ ## func = TRUE
54 #define SET_CALLED(func) \
55 called_ ## func = TRUE
57 #define CHECK_EXPECT2(func) \
59 ok(expect_ ##func, "unexpected call " #func "\n"); \
60 called_ ## func = TRUE; \
63 #define CHECK_EXPECT(func) \
65 CHECK_EXPECT2(func); \
66 expect_ ## func = FALSE; \
69 #define CHECK_CALLED(func) \
71 ok(called_ ## func, "expected " #func "\n"); \
72 expect_ ## func = called_ ## func = FALSE; \
75 static IOleDocumentView *view = NULL;
76 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
78 DEFINE_EXPECT(LockContainer);
79 DEFINE_EXPECT(SetActiveObject);
80 DEFINE_EXPECT(SetActiveObject_null);
81 DEFINE_EXPECT(GetWindow);
82 DEFINE_EXPECT(CanInPlaceActivate);
83 DEFINE_EXPECT(OnInPlaceActivate);
84 DEFINE_EXPECT(OnInPlaceActivateEx);
85 DEFINE_EXPECT(OnUIActivate);
86 DEFINE_EXPECT(GetWindowContext);
87 DEFINE_EXPECT(OnUIDeactivate);
88 DEFINE_EXPECT(OnInPlaceDeactivate);
89 DEFINE_EXPECT(OnInPlaceDeactivateEx);
90 DEFINE_EXPECT(GetContainer);
91 DEFINE_EXPECT(ShowUI);
92 DEFINE_EXPECT(ActivateMe);
93 DEFINE_EXPECT(GetHostInfo);
94 DEFINE_EXPECT(HideUI);
95 DEFINE_EXPECT(GetOptionKeyPath);
96 DEFINE_EXPECT(GetOverrideKeyPath);
97 DEFINE_EXPECT(SetStatusText);
98 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
99 DEFINE_EXPECT(QueryStatus_OPEN);
100 DEFINE_EXPECT(QueryStatus_NEW);
101 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
102 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
103 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
104 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
105 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
106 DEFINE_EXPECT(Exec_ShellDocView_37);
107 DEFINE_EXPECT(Exec_ShellDocView_63);
108 DEFINE_EXPECT(Exec_ShellDocView_67);
109 DEFINE_EXPECT(Exec_ShellDocView_84);
110 DEFINE_EXPECT(Exec_ShellDocView_103);
111 DEFINE_EXPECT(Exec_ShellDocView_105);
112 DEFINE_EXPECT(Exec_ShellDocView_140);
113 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
114 DEFINE_EXPECT(Exec_SETTITLE);
115 DEFINE_EXPECT(Exec_HTTPEQUIV);
116 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
117 DEFINE_EXPECT(Exec_Explorer_69);
118 DEFINE_EXPECT(Exec_DOCCANNAVIGATE);
119 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
120 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
121 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
122 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
123 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
124 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
125 DEFINE_EXPECT(GetDropTarget);
126 DEFINE_EXPECT(UpdateUI);
127 DEFINE_EXPECT(Navigate);
128 DEFINE_EXPECT(OnFrameWindowActivate);
129 DEFINE_EXPECT(OnChanged_READYSTATE);
130 DEFINE_EXPECT(OnChanged_1005);
131 DEFINE_EXPECT(OnChanged_1012);
132 DEFINE_EXPECT(GetDisplayName);
133 DEFINE_EXPECT(BindToStorage);
134 DEFINE_EXPECT(IsSystemMoniker);
135 DEFINE_EXPECT(GetBindResult);
136 DEFINE_EXPECT(GetClassID);
137 DEFINE_EXPECT(Abort);
139 DEFINE_EXPECT(CreateInstance);
140 DEFINE_EXPECT(Start);
141 DEFINE_EXPECT(Terminate);
142 DEFINE_EXPECT(Protocol_Read);
143 DEFINE_EXPECT(LockRequest);
144 DEFINE_EXPECT(UnlockRequest);
145 DEFINE_EXPECT(OnFocus_TRUE);
146 DEFINE_EXPECT(OnFocus_FALSE);
147 DEFINE_EXPECT(RequestUIActivate);
148 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
149 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
150 DEFINE_EXPECT(GetExternal);
151 DEFINE_EXPECT(EnableModeless_TRUE);
152 DEFINE_EXPECT(EnableModeless_FALSE);
153 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
154 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
155 DEFINE_EXPECT(Frame_GetWindow);
156 DEFINE_EXPECT(TranslateUrl);
157 DEFINE_EXPECT(Advise_Close);
158 DEFINE_EXPECT(OnViewChange);
159 DEFINE_EXPECT(EvaluateNewWindow);
161 static IUnknown *doc_unk;
162 static IMoniker *doc_mon;
163 static BOOL expect_LockContainer_fLock;
164 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
165 static BOOL ipsex, ipsw;
166 static BOOL set_clientsite, container_locked, navigated_load;
167 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
168 static BOOL editmode = FALSE, show_failed;
169 static BOOL inplace_deactivated, open_call;
170 static int stream_read, protocol_read;
171 static enum load_state_t {
180 static LPCOLESTR expect_status_text = NULL;
182 static const char html_page[] =
184 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
188 static const char css_data[] = "body {color: red}";
190 static const WCHAR http_urlW[] =
191 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
193 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
194 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
196 #define DOCHOST_DOCCANNAVIGATE 0
198 static HRESULT QueryInterface(REFIID riid, void **ppv);
199 static void test_MSHTML_QueryStatus(IHTMLDocument2*,DWORD);
201 #define test_readyState(u) _test_readyState(__LINE__,u)
202 static void _test_readyState(unsigned,IUnknown*);
204 static const WCHAR wszTimesNewRoman[] =
205 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
206 static const WCHAR wszArial[] =
207 {'A','r','i','a','l',0};
209 static const char *debugstr_guid(REFIID riid)
216 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
217 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
218 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
219 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
224 static int strcmp_wa(LPCWSTR strw, const char *stra)
227 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
228 return lstrcmpA(stra, buf);
231 static const WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
235 const WCHAR *p1 = str, *p2 = sub;
236 while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
237 if (!*p2) return str;
243 static BSTR a2bstr(const char *str)
248 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
249 ret = SysAllocStringLen(NULL, len);
250 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
255 static BOOL is_english(void)
257 return PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
258 && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
261 #define EXPECT_UPDATEUI 1
262 #define EXPECT_SETTITLE 2
264 static void test_timer(DWORD flags)
266 BOOL *b = &called_Exec_SETTITLE;
269 if(flags & EXPECT_UPDATEUI) {
270 SET_EXPECT(UpdateUI);
271 SET_EXPECT(Exec_UPDATECOMMANDS);
272 b = &called_UpdateUI;
274 if(flags & EXPECT_SETTITLE)
275 SET_EXPECT(Exec_SETTITLE);
277 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
278 TranslateMessage(&msg);
279 DispatchMessage(&msg);
282 if(flags & EXPECT_UPDATEUI) {
283 CHECK_CALLED(UpdateUI);
284 CHECK_CALLED(Exec_UPDATECOMMANDS);
286 if(flags & EXPECT_SETTITLE)
287 CHECK_CALLED(Exec_SETTITLE);
290 static IMoniker Moniker;
292 #define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
293 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
296 IPersistMoniker *permon;
297 IMoniker *mon = (void*)0xdeadbeef;
298 BSTR doc_url = (void*)0xdeadbeef;
304 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
305 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
309 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
310 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
312 hres = IHTMLDocument2_get_URL(doc, &doc_url);
313 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
315 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
316 IPersistMoniker_Release(permon);
320 BOOL exb = expect_GetDisplayName;
321 BOOL clb = called_GetDisplayName;
323 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
324 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
327 SET_EXPECT(GetDisplayName);
328 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
329 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
331 CHECK_CALLED(GetDisplayName);
332 expect_GetDisplayName = exb;
333 called_GetDisplayName = clb;
335 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
340 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
342 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
343 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
345 ok(!lstrcmpW(url, exurl), "unexpected url %s\n", wine_dbgstr_w(url));
346 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
350 ok(hres == E_UNEXPECTED,
351 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
352 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
353 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
356 SysFreeString(doc_url);
357 IHTMLDocument_Release(doc);
358 if(mon && mon != (void*)0xdeadbeef)
359 IMoniker_Release(mon);
362 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
364 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
368 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
373 if(IsEqualGUID(&IID_IProxyManager, riid))
374 return E_NOINTERFACE; /* TODO */
375 if(IsEqualGUID(&IID_IDispatchEx, riid))
376 return E_NOINTERFACE; /* TODO */
377 if(IsEqualGUID(&IID_External_unk, riid))
378 return E_NOINTERFACE; /* TODO */
380 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
381 return E_NOINTERFACE;
384 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
389 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
394 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
396 ok(0, "unexpected call\n");
400 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
403 ok(0, "unexpected call\n");
407 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
408 UINT cNames, LCID lcid, DISPID *rgDispId)
410 ok(0, "unexpected call\n");
414 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
415 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
416 EXCEPINFO *pExcepInfo, UINT *puArgErr)
418 ok(0, "unexpected call\n");
422 static const IDispatchVtbl ExternalVtbl = {
423 External_QueryInterface,
426 Dispatch_GetTypeInfoCount,
427 Dispatch_GetTypeInfo,
428 Dispatch_GetIDsOfNames,
432 static IDispatch External = { &ExternalVtbl };
434 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
436 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
442 return E_NOINTERFACE;
445 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
450 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
455 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
456 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
457 DWORD grfPI, HANDLE_PTR dwReserved)
463 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
464 static const WCHAR empty_str = {0};
468 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
469 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
470 ok(!grfPI, "grfPI = %x\n", grfPI);
471 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
473 memset(&bindinfo, 0, sizeof(bindinfo));
474 bindinfo.cbSize = sizeof(bindinfo);
475 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
476 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
477 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
478 "bindf = %x\n", bindf);
480 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
481 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
482 /* TODO: test stgmedData */
483 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
484 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
485 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
486 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
487 ok(bindinfo.dwOptions == 0x80000 ||
488 bindinfo.dwOptions == 0x4080000, /* win2k3 */
489 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
490 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
491 /* TODO: test dwCodePage */
492 /* TODO: test securityAttributes */
493 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
494 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
495 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
497 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
498 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
499 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
501 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
502 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
504 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
506 hres = IInternetProtocolSink_ReportData(pOIProtSink,
507 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
508 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
510 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
511 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
516 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
517 PROTOCOLDATA *pProtocolData)
519 ok(0, "unexpected call\n");
523 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
526 ok(0, "unexpected call\n");
530 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
532 CHECK_EXPECT(Terminate);
536 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
538 ok(0, "unexpected call\n");
542 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
544 ok(0, "unexpected call\n");
548 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
549 ULONG cb, ULONG *pcbRead)
551 CHECK_EXPECT2(Protocol_Read);
553 ok(pv != NULL, "pv == NULL\n");
554 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
555 ok(pcbRead != NULL, "pcbRead == NULL\n");
556 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
561 protocol_read += *pcbRead = sizeof(css_data)-1;
562 memcpy(pv, css_data, sizeof(css_data)-1);
566 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
567 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
569 ok(0, "unexpected call\n");
573 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
575 CHECK_EXPECT(LockRequest);
579 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
581 CHECK_EXPECT(UnlockRequest);
585 static const IInternetProtocolVtbl ProtocolVtbl = {
586 Protocol_QueryInterface,
597 Protocol_LockRequest,
598 Protocol_UnlockRequest
601 static IInternetProtocol Protocol = { &ProtocolVtbl };
603 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
605 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
606 ok(0, "unexpected call\n");
607 return E_NOINTERFACE;
610 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
615 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
620 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
621 REFIID riid, void **ppv)
623 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
624 return E_NOINTERFACE;
626 CHECK_EXPECT(CreateInstance);
627 ok(ppv != NULL, "ppv == NULL\n");
633 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
635 ok(0, "unexpected call\n");
639 static const IClassFactoryVtbl ClassFactoryVtbl = {
640 ClassFactory_QueryInterface,
642 ClassFactory_Release,
643 ClassFactory_CreateInstance,
644 ClassFactory_LockServer
647 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
649 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
651 ok(0, "unexpected call\n");
655 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
660 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
665 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
666 IHlinkBrowseContext *pihlbc)
668 ok(0, "unexpected call\n");
672 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
673 IHlinkBrowseContext **ppihlbc)
675 ok(0, "unexpected call\n");
679 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
680 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
684 CHECK_EXPECT(Navigate);
686 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
687 ok(pbc != NULL, "pbc == NULL\n");
688 ok(pibsc != NULL, "pubsc == NULL\n");
689 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
692 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
693 LPWSTR location = (LPWSTR)0xdeadbeef;
695 IMoniker *mon = NULL;
696 DWORD site_data = 0xdeadbeef;
698 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
700 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
701 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
703 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
704 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
705 ok(location == NULL, "location = %p\n", location);
706 ok(mon != NULL, "mon == NULL\n");
708 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
709 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
710 ok(site == NULL, "site = %p\n, expected NULL\n", site);
711 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
717 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
718 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
720 ok(0, "unexpected call\n");
724 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
725 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
727 ok(0, "unexpected call\n");
731 static const IHlinkFrameVtbl HlinkFrameVtbl = {
732 HlinkFrame_QueryInterface,
735 HlinkFrame_SetBrowseContext,
736 HlinkFrame_GetBrowseContext,
738 HlinkFrame_OnNavigate,
739 HlinkFrame_UpdateHlink
742 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
744 static HRESULT WINAPI NewWindowManager_QueryInterface(INewWindowManager *iface, REFIID riid, void **ppv)
746 ok(0, "unexpected call\n");
747 return E_NOINTERFACE;
750 static ULONG WINAPI NewWindowManager_AddRef(INewWindowManager *iface)
755 static ULONG WINAPI NewWindowManager_Release(INewWindowManager *iface)
760 static HRESULT WINAPI NewWindowManager_EvaluateNewWindow(INewWindowManager *iface, LPCWSTR pszUrl,
761 LPCWSTR pszName, LPCWSTR pszUrlContext, LPCWSTR pszFeatures, BOOL fReplace, DWORD dwFlags,
762 DWORD dwUserActionTime)
764 CHECK_EXPECT(EvaluateNewWindow);
766 ok(!strcmp_wa(pszUrl, "about:blank"), "pszUrl = %s\n", wine_dbgstr_w(pszUrl));
767 ok(!strcmp_wa(pszName, "test"), "pszName = %s\n", wine_dbgstr_w(pszName));
768 ok(!strcmp_wa(pszUrlContext, "about:blank"), "pszUrlContext = %s\n", wine_dbgstr_w(pszUrlContext));
769 ok(!pszFeatures, "pszFeatures = %s\n", wine_dbgstr_w(pszFeatures));
770 ok(!fReplace, "fReplace = %x\n", fReplace);
771 ok(dwFlags == NWMF_FIRST, "dwFlags = %x\n", dwFlags);
772 ok(!dwUserActionTime, "dwUserActionime = %d\n", dwUserActionTime);
777 static const INewWindowManagerVtbl NewWindowManagerVtbl = {
778 NewWindowManager_QueryInterface,
779 NewWindowManager_AddRef,
780 NewWindowManager_Release,
781 NewWindowManager_EvaluateNewWindow
784 static INewWindowManager NewWindowManager = { &NewWindowManagerVtbl };
786 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
787 REFIID riid, void**ppv)
789 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
794 ok(0, "unexpected call\n");
795 return E_NOINTERFACE;
798 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
803 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
808 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
811 case DISPID_READYSTATE:
812 CHECK_EXPECT2(OnChanged_READYSTATE);
814 if(!readystate_set_interactive)
815 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
816 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
817 ? OLECMDF_ENABLED : 0));
819 if(readystate_set_loading) {
820 readystate_set_loading = FALSE;
821 load_state = LD_LOADING;
823 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
824 test_readyState(NULL);
827 CHECK_EXPECT(OnChanged_1005);
829 test_readyState(NULL);
830 readystate_set_interactive = (load_state != LD_INTERACTIVE);
833 CHECK_EXPECT(OnChanged_1012);
846 ok(0, "unexpected id %d\n", dispID);
850 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
852 ok(0, "unexpected call\n");
856 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
857 PropertyNotifySink_QueryInterface,
858 PropertyNotifySink_AddRef,
859 PropertyNotifySink_Release,
860 PropertyNotifySink_OnChanged,
861 PropertyNotifySink_OnRequestEdit
864 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
866 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
868 ok(0, "unexpected call\n");
869 return E_NOINTERFACE;
872 static ULONG WINAPI Stream_AddRef(IStream *iface)
877 static ULONG WINAPI Stream_Release(IStream *iface)
882 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
883 ULONG cb, ULONG *pcbRead)
886 ok(pv != NULL, "pv == NULL\n");
887 ok(cb > sizeof(html_page), "cb = %d\n", cb);
888 ok(pcbRead != NULL, "pcbRead == NULL\n");
889 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
894 memcpy(pv, html_page, sizeof(html_page)-1);
895 stream_read += *pcbRead = sizeof(html_page)-1;
899 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
900 ULONG cb, ULONG *pcbWritten)
902 ok(0, "unexpected call\n");
906 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
907 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
909 ok(0, "unexpected call\n");
913 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
915 ok(0, "unexpected call\n");
919 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
920 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
922 ok(0, "unexpected call\n");
926 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
928 ok(0, "unexpected call\n");
932 static HRESULT WINAPI Stream_Revert(IStream *iface)
934 ok(0, "unexpected call\n");
938 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
939 ULARGE_INTEGER cb, DWORD dwLockType)
941 ok(0, "unexpected call\n");
945 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
946 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
948 ok(0, "unexpected call\n");
952 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
955 ok(0, "unexpected call\n");
959 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
961 ok(0, "unexpected call\n");
965 static const IStreamVtbl StreamVtbl = {
966 Stream_QueryInterface,
982 static IStream Stream = { &StreamVtbl };
984 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
986 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
987 return E_NOINTERFACE; /* TODO */
989 if(IsEqualGUID(&IID_IWinInetInfo, riid))
990 return E_NOINTERFACE; /* TODO */
992 ok(0, "unexpected call\n");
993 return E_NOINTERFACE;
996 static ULONG WINAPI Binding_AddRef(IBinding *iface)
1001 static ULONG WINAPI Binding_Release(IBinding *iface)
1006 static HRESULT WINAPI Binding_Abort(IBinding *iface)
1008 CHECK_EXPECT(Abort);
1012 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
1014 ok(0, "unexpected call\n");
1018 static HRESULT WINAPI Binding_Resume(IBinding *iface)
1020 ok(0, "unexpected call\n");
1024 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
1026 ok(0, "unexpected call\n");
1030 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
1032 ok(0, "unexpected call\n");
1036 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
1037 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
1039 CHECK_EXPECT(GetBindResult);
1043 static const IBindingVtbl BindingVtbl = {
1044 Binding_QueryInterface,
1050 Binding_SetPriority,
1051 Binding_GetPriority,
1052 Binding_GetBindResult
1055 static IBinding Binding = { &BindingVtbl };
1057 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
1058 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
1060 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
1064 if(IsEqualGUID(&IID_IMoniker_unk, riid))
1065 return E_NOINTERFACE; /* TODO */
1066 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
1067 return E_NOINTERFACE; /* TODO */
1069 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
1070 return E_NOINTERFACE;
1073 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
1078 static ULONG WINAPI Moniker_Release(IMoniker *iface)
1083 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
1085 CHECK_EXPECT(GetClassID);
1086 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
1090 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
1092 ok(0, "unexpected call\n");
1096 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1098 ok(0, "unexpected call\n");
1102 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1104 ok(0, "unexpected call\n");
1108 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1110 ok(0, "unexpected call\n");
1114 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1115 REFIID riidResult, void **ppvResult)
1117 ok(0, "unexpected call\n");
1121 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1122 REFIID riid, void **ppv)
1124 IBindStatusCallback *callback = NULL;
1125 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1126 STGMEDIUM stgmedium;
1131 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1132 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1134 CHECK_EXPECT(BindToStorage);
1136 load_state = LD_LOADING;
1138 ok(pbc != NULL, "pbc == NULL\n");
1139 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1140 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1141 ok(ppv != NULL, "ppv == NULL\n");
1142 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1144 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1145 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1146 ok(callback != NULL, "callback == NULL\n");
1148 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1149 bindinfo.cbSize = sizeof(bindinfo);
1151 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1152 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1153 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
1154 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
1155 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1156 /* TODO: test stgmedData */
1157 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
1158 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
1159 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1160 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
1161 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
1162 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
1163 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
1164 /* TODO: test dwCodePage */
1165 /* TODO: test securityAttributes */
1166 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1167 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1168 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
1170 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1171 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1173 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1175 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1177 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1178 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1179 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1182 stgmedium.tymed = TYMED_ISTREAM;
1183 U(stgmedium).pstm = &Stream;
1184 stgmedium.pUnkForRelease = (IUnknown*)iface;
1185 hres = IBindStatusCallback_OnDataAvailable(callback,
1186 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1187 sizeof(html_page)-1, &formatetc, &stgmedium);
1188 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1191 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1192 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1193 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1195 SET_EXPECT(GetBindResult);
1196 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1197 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1198 SET_CALLED(GetBindResult); /* IE7 */
1200 IBindStatusCallback_Release(callback);
1205 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1206 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1208 ok(0, "unexpected call\n");
1212 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1213 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1215 ok(0, "unexpected call\n");
1219 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1221 ok(0, "unexpected call\n");
1225 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1227 ok(0, "unexpected call\n");
1231 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1233 ok(0, "unexpected call\n");
1237 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1238 IMoniker *pmkNewlyRunning)
1240 ok(0, "unexpected call\n");
1244 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1245 IMoniker *pmkToLeft, FILETIME *pFileTime)
1247 ok(0, "unexpected call\n");
1251 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1253 ok(0, "unexpected call\n");
1257 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1258 IMoniker **ppmkPrefix)
1260 ok(0, "unexpected call\n");
1264 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1265 IMoniker **pmkRelPath)
1267 ok(0, "unexpected call\n");
1271 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1272 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1274 CHECK_EXPECT2(GetDisplayName);
1276 /* ok(pbc != NULL, "pbc == NULL\n"); */
1277 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1278 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1280 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1281 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1286 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1287 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1289 ok(0, "unexpected call\n");
1293 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1295 CHECK_EXPECT(IsSystemMoniker);
1299 static const IMonikerVtbl MonikerVtbl = {
1300 Moniker_QueryInterface,
1308 Moniker_BindToObject,
1309 Moniker_BindToStorage,
1311 Moniker_ComposeWith,
1316 Moniker_GetTimeOfLastChange,
1318 Moniker_CommonPrefixWith,
1319 Moniker_RelativePathTo,
1320 Moniker_GetDisplayName,
1321 Moniker_ParseDisplayName,
1322 Moniker_IsSystemMoniker
1325 static IMoniker Moniker = { &MonikerVtbl };
1327 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1329 return QueryInterface(riid, ppv);
1332 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1337 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1342 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1343 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1345 ok(0, "unexpected call\n");
1349 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1350 IEnumUnknown **ppenum)
1352 ok(0, "unexpected call\n");
1356 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1358 CHECK_EXPECT(LockContainer);
1359 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1363 static const IOleContainerVtbl OleContainerVtbl = {
1364 OleContainer_QueryInterface,
1365 OleContainer_AddRef,
1366 OleContainer_Release,
1367 OleContainer_ParseDisplayName,
1368 OleContainer_EnumObjects,
1369 OleContainer_LockContainer
1372 static IOleContainer OleContainer = { &OleContainerVtbl };
1374 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1376 return QueryInterface(riid, ppv);
1379 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1384 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1389 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1391 ok(0, "unexpected call\n");
1395 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1398 ok(0, "unexpected call\n");
1402 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1404 CHECK_EXPECT(GetContainer);
1405 ok(ppContainer != NULL, "ppContainer = NULL\n");
1406 *ppContainer = &OleContainer;
1410 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1412 ok(0, "unexpected call\n");
1416 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1418 ok(0, "unexpected call\n");
1422 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1424 ok(0, "unexpected call\n");
1428 static const IOleClientSiteVtbl ClientSiteVtbl = {
1429 ClientSite_QueryInterface,
1432 ClientSite_SaveObject,
1433 ClientSite_GetMoniker,
1434 ClientSite_GetContainer,
1435 ClientSite_ShowObject,
1436 ClientSite_OnShowWindow,
1437 ClientSite_RequestNewObjectLayout
1440 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1442 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1444 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1446 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1447 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1450 return E_NOINTERFACE;
1453 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1458 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1463 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1465 CHECK_EXPECT(Frame_GetWindow);
1469 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1471 ok(0, "unexpected call\n");
1475 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1477 ok(0, "unexpected call\n");
1481 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1482 LPCBORDERWIDTHS pborderwidths)
1484 ok(0, "unexpected call\n");
1488 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1489 LPCBORDERWIDTHS pborderwidths)
1491 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1495 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1496 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1498 static const WCHAR wszHTML_Document[] =
1499 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1501 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1503 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1504 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1505 if(pActiveObject && is_english())
1506 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1509 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1510 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1512 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1516 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1517 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1519 static const WCHAR wszHTML_Document[] =
1520 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1523 CHECK_EXPECT2(SetActiveObject);
1525 if(pActiveObject && is_english())
1526 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1528 CHECK_EXPECT(SetActiveObject_null);
1530 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1531 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1537 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1538 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1540 ok(0, "unexpected call\n");
1544 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1545 HOLEMENU holemenu, HWND hwndActiveObject)
1547 ok(0, "unexpected call\n");
1551 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1553 ok(0, "unexpected call\n");
1557 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1559 CHECK_EXPECT2(SetStatusText);
1560 if(!expect_status_text)
1561 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1565 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1568 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
1570 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
1574 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1576 ok(0, "unexpected call\n");
1580 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1581 InPlaceFrame_QueryInterface,
1582 InPlaceFrame_AddRef,
1583 InPlaceFrame_Release,
1584 InPlaceFrame_GetWindow,
1585 InPlaceFrame_ContextSensitiveHelp,
1586 InPlaceFrame_GetBorder,
1587 InPlaceFrame_RequestBorderSpace,
1588 InPlaceFrame_SetBorderSpace,
1589 InPlaceFrame_SetActiveObject,
1590 InPlaceFrame_InsertMenus,
1591 InPlaceFrame_SetMenu,
1592 InPlaceFrame_RemoveMenus,
1593 InPlaceFrame_SetStatusText,
1594 InPlaceFrame_EnableModeless,
1595 InPlaceFrame_TranslateAccelerator
1598 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1600 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1601 InPlaceFrame_QueryInterface,
1602 InPlaceFrame_AddRef,
1603 InPlaceFrame_Release,
1604 InPlaceFrame_GetWindow,
1605 InPlaceFrame_ContextSensitiveHelp,
1606 InPlaceFrame_GetBorder,
1607 InPlaceFrame_RequestBorderSpace,
1608 InPlaceFrame_SetBorderSpace,
1609 InPlaceUIWindow_SetActiveObject,
1612 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1614 static HRESULT WINAPI InPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
1616 return QueryInterface(riid, ppv);
1619 static ULONG WINAPI InPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
1624 static ULONG WINAPI InPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
1629 static HRESULT WINAPI InPlaceSiteWindowless_GetWindow(
1630 IOleInPlaceSiteWindowless *iface, HWND *phwnd)
1632 IOleClientSite *client_site;
1633 IOleObject *ole_obj;
1636 CHECK_EXPECT2(GetWindow);
1637 ok(phwnd != NULL, "phwnd = NULL\n");
1638 *phwnd = container_hwnd;
1640 hres = IUnknown_QueryInterface(doc_unk, &IID_IOleObject, (void**)&ole_obj);
1641 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
1643 hres = IOleObject_GetClientSite(ole_obj, &client_site);
1644 IOleObject_Release(ole_obj);
1645 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
1646 ok(client_site == &ClientSite, "client_site != ClientSite\n");
1647 IOleClientSite_Release(client_site);
1652 static HRESULT WINAPI InPlaceSiteWindowless_ContextSensitiveHelp(
1653 IOleInPlaceSiteWindowless *iface, BOOL fEnterMode)
1655 ok(0, "unexpected call\n");
1659 static HRESULT WINAPI InPlaceSiteWindowless_CanInPlaceActivate(
1660 IOleInPlaceSiteWindowless *iface)
1662 CHECK_EXPECT(CanInPlaceActivate);
1666 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivate(
1667 IOleInPlaceSiteWindowless *iface)
1669 CHECK_EXPECT(OnInPlaceActivate);
1670 inplace_deactivated = FALSE;
1674 static HRESULT WINAPI InPlaceSiteWindowless_OnUIActivate(
1675 IOleInPlaceSiteWindowless *iface)
1677 CHECK_EXPECT(OnUIActivate);
1681 static HRESULT WINAPI InPlaceSiteWindowless_GetWindowContext(
1682 IOleInPlaceSiteWindowless *iface, IOleInPlaceFrame **ppFrame,
1683 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1684 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1686 static const RECT rect = {0,0,500,500};
1688 CHECK_EXPECT(GetWindowContext);
1690 ok(ppFrame != NULL, "ppFrame = NULL\n");
1692 *ppFrame = &InPlaceFrame;
1693 ok(ppDoc != NULL, "ppDoc = NULL\n");
1695 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1696 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1698 memcpy(lprcPosRect, &rect, sizeof(RECT));
1699 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1701 memcpy(lprcClipRect, &rect, sizeof(RECT));
1702 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1704 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1705 lpFrameInfo->fMDIApp = FALSE;
1706 lpFrameInfo->hwndFrame = container_hwnd;
1707 lpFrameInfo->haccel = NULL;
1708 lpFrameInfo->cAccelEntries = 0;
1714 static HRESULT WINAPI InPlaceSiteWindowless_Scroll(
1715 IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
1717 ok(0, "unexpected call\n");
1721 static HRESULT WINAPI InPlaceSiteWindowless_OnUIDeactivate(
1722 IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
1724 CHECK_EXPECT(OnUIDeactivate);
1725 ok(!fUndoable, "fUndoable = TRUE\n");
1729 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivate(
1730 IOleInPlaceSiteWindowless *iface)
1732 CHECK_EXPECT(OnInPlaceDeactivate);
1733 inplace_deactivated = TRUE;
1737 static HRESULT WINAPI InPlaceSiteWindowless_DiscardUndoState(
1738 IOleInPlaceSiteWindowless *iface)
1740 ok(0, "unexpected call\n");
1744 static HRESULT WINAPI InPlaceSiteWindowless_DeactivateAndUndo(
1745 IOleInPlaceSiteWindowless *iface)
1747 ok(0, "unexpected call\n");
1751 static HRESULT WINAPI InPlaceSiteWindowless_OnPosRectChange(
1752 IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
1754 ok(0, "unexpected call\n");
1758 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivateEx(
1759 IOleInPlaceSiteWindowless *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1761 CHECK_EXPECT(OnInPlaceActivateEx);
1763 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1764 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1765 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1770 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivateEx(
1771 IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
1773 CHECK_EXPECT(OnInPlaceDeactivateEx);
1775 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1780 static HRESULT WINAPI InPlaceSiteWindowless_RequestUIActivate(
1781 IOleInPlaceSiteWindowless *iface)
1783 CHECK_EXPECT2(RequestUIActivate);
1787 static HRESULT WINAPI InPlaceSiteWindowless_CanWindowlessActivate(
1788 IOleInPlaceSiteWindowless *iface)
1790 ok(0, "unexpected call\n");
1794 static HRESULT WINAPI InPlaceSiteWindowless_GetCapture(
1795 IOleInPlaceSiteWindowless *iface)
1797 ok(0, "unexpected call\n");
1801 static HRESULT WINAPI InPlaceSiteWindowless_SetCapture(
1802 IOleInPlaceSiteWindowless *iface, BOOL fCapture)
1804 ok(0, "unexpected call\n");
1808 static HRESULT WINAPI InPlaceSiteWindowless_GetFocus(
1809 IOleInPlaceSiteWindowless *iface)
1811 ok(0, "unexpected call\n");
1815 static HRESULT WINAPI InPlaceSiteWindowless_SetFocus(
1816 IOleInPlaceSiteWindowless *iface, BOOL fFocus)
1818 ok(0, "unexpected call\n");
1822 static HRESULT WINAPI InPlaceSiteWindowless_GetDC(
1823 IOleInPlaceSiteWindowless *iface, LPCRECT pRect,
1824 DWORD grfFlags, HDC *phDC)
1826 ok(0, "unexpected call\n");
1830 static HRESULT WINAPI InPlaceSiteWindowless_ReleaseDC(
1831 IOleInPlaceSiteWindowless *iface, HDC hDC)
1833 ok(0, "unexpected call\n");
1837 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRect(
1838 IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
1840 ok(0, "unexpected call\n");
1844 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRgn(
1845 IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
1847 ok(0, "unexpected call\n");
1851 static HRESULT WINAPI InPlaceSiteWindowless_ScrollRect(
1852 IOleInPlaceSiteWindowless *iface, INT dx, INT dy,
1853 LPCRECT pRectScroll, LPCRECT pRectClip)
1855 ok(0, "unexpected call\n");
1859 static HRESULT WINAPI InPlaceSiteWindowless_AdjustRect(
1860 IOleInPlaceSiteWindowless *iface, LPRECT prc)
1862 ok(0, "unexpected call\n");
1866 static HRESULT WINAPI InPlaceSiteWindowless_OnDefWindowMessage(
1867 IOleInPlaceSiteWindowless *iface, UINT msg,
1868 WPARAM wParam, LPARAM lParam, LRESULT *plResult)
1870 ok(0, "unexpected call\n");
1874 static const IOleInPlaceSiteWindowlessVtbl InPlaceSiteWindowlessVtbl = {
1875 InPlaceSiteWindowless_QueryInterface,
1876 InPlaceSiteWindowless_AddRef,
1877 InPlaceSiteWindowless_Release,
1878 InPlaceSiteWindowless_GetWindow,
1879 InPlaceSiteWindowless_ContextSensitiveHelp,
1880 InPlaceSiteWindowless_CanInPlaceActivate,
1881 InPlaceSiteWindowless_OnInPlaceActivate,
1882 InPlaceSiteWindowless_OnUIActivate,
1883 InPlaceSiteWindowless_GetWindowContext,
1884 InPlaceSiteWindowless_Scroll,
1885 InPlaceSiteWindowless_OnUIDeactivate,
1886 InPlaceSiteWindowless_OnInPlaceDeactivate,
1887 InPlaceSiteWindowless_DiscardUndoState,
1888 InPlaceSiteWindowless_DeactivateAndUndo,
1889 InPlaceSiteWindowless_OnPosRectChange,
1890 InPlaceSiteWindowless_OnInPlaceActivateEx,
1891 InPlaceSiteWindowless_OnInPlaceDeactivateEx,
1892 InPlaceSiteWindowless_RequestUIActivate,
1893 InPlaceSiteWindowless_CanWindowlessActivate,
1894 InPlaceSiteWindowless_GetCapture,
1895 InPlaceSiteWindowless_SetCapture,
1896 InPlaceSiteWindowless_GetFocus,
1897 InPlaceSiteWindowless_SetFocus,
1898 InPlaceSiteWindowless_GetDC,
1899 InPlaceSiteWindowless_ReleaseDC,
1900 InPlaceSiteWindowless_InvalidateRect,
1901 InPlaceSiteWindowless_InvalidateRgn,
1902 InPlaceSiteWindowless_ScrollRect,
1903 InPlaceSiteWindowless_AdjustRect,
1904 InPlaceSiteWindowless_OnDefWindowMessage
1907 static IOleInPlaceSiteWindowless InPlaceSiteWindowless = { &InPlaceSiteWindowlessVtbl };
1909 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1911 return QueryInterface(riid, ppv);
1914 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1919 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1926 CallUIActivate_None,
1927 CallUIActivate_ActivateMe,
1928 CallUIActivate_AfterShow,
1931 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1932 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1934 IOleDocument *document;
1937 CHECK_EXPECT(ActivateMe);
1938 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1940 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1941 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1943 if(SUCCEEDED(hres)) {
1944 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteWindowless, NULL, 0, &view);
1945 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1947 if(SUCCEEDED(hres)) {
1948 IOleInPlaceActiveObject *activeobj = NULL;
1949 IOleInPlaceSite *inplacesite = NULL;
1950 HWND tmp_hwnd = NULL;
1951 static RECT rect = {0,0,400,500};
1953 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1954 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1955 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
1956 inplacesite, &InPlaceSiteWindowless);
1958 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteWindowless);
1959 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1961 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1962 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1963 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
1964 inplacesite, &InPlaceSiteWindowless);
1966 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1967 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1970 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1971 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1972 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1975 if(call_UIActivate == CallUIActivate_ActivateMe) {
1976 SET_EXPECT(CanInPlaceActivate);
1977 SET_EXPECT(GetWindowContext);
1978 SET_EXPECT(GetWindow);
1980 SET_EXPECT(OnInPlaceActivateEx);
1982 SET_EXPECT(OnInPlaceActivate);
1983 SET_EXPECT(SetStatusText);
1984 SET_EXPECT(Exec_SETPROGRESSMAX);
1985 SET_EXPECT(Exec_SETPROGRESSPOS);
1986 SET_EXPECT(OnUIActivate);
1987 SET_EXPECT(SetActiveObject);
1989 expect_status_text = NULL;
1991 hres = IOleDocumentView_UIActivate(view, TRUE);
1992 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1994 CHECK_CALLED(CanInPlaceActivate);
1995 CHECK_CALLED(GetWindowContext);
1996 CHECK_CALLED(GetWindow);
1998 CHECK_CALLED(OnInPlaceActivateEx);
2000 CHECK_CALLED(OnInPlaceActivate);
2001 CHECK_CALLED(SetStatusText);
2002 CHECK_CALLED(Exec_SETPROGRESSMAX);
2003 CHECK_CALLED(Exec_SETPROGRESSPOS);
2004 CHECK_CALLED(OnUIActivate);
2005 CHECK_CALLED(SetActiveObject);
2006 CHECK_CALLED(ShowUI);
2009 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2010 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2011 ok(hwnd != NULL, "hwnd == NULL\n");
2013 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
2016 hres = IOleDocumentView_UIActivate(view, TRUE);
2017 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
2020 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
2021 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2022 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
2026 hres = IOleDocumentView_SetRect(view, &rect);
2027 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
2029 if(call_UIActivate == CallUIActivate_ActivateMe) {
2030 hres = IOleDocumentView_Show(view, TRUE);
2031 ok(hres == S_OK, "Show failed: %08x\n", hres);
2033 SET_EXPECT(CanInPlaceActivate);
2034 SET_EXPECT(GetWindowContext);
2035 SET_EXPECT(GetWindow);
2037 SET_EXPECT(OnInPlaceActivateEx);
2039 SET_EXPECT(OnInPlaceActivate);
2040 SET_EXPECT(SetStatusText);
2041 SET_EXPECT(Exec_SETPROGRESSMAX);
2042 SET_EXPECT(Exec_SETPROGRESSPOS);
2043 SET_EXPECT(OnUIActivate);
2044 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
2046 hres = IOleDocumentView_Show(view, TRUE);
2048 win_skip("Show failed\n");
2050 IOleInPlaceActiveObject_Release(activeobj);
2051 IOleDocument_Release(document);
2055 ok(hres == S_OK, "Show failed: %08x\n", hres);
2057 CHECK_CALLED(CanInPlaceActivate);
2058 CHECK_CALLED(GetWindowContext);
2059 CHECK_CALLED(GetWindow);
2061 CHECK_CALLED(OnInPlaceActivateEx);
2063 CHECK_CALLED(OnInPlaceActivate);
2064 CHECK_CALLED(SetStatusText);
2065 CHECK_CALLED(Exec_SETPROGRESSMAX);
2066 CHECK_CALLED(Exec_SETPROGRESSPOS);
2069 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2070 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2071 ok(hwnd != NULL, "hwnd == NULL\n");
2073 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
2077 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
2080 IOleInPlaceActiveObject_Release(activeobj);
2083 IOleDocument_Release(document);
2089 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
2090 DocumentSite_QueryInterface,
2091 DocumentSite_AddRef,
2092 DocumentSite_Release,
2093 DocumentSite_ActivateMe
2096 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
2098 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
2100 return QueryInterface(riid, ppv);
2103 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
2108 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
2113 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
2115 ok(0, "unexpected call\n");
2119 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
2121 ok(0, "unexpected call\n");
2125 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
2127 ok(0, "unexpected call\n");
2131 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
2132 POINTF *pPtfContainer, DWORD dwFlags)
2134 ok(0, "unexpected call\n");
2138 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
2139 MSG *pMsg, DWORD grfModifiers)
2141 ok(0, "unexpected call\n");
2145 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
2148 CHECK_EXPECT(OnFocus_TRUE);
2150 CHECK_EXPECT2(OnFocus_FALSE);
2154 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
2156 ok(0, "unexpected call\n");
2160 static const IOleControlSiteVtbl OleControlSiteVtbl = {
2161 OleControlSite_QueryInterface,
2162 OleControlSite_AddRef,
2163 OleControlSite_Release,
2164 OleControlSite_OnControlInfoChanged,
2165 OleControlSite_LockInPlaceActive,
2166 OleControlSite_GetExtendedControl,
2167 OleControlSite_TransformCoords,
2168 OleControlSite_TranslateAccelerator,
2169 OleControlSite_OnFocus,
2170 OleControlSite_ShowPropertyFrame
2173 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
2175 static IDocHostUIHandler2 *expect_uihandler_iface;
2177 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2179 return QueryInterface(riid, ppv);
2182 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
2187 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
2192 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
2193 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
2195 ok(0, "unexpected call\n");
2196 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2200 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
2202 CHECK_EXPECT(GetHostInfo);
2203 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2204 ok(pInfo != NULL, "pInfo=NULL\n");
2206 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
2207 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
2208 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
2209 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
2210 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
2211 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
2212 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
2213 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
2218 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
2219 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
2220 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
2222 CHECK_EXPECT(ShowUI);
2223 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2226 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
2228 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
2229 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2230 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
2231 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2232 if (expect_InPlaceUIWindow_SetActiveObject_active)
2233 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2235 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2240 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2242 CHECK_EXPECT(HideUI);
2243 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2247 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2249 CHECK_EXPECT(UpdateUI);
2250 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2254 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2256 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2258 CHECK_EXPECT2(EnableModeless_TRUE);
2260 CHECK_EXPECT2(EnableModeless_FALSE);
2264 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2266 ok(0, "unexpected call\n");
2267 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2271 static BOOL expect_OnFrameWindowActivate_fActivate;
2272 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2274 CHECK_EXPECT2(OnFrameWindowActivate);
2275 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2276 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2280 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2281 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2283 ok(0, "unexpected call\n");
2287 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2288 const GUID *pguidCmdGroup, DWORD nCmdID)
2290 ok(0, "unexpected call\n");
2291 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2295 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2296 LPOLESTR *pchKey, DWORD dw)
2298 CHECK_EXPECT(GetOptionKeyPath);
2299 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2300 ok(pchKey != NULL, "pchKey = NULL\n");
2301 ok(!dw, "dw=%d, expected 0\n", dw);
2303 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2307 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2308 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2310 CHECK_EXPECT(GetDropTarget);
2311 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2316 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2318 CHECK_EXPECT(GetExternal);
2319 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2320 *ppDispatch = &External;
2324 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2325 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2327 CHECK_EXPECT(TranslateUrl);
2328 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2329 ok(!dwTranslate, "dwTranslate = %x\n", dwTranslate);
2330 ok(!strcmp_wa(pchURLIn, "about:blank"), "pchURLIn = %s\n", wine_dbgstr_w(pchURLIn));
2331 ok(ppchURLOut != NULL, "ppchURLOut == NULL\n");
2332 ok(!*ppchURLOut, "*ppchURLOut = %p\n", *ppchURLOut);
2337 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2338 IDataObject **ppPORet)
2340 ok(0, "unexpected call\n");
2341 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2345 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2346 LPOLESTR *pchKey, DWORD dw)
2348 CHECK_EXPECT(GetOverrideKeyPath);
2349 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2350 ok(pchKey != NULL, "pchKey = NULL\n");
2352 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2353 ok(!dw, "dw=%d, xepected 0\n", dw);
2357 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2358 DocHostUIHandler_QueryInterface,
2359 DocHostUIHandler_AddRef,
2360 DocHostUIHandler_Release,
2361 DocHostUIHandler_ShowContextMenu,
2362 DocHostUIHandler_GetHostInfo,
2363 DocHostUIHandler_ShowUI,
2364 DocHostUIHandler_HideUI,
2365 DocHostUIHandler_UpdateUI,
2366 DocHostUIHandler_EnableModeless,
2367 DocHostUIHandler_OnDocWindowActivate,
2368 DocHostUIHandler_OnFrameWindowActivate,
2369 DocHostUIHandler_ResizeBorder,
2370 DocHostUIHandler_TranslateAccelerator,
2371 DocHostUIHandler_GetOptionKeyPath,
2372 DocHostUIHandler_GetDropTarget,
2373 DocHostUIHandler_GetExternal,
2374 DocHostUIHandler_TranslateUrl,
2375 DocHostUIHandler_FilterDataObject,
2376 DocHostUIHandler_GetOverrideKeyPath
2379 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2381 static HRESULT WINAPI CustomDocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2383 if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
2388 if(IsEqualGUID(&IID_IOleCommandTarget, riid))
2389 return E_NOINTERFACE;
2391 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2392 return E_NOINTERFACE; /* TODO */
2394 ok(0, "unexpected call %s\n", debugstr_guid(riid));
2395 return E_NOINTERFACE;
2398 static const IDocHostUIHandler2Vtbl CustomDocHostUIHandlerVtbl = {
2399 CustomDocHostUIHandler_QueryInterface,
2400 DocHostUIHandler_AddRef,
2401 DocHostUIHandler_Release,
2402 DocHostUIHandler_ShowContextMenu,
2403 DocHostUIHandler_GetHostInfo,
2404 DocHostUIHandler_ShowUI,
2405 DocHostUIHandler_HideUI,
2406 DocHostUIHandler_UpdateUI,
2407 DocHostUIHandler_EnableModeless,
2408 DocHostUIHandler_OnDocWindowActivate,
2409 DocHostUIHandler_OnFrameWindowActivate,
2410 DocHostUIHandler_ResizeBorder,
2411 DocHostUIHandler_TranslateAccelerator,
2412 DocHostUIHandler_GetOptionKeyPath,
2413 DocHostUIHandler_GetDropTarget,
2414 DocHostUIHandler_GetExternal,
2415 DocHostUIHandler_TranslateUrl,
2416 DocHostUIHandler_FilterDataObject,
2417 DocHostUIHandler_GetOverrideKeyPath
2420 static IDocHostUIHandler2 CustomDocHostUIHandler = { &CustomDocHostUIHandlerVtbl };
2422 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2423 REFIID riid, void **ppv)
2425 return QueryInterface(riid, ppv);
2428 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2433 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2438 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2439 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2441 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2442 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2443 ok(!pCmdText, "pCmdText != NULL\n");
2445 switch(prgCmds[0].cmdID) {
2446 case OLECMDID_SETPROGRESSTEXT:
2447 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2448 prgCmds[0].cmdf = OLECMDF_ENABLED;
2451 CHECK_EXPECT(QueryStatus_OPEN);
2452 prgCmds[0].cmdf = 0;
2455 CHECK_EXPECT(QueryStatus_NEW);
2456 prgCmds[0].cmdf = 0;
2459 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2465 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2466 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2468 if((!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2469 && (!pguidCmdGroup || !IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup) || nCmdID != 63))
2470 test_readyState(NULL);
2472 if(!pguidCmdGroup) {
2474 case OLECMDID_SETPROGRESSMAX:
2475 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2476 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2477 ok(pvaIn != NULL, "pvaIn == NULL\n");
2479 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2480 if(load_state == LD_NO)
2481 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2483 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2485 case OLECMDID_SETPROGRESSPOS:
2486 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2487 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2488 ok(pvaIn != NULL, "pvaIn == NULL\n");
2490 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2491 if(load_state == LD_NO)
2492 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2494 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2496 case OLECMDID_HTTPEQUIV_DONE:
2497 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2498 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2499 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2500 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2501 readystate_set_loading = FALSE;
2502 readystate_set_interactive = FALSE;
2503 load_state = LD_COMPLETE;
2505 case OLECMDID_SETDOWNLOADSTATE:
2506 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2507 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2508 ok(pvaIn != NULL, "pvaIn == NULL\n");
2509 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2511 switch(V_I4(pvaIn)) {
2513 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2514 load_state = LD_INTERACTIVE;
2517 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2518 readystate_set_interactive = (load_state != LD_INTERACTIVE);
2521 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2525 case OLECMDID_UPDATECOMMANDS:
2526 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2527 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2528 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2529 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2531 case OLECMDID_SETTITLE:
2532 CHECK_EXPECT2(Exec_SETTITLE);
2533 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2534 ok(pvaIn != NULL, "pvaIn == NULL\n");
2535 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2536 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2537 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2539 case OLECMDID_HTTPEQUIV:
2540 CHECK_EXPECT2(Exec_HTTPEQUIV);
2541 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
2542 ok(pvaIn != NULL, "pvaIn == NULL\n");
2543 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2544 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2545 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
2546 test_readyState(NULL);
2548 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
2549 return E_FAIL; /* FIXME */
2551 ok(0, "unexpected command %d\n", nCmdID);
2556 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2557 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2561 CHECK_EXPECT2(Exec_ShellDocView_37);
2563 if(load_from_stream || navigated_load)
2564 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2566 test_GetCurMoniker(doc_unk, doc_mon, NULL);
2568 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2569 ok(pvaIn != NULL, "pvaIn == NULL\n");
2571 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2572 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2577 IHTMLPrivateWindow *priv_window;
2580 CHECK_EXPECT(Exec_ShellDocView_63);
2581 ok(pvaIn != NULL, "pvaIn == NULL\n");
2582 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2583 ok(V_UNKNOWN(pvaIn) != NULL, "VPUNKNOWN(pvaIn) = NULL\n");
2584 ok(pvaOut != NULL, "pvaOut == NULL\n");
2585 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2587 hres = IUnknown_QueryInterface(V_UNKNOWN(pvaIn), &IID_IHTMLPrivateWindow, (void**)&priv_window);
2588 ok(hres == S_OK, "Could not get IHTMLPrivateWindow: %08x\n", hres);
2590 IHTMLPrivateWindow_Release(priv_window);
2592 load_state = LD_LOADING;
2593 return S_OK; /* TODO */
2597 CHECK_EXPECT(Exec_ShellDocView_67);
2598 ok(pvaIn != NULL, "pvaIn == NULL\n");
2599 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2600 ok(!strcmp_wa(V_BSTR(pvaIn), "about:blank"), "V_BSTR(pvaIn) = %s\n", wine_dbgstr_w(V_BSTR(pvaIn)));
2601 ok(pvaOut != NULL, "pvaOut == NULL\n");
2602 ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2603 ok(V_BOOL(pvaOut) == VARIANT_TRUE, "V_BOOL(pvaOut) = %x\n", V_BOOL(pvaOut));
2604 load_state = LD_DOLOAD;
2608 CHECK_EXPECT2(Exec_ShellDocView_84);
2610 ok(pvaIn == NULL, "pvaIn != NULL\n");
2611 ok(pvaOut != NULL, "pvaOut == NULL\n");
2613 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2618 CHECK_EXPECT2(Exec_ShellDocView_103);
2620 ok(pvaIn == NULL, "pvaIn != NULL\n");
2621 ok(pvaOut == NULL, "pvaOut != NULL\n");
2626 CHECK_EXPECT2(Exec_ShellDocView_105);
2628 ok(pvaIn != NULL, "pvaIn == NULL\n");
2629 ok(pvaOut == NULL, "pvaOut != NULL\n");
2634 CHECK_EXPECT2(Exec_ShellDocView_140);
2636 ok(pvaIn == NULL, "pvaIn != NULL\n");
2637 ok(pvaOut == NULL, "pvaOut != NULL\n");
2642 ok(0, "unexpected command %d\n", nCmdID);
2647 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2648 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2651 case IDM_PARSECOMPLETE:
2652 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2653 ok(pvaIn == NULL, "pvaIn != NULL\n");
2654 ok(pvaOut == NULL, "pvaOut != NULL\n");
2657 ok(0, "unexpected command %d\n", nCmdID);
2661 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
2663 case DOCHOST_DOCCANNAVIGATE:
2664 CHECK_EXPECT(Exec_DOCCANNAVIGATE);
2665 ok(pvaIn != NULL, "pvaIn == NULL\n");
2666 ok(pvaOut == NULL, "pvaOut != NULL\n");
2667 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) != VT_UNKNOWN\n");
2668 /* FIXME: test V_UNKNOWN(pvaIn) == window */
2671 return E_FAIL; /* TODO */
2675 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2676 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2680 CHECK_EXPECT2(Exec_Explorer_69);
2681 ok(pvaIn == NULL, "pvaIn != NULL\n");
2682 ok(pvaOut != NULL, "pvaOut == NULL\n");
2685 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2690 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2692 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2693 SET_EXPECT(SetStatusText);
2694 ok(pvaIn == NULL, "pvaIn != NULL\n");
2695 ok(pvaOut == NULL, "pvaOut != NULL\n");
2697 case OLECMDID_SHOWSCRIPTERROR:
2701 ok(0, "unexpected command %d\n", nCmdID);
2706 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2710 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2711 OleCommandTarget_QueryInterface,
2712 OleCommandTarget_AddRef,
2713 OleCommandTarget_Release,
2714 OleCommandTarget_QueryStatus,
2715 OleCommandTarget_Exec
2718 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2720 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2722 return QueryInterface(riid, ppv);
2725 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2726 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2727 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2729 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2730 ok(pDispParams != NULL, "pDispParams == NULL\n");
2731 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2732 ok(puArgErr != NULL, "puArgErr == NULL\n");
2733 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2734 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2735 test_readyState(NULL);
2737 switch(dispIdMember) {
2738 case DISPID_AMBIENT_USERMODE:
2739 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2740 V_VT(pVarResult) = VT_BOOL;
2741 V_BOOL(pVarResult) = VARIANT_TRUE;
2743 case DISPID_AMBIENT_DLCONTROL:
2744 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2746 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2747 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2749 case DISPID_AMBIENT_SILENT:
2750 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2751 V_VT(pVarResult) = VT_BOOL;
2752 V_BOOL(pVarResult) = VARIANT_FALSE;
2754 case DISPID_AMBIENT_USERAGENT:
2755 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2757 case DISPID_AMBIENT_PALETTE:
2758 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2762 ok(0, "unexpected dispid %d\n", dispIdMember);
2766 static IDispatchVtbl DispatchVtbl = {
2767 Dispatch_QueryInterface,
2770 Dispatch_GetTypeInfoCount,
2771 Dispatch_GetTypeInfo,
2772 Dispatch_GetIDsOfNames,
2776 static IDispatch Dispatch = { &DispatchVtbl };
2778 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2779 REFIID riid, void **ppv)
2781 return QueryInterface(riid, ppv);
2784 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2789 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2794 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2795 REFIID riid, void **ppv)
2798 * Services used by HTMLDocument:
2801 * IInternetSecurityManager
2803 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2806 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2807 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2808 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2810 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2811 * IElementBehaviorFactory
2812 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2822 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2823 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2828 if(IsEqualGUID(&SID_SNewWindowManager, guidService)) {
2829 ok(IsEqualGUID(&IID_INewWindowManager, riid), "unexpected riid\n");
2830 *ppv = &NewWindowManager;
2834 return E_NOINTERFACE;
2837 static const IServiceProviderVtbl ServiceProviderVtbl = {
2838 ServiceProvider_QueryInterface,
2839 ServiceProvider_AddRef,
2840 ServiceProvider_Release,
2841 ServiceProvider_QueryService
2844 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2846 static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSinkEx *iface,
2847 REFIID riid, void **ppv)
2849 return QueryInterface(riid, ppv);
2852 static ULONG WINAPI AdviseSink_AddRef(IAdviseSinkEx *iface)
2857 static ULONG WINAPI AdviseSink_Release(IAdviseSinkEx *iface)
2862 static void WINAPI AdviseSink_OnDataChange(IAdviseSinkEx *iface,
2863 FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
2865 ok(0, "unexpected call\n");
2868 static void WINAPI AdviseSink_OnViewChange(IAdviseSinkEx *iface,
2869 DWORD dwAspect, LONG lindex)
2871 ok(0, "unexpected call\n");
2874 static void WINAPI AdviseSink_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
2876 ok(0, "unexpected call\n");
2879 static void WINAPI AdviseSink_OnSave(IAdviseSinkEx *iface)
2881 ok(0, "unexpected call\n");
2884 static void WINAPI AdviseSink_OnClose(IAdviseSinkEx *iface)
2886 ok(0, "unexpected call\n");
2889 static void WINAPI AdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
2891 ok(0, "unexpected call\n");
2894 static void WINAPI ObjectAdviseSink_OnClose(IAdviseSinkEx *iface)
2896 CHECK_EXPECT(Advise_Close);
2899 static const IAdviseSinkExVtbl AdviseSinkVtbl = {
2900 AdviseSink_QueryInterface,
2903 AdviseSink_OnDataChange,
2904 AdviseSink_OnViewChange,
2905 AdviseSink_OnRename,
2907 ObjectAdviseSink_OnClose,
2908 AdviseSinkEx_OnViewStatusChange
2911 static IAdviseSinkEx AdviseSink = { &AdviseSinkVtbl };
2913 static HRESULT WINAPI ViewAdviseSink_QueryInterface(IAdviseSinkEx *iface,
2914 REFIID riid, void **ppv)
2916 if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) {
2921 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2923 return E_NOINTERFACE;
2926 static void WINAPI ViewAdviseSink_OnViewChange(IAdviseSinkEx *iface,
2927 DWORD dwAspect, LONG lindex)
2929 CHECK_EXPECT2(OnViewChange);
2931 ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %d\n", dwAspect);
2932 ok(lindex == -1, "lindex = %d\n", lindex);
2935 static const IAdviseSinkExVtbl ViewAdviseSinkVtbl = {
2936 ViewAdviseSink_QueryInterface,
2939 AdviseSink_OnDataChange,
2940 ViewAdviseSink_OnViewChange,
2941 AdviseSink_OnRename,
2944 AdviseSinkEx_OnViewStatusChange
2947 static IAdviseSinkEx ViewAdviseSink = { &ViewAdviseSinkVtbl };
2949 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2950 DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2951 DEFINE_GUID(IID_IRenMailEditor, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2952 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
2953 DEFINE_GUID(IID_IDocHostUIHandlerPriv, 0xf0d241d1,0x5d0e,0x4e85,0xbc,0xb4,0xfa,0xd7,0xf7,0xc5,0x52,0x8c);
2955 static HRESULT QueryInterface(REFIID riid, void **ppv)
2959 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2961 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2962 *ppv = &DocumentSite;
2963 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2964 *ppv = &DocHostUIHandler;
2965 else if(IsEqualGUID(&IID_IOleContainer, riid))
2966 *ppv = &OleContainer;
2967 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2968 *ppv = &InPlaceSiteWindowless;
2969 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2970 *ppv = &OleCommandTarget;
2971 else if(IsEqualGUID(&IID_IDispatch, riid))
2973 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2974 *ppv = &ServiceProvider;
2975 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2976 *ppv = ipsex ? &InPlaceSiteWindowless : NULL;
2977 else if(IsEqualGUID(&IID_IOleInPlaceSiteWindowless, riid))
2978 *ppv = ipsw ? &InPlaceSiteWindowless : NULL;
2979 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2980 *ppv = &OleControlSite;
2981 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2982 return E_NOINTERFACE; /* TODO */
2983 else if(IsEqualGUID(&IID_IProxyManager, riid))
2984 return E_NOINTERFACE; /* ? */
2985 else if(IsEqualGUID(&IID_unk1, riid))
2986 return E_NOINTERFACE; /* HTMLWindow2 ? */
2987 else if(IsEqualGUID(&IID_IThumbnailView, riid))
2988 return E_NOINTERFACE; /* ? */
2989 else if(IsEqualGUID(&IID_IRenMailEditor, riid))
2990 return E_NOINTERFACE; /* ? */
2991 else if(IsEqualGUID(&IID_unk4, riid))
2992 return E_NOINTERFACE; /* ? */
2993 else if(IsEqualGUID(&IID_IDocHostUIHandlerPriv, riid))
2994 return E_NOINTERFACE; /* ? */
2996 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
3000 return E_NOINTERFACE;
3003 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3005 return DefWindowProc(hwnd, msg, wParam, lParam);
3008 static void test_doscroll(IUnknown *unk)
3010 IHTMLDocument3 *doc;
3011 IHTMLElement2 *elem2;
3016 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument3, (void**)&doc);
3017 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3021 hres = IHTMLDocument3_get_documentElement(doc, &elem);
3022 IHTMLDocument3_Release(doc);
3023 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
3024 switch(load_state) {
3028 ok(!elem, "elem != NULL\n");
3031 case LD_INTERACTIVE:
3033 ok(elem != NULL, "elem == NULL\n");
3038 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
3039 IHTMLElement_Release(elem);
3040 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
3043 V_BSTR(&v) = a2bstr("left");
3044 hres = IHTMLElement2_doScroll(elem2, v);
3045 SysFreeString(V_BSTR(&v));
3046 IHTMLElement2_Release(elem2);
3048 if(inplace_deactivated)
3049 ok(hres == E_PENDING, "doScroll failed: %08x\n", hres);
3050 else if(load_state == LD_COMPLETE)
3051 ok(hres == S_OK, "doScroll failed: %08x\n", hres);
3053 ok(hres == E_PENDING || hres == S_OK, "doScroll failed: %08x\n", hres);
3056 static void _test_readyState(unsigned line, IUnknown *unk)
3058 IHTMLDocument2 *htmldoc;
3059 DISPPARAMS dispparams;
3065 static const LPCSTR expected_state[] = {
3080 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
3081 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
3085 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
3086 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
3088 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
3089 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
3091 if(!strcmp_wa(state, "interactive") && load_state == LD_LOADING)
3092 load_state = LD_INTERACTIVE;
3095 (!strcmp_wa(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
3096 wine_dbgstr_w(state), load_state);
3097 SysFreeString(state);
3099 hres = IHTMLDocument2_get_body(htmldoc, &elem);
3100 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
3102 IHTMLElement2 *elem2;
3105 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
3106 IHTMLElement_Release(elem);
3107 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
3109 hres = IHTMLElement2_get_readyState(elem2, &var);
3110 IHTMLElement2_Release(elem2);
3111 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
3112 ok(V_VT(&var) == VT_BSTR, "V_VT(state) = %d\n", V_VT(&var));
3113 ok(!strcmp_wa(V_BSTR(&var), "complete"), "unexpected body state %s\n", wine_dbgstr_w(V_BSTR(&var)));
3116 ok_(__FILE__,line)(load_state != LD_COMPLETE, "body is NULL in complete state\n");
3119 dispparams.cArgs = 0;
3120 dispparams.cNamedArgs = 0;
3121 dispparams.rgdispidNamedArgs = NULL;
3122 dispparams.rgvarg = NULL;
3126 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
3127 &dispparams, &out, NULL, NULL);
3128 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
3130 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
3131 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
3133 test_doscroll((IUnknown*)htmldoc);
3135 IHTMLDocument2_Release(htmldoc);
3138 static void test_ViewAdviseSink(IHTMLDocument2 *doc)
3143 hres = IHTMLDocument2_QueryInterface(doc, &IID_IViewObject, (void**)&view);
3144 ok(hres == S_OK, "QueryInterface(IID_IViewObject) failed: %08x\n", hres);
3146 hres = IViewObject_SetAdvise(view, DVASPECT_CONTENT, ADVF_PRIMEFIRST, (IAdviseSink*)&ViewAdviseSink);
3147 ok(hres == S_OK, "SetAdvise failed: %08x\n", hres);
3149 IViewObject_Release(view);
3152 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
3154 IConnectionPointContainer *tmp_container = NULL;
3155 IConnectionPoint *cp;
3159 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
3160 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
3164 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
3165 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
3166 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
3168 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
3169 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
3171 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
3172 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
3173 ok(tmp_container == container, "container != tmp_container\n");
3175 IConnectionPointContainer_Release(tmp_container);
3177 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
3178 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
3180 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
3183 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
3184 ok(hres == S_OK, "Advise failed: %08x\n", hres);
3187 IConnectionPoint_Release(cp);
3190 static void test_ConnectionPointContainer(IHTMLDocument2 *doc)
3192 IConnectionPointContainer *container;
3195 hres = IUnknown_QueryInterface(doc, &IID_IConnectionPointContainer, (void**)&container);
3196 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
3200 test_ConnectionPoint(container, &IID_IDispatch);
3201 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
3202 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
3203 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
3205 IConnectionPointContainer_Release(container);
3208 static void set_custom_uihandler(IHTMLDocument2 *doc, IDocHostUIHandler2 *uihandler)
3210 ICustomDoc *custom_doc;
3213 hres = IHTMLDocument2_QueryInterface(doc, &IID_ICustomDoc, (void**)&custom_doc);
3214 ok(hres == S_OK, "Could not get ICustomDoc iface: %08x\n", hres);
3216 expect_uihandler_iface = uihandler;
3218 hres = ICustomDoc_SetUIHandler(custom_doc, (IDocHostUIHandler*)uihandler);
3219 ICustomDoc_Release(custom_doc);
3220 ok(hres == S_OK, "SetUIHandler failed: %08x\n", hres);
3223 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
3227 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
3229 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
3231 test_readyState((IUnknown*)persist);
3235 CreateBindCtx(0, &bind);
3236 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
3237 (IUnknown*)&ClientSite);
3240 SET_EXPECT(GetDisplayName);
3241 if(!set_clientsite) {
3242 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3243 SET_EXPECT(GetHostInfo);
3244 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3245 SET_EXPECT(Invoke_AMBIENT_SILENT);
3246 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3247 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3248 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3249 SET_EXPECT(GetOptionKeyPath);
3250 SET_EXPECT(GetOverrideKeyPath);
3251 SET_EXPECT(GetWindow);
3252 SET_EXPECT(Exec_DOCCANNAVIGATE);
3253 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3254 SET_EXPECT(Exec_SETPROGRESSMAX);
3255 SET_EXPECT(Exec_SETPROGRESSPOS);
3256 SET_EXPECT(Exec_ShellDocView_37);
3258 if(!container_locked) {
3259 SET_EXPECT(GetContainer);
3260 SET_EXPECT(LockContainer);
3262 SET_EXPECT(OnChanged_READYSTATE);
3263 SET_EXPECT(Exec_ShellDocView_84);
3264 SET_EXPECT(IsSystemMoniker);
3266 SET_EXPECT(BindToStorage);
3267 SET_EXPECT(SetActiveObject);
3268 if(set_clientsite) {
3269 SET_EXPECT(Invoke_AMBIENT_SILENT);
3270 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3271 SET_EXPECT(Exec_ShellDocView_37);
3273 load_state = LD_DOLOAD;
3274 expect_LockContainer_fLock = TRUE;
3275 readystate_set_loading = TRUE;
3277 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
3278 ok(hres == S_OK, "Load failed: %08x\n", hres);
3281 CHECK_CALLED(GetDisplayName);
3282 if(!set_clientsite) {
3283 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3284 CHECK_CALLED(GetHostInfo);
3285 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3286 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3287 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3288 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3289 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3290 CHECK_CALLED(GetOptionKeyPath);
3291 CHECK_CALLED(GetOverrideKeyPath);
3292 CHECK_CALLED(GetWindow);
3293 CHECK_CALLED(Exec_DOCCANNAVIGATE);
3294 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3295 CHECK_CALLED(Exec_SETPROGRESSMAX);
3296 CHECK_CALLED(Exec_SETPROGRESSPOS);
3297 CHECK_CALLED(Exec_ShellDocView_37);
3299 if(!container_locked) {
3300 CHECK_CALLED(GetContainer);
3301 CHECK_CALLED(LockContainer);
3302 container_locked = TRUE;
3304 CHECK_CALLED(OnChanged_READYSTATE);
3305 SET_CALLED(IsSystemMoniker); /* IE7 */
3306 SET_CALLED(Exec_ShellDocView_84);
3308 CHECK_CALLED(BindToStorage);
3309 SET_CALLED(SetActiveObject); /* FIXME */
3310 if(set_clientsite) {
3311 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3312 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3313 CHECK_CALLED(Exec_ShellDocView_37);
3316 set_clientsite = container_locked = TRUE;
3318 test_GetCurMoniker((IUnknown*)persist, mon, NULL);
3320 IBindCtx_Release(bind);
3322 test_readyState((IUnknown*)persist);
3325 #define DWL_VERBDONE 0x0001
3326 #define DWL_CSS 0x0002
3327 #define DWL_TRYCSS 0x0004
3328 #define DWL_HTTP 0x0008
3329 #define DWL_EMPTY 0x0010
3331 static void test_download(DWORD flags)
3336 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
3337 ok(hwnd != NULL, "Could not find hidden window\n");
3339 test_readyState(NULL);
3341 if(flags & (DWL_VERBDONE|DWL_HTTP))
3342 SET_EXPECT(Exec_SETPROGRESSMAX);
3343 if((flags & DWL_VERBDONE) && !load_from_stream)
3344 SET_EXPECT(GetHostInfo);
3345 SET_EXPECT(SetStatusText);
3346 if(!(flags & DWL_EMPTY))
3347 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
3348 SET_EXPECT(OnViewChange);
3349 SET_EXPECT(GetDropTarget);
3350 if(flags & DWL_TRYCSS)
3351 SET_EXPECT(Exec_ShellDocView_84);
3352 if(flags & DWL_CSS) {
3353 SET_EXPECT(CreateInstance);
3355 SET_EXPECT(LockRequest);
3356 SET_EXPECT(Terminate);
3357 SET_EXPECT(Protocol_Read);
3358 SET_EXPECT(UnlockRequest);
3360 SET_EXPECT(Exec_Explorer_69);
3361 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
3362 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
3363 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
3364 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
3366 SET_EXPECT(Exec_ShellDocView_37);
3367 if(flags & DWL_HTTP) {
3368 SET_EXPECT(OnChanged_1012);
3369 SET_EXPECT(Exec_HTTPEQUIV);
3370 SET_EXPECT(Exec_SETTITLE);
3372 SET_EXPECT(OnChanged_1005);
3373 SET_EXPECT(OnChanged_READYSTATE);
3374 SET_EXPECT(Exec_SETPROGRESSPOS);
3375 if(!(flags & DWL_EMPTY))
3376 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
3377 SET_EXPECT(Exec_ShellDocView_103);
3378 SET_EXPECT(Exec_ShellDocView_105);
3379 SET_EXPECT(Exec_ShellDocView_140);
3380 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
3381 SET_EXPECT(Exec_HTTPEQUIV_DONE);
3382 SET_EXPECT(SetStatusText);
3383 if(navigated_load) {
3384 SET_EXPECT(UpdateUI);
3385 SET_EXPECT(Exec_UPDATECOMMANDS);
3386 SET_EXPECT(Exec_SETTITLE);
3388 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
3390 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
3391 TranslateMessage(&msg);
3392 DispatchMessage(&msg);
3395 if(flags & DWL_VERBDONE)
3396 CHECK_CALLED(Exec_SETPROGRESSMAX);
3397 if(flags & DWL_HTTP)
3398 SET_CALLED(Exec_SETPROGRESSMAX);
3399 if((flags & DWL_VERBDONE) && !load_from_stream) {
3401 todo_wine CHECK_CALLED(GetHostInfo);
3403 CHECK_CALLED(GetHostInfo);
3405 CHECK_CALLED(SetStatusText);
3406 if(!(flags & DWL_EMPTY))
3407 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
3408 CHECK_CALLED(OnViewChange);
3410 CHECK_CALLED(GetDropTarget);
3412 SET_CALLED(GetDropTarget);
3413 if(flags & DWL_TRYCSS)
3414 SET_CALLED(Exec_ShellDocView_84);
3415 if(flags & DWL_CSS) {
3416 CHECK_CALLED(CreateInstance);
3417 CHECK_CALLED(Start);
3418 CHECK_CALLED(LockRequest);
3419 CHECK_CALLED(Terminate);
3420 CHECK_CALLED(Protocol_Read);
3421 CHECK_CALLED(UnlockRequest);
3423 SET_CALLED(Exec_Explorer_69);
3424 SET_CALLED(EnableModeless_TRUE); /* IE7 */
3425 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
3426 SET_CALLED(EnableModeless_FALSE); /* IE7 */
3427 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
3429 todo_wine CHECK_CALLED(Exec_ShellDocView_37);
3430 if(flags & DWL_HTTP) todo_wine {
3431 CHECK_CALLED(OnChanged_1012);
3432 CHECK_CALLED(Exec_HTTPEQUIV);
3433 CHECK_CALLED(Exec_SETTITLE);
3435 CHECK_CALLED(OnChanged_1005);
3436 CHECK_CALLED(OnChanged_READYSTATE);
3437 CHECK_CALLED(Exec_SETPROGRESSPOS);
3438 if(!(flags & DWL_EMPTY))
3439 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
3440 SET_CALLED(Exec_ShellDocView_103);
3441 SET_CALLED(Exec_ShellDocView_105);
3442 SET_CALLED(Exec_ShellDocView_140);
3443 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
3444 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
3445 SET_CALLED(SetStatusText);
3446 if(navigated_load) { /* avoiding race, FIXME: fund better way */
3447 SET_CALLED(UpdateUI);
3448 SET_CALLED(Exec_UPDATECOMMANDS);
3449 SET_CALLED(Exec_SETTITLE);
3452 load_state = LD_COMPLETE;
3454 test_readyState(NULL);
3457 static void test_Persist(IHTMLDocument2 *doc, IMoniker *mon)
3459 IPersistMoniker *persist_mon;
3460 IPersistFile *persist_file;
3464 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&persist_file);
3465 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
3466 if(SUCCEEDED(hres)) {
3467 hres = IPersist_GetClassID(persist_file, NULL);
3468 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
3470 hres = IPersist_GetClassID(persist_file, &guid);
3471 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
3472 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
3474 IPersist_Release(persist_file);
3477 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist_mon);
3478 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
3479 if(SUCCEEDED(hres)) {
3480 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
3481 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
3483 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
3484 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
3485 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
3487 if(load_state == LD_DOLOAD)
3488 test_Load(persist_mon, mon);
3490 test_readyState((IUnknown*)doc);
3492 IPersistMoniker_Release(persist_mon);
3496 static void test_put_href(IHTMLDocument2 *doc)
3498 IHTMLPrivateWindow *priv_window;
3499 IHTMLWindow2 *window;
3500 IHTMLLocation *location;
3506 hres = IHTMLDocument2_get_location(doc, &location);
3507 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3508 ok(location != NULL, "location == NULL\n");
3510 SET_EXPECT(TranslateUrl);
3511 SET_EXPECT(Navigate);
3512 str = a2bstr("about:blank");
3513 hres = IHTMLLocation_put_href(location, str);
3514 ok(hres == S_OK, "put_href failed: %08x\n", hres);
3515 CHECK_CALLED(TranslateUrl);
3516 CHECK_CALLED(Navigate);
3518 IHTMLLocation_Release(location);
3520 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3521 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3523 hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window);
3524 IHTMLWindow2_Release(window);
3525 ok(hres == S_OK, "QueryInterface(IID_IHTMLPrivateWindow) failed: %08x\n", hres);
3527 readystate_set_loading = TRUE;
3528 navigated_load = TRUE;
3529 SET_EXPECT(TranslateUrl);
3530 SET_EXPECT(Exec_ShellDocView_67);
3531 SET_EXPECT(Invoke_AMBIENT_SILENT);
3532 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3533 SET_EXPECT(OnChanged_READYSTATE);
3534 SET_EXPECT(Exec_ShellDocView_63);
3537 V_VT(&vempty) = VT_EMPTY;
3538 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, str2, NULL, NULL, &vempty, &vempty, 0);
3540 SysFreeString(str2);
3541 ok(hres == S_OK, "SuperNavigate failed: %08x\n", hres);
3543 CHECK_CALLED(TranslateUrl);
3544 CHECK_CALLED(Exec_ShellDocView_67);
3545 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3546 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3547 SET_CALLED(OnChanged_READYSTATE); /* not always called */
3548 CHECK_CALLED(Exec_ShellDocView_63);
3550 test_GetCurMoniker(doc_unk, doc_mon, NULL);
3551 IHTMLPrivateWindow_Release(priv_window);
3553 test_download(DWL_VERBDONE);
3556 static void test_open_window(IHTMLDocument2 *doc)
3558 IHTMLWindow2 *window, *new_window;
3562 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3563 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3565 url = a2bstr("about:blank");
3566 name = a2bstr("test");
3567 new_window = (void*)0xdeadbeef;
3571 SET_EXPECT(TranslateUrl);
3572 SET_EXPECT(EvaluateNewWindow);
3574 hres = IHTMLWindow2_open(window, url, name, NULL, VARIANT_FALSE, &new_window);
3577 SysFreeString(name);
3580 CHECK_CALLED(TranslateUrl);
3582 if(!called_EvaluateNewWindow) {
3584 win_skip("INewWindowManager not supported\n");
3585 if(SUCCEEDED(hres) && new_window)
3586 IHTMLWindow2_Release(new_window);
3587 IHTMLWindow2_Release(window);
3592 CHECK_CALLED(EvaluateNewWindow);
3595 ok(hres == S_OK, "open failed: %08x\n", hres);
3597 ok(new_window == NULL, "new_window != NULL\n");
3599 IHTMLWindow2_Release(window);
3602 static void test_clear(IHTMLDocument2 *doc)
3606 hres = IHTMLDocument2_clear(doc);
3607 ok(hres == S_OK, "clear failed: %08x\n", hres);
3610 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
3612 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
3613 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
3614 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
3615 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
3616 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
3617 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
3618 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
3619 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
3620 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
3621 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
3622 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
3623 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
3624 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
3625 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
3626 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
3627 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
3628 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
3629 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
3630 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
3631 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
3633 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
3634 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
3636 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
3638 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
3640 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
3641 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
3643 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
3644 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
3646 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
3648 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
3649 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
3652 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
3653 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
3655 IOleCommandTarget *cmdtrg;
3656 OLECMD olecmd = {cmdid, 0};
3659 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3660 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3664 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
3665 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
3667 IOleCommandTarget_Release(cmdtrg);
3669 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
3670 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
3673 static void test_MSHTML_QueryStatus(IHTMLDocument2 *doc, DWORD cmdf)
3675 IUnknown *unk = doc ? (IUnknown*)doc : doc_unk;
3677 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
3678 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
3679 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
3680 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
3681 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
3682 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
3683 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
3684 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
3685 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
3686 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
3687 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
3688 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
3689 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
3690 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
3691 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
3692 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
3695 static void test_OleCommandTarget(IHTMLDocument2 *doc)
3697 IOleCommandTarget *cmdtrg;
3698 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
3702 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3703 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3707 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3708 cmds[i].cmdID = i+1;
3709 cmds[i].cmdf = 0xf0f0;
3712 SET_EXPECT(QueryStatus_OPEN);
3713 SET_EXPECT(QueryStatus_NEW);
3714 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
3715 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3716 CHECK_CALLED(QueryStatus_OPEN);
3717 CHECK_CALLED(QueryStatus_NEW);
3719 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3720 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
3721 if(i+1 == OLECMDID_FIND)
3723 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
3724 i+1, cmds[i].cmdf, expect_cmds[i+1]);
3727 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
3728 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
3730 IOleCommandTarget_Release(cmdtrg);
3733 static void test_OleCommandTarget_fail(IHTMLDocument2 *doc)
3735 IOleCommandTarget *cmdtrg;
3740 {OLECMDID_OPEN, 0xf0f0},
3741 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
3744 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3745 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
3749 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
3750 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3752 SET_EXPECT(QueryStatus_OPEN);
3753 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
3754 CHECK_CALLED(QueryStatus_OPEN);
3756 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3757 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3758 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3759 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3760 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3761 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3762 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3764 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3765 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3766 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3768 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3769 if(!expect_cmds[i]) {
3770 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3771 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3772 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3773 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3777 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3778 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3779 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3780 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3782 IOleCommandTarget_Release(cmdtrg);
3785 static void test_exec_onunload(IHTMLDocument2 *doc)
3787 IOleCommandTarget *cmdtrg;
3791 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3792 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3796 memset(&var, 0x0a, sizeof(var));
3797 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3798 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3799 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3800 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3801 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3803 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3804 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3805 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3807 IOleCommandTarget_Release(cmdtrg);
3810 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3812 IOleCommandTarget *cmdtrg;
3815 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3816 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3823 load_state = LD_DOLOAD;
3826 SET_EXPECT(GetClassID);
3827 SET_EXPECT(SetStatusText);
3828 SET_EXPECT(Exec_ShellDocView_37);
3829 SET_EXPECT(GetHostInfo);
3831 SET_EXPECT(GetDisplayName);
3832 SET_EXPECT(Invoke_AMBIENT_SILENT);
3833 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3834 SET_EXPECT(OnChanged_READYSTATE);
3835 SET_EXPECT(IsSystemMoniker);
3836 SET_EXPECT(Exec_ShellDocView_84);
3838 SET_EXPECT(BindToStorage);
3839 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3842 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3844 expect_status_text = NULL;
3845 readystate_set_loading = TRUE;
3847 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3848 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3849 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3852 CHECK_CALLED(GetClassID);
3853 CHECK_CALLED(SetStatusText);
3854 CHECK_CALLED(Exec_ShellDocView_37);
3855 CHECK_CALLED(GetHostInfo);
3857 CHECK_CALLED(GetDisplayName);
3858 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3859 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3860 CHECK_CALLED(OnChanged_READYSTATE);
3861 SET_CALLED(IsSystemMoniker); /* IE7 */
3862 SET_CALLED(Exec_ShellDocView_84);
3864 CHECK_CALLED(BindToStorage);
3865 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3866 CHECK_CALLED(HideUI);
3867 CHECK_CALLED(ShowUI);
3868 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3870 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3872 IOleCommandTarget_Release(cmdtrg);
3874 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3875 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3876 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3879 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3881 IOleCommandTarget *cmdtrg;
3882 VARIANT *in = NULL, _in, *out = NULL, _out;
3885 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3886 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3893 V_BSTR(in) = SysAllocString(name);
3899 V_I4(out) = 0xdeadbeef;
3902 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3903 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3909 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3910 if(V_VT(out) == VT_BSTR) {
3912 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3913 "unexpected fontname %s\n", wine_dbgstr_w(name));
3915 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3920 IOleCommandTarget_Release(cmdtrg);
3923 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3925 IOleCommandTarget *cmdtrg;
3928 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3929 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3933 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3934 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3935 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3937 IOleCommandTarget_Release(cmdtrg);
3940 static void test_IsDirty(IHTMLDocument2 *doc, HRESULT exhres)
3942 IPersistStreamInit *perinit;
3943 IPersistMoniker *permon;
3944 IPersistFile *perfile;
3947 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&perinit);
3948 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3949 if(SUCCEEDED(hres)) {
3950 hres = IPersistStreamInit_IsDirty(perinit);
3951 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3952 IPersistStreamInit_Release(perinit);
3955 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&permon);
3956 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3957 if(SUCCEEDED(hres)) {
3958 hres = IPersistMoniker_IsDirty(permon);
3959 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3960 IPersistMoniker_Release(permon);
3963 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&perfile);
3964 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3965 if(SUCCEEDED(hres)) {
3966 hres = IPersistFile_IsDirty(perfile);
3967 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3968 IPersistFile_Release(perfile);
3972 static HWND create_container_window(void)
3974 static const WCHAR wszHTMLDocumentTest[] =
3975 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3976 static WNDCLASSEXW wndclass = {
3977 sizeof(WNDCLASSEXW),
3980 0, 0, NULL, NULL, NULL, NULL, NULL,
3981 wszHTMLDocumentTest,
3985 RegisterClassExW(&wndclass);
3986 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3987 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3988 515, 530, NULL, NULL, NULL, NULL);
3991 static void test_DoVerb(IOleObject *oleobj)
3993 RECT rect = {0,0,500,500};
3996 if(!container_locked) {
3997 SET_EXPECT(GetContainer);
3998 SET_EXPECT(LockContainer);
4000 SET_EXPECT(ActivateMe);
4001 expect_LockContainer_fLock = TRUE;
4003 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
4004 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
4006 if(!container_locked) {
4007 CHECK_CALLED(GetContainer);
4008 CHECK_CALLED(LockContainer);
4009 container_locked = TRUE;
4011 CHECK_CALLED(ActivateMe);
4014 #define CLIENTSITE_EXPECTPATH 0x00000001
4015 #define CLIENTSITE_SETNULL 0x00000002
4016 #define CLIENTSITE_DONTSET 0x00000004
4018 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
4020 IOleClientSite *clientsite;
4023 if(flags & CLIENTSITE_SETNULL) {
4024 hres = IOleObject_GetClientSite(oleobj, &clientsite);
4026 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
4028 ok(!clientsite, "clientsite != NULL\n");
4030 hres = IOleObject_SetClientSite(oleobj, NULL);
4031 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4033 set_clientsite = FALSE;
4036 if(flags & CLIENTSITE_DONTSET)
4039 if(!expect_uihandler_iface)
4040 expect_uihandler_iface = &DocHostUIHandler;
4042 hres = IOleObject_GetClientSite(oleobj, &clientsite);
4043 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
4044 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
4045 clientsite, set_clientsite ? &ClientSite : NULL);
4047 if(!set_clientsite) {
4048 if(expect_uihandler_iface)
4049 SET_EXPECT(GetHostInfo);
4050 if(flags & CLIENTSITE_EXPECTPATH) {
4051 SET_EXPECT(GetOptionKeyPath);
4052 SET_EXPECT(GetOverrideKeyPath);
4054 SET_EXPECT(GetWindow);
4055 if(flags & CLIENTSITE_EXPECTPATH)
4056 SET_EXPECT(Exec_DOCCANNAVIGATE);
4057 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
4058 SET_EXPECT(Exec_SETPROGRESSMAX);
4059 SET_EXPECT(Exec_SETPROGRESSPOS);
4060 SET_EXPECT(Invoke_AMBIENT_USERMODE);
4061 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4062 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4063 SET_EXPECT(Invoke_AMBIENT_SILENT);
4064 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
4065 SET_EXPECT(Invoke_AMBIENT_PALETTE);
4067 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
4068 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4070 if(expect_uihandler_iface)
4071 CHECK_CALLED(GetHostInfo);
4072 if(flags & CLIENTSITE_EXPECTPATH) {
4073 CHECK_CALLED(GetOptionKeyPath);
4074 CHECK_CALLED(GetOverrideKeyPath);
4076 CHECK_CALLED(GetWindow);
4077 if(flags & CLIENTSITE_EXPECTPATH)
4078 CHECK_CALLED(Exec_DOCCANNAVIGATE);
4079 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
4080 CHECK_CALLED(Exec_SETPROGRESSMAX);
4081 CHECK_CALLED(Exec_SETPROGRESSPOS);
4082 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4083 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4084 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4085 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4086 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4087 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4089 set_clientsite = TRUE;
4092 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
4093 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4095 hres = IOleObject_GetClientSite(oleobj, &clientsite);
4096 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
4097 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
4100 static void test_OnAmbientPropertyChange(IHTMLDocument2 *doc)
4102 IOleControl *control = NULL;
4105 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
4106 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
4110 SET_EXPECT(Invoke_AMBIENT_USERMODE);
4111 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
4112 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4113 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4115 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4116 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
4117 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4118 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4120 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4121 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4122 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
4123 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4124 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4125 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4127 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4128 SET_EXPECT(Invoke_AMBIENT_SILENT);
4129 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
4130 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4131 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4132 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4134 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
4135 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
4136 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4137 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4139 SET_EXPECT(Invoke_AMBIENT_PALETTE);
4140 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
4141 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4142 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4144 IOleControl_Release(control);
4149 static void test_OnAmbientPropertyChange2(IHTMLDocument2 *doc)
4151 IOleControl *control = NULL;
4154 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
4155 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
4159 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
4160 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
4162 IOleControl_Release(control);
4165 static void test_Close(IHTMLDocument2 *doc, BOOL set_client)
4167 IOleObject *oleobj = NULL;
4170 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4171 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4175 SET_EXPECT(GetContainer);
4176 SET_EXPECT(LockContainer);
4177 expect_LockContainer_fLock = FALSE;
4178 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
4179 ok(hres == S_OK, "Close failed: %08x\n", hres);
4180 CHECK_CALLED(GetContainer);
4181 CHECK_CALLED(LockContainer);
4182 container_locked = FALSE;
4185 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
4187 IOleObject_Release(oleobj);
4190 static void test_Advise(IHTMLDocument2 *doc)
4192 IOleObject *oleobj = NULL;
4193 IEnumSTATDATA *enum_advise = (void*)0xdeadbeef;
4197 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4198 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4202 hres = IOleObject_Unadvise(oleobj, 0);
4203 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
4205 hres = IOleObject_EnumAdvise(oleobj, &enum_advise);
4206 ok(hres == S_OK, "EnumAdvise returned: %08x\n", hres);
4207 ok(enum_advise == NULL, "enum_advise != NULL\n");
4210 hres = IOleObject_Advise(oleobj, NULL, &conn);
4211 /* Old IE returns S_OK and sets conn to 1 */
4212 ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres);
4213 ok(conn == 0 || conn == 1, "conn = %d\n", conn);
4215 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL);
4216 ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
4218 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4219 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4220 ok(conn == 1, "conn = %d\n", conn);
4222 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4223 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4224 ok(conn == 2, "conn = %d\n", conn);
4226 hres = IOleObject_Unadvise(oleobj, 1);
4227 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4229 hres = IOleObject_Unadvise(oleobj, 1);
4230 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
4232 hres = IOleObject_Unadvise(oleobj, 2);
4233 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4235 IOleObject_Release(oleobj);
4238 static void test_OnFrameWindowActivate(IUnknown *unk)
4240 IOleInPlaceActiveObject *inplaceact;
4243 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
4244 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
4248 if(set_clientsite) {
4249 expect_OnFrameWindowActivate_fActivate = TRUE;
4250 SET_EXPECT(OnFrameWindowActivate);
4251 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4252 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4253 CHECK_CALLED(OnFrameWindowActivate);
4255 SET_EXPECT(OnFrameWindowActivate);
4256 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4257 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4258 CHECK_CALLED(OnFrameWindowActivate);
4260 expect_OnFrameWindowActivate_fActivate = FALSE;
4261 SET_EXPECT(OnFrameWindowActivate);
4262 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
4263 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4264 CHECK_CALLED(OnFrameWindowActivate);
4266 expect_OnFrameWindowActivate_fActivate = TRUE;
4267 SET_EXPECT(OnFrameWindowActivate);
4268 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4269 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4270 CHECK_CALLED(OnFrameWindowActivate);
4272 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
4273 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4275 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4276 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4279 IOleInPlaceActiveObject_Release(inplaceact);
4282 static void test_InPlaceDeactivate(IHTMLDocument2 *doc, BOOL expect_call)
4284 IOleInPlaceObjectWindowless *windowlessobj = NULL;
4287 hres = IUnknown_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless,
4288 (void**)&windowlessobj);
4289 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
4294 SET_EXPECT(OnFocus_FALSE);
4296 SET_EXPECT(OnInPlaceDeactivateEx);
4298 SET_EXPECT(OnInPlaceDeactivate);
4300 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
4301 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
4303 CHECK_CALLED(OnFocus_FALSE);
4305 CHECK_CALLED(OnInPlaceDeactivateEx);
4307 CHECK_CALLED(OnInPlaceDeactivate);
4310 IOleInPlaceObjectWindowless_Release(windowlessobj);
4313 static void test_Activate(IHTMLDocument2 *doc, DWORD flags)
4315 IOleObject *oleobj = NULL;
4316 IOleDocumentView *docview;
4323 IOleDocumentView_Release(view);
4326 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4327 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4329 hres = IOleObject_GetUserClassID(oleobj, NULL);
4330 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
4332 hres = IOleObject_GetUserClassID(oleobj, &guid);
4333 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
4334 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
4336 test_OnFrameWindowActivate((IUnknown*)doc);
4338 test_ClientSite(oleobj, flags);
4339 test_InPlaceDeactivate(doc, FALSE);
4340 test_DoVerb(oleobj);
4342 if(call_UIActivate == CallUIActivate_AfterShow) {
4343 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
4344 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
4346 SET_EXPECT(OnFocus_TRUE);
4347 SET_EXPECT(SetActiveObject);
4349 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4350 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4351 expect_status_text = NULL;
4353 hres = IOleDocumentView_UIActivate(docview, TRUE);
4354 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4356 CHECK_CALLED(OnFocus_TRUE);
4357 CHECK_CALLED(SetActiveObject);
4358 CHECK_CALLED(ShowUI);
4359 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4360 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4362 IOleDocumentView_Release(docview);
4365 IOleObject_Release(oleobj);
4367 test_OnFrameWindowActivate((IUnknown*)doc);
4370 static void test_Window(IHTMLDocument2 *doc, BOOL expect_success)
4372 IOleInPlaceActiveObject *activeobject = NULL;
4376 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
4377 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
4381 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
4383 if(expect_success) {
4384 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
4385 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
4387 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
4388 ok(IsWindow(hwnd), "hwnd is destroyed\n");
4391 IOleInPlaceActiveObject_Release(activeobject);
4394 static void test_CloseView(void)
4396 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
4402 hres = IOleDocumentView_Show(view, FALSE);
4403 ok(hres == S_OK, "Show failed: %08x\n", hres);
4405 hres = IOleDocumentView_CloseView(view, 0);
4406 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
4408 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
4409 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
4411 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
4412 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
4413 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
4416 static void test_UIDeactivate(void)
4420 if(call_UIActivate == CallUIActivate_AfterShow) {
4421 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4423 if(call_UIActivate != CallUIActivate_None) {
4424 SET_EXPECT(SetActiveObject_null);
4426 SET_EXPECT(OnUIDeactivate);
4429 hres = IOleDocumentView_UIActivate(view, FALSE);
4430 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
4432 if(call_UIActivate != CallUIActivate_None) {
4433 CHECK_CALLED(SetActiveObject_null);
4434 CHECK_CALLED(HideUI);
4435 CHECK_CALLED(OnUIDeactivate);
4437 if(call_UIActivate == CallUIActivate_AfterShow) {
4438 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4442 static void test_Hide(void)
4449 hres = IOleDocumentView_Show(view, FALSE);
4450 ok(hres == S_OK, "Show failed: %08x\n", hres);
4453 static IHTMLDocument2 *create_document(void)
4455 IHTMLDocument2 *doc;
4458 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
4459 &IID_IHTMLDocument2, (void**)&doc);
4460 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
4467 static void release_document(IHTMLDocument2 *doc)
4473 /* Some broken IEs don't like if the last released reference is IHTMLDocument2 iface.
4474 * To workaround it, we release it via IUnknown iface */
4475 hres = IHTMLDocument2_QueryInterface(doc, &IID_IUnknown, (void**)&unk);
4476 ok(hres == S_OK, "Could not get IUnknown iface: %08x\n", hres);
4478 IHTMLDocument2_Release(doc);
4479 ref = IUnknown_Release(unk);
4480 ok(!ref, "ref = %d\n", ref);
4483 static void test_Navigate(IHTMLDocument2 *doc)
4485 IHlinkTarget *hlink;
4488 hres = IUnknown_QueryInterface(doc, &IID_IHlinkTarget, (void**)&hlink);
4489 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
4491 SET_EXPECT(ActivateMe);
4492 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
4493 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
4494 CHECK_CALLED(ActivateMe);
4496 IHlinkTarget_Release(hlink);
4499 static void test_external(IHTMLDocument2 *doc, BOOL initialized)
4501 IDispatch *external;
4502 IHTMLWindow2 *htmlwin;
4505 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
4506 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4509 SET_EXPECT(GetExternal);
4510 external = (void*)0xdeadbeef;
4511 hres = IHTMLWindow2_get_external(htmlwin, &external);
4513 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
4514 CHECK_CALLED(GetExternal);
4515 ok(external != NULL, "external == NULL\n");
4517 ok(hres == S_OK, "get_external failed: %08x\n", hres);
4518 ok(external == NULL, "external != NULL\n");
4521 IHTMLWindow2_Release(htmlwin);
4524 static void test_StreamLoad(IHTMLDocument2 *doc)
4526 IPersistStreamInit *init;
4529 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4530 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
4534 SET_EXPECT(Invoke_AMBIENT_SILENT);
4535 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4536 SET_EXPECT(Exec_ShellDocView_37);
4537 SET_EXPECT(OnChanged_READYSTATE);
4539 readystate_set_loading = TRUE;
4541 hres = IPersistStreamInit_Load(init, &Stream);
4542 ok(hres == S_OK, "Load failed: %08x\n", hres);
4544 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4545 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4546 CHECK_CALLED(Exec_ShellDocView_37);
4547 CHECK_CALLED(OnChanged_READYSTATE);
4550 test_timer(EXPECT_SETTITLE);
4551 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4553 IPersistStreamInit_Release(init);
4556 static void test_StreamInitNew(IHTMLDocument2 *doc)
4558 IPersistStreamInit *init;
4561 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4562 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
4566 SET_EXPECT(Invoke_AMBIENT_SILENT);
4567 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4568 SET_EXPECT(Exec_ShellDocView_37);
4569 SET_EXPECT(OnChanged_READYSTATE);
4570 readystate_set_loading = TRUE;
4572 hres = IPersistStreamInit_InitNew(init);
4573 ok(hres == S_OK, "Load failed: %08x\n", hres);
4575 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4576 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4577 CHECK_CALLED(Exec_ShellDocView_37);
4578 CHECK_CALLED(OnChanged_READYSTATE);
4580 test_timer(EXPECT_SETTITLE);
4581 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4583 IPersistStreamInit_Release(init);
4586 static void test_QueryInterface(IHTMLDocument2 *doc)
4591 static const IID IID_UndocumentedScriptIface =
4592 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
4594 qi = (void*)0xdeadbeef;
4595 hres = IUnknown_QueryInterface(doc, &IID_IRunnableObject, (void**)&qi);
4596 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4597 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
4599 qi = (void*)0xdeadbeef;
4600 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode, (void**)&qi);
4601 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4602 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4604 qi = (void*)0xdeadbeef;
4605 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode2, (void**)&qi);
4606 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4607 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4609 qi = (void*)0xdeadbeef;
4610 hres = IUnknown_QueryInterface(doc, &IID_IPersistPropertyBag, (void**)&qi);
4611 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4612 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4614 qi = (void*)0xdeadbeef;
4615 hres = IUnknown_QueryInterface(doc, &IID_UndocumentedScriptIface, (void**)&qi);
4616 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4617 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4619 qi = (void*)0xdeadbeef;
4620 hres = IUnknown_QueryInterface(doc, &IID_IMarshal, (void**)&qi);
4621 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4622 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4624 qi = (void*)0xdeadbeef;
4625 hres = IUnknown_QueryInterface(doc, &IID_IExternalConnection, (void**)&qi);
4626 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4627 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4629 qi = (void*)0xdeadbeef;
4630 hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi);
4631 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4632 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4634 hres = IUnknown_QueryInterface(doc, &IID_IDispatch, (void**)&qi);
4635 ok(hres == S_OK, "Could not get IDispatch interface: %08x\n", hres);
4636 ok(qi != (IUnknown*)doc, "disp == doc\n");
4637 IUnknown_Release(qi);
4640 static void init_test(enum load_state_t ls) {
4642 hwnd = last_hwnd = NULL;
4643 set_clientsite = FALSE;
4644 load_from_stream = FALSE;
4645 call_UIActivate = CallUIActivate_None;
4651 inplace_deactivated = FALSE;
4652 navigated_load = FALSE;
4653 expect_uihandler_iface = &DocHostUIHandler;
4656 static void test_HTMLDocument(BOOL do_load)
4658 IHTMLDocument2 *doc;
4660 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
4662 init_test(do_load ? LD_DOLOAD : LD_NO);
4664 doc = create_document();
4665 doc_unk = (IUnknown*)doc;
4667 test_QueryInterface(doc);
4669 test_IsDirty(doc, S_FALSE);
4670 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4671 test_external(doc, FALSE);
4672 test_ViewAdviseSink(doc);
4673 test_ConnectionPointContainer(doc);
4674 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4675 test_Persist(doc, &Moniker);
4677 test_OnAmbientPropertyChange2(doc);
4679 test_Activate(doc, CLIENTSITE_EXPECTPATH);
4682 set_custom_uihandler(doc, &CustomDocHostUIHandler);
4683 test_download(DWL_CSS|DWL_TRYCSS);
4684 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4687 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4688 test_OleCommandTarget_fail(doc);
4689 test_OleCommandTarget(doc);
4690 test_OnAmbientPropertyChange(doc);
4691 test_Window(doc, TRUE);
4692 test_external(doc, TRUE);
4694 test_UIDeactivate();
4695 test_OleCommandTarget(doc);
4696 test_Window(doc, TRUE);
4697 test_InPlaceDeactivate(doc, TRUE);
4699 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
4700 * MSHTML. It doesn't with Wine. */
4702 test_Window(doc, FALSE);
4704 test_InPlaceDeactivate(doc, FALSE);
4706 test_Close(doc, FALSE);
4708 /* Activate HTMLDocument again */
4709 test_Activate(doc, CLIENTSITE_SETNULL);
4710 test_Window(doc, TRUE);
4711 test_OleCommandTarget(doc);
4712 test_UIDeactivate();
4713 test_InPlaceDeactivate(doc, TRUE);
4714 test_Close(doc, FALSE);
4716 /* Activate HTMLDocument again, this time without UIActivate */
4717 call_UIActivate = CallUIActivate_None;
4718 test_Activate(doc, CLIENTSITE_SETNULL);
4719 test_Window(doc, TRUE);
4721 test_external(doc, TRUE);
4722 set_custom_uihandler(doc, NULL);
4723 test_external(doc, FALSE);
4725 test_UIDeactivate();
4726 test_InPlaceDeactivate(doc, TRUE);
4729 test_Close(doc, TRUE);
4730 test_OnAmbientPropertyChange2(doc);
4731 test_GetCurMoniker((IUnknown*)doc, do_load ? &Moniker : NULL, NULL);
4734 /* Activate HTMLDocument again, calling UIActivate after showing the window */
4735 call_UIActivate = CallUIActivate_AfterShow;
4736 test_Activate(doc, 0);
4737 test_Window(doc, TRUE);
4738 test_OleCommandTarget(doc);
4739 test_UIDeactivate();
4740 test_InPlaceDeactivate(doc, TRUE);
4741 test_Close(doc, FALSE);
4742 call_UIActivate = CallUIActivate_None;
4746 IOleDocumentView_Release(view);
4749 ok(IsWindow(hwnd), "hwnd is destroyed\n");
4750 release_document(doc);
4751 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
4754 static void test_HTMLDocument_hlink(void)
4756 IHTMLDocument2 *doc;
4758 trace("Testing HTMLDocument (hlink)...\n");
4760 init_test(LD_DOLOAD);
4763 doc = create_document();
4764 doc_unk = (IUnknown*)doc;
4766 set_custom_uihandler(doc, &CustomDocHostUIHandler);
4767 test_ViewAdviseSink(doc);
4768 test_ConnectionPointContainer(doc);
4769 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4770 test_Persist(doc, &Moniker);
4773 IUnknown_Release(doc);
4777 test_download(DWL_CSS|DWL_TRYCSS);
4779 test_IsDirty(doc, S_FALSE);
4780 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4782 test_exec_onunload(doc);
4783 test_Window(doc, TRUE);
4784 test_InPlaceDeactivate(doc, TRUE);
4785 test_Close(doc, FALSE);
4786 test_IsDirty(doc, S_FALSE);
4787 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4789 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4792 IOleDocumentView_Release(view);
4795 release_document(doc);
4798 static void test_cookies(IHTMLDocument2 *doc)
4806 hres = IHTMLDocument2_get_cookie(doc, &str);
4807 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4809 size = sizeof(buf)/sizeof(WCHAR);
4810 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4811 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4812 ok(!lstrcmpW(buf, str), "cookie = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(buf));
4816 str = a2bstr("test=testval");
4817 hres = IHTMLDocument2_put_cookie(doc, str);
4818 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
4821 hres = IHTMLDocument2_get_cookie(doc, &str2);
4822 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4823 ok(str2 != NULL, "cookie = NULL\n");
4824 size = sizeof(buf)/sizeof(WCHAR);
4825 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4826 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4827 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
4828 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
4830 SysFreeString(str2);
4832 str = a2bstr("test=testval2");
4833 hres = IHTMLDocument2_put_cookie(doc, str);
4834 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
4837 hres = IHTMLDocument2_get_cookie(doc, &str2);
4838 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4839 ok(str2 != NULL, "cookie = NULL\n");
4840 size = sizeof(buf)/sizeof(WCHAR);
4841 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4842 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4843 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
4844 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
4846 SysFreeString(str2);
4849 static void test_HTMLDocument_http(void)
4852 IHTMLDocument2 *doc;
4856 trace("Testing HTMLDocument (http)...\n");
4858 if(!winetest_interactive && is_ie_hardened()) {
4859 win_skip("IE running in Enhanced Security Configuration\n");
4863 init_test(LD_DOLOAD);
4866 doc = create_document();
4867 doc_unk = (IUnknown*)doc;
4869 hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
4870 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
4872 test_ViewAdviseSink(doc);
4873 test_ConnectionPointContainer(doc);
4874 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4875 test_Persist(doc, http_mon);
4878 IUnknown_Release(doc);
4882 test_download(DWL_HTTP);
4884 test_IsDirty(doc, S_FALSE);
4885 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4886 test_GetCurMoniker((IUnknown*)doc, http_mon, NULL);
4889 test_open_window(doc);
4891 test_InPlaceDeactivate(doc, TRUE);
4892 test_Close(doc, FALSE);
4893 test_IsDirty(doc, S_FALSE);
4894 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4897 IOleDocumentView_Release(view);
4900 release_document(doc);
4902 ref = IMoniker_Release(http_mon);
4903 ok(!ref, "ref=%d, expected 0\n", ref);
4906 static void test_QueryService(IHTMLDocument2 *doc, BOOL success)
4908 IHTMLWindow2 *window, *sp_window;
4909 IServiceProvider *sp;
4913 hres = IUnknown_QueryInterface(doc, &IID_IServiceProvider, (void**)&sp);
4914 ok(hres == S_OK, "QueryService returned %08x\n", hres);
4916 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
4918 ok(hres == E_NOINTERFACE, "QueryService returned %08x, expected E_NOINTERFACE\n", hres);
4919 IServiceProvider_Release(sp);
4923 ok(hres == S_OK, "QueryService(IID_IHlinkFrame) failed: %08x\n", hres);
4924 ok(hf == &HlinkFrame, "hf != HlinkFrame\n");
4925 IHlinkFrame_Release(hf);
4927 IServiceProvider_Release(sp);
4929 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4930 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4932 hres = IHTMLWindow2_QueryInterface(window, &IID_IServiceProvider, (void**)&sp);
4933 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
4935 hres = IServiceProvider_QueryService(sp, &IID_IHTMLWindow2, &IID_IHTMLWindow2, (void**)&sp_window);
4936 ok(hres == S_OK, "QueryService(IID_IHTMLWindow2) failed: %08x\n", hres);
4937 /* FIXME: test returned window */
4938 IHTMLWindow2_Release(sp_window);
4940 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
4941 ok(hres == S_OK, "QueryService(IID_IHlinkFrame) failed: %08x\n", hres);
4942 ok(hf == &HlinkFrame, "hf != HlinkFrame\n");
4943 IHlinkFrame_Release(hf);
4945 IServiceProvider_Release(sp);
4946 IHTMLWindow2_Release(window);
4949 static void test_HTMLDocument_StreamLoad(void)
4951 IHTMLDocument2 *doc;
4956 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
4958 init_test(LD_DOLOAD);
4959 load_from_stream = TRUE;
4961 doc = create_document();
4962 doc_unk = (IUnknown*)doc;
4964 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4965 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4967 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4968 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4970 test_readyState((IUnknown*)doc);
4971 test_IsDirty(doc, S_FALSE);
4972 test_ViewAdviseSink(doc);
4973 test_ConnectionPointContainer(doc);
4974 test_QueryService(doc, FALSE);
4975 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4976 test_QueryService(doc, TRUE);
4977 test_DoVerb(oleobj);
4978 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4980 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4981 test_StreamLoad(doc);
4982 test_download(DWL_VERBDONE|DWL_TRYCSS);
4983 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4985 test_UIDeactivate();
4986 test_InPlaceDeactivate(doc, TRUE);
4987 SET_EXPECT(Advise_Close);
4988 test_Close(doc, TRUE);
4989 CHECK_CALLED(Advise_Close);
4990 test_external(doc, FALSE);
4991 test_IsDirty(doc, S_FALSE);
4993 set_custom_uihandler(doc, &CustomDocHostUIHandler);
4994 test_ClientSite(oleobj, CLIENTSITE_SETNULL);
4995 test_external(doc, TRUE);
4996 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
4997 test_external(doc, TRUE);
4998 set_custom_uihandler(doc, NULL);
4999 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
5001 IOleObject_Release(oleobj);
5003 IOleDocumentView_Release(view);
5007 release_document(doc);
5010 static void test_HTMLDocument_StreamInitNew(void)
5012 IHTMLDocument2 *doc;
5017 trace("Testing HTMLDocument (IPersistStreamInit::InitNew)...\n");
5019 init_test(LD_DOLOAD);
5020 load_from_stream = TRUE;
5022 doc = create_document();
5023 doc_unk = (IUnknown*)doc;
5025 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5026 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
5028 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
5029 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5031 test_readyState((IUnknown*)doc);
5032 test_IsDirty(doc, S_FALSE);
5033 test_ViewAdviseSink(doc);
5034 test_ConnectionPointContainer(doc);
5035 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
5036 test_DoVerb(oleobj);
5037 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5039 IOleObject_Release(oleobj);
5041 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
5042 test_StreamInitNew(doc);
5043 test_download(DWL_VERBDONE|DWL_TRYCSS|DWL_EMPTY);
5044 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5046 test_UIDeactivate();
5047 test_InPlaceDeactivate(doc, TRUE);
5048 SET_EXPECT(Advise_Close);
5049 test_Close(doc, FALSE);
5050 CHECK_CALLED(Advise_Close);
5051 test_IsDirty(doc, S_FALSE);
5054 IOleDocumentView_Release(view);
5058 release_document(doc);
5061 static void test_edit_uiactivate(IOleObject *oleobj)
5063 IOleDocumentView *docview;
5066 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
5067 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
5069 SET_EXPECT(OnFocus_TRUE);
5070 SET_EXPECT(SetActiveObject);
5072 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5073 SET_EXPECT(InPlaceFrame_SetBorderSpace);
5074 expect_status_text = NULL;
5076 hres = IOleDocumentView_UIActivate(docview, TRUE);
5077 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
5079 CHECK_CALLED(OnFocus_TRUE);
5080 CHECK_CALLED(SetActiveObject);
5081 CHECK_CALLED(ShowUI);
5082 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5083 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
5085 IOleDocumentView_Release(docview);
5088 static void test_editing_mode(BOOL do_load)
5090 IHTMLDocument2 *doc;
5096 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
5098 init_test(do_load ? LD_DOLOAD : LD_NO);
5099 call_UIActivate = CallUIActivate_AfterShow;
5101 doc = create_document();
5102 unk = doc_unk = (IUnknown*)doc;
5104 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5105 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
5107 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
5108 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5110 test_readyState((IUnknown*)doc);
5111 test_ViewAdviseSink(doc);
5112 test_ConnectionPointContainer(doc);
5113 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
5114 test_DoVerb(oleobj);
5115 test_edit_uiactivate(oleobj);
5117 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5119 test_Persist(doc, &Moniker);
5120 stream_read = protocol_read = 0;
5121 test_exec_editmode(unk, do_load);
5122 test_UIDeactivate();
5123 call_UIActivate = CallUIActivate_None;
5124 IOleObject_Release(oleobj);
5126 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5127 test_download(DWL_VERBDONE | (do_load ? DWL_CSS|DWL_TRYCSS : 0));
5129 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
5130 test_timer(EXPECT_UPDATEUI);
5131 SET_CALLED(SetStatusText);
5133 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
5136 test_exec_fontname(unk, NULL, wszTimesNewRoman);
5137 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
5138 test_timer(EXPECT_UPDATEUI);
5139 test_exec_fontname(unk, NULL, wszArial);
5141 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
5142 test_timer(EXPECT_UPDATEUI);
5143 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
5144 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
5146 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
5147 test_timer(EXPECT_UPDATEUI);
5148 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
5149 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
5150 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
5151 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
5153 test_exec_noargs(unk, IDM_HORIZONTALLINE);
5154 test_timer(EXPECT_UPDATEUI);
5155 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
5156 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
5159 test_UIDeactivate();
5160 test_InPlaceDeactivate(doc, TRUE);
5161 SET_EXPECT(Advise_Close);
5162 test_Close(doc, FALSE);
5163 CHECK_CALLED(Advise_Close);
5166 IOleDocumentView_Release(view);
5170 release_document(doc);
5173 static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw)
5175 IHTMLDocument2 *doc;
5177 IOleInPlaceSite *inplacesite;
5180 trace("Running OleDocumentView_UIActivate tests (%d %d %d)\n", do_load, use_ipsex, use_ipsw);
5182 init_test(do_load ? LD_DOLOAD : LD_NO);
5184 doc = create_document();
5185 doc_unk = (IUnknown*)doc;
5190 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5191 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
5193 hres = IUnknown_QueryInterface(doc, &IID_IOleDocumentView, (void**)&view);
5194 ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08x\n", hres);
5196 SET_EXPECT(Invoke_AMBIENT_USERMODE);
5197 SET_EXPECT(GetHostInfo);
5198 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
5199 SET_EXPECT(Invoke_AMBIENT_SILENT);
5200 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5201 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
5202 SET_EXPECT(Invoke_AMBIENT_PALETTE);
5203 SET_EXPECT(GetOptionKeyPath);
5204 SET_EXPECT(GetOverrideKeyPath);
5205 SET_EXPECT(GetWindow);
5206 SET_EXPECT(Exec_DOCCANNAVIGATE);
5207 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
5208 SET_EXPECT(Exec_SETPROGRESSMAX);
5209 SET_EXPECT(Exec_SETPROGRESSPOS);
5211 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
5212 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
5213 set_clientsite = TRUE;
5215 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
5216 CHECK_CALLED(GetHostInfo);
5217 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
5218 CHECK_CALLED(Invoke_AMBIENT_SILENT);
5219 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5220 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
5221 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
5222 CHECK_CALLED(GetOptionKeyPath);
5223 CHECK_CALLED(GetOverrideKeyPath);
5224 CHECK_CALLED(GetWindow);
5225 CHECK_CALLED(Exec_DOCCANNAVIGATE);
5226 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
5227 CHECK_CALLED(Exec_SETPROGRESSMAX);
5228 CHECK_CALLED(Exec_SETPROGRESSPOS);
5230 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
5231 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
5232 ok(inplacesite == NULL, "inplacesite = %p, expected NULL\n", inplacesite);
5234 SET_EXPECT(GetContainer);
5235 SET_EXPECT(LockContainer);
5236 SET_EXPECT(CanInPlaceActivate);
5237 SET_EXPECT(GetWindowContext);
5238 SET_EXPECT(GetWindow);
5240 SET_EXPECT(OnInPlaceActivateEx);
5241 SET_EXPECT(RequestUIActivate);
5244 SET_EXPECT(OnInPlaceActivate);
5245 SET_EXPECT(OnUIActivate);
5246 SET_EXPECT(SetStatusText);
5247 SET_EXPECT(Exec_SETPROGRESSMAX);
5248 SET_EXPECT(Exec_SETPROGRESSPOS);
5250 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5251 SET_EXPECT(InPlaceFrame_SetBorderSpace);
5252 SET_EXPECT(OnFocus_TRUE);
5253 SET_EXPECT(SetActiveObject);
5254 expect_LockContainer_fLock = TRUE;
5256 hres = IOleDocumentView_UIActivate(view, TRUE);
5257 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5259 CHECK_CALLED(GetContainer);
5260 CHECK_CALLED(LockContainer);
5261 CHECK_CALLED(CanInPlaceActivate);
5262 CHECK_CALLED(GetWindowContext);
5263 CHECK_CALLED(GetWindow);
5265 CHECK_CALLED(OnInPlaceActivateEx);
5266 SET_EXPECT(RequestUIActivate);
5269 CHECK_CALLED(OnInPlaceActivate);
5270 CHECK_CALLED(OnUIActivate);
5271 CHECK_CALLED(SetStatusText);
5272 CHECK_CALLED(Exec_SETPROGRESSMAX);
5273 CHECK_CALLED(Exec_SETPROGRESSPOS);
5274 CHECK_CALLED(ShowUI);
5275 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5276 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
5277 CHECK_CALLED(OnFocus_TRUE);
5278 CHECK_CALLED(SetActiveObject);
5279 container_locked = TRUE;
5281 SET_EXPECT(SetActiveObject_null);
5282 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5284 SET_EXPECT(OnUIDeactivate);
5286 hres = IOleDocumentView_UIActivate(view, FALSE);
5287 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5289 CHECK_CALLED(SetActiveObject_null);
5290 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5291 CHECK_CALLED(HideUI);
5292 CHECK_CALLED(OnUIDeactivate);
5294 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
5295 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
5296 ok(inplacesite != NULL, "inplacesite = NULL\n");
5297 IOleInPlaceSite_Release(inplacesite);
5299 SET_EXPECT(OnFocus_FALSE);
5301 SET_EXPECT(OnInPlaceDeactivateEx);
5303 SET_EXPECT(OnInPlaceDeactivate);
5307 CHECK_CALLED(OnFocus_FALSE);
5309 CHECK_CALLED(OnInPlaceDeactivateEx);
5311 CHECK_CALLED(OnInPlaceDeactivate);
5313 test_Close(doc, TRUE);
5315 IOleObject_Release(oleobj);
5316 IOleDocumentView_Release(view);
5319 release_document(doc);
5322 static void register_protocol(void)
5324 IInternetSession *session;
5327 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
5329 hres = CoInternetGetSession(0, &session, 0);
5330 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
5332 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
5333 wsz_winetest, 0, NULL, 0);
5334 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
5336 IInternetSession_Release(session);
5339 static void test_HTMLDoc_ISupportErrorInfo(void)
5341 IHTMLDocument2 *doc;
5343 ISupportErrorInfo *sinfo;
5345 doc = create_document();
5347 hres = IUnknown_QueryInterface(doc, &IID_ISupportErrorInfo, (void**)&sinfo);
5348 ok(hres == S_OK, "got %x\n", hres);
5349 ok(sinfo != NULL, "got %p\n", sinfo);
5352 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
5353 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
5354 IUnknown_Release(sinfo);
5357 release_document(doc);
5360 static void test_IPersistHistory(void)
5362 IHTMLDocument2 *doc;
5364 IPersistHistory *phist;
5366 doc = create_document();
5368 hres = IUnknown_QueryInterface(doc, &IID_IPersistHistory, (void**)&phist);
5369 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
5371 IPersistHistory_Release(phist);
5373 release_document(doc);
5376 static BOOL check_ie(void)
5378 IHTMLDocument2 *doc;
5379 IHTMLDocument5 *doc5;
5382 doc = create_document();
5386 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
5388 IHTMLDocument5_Release(doc5);
5390 release_document(doc);
5391 return SUCCEEDED(hres);
5400 win_skip("Too old IE\n");
5404 container_hwnd = create_container_window();
5405 register_protocol();
5407 test_HTMLDocument_hlink();
5409 test_HTMLDocument(FALSE);
5410 test_HTMLDocument(TRUE);
5411 test_HTMLDocument_StreamLoad();
5412 test_HTMLDocument_StreamInitNew();
5413 test_editing_mode(FALSE);
5414 test_editing_mode(TRUE);
5415 test_HTMLDocument_http();
5416 test_UIActivate(FALSE, FALSE, FALSE);
5417 test_UIActivate(FALSE, TRUE, FALSE);
5418 test_UIActivate(FALSE, TRUE, TRUE);
5419 test_UIActivate(TRUE, FALSE, FALSE);
5420 test_UIActivate(TRUE, TRUE, FALSE);
5421 test_UIActivate(TRUE, TRUE, TRUE);
5423 test_HTMLDoc_ISupportErrorInfo();
5424 test_IPersistHistory();
5426 DestroyWindow(container_hwnd);