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>
41 #include "mshtml_test.h"
43 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
45 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
47 #define DEFINE_EXPECT(func) \
48 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
50 #define SET_EXPECT(func) \
51 expect_ ## func = TRUE
53 #define SET_CALLED(func) \
54 called_ ## func = TRUE
56 #define CHECK_EXPECT2(func) \
58 ok(expect_ ##func, "unexpected call " #func "\n"); \
59 called_ ## func = TRUE; \
62 #define CHECK_EXPECT(func) \
64 CHECK_EXPECT2(func); \
65 expect_ ## func = FALSE; \
68 #define CHECK_CALLED(func) \
70 ok(called_ ## func, "expected " #func "\n"); \
71 expect_ ## func = called_ ## func = FALSE; \
74 static IOleDocumentView *view = NULL;
75 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
77 DEFINE_EXPECT(LockContainer);
78 DEFINE_EXPECT(SetActiveObject);
79 DEFINE_EXPECT(SetActiveObject_null);
80 DEFINE_EXPECT(GetWindow);
81 DEFINE_EXPECT(CanInPlaceActivate);
82 DEFINE_EXPECT(OnInPlaceActivate);
83 DEFINE_EXPECT(OnInPlaceActivateEx);
84 DEFINE_EXPECT(OnUIActivate);
85 DEFINE_EXPECT(GetWindowContext);
86 DEFINE_EXPECT(OnUIDeactivate);
87 DEFINE_EXPECT(OnInPlaceDeactivate);
88 DEFINE_EXPECT(OnInPlaceDeactivateEx);
89 DEFINE_EXPECT(GetContainer);
90 DEFINE_EXPECT(ShowUI);
91 DEFINE_EXPECT(ActivateMe);
92 DEFINE_EXPECT(GetHostInfo);
93 DEFINE_EXPECT(HideUI);
94 DEFINE_EXPECT(GetOptionKeyPath);
95 DEFINE_EXPECT(GetOverrideKeyPath);
96 DEFINE_EXPECT(SetStatusText);
97 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
98 DEFINE_EXPECT(QueryStatus_OPEN);
99 DEFINE_EXPECT(QueryStatus_NEW);
100 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
101 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
102 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
103 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
104 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
105 DEFINE_EXPECT(Exec_ShellDocView_37);
106 DEFINE_EXPECT(Exec_ShellDocView_63);
107 DEFINE_EXPECT(Exec_ShellDocView_67);
108 DEFINE_EXPECT(Exec_ShellDocView_84);
109 DEFINE_EXPECT(Exec_ShellDocView_103);
110 DEFINE_EXPECT(Exec_ShellDocView_105);
111 DEFINE_EXPECT(Exec_ShellDocView_140);
112 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
113 DEFINE_EXPECT(Exec_SETTITLE);
114 DEFINE_EXPECT(Exec_HTTPEQUIV);
115 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
116 DEFINE_EXPECT(Exec_Explorer_69);
117 DEFINE_EXPECT(Exec_DOCCANNAVIGATE);
118 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
119 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
120 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
121 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
122 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
123 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
124 DEFINE_EXPECT(GetDropTarget);
125 DEFINE_EXPECT(UpdateUI);
126 DEFINE_EXPECT(Navigate);
127 DEFINE_EXPECT(OnFrameWindowActivate);
128 DEFINE_EXPECT(OnChanged_READYSTATE);
129 DEFINE_EXPECT(OnChanged_1005);
130 DEFINE_EXPECT(OnChanged_1012);
131 DEFINE_EXPECT(GetDisplayName);
132 DEFINE_EXPECT(BindToStorage);
133 DEFINE_EXPECT(IsSystemMoniker);
134 DEFINE_EXPECT(GetBindResult);
135 DEFINE_EXPECT(GetClassID);
136 DEFINE_EXPECT(Abort);
138 DEFINE_EXPECT(CreateInstance);
139 DEFINE_EXPECT(Start);
140 DEFINE_EXPECT(Terminate);
141 DEFINE_EXPECT(Protocol_Read);
142 DEFINE_EXPECT(LockRequest);
143 DEFINE_EXPECT(UnlockRequest);
144 DEFINE_EXPECT(OnFocus_TRUE);
145 DEFINE_EXPECT(OnFocus_FALSE);
146 DEFINE_EXPECT(RequestUIActivate);
147 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
148 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
149 DEFINE_EXPECT(GetExternal);
150 DEFINE_EXPECT(EnableModeless_TRUE);
151 DEFINE_EXPECT(EnableModeless_FALSE);
152 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
153 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
154 DEFINE_EXPECT(Frame_GetWindow);
155 DEFINE_EXPECT(TranslateUrl);
156 DEFINE_EXPECT(Advise_Close);
157 DEFINE_EXPECT(OnViewChange);
159 static IUnknown *doc_unk;
160 static IMoniker *doc_mon;
161 static BOOL expect_LockContainer_fLock;
162 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
163 static BOOL ipsex, ipsw;
164 static BOOL set_clientsite, container_locked, navigated_load;
165 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
166 static BOOL editmode = FALSE, show_failed;
167 static BOOL inplace_deactivated;
168 static int stream_read, protocol_read;
169 static enum load_state_t {
178 static LPCOLESTR expect_status_text = NULL;
180 static const char html_page[] =
182 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
186 static const char css_data[] = "body {color: red}";
188 static const WCHAR http_urlW[] =
189 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
191 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
192 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
194 #define DOCHOST_DOCCANNAVIGATE 0
196 static HRESULT QueryInterface(REFIID riid, void **ppv);
197 static void test_MSHTML_QueryStatus(IHTMLDocument2*,DWORD);
199 #define test_readyState(u) _test_readyState(__LINE__,u)
200 static void _test_readyState(unsigned,IUnknown*);
202 static const WCHAR wszTimesNewRoman[] =
203 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
204 static const WCHAR wszArial[] =
205 {'A','r','i','a','l',0};
207 static const char *debugstr_guid(REFIID riid)
214 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
215 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
216 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
217 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
222 static int strcmp_wa(LPCWSTR strw, const char *stra)
225 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
226 return lstrcmpA(stra, buf);
229 static const WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
233 const WCHAR *p1 = str, *p2 = sub;
234 while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
235 if (!*p2) return str;
241 static BSTR a2bstr(const char *str)
246 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
247 ret = SysAllocStringLen(NULL, len);
248 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
253 static BOOL is_english(void)
255 return PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
256 && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
259 #define EXPECT_UPDATEUI 1
260 #define EXPECT_SETTITLE 2
262 static void test_timer(DWORD flags)
264 BOOL *b = &called_Exec_SETTITLE;
267 if(flags & EXPECT_UPDATEUI) {
268 SET_EXPECT(UpdateUI);
269 SET_EXPECT(Exec_UPDATECOMMANDS);
270 b = &called_UpdateUI;
272 if(flags & EXPECT_SETTITLE)
273 SET_EXPECT(Exec_SETTITLE);
275 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
276 TranslateMessage(&msg);
277 DispatchMessage(&msg);
280 if(flags & EXPECT_UPDATEUI) {
281 CHECK_CALLED(UpdateUI);
282 CHECK_CALLED(Exec_UPDATECOMMANDS);
284 if(flags & EXPECT_SETTITLE)
285 CHECK_CALLED(Exec_SETTITLE);
288 static IMoniker Moniker;
290 #define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
291 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
294 IPersistMoniker *permon;
295 IMoniker *mon = (void*)0xdeadbeef;
296 BSTR doc_url = (void*)0xdeadbeef;
299 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
300 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
304 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
305 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
307 hres = IHTMLDocument2_get_URL(doc, &doc_url);
308 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
310 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
311 IPersistMoniker_Release(permon);
315 BOOL exb = expect_GetDisplayName;
316 BOOL clb = called_GetDisplayName;
318 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
319 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
322 SET_EXPECT(GetDisplayName);
323 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
324 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
326 CHECK_CALLED(GetDisplayName);
327 expect_GetDisplayName = exb;
328 called_GetDisplayName = clb;
330 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
335 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
337 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
338 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
340 ok(!lstrcmpW(url, exurl), "unexpected url %s\n", wine_dbgstr_w(url));
341 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
345 ok(hres == E_UNEXPECTED,
346 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
347 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
348 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
351 SysFreeString(doc_url);
352 IHTMLDocument_Release(doc);
353 if(mon && mon != (void*)0xdeadbeef)
354 IMoniker_Release(mon);
357 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
359 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
363 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
368 if(IsEqualGUID(&IID_IProxyManager, riid))
369 return E_NOINTERFACE; /* TODO */
370 if(IsEqualGUID(&IID_IDispatchEx, riid))
371 return E_NOINTERFACE; /* TODO */
372 if(IsEqualGUID(&IID_External_unk, riid))
373 return E_NOINTERFACE; /* TODO */
375 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
376 return E_NOINTERFACE;
379 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
384 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
389 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
391 ok(0, "unexpected call\n");
395 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
398 ok(0, "unexpected call\n");
402 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
403 UINT cNames, LCID lcid, DISPID *rgDispId)
405 ok(0, "unexpected call\n");
409 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
410 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
411 EXCEPINFO *pExcepInfo, UINT *puArgErr)
413 ok(0, "unexpected call\n");
417 static const IDispatchVtbl ExternalVtbl = {
418 External_QueryInterface,
421 Dispatch_GetTypeInfoCount,
422 Dispatch_GetTypeInfo,
423 Dispatch_GetIDsOfNames,
427 static IDispatch External = { &ExternalVtbl };
429 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
431 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
437 return E_NOINTERFACE;
440 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
445 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
450 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
451 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
452 DWORD grfPI, HANDLE_PTR dwReserved)
458 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
459 static const WCHAR empty_str = {0};
463 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
464 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
465 ok(!grfPI, "grfPI = %x\n", grfPI);
466 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
468 memset(&bindinfo, 0, sizeof(bindinfo));
469 bindinfo.cbSize = sizeof(bindinfo);
470 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
471 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
472 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
473 "bindf = %x\n", bindf);
475 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
476 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
477 /* TODO: test stgmedData */
478 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
479 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
480 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
481 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
482 ok(bindinfo.dwOptions == 0x80000 ||
483 bindinfo.dwOptions == 0x4080000, /* win2k3 */
484 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
485 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
486 /* TODO: test dwCodePage */
487 /* TODO: test securityAttributes */
488 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
489 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
490 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
492 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
493 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
494 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
496 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
497 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
499 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
501 hres = IInternetProtocolSink_ReportData(pOIProtSink,
502 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
503 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
505 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
506 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
511 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
512 PROTOCOLDATA *pProtocolData)
514 ok(0, "unexpected call\n");
518 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
521 ok(0, "unexpected call\n");
525 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
527 CHECK_EXPECT(Terminate);
531 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
533 ok(0, "unexpected call\n");
537 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
539 ok(0, "unexpected call\n");
543 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
544 ULONG cb, ULONG *pcbRead)
546 CHECK_EXPECT2(Protocol_Read);
548 ok(pv != NULL, "pv == NULL\n");
549 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
550 ok(pcbRead != NULL, "pcbRead == NULL\n");
551 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
556 protocol_read += *pcbRead = sizeof(css_data)-1;
557 memcpy(pv, css_data, sizeof(css_data)-1);
561 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
562 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
564 ok(0, "unexpected call\n");
568 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
570 CHECK_EXPECT(LockRequest);
574 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
576 CHECK_EXPECT(UnlockRequest);
580 static const IInternetProtocolVtbl ProtocolVtbl = {
581 Protocol_QueryInterface,
592 Protocol_LockRequest,
593 Protocol_UnlockRequest
596 static IInternetProtocol Protocol = { &ProtocolVtbl };
598 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
600 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
601 ok(0, "unexpected call\n");
602 return E_NOINTERFACE;
605 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
610 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
615 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
616 REFIID riid, void **ppv)
618 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
619 return E_NOINTERFACE;
621 CHECK_EXPECT(CreateInstance);
622 ok(ppv != NULL, "ppv == NULL\n");
628 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
630 ok(0, "unexpected call\n");
634 static const IClassFactoryVtbl ClassFactoryVtbl = {
635 ClassFactory_QueryInterface,
637 ClassFactory_Release,
638 ClassFactory_CreateInstance,
639 ClassFactory_LockServer
642 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
644 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
646 ok(0, "unexpected call\n");
650 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
655 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
660 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
661 IHlinkBrowseContext *pihlbc)
663 ok(0, "unexpected call\n");
667 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
668 IHlinkBrowseContext **ppihlbc)
670 ok(0, "unexpected call\n");
674 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
675 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
679 CHECK_EXPECT(Navigate);
681 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
682 ok(pbc != NULL, "pbc == NULL\n");
683 ok(pibsc != NULL, "pubsc == NULL\n");
684 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
687 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
688 LPWSTR location = (LPWSTR)0xdeadbeef;
690 IMoniker *mon = NULL;
691 DWORD site_data = 0xdeadbeef;
693 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
695 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
696 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
698 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
699 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
700 ok(location == NULL, "location = %p\n", location);
701 ok(mon != NULL, "mon == NULL\n");
703 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
704 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
705 ok(site == NULL, "site = %p\n, expected NULL\n", site);
707 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
713 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
714 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
716 ok(0, "unexpected call\n");
720 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
721 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
723 ok(0, "unexpected call\n");
727 static const IHlinkFrameVtbl HlinkFrameVtbl = {
728 HlinkFrame_QueryInterface,
731 HlinkFrame_SetBrowseContext,
732 HlinkFrame_GetBrowseContext,
734 HlinkFrame_OnNavigate,
735 HlinkFrame_UpdateHlink
738 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
740 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
741 REFIID riid, void**ppv)
743 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
748 ok(0, "unexpected call\n");
749 return E_NOINTERFACE;
752 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
757 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
762 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
765 case DISPID_READYSTATE:
766 CHECK_EXPECT2(OnChanged_READYSTATE);
768 if(!readystate_set_interactive)
769 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
770 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
771 ? OLECMDF_ENABLED : 0));
773 if(readystate_set_loading) {
774 readystate_set_loading = FALSE;
775 load_state = LD_LOADING;
777 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
778 test_readyState(NULL);
781 CHECK_EXPECT(OnChanged_1005);
783 test_readyState(NULL);
784 readystate_set_interactive = (load_state != LD_INTERACTIVE);
787 CHECK_EXPECT(OnChanged_1012);
796 ok(0, "unexpected id %d\n", dispID);
800 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
802 ok(0, "unexpected call\n");
806 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
807 PropertyNotifySink_QueryInterface,
808 PropertyNotifySink_AddRef,
809 PropertyNotifySink_Release,
810 PropertyNotifySink_OnChanged,
811 PropertyNotifySink_OnRequestEdit
814 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
816 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
818 ok(0, "unexpected call\n");
819 return E_NOINTERFACE;
822 static ULONG WINAPI Stream_AddRef(IStream *iface)
827 static ULONG WINAPI Stream_Release(IStream *iface)
832 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
833 ULONG cb, ULONG *pcbRead)
836 ok(pv != NULL, "pv == NULL\n");
837 ok(cb > sizeof(html_page), "cb = %d\n", cb);
838 ok(pcbRead != NULL, "pcbRead == NULL\n");
839 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
844 memcpy(pv, html_page, sizeof(html_page)-1);
845 stream_read += *pcbRead = sizeof(html_page)-1;
849 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
850 ULONG cb, ULONG *pcbWritten)
852 ok(0, "unexpected call\n");
856 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
857 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
859 ok(0, "unexpected call\n");
863 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
865 ok(0, "unexpected call\n");
869 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
870 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
872 ok(0, "unexpected call\n");
876 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
878 ok(0, "unexpected call\n");
882 static HRESULT WINAPI Stream_Revert(IStream *iface)
884 ok(0, "unexpected call\n");
888 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
889 ULARGE_INTEGER cb, DWORD dwLockType)
891 ok(0, "unexpected call\n");
895 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
896 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
898 ok(0, "unexpected call\n");
902 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
905 ok(0, "unexpected call\n");
909 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
911 ok(0, "unexpected call\n");
915 static const IStreamVtbl StreamVtbl = {
916 Stream_QueryInterface,
932 static IStream Stream = { &StreamVtbl };
934 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
936 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
937 return E_NOINTERFACE; /* TODO */
939 if(IsEqualGUID(&IID_IWinInetInfo, riid))
940 return E_NOINTERFACE; /* TODO */
942 ok(0, "unexpected call\n");
943 return E_NOINTERFACE;
946 static ULONG WINAPI Binding_AddRef(IBinding *iface)
951 static ULONG WINAPI Binding_Release(IBinding *iface)
956 static HRESULT WINAPI Binding_Abort(IBinding *iface)
962 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
964 ok(0, "unexpected call\n");
968 static HRESULT WINAPI Binding_Resume(IBinding *iface)
970 ok(0, "unexpected call\n");
974 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
976 ok(0, "unexpected call\n");
980 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
982 ok(0, "unexpected call\n");
986 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
987 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
989 CHECK_EXPECT(GetBindResult);
993 static const IBindingVtbl BindingVtbl = {
994 Binding_QueryInterface,
1000 Binding_SetPriority,
1001 Binding_GetPriority,
1002 Binding_GetBindResult
1005 static IBinding Binding = { &BindingVtbl };
1007 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
1008 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
1010 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
1014 if(IsEqualGUID(&IID_IMoniker_unk, riid))
1015 return E_NOINTERFACE; /* TODO */
1016 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
1017 return E_NOINTERFACE; /* TODO */
1019 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
1020 return E_NOINTERFACE;
1023 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
1028 static ULONG WINAPI Moniker_Release(IMoniker *iface)
1033 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
1035 CHECK_EXPECT(GetClassID);
1036 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
1040 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
1042 ok(0, "unexpected call\n");
1046 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1048 ok(0, "unexpected call\n");
1052 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1054 ok(0, "unexpected call\n");
1058 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1060 ok(0, "unexpected call\n");
1064 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1065 REFIID riidResult, void **ppvResult)
1067 ok(0, "unexpected call\n");
1071 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1072 REFIID riid, void **ppv)
1074 IBindStatusCallback *callback = NULL;
1075 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1076 STGMEDIUM stgmedium;
1081 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1082 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1084 CHECK_EXPECT(BindToStorage);
1086 load_state = LD_LOADING;
1088 ok(pbc != NULL, "pbc == NULL\n");
1089 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1090 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1091 ok(ppv != NULL, "ppv == NULL\n");
1092 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1094 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1095 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1096 ok(callback != NULL, "callback == NULL\n");
1098 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1099 bindinfo.cbSize = sizeof(bindinfo);
1101 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1102 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1103 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
1104 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
1105 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1106 /* TODO: test stgmedData */
1107 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
1108 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
1109 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1110 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
1111 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
1112 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
1113 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
1114 /* TODO: test dwCodePage */
1115 /* TODO: test securityAttributes */
1116 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1117 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1118 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
1120 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1121 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1123 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1125 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1127 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1128 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1129 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1132 stgmedium.tymed = TYMED_ISTREAM;
1133 U(stgmedium).pstm = &Stream;
1134 stgmedium.pUnkForRelease = (IUnknown*)iface;
1135 hres = IBindStatusCallback_OnDataAvailable(callback,
1136 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1137 sizeof(html_page)-1, &formatetc, &stgmedium);
1138 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1141 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1142 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1143 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1145 SET_EXPECT(GetBindResult);
1146 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1147 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1148 SET_CALLED(GetBindResult); /* IE7 */
1150 IBindStatusCallback_Release(callback);
1155 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1156 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1158 ok(0, "unexpected call\n");
1162 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1163 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1165 ok(0, "unexpected call\n");
1169 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1171 ok(0, "unexpected call\n");
1175 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1177 ok(0, "unexpected call\n");
1181 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1183 ok(0, "unexpected call\n");
1187 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1188 IMoniker *pmkNewlyRunning)
1190 ok(0, "unexpected call\n");
1194 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1195 IMoniker *pmkToLeft, FILETIME *pFileTime)
1197 ok(0, "unexpected call\n");
1201 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1203 ok(0, "unexpected call\n");
1207 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1208 IMoniker **ppmkPrefix)
1210 ok(0, "unexpected call\n");
1214 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1215 IMoniker **pmkRelPath)
1217 ok(0, "unexpected call\n");
1221 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1222 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1224 CHECK_EXPECT2(GetDisplayName);
1226 /* ok(pbc != NULL, "pbc == NULL\n"); */
1227 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1228 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1230 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1231 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1236 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1237 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1239 ok(0, "unexpected call\n");
1243 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1245 CHECK_EXPECT(IsSystemMoniker);
1249 static const IMonikerVtbl MonikerVtbl = {
1250 Moniker_QueryInterface,
1258 Moniker_BindToObject,
1259 Moniker_BindToStorage,
1261 Moniker_ComposeWith,
1266 Moniker_GetTimeOfLastChange,
1268 Moniker_CommonPrefixWith,
1269 Moniker_RelativePathTo,
1270 Moniker_GetDisplayName,
1271 Moniker_ParseDisplayName,
1272 Moniker_IsSystemMoniker
1275 static IMoniker Moniker = { &MonikerVtbl };
1277 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1279 return QueryInterface(riid, ppv);
1282 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1287 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1292 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1293 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1295 ok(0, "unexpected call\n");
1299 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1300 IEnumUnknown **ppenum)
1302 ok(0, "unexpected call\n");
1306 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1308 CHECK_EXPECT(LockContainer);
1309 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1313 static const IOleContainerVtbl OleContainerVtbl = {
1314 OleContainer_QueryInterface,
1315 OleContainer_AddRef,
1316 OleContainer_Release,
1317 OleContainer_ParseDisplayName,
1318 OleContainer_EnumObjects,
1319 OleContainer_LockContainer
1322 static IOleContainer OleContainer = { &OleContainerVtbl };
1324 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1326 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1328 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1329 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1332 return E_NOINTERFACE;
1335 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1340 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1345 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1347 CHECK_EXPECT(Frame_GetWindow);
1351 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1353 ok(0, "unexpected call\n");
1357 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1359 ok(0, "unexpected call\n");
1363 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1364 LPCBORDERWIDTHS pborderwidths)
1366 ok(0, "unexpected call\n");
1370 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1371 LPCBORDERWIDTHS pborderwidths)
1373 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1377 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1378 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1380 static const WCHAR wszHTML_Document[] =
1381 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1383 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1385 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1386 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1387 if(pActiveObject && is_english())
1388 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1391 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1392 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1394 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1398 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1399 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1401 static const WCHAR wszHTML_Document[] =
1402 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1405 CHECK_EXPECT2(SetActiveObject);
1407 if(pActiveObject && is_english())
1408 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1410 CHECK_EXPECT(SetActiveObject_null);
1412 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1413 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1419 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1420 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1422 ok(0, "unexpected call\n");
1426 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1427 HOLEMENU holemenu, HWND hwndActiveObject)
1429 ok(0, "unexpected call\n");
1433 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1435 ok(0, "unexpected call\n");
1439 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1441 CHECK_EXPECT2(SetStatusText);
1442 if(!expect_status_text)
1443 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1447 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1450 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
1452 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
1456 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1458 ok(0, "unexpected call\n");
1462 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1463 InPlaceFrame_QueryInterface,
1464 InPlaceFrame_AddRef,
1465 InPlaceFrame_Release,
1466 InPlaceFrame_GetWindow,
1467 InPlaceFrame_ContextSensitiveHelp,
1468 InPlaceFrame_GetBorder,
1469 InPlaceFrame_RequestBorderSpace,
1470 InPlaceFrame_SetBorderSpace,
1471 InPlaceFrame_SetActiveObject,
1472 InPlaceFrame_InsertMenus,
1473 InPlaceFrame_SetMenu,
1474 InPlaceFrame_RemoveMenus,
1475 InPlaceFrame_SetStatusText,
1476 InPlaceFrame_EnableModeless,
1477 InPlaceFrame_TranslateAccelerator
1480 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1482 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1483 InPlaceFrame_QueryInterface,
1484 InPlaceFrame_AddRef,
1485 InPlaceFrame_Release,
1486 InPlaceFrame_GetWindow,
1487 InPlaceFrame_ContextSensitiveHelp,
1488 InPlaceFrame_GetBorder,
1489 InPlaceFrame_RequestBorderSpace,
1490 InPlaceFrame_SetBorderSpace,
1491 InPlaceUIWindow_SetActiveObject,
1494 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1496 static HRESULT WINAPI InPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
1498 return QueryInterface(riid, ppv);
1501 static ULONG WINAPI InPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
1506 static ULONG WINAPI InPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
1511 static HRESULT WINAPI InPlaceSiteWindowless_GetWindow(
1512 IOleInPlaceSiteWindowless *iface, HWND *phwnd)
1514 CHECK_EXPECT2(GetWindow);
1515 ok(phwnd != NULL, "phwnd = NULL\n");
1516 *phwnd = container_hwnd;
1520 static HRESULT WINAPI InPlaceSiteWindowless_ContextSensitiveHelp(
1521 IOleInPlaceSiteWindowless *iface, BOOL fEnterMode)
1523 ok(0, "unexpected call\n");
1527 static HRESULT WINAPI InPlaceSiteWindowless_CanInPlaceActivate(
1528 IOleInPlaceSiteWindowless *iface)
1530 CHECK_EXPECT(CanInPlaceActivate);
1534 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivate(
1535 IOleInPlaceSiteWindowless *iface)
1537 CHECK_EXPECT(OnInPlaceActivate);
1538 inplace_deactivated = FALSE;
1542 static HRESULT WINAPI InPlaceSiteWindowless_OnUIActivate(
1543 IOleInPlaceSiteWindowless *iface)
1545 CHECK_EXPECT(OnUIActivate);
1549 static HRESULT WINAPI InPlaceSiteWindowless_GetWindowContext(
1550 IOleInPlaceSiteWindowless *iface, IOleInPlaceFrame **ppFrame,
1551 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1552 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1554 static const RECT rect = {0,0,500,500};
1556 CHECK_EXPECT(GetWindowContext);
1558 ok(ppFrame != NULL, "ppFrame = NULL\n");
1560 *ppFrame = &InPlaceFrame;
1561 ok(ppDoc != NULL, "ppDoc = NULL\n");
1563 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1564 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1566 memcpy(lprcPosRect, &rect, sizeof(RECT));
1567 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1569 memcpy(lprcClipRect, &rect, sizeof(RECT));
1570 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1572 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1573 lpFrameInfo->fMDIApp = FALSE;
1574 lpFrameInfo->hwndFrame = container_hwnd;
1575 lpFrameInfo->haccel = NULL;
1576 lpFrameInfo->cAccelEntries = 0;
1582 static HRESULT WINAPI InPlaceSiteWindowless_Scroll(
1583 IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
1585 ok(0, "unexpected call\n");
1589 static HRESULT WINAPI InPlaceSiteWindowless_OnUIDeactivate(
1590 IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
1592 CHECK_EXPECT(OnUIDeactivate);
1593 ok(!fUndoable, "fUndoable = TRUE\n");
1597 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivate(
1598 IOleInPlaceSiteWindowless *iface)
1600 CHECK_EXPECT(OnInPlaceDeactivate);
1601 inplace_deactivated = TRUE;
1605 static HRESULT WINAPI InPlaceSiteWindowless_DiscardUndoState(
1606 IOleInPlaceSiteWindowless *iface)
1608 ok(0, "unexpected call\n");
1612 static HRESULT WINAPI InPlaceSiteWindowless_DeactivateAndUndo(
1613 IOleInPlaceSiteWindowless *iface)
1615 ok(0, "unexpected call\n");
1619 static HRESULT WINAPI InPlaceSiteWindowless_OnPosRectChange(
1620 IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
1622 ok(0, "unexpected call\n");
1626 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivateEx(
1627 IOleInPlaceSiteWindowless *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1629 CHECK_EXPECT(OnInPlaceActivateEx);
1631 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1632 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1633 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1638 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivateEx(
1639 IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
1641 CHECK_EXPECT(OnInPlaceDeactivateEx);
1643 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1648 static HRESULT WINAPI InPlaceSiteWindowless_RequestUIActivate(
1649 IOleInPlaceSiteWindowless *iface)
1651 CHECK_EXPECT2(RequestUIActivate);
1655 static HRESULT WINAPI InPlaceSiteWindowless_CanWindowlessActivate(
1656 IOleInPlaceSiteWindowless *iface)
1658 ok(0, "unexpected call\n");
1662 static HRESULT WINAPI InPlaceSiteWindowless_GetCapture(
1663 IOleInPlaceSiteWindowless *iface)
1665 ok(0, "unexpected call\n");
1669 static HRESULT WINAPI InPlaceSiteWindowless_SetCapture(
1670 IOleInPlaceSiteWindowless *iface, BOOL fCapture)
1672 ok(0, "unexpected call\n");
1676 static HRESULT WINAPI InPlaceSiteWindowless_GetFocus(
1677 IOleInPlaceSiteWindowless *iface)
1679 ok(0, "unexpected call\n");
1683 static HRESULT WINAPI InPlaceSiteWindowless_SetFocus(
1684 IOleInPlaceSiteWindowless *iface, BOOL fFocus)
1686 ok(0, "unexpected call\n");
1690 static HRESULT WINAPI InPlaceSiteWindowless_GetDC(
1691 IOleInPlaceSiteWindowless *iface, LPCRECT pRect,
1692 DWORD grfFlags, HDC *phDC)
1694 ok(0, "unexpected call\n");
1698 static HRESULT WINAPI InPlaceSiteWindowless_ReleaseDC(
1699 IOleInPlaceSiteWindowless *iface, HDC hDC)
1701 ok(0, "unexpected call\n");
1705 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRect(
1706 IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
1708 ok(0, "unexpected call\n");
1712 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRgn(
1713 IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
1715 ok(0, "unexpected call\n");
1719 static HRESULT WINAPI InPlaceSiteWindowless_ScrollRect(
1720 IOleInPlaceSiteWindowless *iface, INT dx, INT dy,
1721 LPCRECT pRectScroll, LPCRECT pRectClip)
1723 ok(0, "unexpected call\n");
1727 static HRESULT WINAPI InPlaceSiteWindowless_AdjustRect(
1728 IOleInPlaceSiteWindowless *iface, LPRECT prc)
1730 ok(0, "unexpected call\n");
1734 static HRESULT WINAPI InPlaceSiteWindowless_OnDefWindowMessage(
1735 IOleInPlaceSiteWindowless *iface, UINT msg,
1736 WPARAM wParam, LPARAM lParam, LRESULT *plResult)
1738 ok(0, "unexpected call\n");
1742 static const IOleInPlaceSiteWindowlessVtbl InPlaceSiteWindowlessVtbl = {
1743 InPlaceSiteWindowless_QueryInterface,
1744 InPlaceSiteWindowless_AddRef,
1745 InPlaceSiteWindowless_Release,
1746 InPlaceSiteWindowless_GetWindow,
1747 InPlaceSiteWindowless_ContextSensitiveHelp,
1748 InPlaceSiteWindowless_CanInPlaceActivate,
1749 InPlaceSiteWindowless_OnInPlaceActivate,
1750 InPlaceSiteWindowless_OnUIActivate,
1751 InPlaceSiteWindowless_GetWindowContext,
1752 InPlaceSiteWindowless_Scroll,
1753 InPlaceSiteWindowless_OnUIDeactivate,
1754 InPlaceSiteWindowless_OnInPlaceDeactivate,
1755 InPlaceSiteWindowless_DiscardUndoState,
1756 InPlaceSiteWindowless_DeactivateAndUndo,
1757 InPlaceSiteWindowless_OnPosRectChange,
1758 InPlaceSiteWindowless_OnInPlaceActivateEx,
1759 InPlaceSiteWindowless_OnInPlaceDeactivateEx,
1760 InPlaceSiteWindowless_RequestUIActivate,
1761 InPlaceSiteWindowless_CanWindowlessActivate,
1762 InPlaceSiteWindowless_GetCapture,
1763 InPlaceSiteWindowless_SetCapture,
1764 InPlaceSiteWindowless_GetFocus,
1765 InPlaceSiteWindowless_SetFocus,
1766 InPlaceSiteWindowless_GetDC,
1767 InPlaceSiteWindowless_ReleaseDC,
1768 InPlaceSiteWindowless_InvalidateRect,
1769 InPlaceSiteWindowless_InvalidateRgn,
1770 InPlaceSiteWindowless_ScrollRect,
1771 InPlaceSiteWindowless_AdjustRect,
1772 InPlaceSiteWindowless_OnDefWindowMessage
1775 static IOleInPlaceSiteWindowless InPlaceSiteWindowless = { &InPlaceSiteWindowlessVtbl };
1777 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1779 return QueryInterface(riid, ppv);
1782 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1787 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1792 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1794 ok(0, "unexpected call\n");
1798 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1801 ok(0, "unexpected call\n");
1805 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1807 CHECK_EXPECT(GetContainer);
1808 ok(ppContainer != NULL, "ppContainer = NULL\n");
1809 *ppContainer = &OleContainer;
1813 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1815 ok(0, "unexpected call\n");
1819 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1821 ok(0, "unexpected call\n");
1825 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1827 ok(0, "unexpected call\n");
1831 static const IOleClientSiteVtbl ClientSiteVtbl = {
1832 ClientSite_QueryInterface,
1835 ClientSite_SaveObject,
1836 ClientSite_GetMoniker,
1837 ClientSite_GetContainer,
1838 ClientSite_ShowObject,
1839 ClientSite_OnShowWindow,
1840 ClientSite_RequestNewObjectLayout
1843 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1845 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1847 return QueryInterface(riid, ppv);
1850 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1855 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1862 CallUIActivate_None,
1863 CallUIActivate_ActivateMe,
1864 CallUIActivate_AfterShow,
1867 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1868 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1870 IOleDocument *document;
1873 CHECK_EXPECT(ActivateMe);
1874 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1876 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1877 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1879 if(SUCCEEDED(hres)) {
1880 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteWindowless, NULL, 0, &view);
1881 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1883 if(SUCCEEDED(hres)) {
1884 IOleInPlaceActiveObject *activeobj = NULL;
1885 IOleInPlaceSite *inplacesite = NULL;
1886 HWND tmp_hwnd = NULL;
1887 static RECT rect = {0,0,400,500};
1889 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1890 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1891 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
1892 inplacesite, &InPlaceSiteWindowless);
1894 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteWindowless);
1895 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1897 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1898 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1899 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
1900 inplacesite, &InPlaceSiteWindowless);
1902 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1903 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1906 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1907 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1908 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1911 if(call_UIActivate == CallUIActivate_ActivateMe) {
1912 SET_EXPECT(CanInPlaceActivate);
1913 SET_EXPECT(GetWindowContext);
1914 SET_EXPECT(GetWindow);
1916 SET_EXPECT(OnInPlaceActivateEx);
1918 SET_EXPECT(OnInPlaceActivate);
1919 SET_EXPECT(SetStatusText);
1920 SET_EXPECT(Exec_SETPROGRESSMAX);
1921 SET_EXPECT(Exec_SETPROGRESSPOS);
1922 SET_EXPECT(OnUIActivate);
1923 SET_EXPECT(SetActiveObject);
1925 expect_status_text = NULL;
1927 hres = IOleDocumentView_UIActivate(view, TRUE);
1928 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1930 CHECK_CALLED(CanInPlaceActivate);
1931 CHECK_CALLED(GetWindowContext);
1932 CHECK_CALLED(GetWindow);
1934 CHECK_CALLED(OnInPlaceActivateEx);
1936 CHECK_CALLED(OnInPlaceActivate);
1937 CHECK_CALLED(SetStatusText);
1938 CHECK_CALLED(Exec_SETPROGRESSMAX);
1939 CHECK_CALLED(Exec_SETPROGRESSPOS);
1940 CHECK_CALLED(OnUIActivate);
1941 CHECK_CALLED(SetActiveObject);
1942 CHECK_CALLED(ShowUI);
1945 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1946 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1947 ok(hwnd != NULL, "hwnd == NULL\n");
1949 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1952 hres = IOleDocumentView_UIActivate(view, TRUE);
1953 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1956 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1957 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1958 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1962 hres = IOleDocumentView_SetRect(view, &rect);
1963 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1965 if(call_UIActivate == CallUIActivate_ActivateMe) {
1966 hres = IOleDocumentView_Show(view, TRUE);
1967 ok(hres == S_OK, "Show failed: %08x\n", hres);
1969 SET_EXPECT(CanInPlaceActivate);
1970 SET_EXPECT(GetWindowContext);
1971 SET_EXPECT(GetWindow);
1973 SET_EXPECT(OnInPlaceActivateEx);
1975 SET_EXPECT(OnInPlaceActivate);
1976 SET_EXPECT(SetStatusText);
1977 SET_EXPECT(Exec_SETPROGRESSMAX);
1978 SET_EXPECT(Exec_SETPROGRESSPOS);
1979 SET_EXPECT(OnUIActivate);
1980 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1982 hres = IOleDocumentView_Show(view, TRUE);
1984 win_skip("Show failed\n");
1986 IOleInPlaceActiveObject_Release(activeobj);
1987 IOleDocument_Release(document);
1991 ok(hres == S_OK, "Show failed: %08x\n", hres);
1993 CHECK_CALLED(CanInPlaceActivate);
1994 CHECK_CALLED(GetWindowContext);
1995 CHECK_CALLED(GetWindow);
1997 CHECK_CALLED(OnInPlaceActivateEx);
1999 CHECK_CALLED(OnInPlaceActivate);
2000 CHECK_CALLED(SetStatusText);
2001 CHECK_CALLED(Exec_SETPROGRESSMAX);
2002 CHECK_CALLED(Exec_SETPROGRESSPOS);
2005 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2006 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2007 ok(hwnd != NULL, "hwnd == NULL\n");
2009 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
2013 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
2016 IOleInPlaceActiveObject_Release(activeobj);
2019 IOleDocument_Release(document);
2025 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
2026 DocumentSite_QueryInterface,
2027 DocumentSite_AddRef,
2028 DocumentSite_Release,
2029 DocumentSite_ActivateMe
2032 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
2034 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
2036 return QueryInterface(riid, ppv);
2039 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
2044 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
2049 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
2051 ok(0, "unexpected call\n");
2055 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
2057 ok(0, "unexpected call\n");
2061 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
2063 ok(0, "unexpected call\n");
2067 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
2068 POINTF *pPtfContainer, DWORD dwFlags)
2070 ok(0, "unexpected call\n");
2074 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
2075 MSG *pMsg, DWORD grfModifiers)
2077 ok(0, "unexpected call\n");
2081 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
2084 CHECK_EXPECT(OnFocus_TRUE);
2086 CHECK_EXPECT2(OnFocus_FALSE);
2090 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
2092 ok(0, "unexpected call\n");
2096 static const IOleControlSiteVtbl OleControlSiteVtbl = {
2097 OleControlSite_QueryInterface,
2098 OleControlSite_AddRef,
2099 OleControlSite_Release,
2100 OleControlSite_OnControlInfoChanged,
2101 OleControlSite_LockInPlaceActive,
2102 OleControlSite_GetExtendedControl,
2103 OleControlSite_TransformCoords,
2104 OleControlSite_TranslateAccelerator,
2105 OleControlSite_OnFocus,
2106 OleControlSite_ShowPropertyFrame
2109 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
2111 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2113 return QueryInterface(riid, ppv);
2116 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
2121 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
2126 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
2127 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
2129 ok(0, "unexpected call\n");
2133 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
2135 CHECK_EXPECT(GetHostInfo);
2136 ok(pInfo != NULL, "pInfo=NULL\n");
2138 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
2139 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
2140 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
2141 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
2142 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
2143 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
2144 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
2145 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
2150 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
2151 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
2152 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
2154 CHECK_EXPECT(ShowUI);
2157 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
2159 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
2160 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2161 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
2162 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2163 if (expect_InPlaceUIWindow_SetActiveObject_active)
2164 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2166 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2171 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2173 CHECK_EXPECT(HideUI);
2177 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2179 CHECK_EXPECT(UpdateUI);
2183 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2186 CHECK_EXPECT2(EnableModeless_TRUE);
2188 CHECK_EXPECT2(EnableModeless_FALSE);
2192 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2194 ok(0, "unexpected call\n");
2198 static BOOL expect_OnFrameWindowActivate_fActivate;
2199 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2201 CHECK_EXPECT2(OnFrameWindowActivate);
2202 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2206 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2207 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2209 ok(0, "unexpected call\n");
2213 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2214 const GUID *pguidCmdGroup, DWORD nCmdID)
2216 ok(0, "unexpected call\n");
2220 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2221 LPOLESTR *pchKey, DWORD dw)
2223 CHECK_EXPECT(GetOptionKeyPath);
2224 ok(pchKey != NULL, "pchKey = NULL\n");
2225 ok(!dw, "dw=%d, expected 0\n", dw);
2227 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2231 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2232 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2234 CHECK_EXPECT(GetDropTarget);
2239 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2241 CHECK_EXPECT(GetExternal);
2242 *ppDispatch = &External;
2246 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2247 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2249 CHECK_EXPECT(TranslateUrl);
2250 ok(!dwTranslate, "dwTranslate = %x\n", dwTranslate);
2251 ok(!strcmp_wa(pchURLIn, "about:blank"), "pchURLIn = %s\n", wine_dbgstr_w(pchURLIn));
2252 ok(ppchURLOut != NULL, "ppchURLOut == NULL\n");
2253 ok(!*ppchURLOut, "*ppchURLOut = %p\n", *ppchURLOut);
2258 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2259 IDataObject **ppPORet)
2261 ok(0, "unexpected call\n");
2265 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2266 LPOLESTR *pchKey, DWORD dw)
2268 CHECK_EXPECT(GetOverrideKeyPath);
2269 ok(pchKey != NULL, "pchKey = NULL\n");
2271 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2272 ok(!dw, "dw=%d, xepected 0\n", dw);
2276 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2277 DocHostUIHandler_QueryInterface,
2278 DocHostUIHandler_AddRef,
2279 DocHostUIHandler_Release,
2280 DocHostUIHandler_ShowContextMenu,
2281 DocHostUIHandler_GetHostInfo,
2282 DocHostUIHandler_ShowUI,
2283 DocHostUIHandler_HideUI,
2284 DocHostUIHandler_UpdateUI,
2285 DocHostUIHandler_EnableModeless,
2286 DocHostUIHandler_OnDocWindowActivate,
2287 DocHostUIHandler_OnFrameWindowActivate,
2288 DocHostUIHandler_ResizeBorder,
2289 DocHostUIHandler_TranslateAccelerator,
2290 DocHostUIHandler_GetOptionKeyPath,
2291 DocHostUIHandler_GetDropTarget,
2292 DocHostUIHandler_GetExternal,
2293 DocHostUIHandler_TranslateUrl,
2294 DocHostUIHandler_FilterDataObject,
2295 DocHostUIHandler_GetOverrideKeyPath
2298 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2300 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2301 REFIID riid, void **ppv)
2303 return QueryInterface(riid, ppv);
2306 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2311 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2316 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2317 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2319 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2320 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2321 ok(!pCmdText, "pCmdText != NULL\n");
2323 switch(prgCmds[0].cmdID) {
2324 case OLECMDID_SETPROGRESSTEXT:
2325 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2326 prgCmds[0].cmdf = OLECMDF_ENABLED;
2329 CHECK_EXPECT(QueryStatus_OPEN);
2330 prgCmds[0].cmdf = 0;
2333 CHECK_EXPECT(QueryStatus_NEW);
2334 prgCmds[0].cmdf = 0;
2337 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2343 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2344 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2346 if((!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2347 && (!pguidCmdGroup || !IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup) || nCmdID != 63))
2348 test_readyState(NULL);
2350 if(!pguidCmdGroup) {
2352 case OLECMDID_SETPROGRESSMAX:
2353 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2354 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2355 ok(pvaIn != NULL, "pvaIn == NULL\n");
2357 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2358 if(load_state == LD_NO)
2359 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2361 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2363 case OLECMDID_SETPROGRESSPOS:
2364 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2365 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2366 ok(pvaIn != NULL, "pvaIn == NULL\n");
2368 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2369 if(load_state == LD_NO)
2370 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2372 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2374 case OLECMDID_HTTPEQUIV_DONE:
2375 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2376 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2377 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2378 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2379 readystate_set_loading = FALSE;
2380 readystate_set_interactive = FALSE;
2381 load_state = LD_COMPLETE;
2383 case OLECMDID_SETDOWNLOADSTATE:
2384 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2385 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2386 ok(pvaIn != NULL, "pvaIn == NULL\n");
2387 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2389 switch(V_I4(pvaIn)) {
2391 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2392 load_state = LD_INTERACTIVE;
2395 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2396 readystate_set_interactive = (load_state != LD_INTERACTIVE);
2399 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2403 case OLECMDID_UPDATECOMMANDS:
2404 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2405 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2406 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2407 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2409 case OLECMDID_SETTITLE:
2410 CHECK_EXPECT2(Exec_SETTITLE);
2411 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2412 ok(pvaIn != NULL, "pvaIn == NULL\n");
2413 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2414 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2415 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2417 case OLECMDID_HTTPEQUIV:
2418 CHECK_EXPECT2(Exec_HTTPEQUIV);
2419 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
2420 ok(pvaIn != NULL, "pvaIn == NULL\n");
2421 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2422 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2423 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
2424 test_readyState(NULL);
2427 ok(0, "unexpected command %d\n", nCmdID);
2432 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2433 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2437 CHECK_EXPECT2(Exec_ShellDocView_37);
2439 if(load_from_stream || navigated_load)
2440 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2442 test_GetCurMoniker(doc_unk, doc_mon, NULL);
2444 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2445 ok(pvaIn != NULL, "pvaIn == NULL\n");
2447 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2448 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2453 IHTMLPrivateWindow *priv_window;
2456 CHECK_EXPECT(Exec_ShellDocView_63);
2457 ok(pvaIn != NULL, "pvaIn == NULL\n");
2458 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2459 ok(V_UNKNOWN(pvaIn) != NULL, "VPUNKNOWN(pvaIn) = NULL\n");
2460 ok(pvaOut != NULL, "pvaOut == NULL\n");
2461 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2463 hres = IUnknown_QueryInterface(V_UNKNOWN(pvaIn), &IID_IHTMLPrivateWindow, (void**)&priv_window);
2464 ok(hres == S_OK, "Could not get IHTMLPrivateWindow: %08x\n", hres);
2466 IHTMLPrivateWindow_Release(priv_window);
2468 load_state = LD_LOADING;
2469 return S_OK; /* TODO */
2473 CHECK_EXPECT(Exec_ShellDocView_67);
2474 ok(pvaIn != NULL, "pvaIn == NULL\n");
2475 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2476 ok(!strcmp_wa(V_BSTR(pvaIn), "about:blank"), "V_BSTR(pvaIn) = %s\n", wine_dbgstr_w(V_BSTR(pvaIn)));
2477 ok(pvaOut != NULL, "pvaOut == NULL\n");
2478 ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2479 ok(V_BOOL(pvaOut) == VARIANT_TRUE, "V_BOOL(pvaOut) = %x\n", V_BOOL(pvaOut));
2480 load_state = LD_DOLOAD;
2484 CHECK_EXPECT2(Exec_ShellDocView_84);
2486 ok(pvaIn == NULL, "pvaIn != NULL\n");
2487 ok(pvaOut != NULL, "pvaOut == NULL\n");
2489 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2494 CHECK_EXPECT2(Exec_ShellDocView_103);
2496 ok(pvaIn == NULL, "pvaIn != NULL\n");
2497 ok(pvaOut == NULL, "pvaOut != NULL\n");
2502 CHECK_EXPECT2(Exec_ShellDocView_105);
2504 ok(pvaIn != NULL, "pvaIn == NULL\n");
2505 ok(pvaOut == NULL, "pvaOut != NULL\n");
2510 CHECK_EXPECT2(Exec_ShellDocView_140);
2512 ok(pvaIn == NULL, "pvaIn != NULL\n");
2513 ok(pvaOut == NULL, "pvaOut != NULL\n");
2518 ok(0, "unexpected command %d\n", nCmdID);
2523 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2524 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2527 case IDM_PARSECOMPLETE:
2528 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2529 ok(pvaIn == NULL, "pvaIn != NULL\n");
2530 ok(pvaOut == NULL, "pvaOut != NULL\n");
2533 ok(0, "unexpected command %d\n", nCmdID);
2537 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
2539 case DOCHOST_DOCCANNAVIGATE:
2540 CHECK_EXPECT(Exec_DOCCANNAVIGATE);
2541 ok(pvaIn != NULL, "pvaIn == NULL\n");
2542 ok(pvaOut == NULL, "pvaOut != NULL\n");
2543 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) != VT_UNKNOWN\n");
2544 /* FIXME: test V_UNKNOWN(pvaIn) == window */
2547 return E_FAIL; /* TODO */
2551 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2552 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2556 CHECK_EXPECT2(Exec_Explorer_69);
2557 ok(pvaIn == NULL, "pvaIn != NULL\n");
2558 ok(pvaOut != NULL, "pvaOut == NULL\n");
2561 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2566 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2568 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2569 SET_EXPECT(SetStatusText);
2570 ok(pvaIn == NULL, "pvaIn != NULL\n");
2571 ok(pvaOut == NULL, "pvaOut != NULL\n");
2573 case OLECMDID_SHOWSCRIPTERROR:
2577 ok(0, "unexpected command %d\n", nCmdID);
2582 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2586 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2587 OleCommandTarget_QueryInterface,
2588 OleCommandTarget_AddRef,
2589 OleCommandTarget_Release,
2590 OleCommandTarget_QueryStatus,
2591 OleCommandTarget_Exec
2594 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2596 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2598 return QueryInterface(riid, ppv);
2601 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2602 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2603 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2605 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2606 ok(pDispParams != NULL, "pDispParams == NULL\n");
2607 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2608 ok(puArgErr != NULL, "puArgErr == NULL\n");
2609 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2610 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2611 test_readyState(NULL);
2613 switch(dispIdMember) {
2614 case DISPID_AMBIENT_USERMODE:
2615 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2616 V_VT(pVarResult) = VT_BOOL;
2617 V_BOOL(pVarResult) = VARIANT_TRUE;
2619 case DISPID_AMBIENT_DLCONTROL:
2620 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2622 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2623 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2625 case DISPID_AMBIENT_SILENT:
2626 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2627 V_VT(pVarResult) = VT_BOOL;
2628 V_BOOL(pVarResult) = VARIANT_FALSE;
2630 case DISPID_AMBIENT_USERAGENT:
2631 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2633 case DISPID_AMBIENT_PALETTE:
2634 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2638 ok(0, "unexpected dispid %d\n", dispIdMember);
2642 static IDispatchVtbl DispatchVtbl = {
2643 Dispatch_QueryInterface,
2646 Dispatch_GetTypeInfoCount,
2647 Dispatch_GetTypeInfo,
2648 Dispatch_GetIDsOfNames,
2652 static IDispatch Dispatch = { &DispatchVtbl };
2654 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2655 REFIID riid, void **ppv)
2657 return QueryInterface(riid, ppv);
2660 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2665 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2670 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2671 REFIID riid, void **ppv)
2674 * Services used by HTMLDocument:
2677 * IInternetSecurityManager
2679 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2682 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2683 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2684 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2686 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2687 * IElementBehaviorFactory
2688 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2698 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2699 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2704 return E_NOINTERFACE;
2707 static const IServiceProviderVtbl ServiceProviderVtbl = {
2708 ServiceProvider_QueryInterface,
2709 ServiceProvider_AddRef,
2710 ServiceProvider_Release,
2711 ServiceProvider_QueryService
2714 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2716 static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSinkEx *iface,
2717 REFIID riid, void **ppv)
2719 return QueryInterface(riid, ppv);
2722 static ULONG WINAPI AdviseSink_AddRef(IAdviseSinkEx *iface)
2727 static ULONG WINAPI AdviseSink_Release(IAdviseSinkEx *iface)
2732 static void WINAPI AdviseSink_OnDataChange(IAdviseSinkEx *iface,
2733 FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
2735 ok(0, "unexpected call\n");
2738 static void WINAPI AdviseSink_OnViewChange(IAdviseSinkEx *iface,
2739 DWORD dwAspect, LONG lindex)
2741 ok(0, "unexpected call\n");
2744 static void WINAPI AdviseSink_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
2746 ok(0, "unexpected call\n");
2749 static void WINAPI AdviseSink_OnSave(IAdviseSinkEx *iface)
2751 ok(0, "unexpected call\n");
2754 static void WINAPI AdviseSink_OnClose(IAdviseSinkEx *iface)
2756 ok(0, "unexpected call\n");
2759 static void WINAPI AdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
2761 ok(0, "unexpected call\n");
2764 static void WINAPI ObjectAdviseSink_OnClose(IAdviseSinkEx *iface)
2766 CHECK_EXPECT(Advise_Close);
2769 static const IAdviseSinkExVtbl AdviseSinkVtbl = {
2770 AdviseSink_QueryInterface,
2773 AdviseSink_OnDataChange,
2774 AdviseSink_OnViewChange,
2775 AdviseSink_OnRename,
2777 ObjectAdviseSink_OnClose,
2778 AdviseSinkEx_OnViewStatusChange
2781 static IAdviseSinkEx AdviseSink = { &AdviseSinkVtbl };
2783 static HRESULT WINAPI ViewAdviseSink_QueryInterface(IAdviseSinkEx *iface,
2784 REFIID riid, void **ppv)
2786 if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) {
2791 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2793 return E_NOINTERFACE;
2796 static void WINAPI ViewAdviseSink_OnViewChange(IAdviseSinkEx *iface,
2797 DWORD dwAspect, LONG lindex)
2799 CHECK_EXPECT2(OnViewChange);
2801 ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %d\n", dwAspect);
2802 ok(lindex == -1, "lindex = %d\n", lindex);
2805 static const IAdviseSinkExVtbl ViewAdviseSinkVtbl = {
2806 ViewAdviseSink_QueryInterface,
2809 AdviseSink_OnDataChange,
2810 ViewAdviseSink_OnViewChange,
2811 AdviseSink_OnRename,
2814 AdviseSinkEx_OnViewStatusChange
2817 static IAdviseSinkEx ViewAdviseSink = { &ViewAdviseSinkVtbl };
2819 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2820 DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2821 DEFINE_GUID(IID_IRenMailEditor, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2822 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
2823 DEFINE_GUID(IID_IDocHostUIHandlerPriv, 0xf0d241d1,0x5d0e,0x4e85,0xbc,0xb4,0xfa,0xd7,0xf7,0xc5,0x52,0x8c);
2825 static HRESULT QueryInterface(REFIID riid, void **ppv)
2829 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2831 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2832 *ppv = &DocumentSite;
2833 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2834 *ppv = &DocHostUIHandler;
2835 else if(IsEqualGUID(&IID_IOleContainer, riid))
2836 *ppv = &OleContainer;
2837 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2838 *ppv = &InPlaceSiteWindowless;
2839 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2840 *ppv = &OleCommandTarget;
2841 else if(IsEqualGUID(&IID_IDispatch, riid))
2843 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2844 *ppv = &ServiceProvider;
2845 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2846 *ppv = ipsex ? &InPlaceSiteWindowless : NULL;
2847 else if(IsEqualGUID(&IID_IOleInPlaceSiteWindowless, riid))
2848 *ppv = ipsw ? &InPlaceSiteWindowless : NULL;
2849 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2850 *ppv = &OleControlSite;
2851 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2852 return E_NOINTERFACE; /* TODO */
2853 else if(IsEqualGUID(&IID_IProxyManager, riid))
2854 return E_NOINTERFACE; /* ? */
2855 else if(IsEqualGUID(&IID_unk1, riid))
2856 return E_NOINTERFACE; /* HTMLWindow2 ? */
2857 else if(IsEqualGUID(&IID_IThumbnailView, riid))
2858 return E_NOINTERFACE; /* ? */
2859 else if(IsEqualGUID(&IID_IRenMailEditor, riid))
2860 return E_NOINTERFACE; /* ? */
2861 else if(IsEqualGUID(&IID_unk4, riid))
2862 return E_NOINTERFACE; /* ? */
2863 else if(IsEqualGUID(&IID_IDocHostUIHandlerPriv, riid))
2864 return E_NOINTERFACE; /* ? */
2866 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2870 return E_NOINTERFACE;
2873 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2875 return DefWindowProc(hwnd, msg, wParam, lParam);
2878 static void test_doscroll(IUnknown *unk)
2880 IHTMLDocument3 *doc;
2881 IHTMLElement2 *elem2;
2886 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument3, (void**)&doc);
2887 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2891 hres = IHTMLDocument3_get_documentElement(doc, &elem);
2892 IHTMLDocument3_Release(doc);
2893 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
2894 switch(load_state) {
2898 ok(!elem, "elem != NULL\n");
2901 case LD_INTERACTIVE:
2903 ok(elem != NULL, "elem == NULL\n");
2908 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
2909 IHTMLElement_Release(elem);
2910 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
2913 V_BSTR(&v) = a2bstr("left");
2914 hres = IHTMLElement2_doScroll(elem2, v);
2915 SysFreeString(V_BSTR(&v));
2916 IHTMLElement2_Release(elem2);
2918 if(inplace_deactivated)
2919 ok(hres == E_PENDING, "doScroll failed: %08x\n", hres);
2920 else if(load_state == LD_COMPLETE)
2921 ok(hres == S_OK, "doScroll failed: %08x\n", hres);
2923 ok(hres == E_PENDING || hres == S_OK, "doScroll failed: %08x\n", hres);
2926 static void _test_readyState(unsigned line, IUnknown *unk)
2928 IHTMLDocument2 *htmldoc;
2929 DISPPARAMS dispparams;
2935 static const LPCSTR expected_state[] = {
2947 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2948 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2952 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2953 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2955 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2956 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2958 if(!strcmp_wa(state, "interactive") && load_state == LD_LOADING)
2959 load_state = LD_INTERACTIVE;
2962 (!strcmp_wa(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
2963 wine_dbgstr_w(state), load_state);
2964 SysFreeString(state);
2966 hres = IHTMLDocument2_get_body(htmldoc, &elem);
2967 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2969 IHTMLElement2 *elem2;
2972 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
2973 IHTMLElement_Release(elem);
2974 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
2976 hres = IHTMLElement2_get_readyState(elem2, &var);
2977 IHTMLElement2_Release(elem2);
2978 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
2979 ok(V_VT(&var) == VT_BSTR, "V_VT(state) = %d\n", V_VT(&var));
2980 ok(!strcmp_wa(V_BSTR(&var), "complete"), "unexpected body state %s\n", wine_dbgstr_w(V_BSTR(&var)));
2983 ok_(__FILE__,line)(load_state != LD_COMPLETE, "body is NULL in complete state\n");
2986 dispparams.cArgs = 0;
2987 dispparams.cNamedArgs = 0;
2988 dispparams.rgdispidNamedArgs = NULL;
2989 dispparams.rgvarg = NULL;
2993 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2994 &dispparams, &out, NULL, NULL);
2995 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2997 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2998 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
3000 test_doscroll((IUnknown*)htmldoc);
3002 IHTMLDocument2_Release(htmldoc);
3005 static void test_ViewAdviseSink(IHTMLDocument2 *doc)
3010 hres = IHTMLDocument2_QueryInterface(doc, &IID_IViewObject, (void**)&view);
3011 ok(hres == S_OK, "QueryInterface(IID_IViewObject) failed: %08x\n", hres);
3013 hres = IViewObject_SetAdvise(view, DVASPECT_CONTENT, ADVF_PRIMEFIRST, (IAdviseSink*)&ViewAdviseSink);
3014 ok(hres == S_OK, "SetAdvise failed: %08x\n", hres);
3016 IViewObject_Release(view);
3019 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
3021 IConnectionPointContainer *tmp_container = NULL;
3022 IConnectionPoint *cp;
3026 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
3027 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
3031 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
3032 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
3033 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
3035 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
3036 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
3038 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
3039 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
3040 ok(tmp_container == container, "container != tmp_container\n");
3042 IConnectionPointContainer_Release(tmp_container);
3044 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
3045 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
3047 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
3050 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
3051 ok(hres == S_OK, "Advise failed: %08x\n", hres);
3054 IConnectionPoint_Release(cp);
3057 static void test_ConnectionPointContainer(IHTMLDocument2 *doc)
3059 IConnectionPointContainer *container;
3062 hres = IUnknown_QueryInterface(doc, &IID_IConnectionPointContainer, (void**)&container);
3063 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
3067 test_ConnectionPoint(container, &IID_IDispatch);
3068 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
3069 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
3070 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
3072 IConnectionPointContainer_Release(container);
3075 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
3079 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
3081 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
3083 test_readyState((IUnknown*)persist);
3087 CreateBindCtx(0, &bind);
3088 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
3089 (IUnknown*)&ClientSite);
3092 SET_EXPECT(GetDisplayName);
3093 if(!set_clientsite) {
3094 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3095 SET_EXPECT(GetHostInfo);
3096 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3097 SET_EXPECT(Invoke_AMBIENT_SILENT);
3098 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3099 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3100 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3101 SET_EXPECT(GetOptionKeyPath);
3102 SET_EXPECT(GetOverrideKeyPath);
3103 SET_EXPECT(GetWindow);
3104 SET_EXPECT(Exec_DOCCANNAVIGATE);
3105 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3106 SET_EXPECT(Exec_SETPROGRESSMAX);
3107 SET_EXPECT(Exec_SETPROGRESSPOS);
3108 SET_EXPECT(Exec_ShellDocView_37);
3110 if(!container_locked) {
3111 SET_EXPECT(GetContainer);
3112 SET_EXPECT(LockContainer);
3114 SET_EXPECT(OnChanged_READYSTATE);
3115 SET_EXPECT(Exec_ShellDocView_84);
3116 SET_EXPECT(IsSystemMoniker);
3118 SET_EXPECT(BindToStorage);
3119 SET_EXPECT(SetActiveObject);
3120 if(set_clientsite) {
3121 SET_EXPECT(Invoke_AMBIENT_SILENT);
3122 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3123 SET_EXPECT(Exec_ShellDocView_37);
3125 load_state = LD_DOLOAD;
3126 expect_LockContainer_fLock = TRUE;
3127 readystate_set_loading = TRUE;
3129 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
3130 ok(hres == S_OK, "Load failed: %08x\n", hres);
3133 CHECK_CALLED(GetDisplayName);
3134 if(!set_clientsite) {
3135 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3136 CHECK_CALLED(GetHostInfo);
3137 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3138 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3139 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3140 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3141 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3142 CHECK_CALLED(GetOptionKeyPath);
3143 CHECK_CALLED(GetOverrideKeyPath);
3144 CHECK_CALLED(GetWindow);
3145 CHECK_CALLED(Exec_DOCCANNAVIGATE);
3146 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3147 CHECK_CALLED(Exec_SETPROGRESSMAX);
3148 CHECK_CALLED(Exec_SETPROGRESSPOS);
3149 CHECK_CALLED(Exec_ShellDocView_37);
3151 if(!container_locked) {
3152 CHECK_CALLED(GetContainer);
3153 CHECK_CALLED(LockContainer);
3154 container_locked = TRUE;
3156 CHECK_CALLED(OnChanged_READYSTATE);
3157 SET_CALLED(IsSystemMoniker); /* IE7 */
3158 SET_CALLED(Exec_ShellDocView_84);
3160 CHECK_CALLED(BindToStorage);
3161 SET_CALLED(SetActiveObject); /* FIXME */
3162 if(set_clientsite) {
3163 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3164 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3165 CHECK_CALLED(Exec_ShellDocView_37);
3168 set_clientsite = container_locked = TRUE;
3170 test_GetCurMoniker((IUnknown*)persist, mon, NULL);
3172 IBindCtx_Release(bind);
3174 test_readyState((IUnknown*)persist);
3177 #define DWL_VERBDONE 0x0001
3178 #define DWL_CSS 0x0002
3179 #define DWL_TRYCSS 0x0004
3180 #define DWL_HTTP 0x0008
3181 #define DWL_EMPTY 0x0010
3183 static void test_download(DWORD flags)
3188 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
3189 ok(hwnd != NULL, "Could not find hidden window\n");
3191 test_readyState(NULL);
3193 if(flags & (DWL_VERBDONE|DWL_HTTP))
3194 SET_EXPECT(Exec_SETPROGRESSMAX);
3195 if((flags & DWL_VERBDONE) && !load_from_stream)
3196 SET_EXPECT(GetHostInfo);
3197 SET_EXPECT(SetStatusText);
3198 if(!(flags & DWL_EMPTY))
3199 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
3200 SET_EXPECT(OnViewChange);
3201 SET_EXPECT(GetDropTarget);
3202 if(flags & DWL_TRYCSS)
3203 SET_EXPECT(Exec_ShellDocView_84);
3204 if(flags & DWL_CSS) {
3205 SET_EXPECT(CreateInstance);
3207 SET_EXPECT(LockRequest);
3208 SET_EXPECT(Terminate);
3209 SET_EXPECT(Protocol_Read);
3210 SET_EXPECT(UnlockRequest);
3212 SET_EXPECT(Exec_Explorer_69);
3213 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
3214 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
3215 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
3216 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
3218 SET_EXPECT(Exec_ShellDocView_37);
3219 if(flags & DWL_HTTP) {
3220 SET_EXPECT(OnChanged_1012);
3221 SET_EXPECT(Exec_HTTPEQUIV);
3222 SET_EXPECT(Exec_SETTITLE);
3224 SET_EXPECT(OnChanged_1005);
3225 SET_EXPECT(OnChanged_READYSTATE);
3226 SET_EXPECT(Exec_SETPROGRESSPOS);
3227 if(!(flags & DWL_EMPTY))
3228 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
3229 SET_EXPECT(Exec_ShellDocView_103);
3230 SET_EXPECT(Exec_ShellDocView_105);
3231 SET_EXPECT(Exec_ShellDocView_140);
3232 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
3233 SET_EXPECT(Exec_HTTPEQUIV_DONE);
3234 SET_EXPECT(SetStatusText);
3235 if(navigated_load) {
3236 SET_EXPECT(UpdateUI);
3237 SET_EXPECT(Exec_UPDATECOMMANDS);
3238 SET_EXPECT(Exec_SETTITLE);
3240 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
3242 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
3243 TranslateMessage(&msg);
3244 DispatchMessage(&msg);
3247 if(flags & DWL_VERBDONE)
3248 CHECK_CALLED(Exec_SETPROGRESSMAX);
3249 if(flags & DWL_HTTP)
3250 SET_CALLED(Exec_SETPROGRESSMAX);
3251 if((flags & DWL_VERBDONE) && !load_from_stream) {
3253 todo_wine CHECK_CALLED(GetHostInfo);
3255 CHECK_CALLED(GetHostInfo);
3257 CHECK_CALLED(SetStatusText);
3258 if(!(flags & DWL_EMPTY))
3259 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
3260 CHECK_CALLED(OnViewChange);
3262 CHECK_CALLED(GetDropTarget);
3264 SET_CALLED(GetDropTarget);
3265 if(flags & DWL_TRYCSS)
3266 SET_CALLED(Exec_ShellDocView_84);
3267 if(flags & DWL_CSS) {
3268 CHECK_CALLED(CreateInstance);
3269 CHECK_CALLED(Start);
3270 CHECK_CALLED(LockRequest);
3271 CHECK_CALLED(Terminate);
3272 CHECK_CALLED(Protocol_Read);
3273 CHECK_CALLED(UnlockRequest);
3275 SET_CALLED(Exec_Explorer_69);
3276 SET_CALLED(EnableModeless_TRUE); /* IE7 */
3277 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
3278 SET_CALLED(EnableModeless_FALSE); /* IE7 */
3279 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
3281 todo_wine CHECK_CALLED(Exec_ShellDocView_37);
3282 if(flags & DWL_HTTP) todo_wine {
3283 CHECK_CALLED(OnChanged_1012);
3284 CHECK_CALLED(Exec_HTTPEQUIV);
3285 CHECK_CALLED(Exec_SETTITLE);
3287 CHECK_CALLED(OnChanged_1005);
3288 CHECK_CALLED(OnChanged_READYSTATE);
3289 CHECK_CALLED(Exec_SETPROGRESSPOS);
3290 if(!(flags & DWL_EMPTY))
3291 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
3292 SET_CALLED(Exec_ShellDocView_103);
3293 SET_CALLED(Exec_ShellDocView_105);
3294 SET_CALLED(Exec_ShellDocView_140);
3295 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
3296 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
3297 SET_CALLED(SetStatusText);
3298 if(navigated_load) { /* avoiding race, FIXME: fund better way */
3299 SET_CALLED(UpdateUI);
3300 SET_CALLED(Exec_UPDATECOMMANDS);
3301 SET_CALLED(Exec_SETTITLE);
3304 load_state = LD_COMPLETE;
3306 test_readyState(NULL);
3309 static void test_Persist(IHTMLDocument2 *doc, IMoniker *mon)
3311 IPersistMoniker *persist_mon;
3312 IPersistFile *persist_file;
3316 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&persist_file);
3317 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
3318 if(SUCCEEDED(hres)) {
3319 hres = IPersist_GetClassID(persist_file, NULL);
3320 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
3322 hres = IPersist_GetClassID(persist_file, &guid);
3323 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
3324 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
3326 IPersist_Release(persist_file);
3329 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist_mon);
3330 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
3331 if(SUCCEEDED(hres)) {
3332 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
3333 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
3335 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
3336 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
3337 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
3339 if(load_state == LD_DOLOAD)
3340 test_Load(persist_mon, mon);
3342 test_readyState((IUnknown*)doc);
3344 IPersistMoniker_Release(persist_mon);
3348 static void test_put_href(IHTMLDocument2 *doc)
3350 IHTMLPrivateWindow *priv_window;
3351 IHTMLWindow2 *window;
3352 IHTMLLocation *location;
3358 hres = IHTMLDocument2_get_location(doc, &location);
3359 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3360 ok(location != NULL, "location == NULL\n");
3362 SET_EXPECT(TranslateUrl);
3363 SET_EXPECT(Navigate);
3364 str = a2bstr("about:blank");
3365 hres = IHTMLLocation_put_href(location, str);
3366 ok(hres == S_OK, "put_href failed: %08x\n", hres);
3367 CHECK_CALLED(TranslateUrl);
3368 CHECK_CALLED(Navigate);
3370 IHTMLLocation_Release(location);
3372 hres = IHTMLDocument2_get_parentWindow(doc, &window);
3373 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3375 hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window);
3376 IHTMLWindow2_Release(window);
3377 ok(hres == S_OK, "QueryInterface(IID_IHTMLPrivateWindow) failed: %08x\n", hres);
3379 readystate_set_loading = TRUE;
3380 navigated_load = TRUE;
3381 SET_EXPECT(TranslateUrl);
3382 SET_EXPECT(Exec_ShellDocView_67);
3383 SET_EXPECT(Invoke_AMBIENT_SILENT);
3384 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3385 SET_EXPECT(OnChanged_READYSTATE);
3386 SET_EXPECT(Exec_ShellDocView_63);
3389 V_VT(&vempty) = VT_EMPTY;
3390 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, str2, NULL, NULL, &vempty, &vempty, 0);
3392 SysFreeString(str2);
3393 ok(hres == S_OK, "SuperNavigate failed: %08x\n", hres);
3395 CHECK_CALLED(TranslateUrl);
3396 CHECK_CALLED(Exec_ShellDocView_67);
3397 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3398 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3399 SET_CALLED(OnChanged_READYSTATE); /* not always called */
3400 CHECK_CALLED(Exec_ShellDocView_63);
3402 test_GetCurMoniker(doc_unk, doc_mon, NULL);
3403 IHTMLPrivateWindow_Release(priv_window);
3405 test_download(DWL_VERBDONE);
3408 static void test_clear(IHTMLDocument2 *doc)
3412 hres = IHTMLDocument2_clear(doc);
3413 ok(hres == S_OK, "clear failed: %08x\n", hres);
3416 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
3418 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
3419 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
3420 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
3421 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
3422 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
3423 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
3424 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
3425 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
3426 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
3427 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
3428 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
3429 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
3430 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
3431 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
3432 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
3433 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
3434 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
3435 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
3436 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
3437 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
3439 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
3440 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
3442 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
3444 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
3446 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
3447 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
3449 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
3450 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
3452 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
3454 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
3455 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
3458 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
3459 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
3461 IOleCommandTarget *cmdtrg;
3462 OLECMD olecmd = {cmdid, 0};
3465 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3466 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3470 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
3471 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
3473 IOleCommandTarget_Release(cmdtrg);
3475 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
3476 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
3479 static void test_MSHTML_QueryStatus(IHTMLDocument2 *doc, DWORD cmdf)
3481 IUnknown *unk = doc ? (IUnknown*)doc : doc_unk;
3483 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
3484 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
3485 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
3486 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
3487 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
3488 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
3489 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
3490 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
3491 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
3492 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
3493 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
3494 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
3495 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
3496 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
3497 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
3498 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
3501 static void test_OleCommandTarget(IHTMLDocument2 *doc)
3503 IOleCommandTarget *cmdtrg;
3504 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
3508 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3509 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3513 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3514 cmds[i].cmdID = i+1;
3515 cmds[i].cmdf = 0xf0f0;
3518 SET_EXPECT(QueryStatus_OPEN);
3519 SET_EXPECT(QueryStatus_NEW);
3520 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
3521 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3522 CHECK_CALLED(QueryStatus_OPEN);
3523 CHECK_CALLED(QueryStatus_NEW);
3525 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3526 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
3527 if(i+1 == OLECMDID_FIND)
3529 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
3530 i+1, cmds[i].cmdf, expect_cmds[i+1]);
3533 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
3534 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
3536 IOleCommandTarget_Release(cmdtrg);
3539 static void test_OleCommandTarget_fail(IHTMLDocument2 *doc)
3541 IOleCommandTarget *cmdtrg;
3546 {OLECMDID_OPEN, 0xf0f0},
3547 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
3550 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3551 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
3555 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
3556 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3558 SET_EXPECT(QueryStatus_OPEN);
3559 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
3560 CHECK_CALLED(QueryStatus_OPEN);
3562 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3563 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3564 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3565 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3566 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3567 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3568 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3570 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3571 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3572 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3574 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3575 if(!expect_cmds[i]) {
3576 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3577 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3578 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3579 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3583 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3584 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3585 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3586 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3588 IOleCommandTarget_Release(cmdtrg);
3591 static void test_exec_onunload(IHTMLDocument2 *doc)
3593 IOleCommandTarget *cmdtrg;
3597 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3598 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3602 memset(&var, 0x0a, sizeof(var));
3603 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3604 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3605 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3606 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3607 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3609 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3610 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3611 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3613 IOleCommandTarget_Release(cmdtrg);
3616 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3618 IOleCommandTarget *cmdtrg;
3621 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3622 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3629 load_state = LD_DOLOAD;
3632 SET_EXPECT(GetClassID);
3633 SET_EXPECT(SetStatusText);
3634 SET_EXPECT(Exec_ShellDocView_37);
3635 SET_EXPECT(GetHostInfo);
3637 SET_EXPECT(GetDisplayName);
3638 SET_EXPECT(Invoke_AMBIENT_SILENT);
3639 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3640 SET_EXPECT(OnChanged_READYSTATE);
3641 SET_EXPECT(IsSystemMoniker);
3642 SET_EXPECT(Exec_ShellDocView_84);
3644 SET_EXPECT(BindToStorage);
3645 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3648 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3650 expect_status_text = NULL;
3651 readystate_set_loading = TRUE;
3653 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3654 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3655 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3658 CHECK_CALLED(GetClassID);
3659 CHECK_CALLED(SetStatusText);
3660 CHECK_CALLED(Exec_ShellDocView_37);
3661 CHECK_CALLED(GetHostInfo);
3663 CHECK_CALLED(GetDisplayName);
3664 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3665 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3666 CHECK_CALLED(OnChanged_READYSTATE);
3667 SET_CALLED(IsSystemMoniker); /* IE7 */
3668 SET_CALLED(Exec_ShellDocView_84);
3670 CHECK_CALLED(BindToStorage);
3671 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3672 CHECK_CALLED(HideUI);
3673 CHECK_CALLED(ShowUI);
3674 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3676 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3678 IOleCommandTarget_Release(cmdtrg);
3680 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3681 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3682 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3685 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3687 IOleCommandTarget *cmdtrg;
3688 VARIANT *in = NULL, _in, *out = NULL, _out;
3691 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3692 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3699 V_BSTR(in) = SysAllocString(name);
3705 V_I4(out) = 0xdeadbeef;
3708 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3709 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3715 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3716 if(V_VT(out) == VT_BSTR) {
3718 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3719 "unexpected fontname %s\n", wine_dbgstr_w(name));
3721 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3726 IOleCommandTarget_Release(cmdtrg);
3729 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3731 IOleCommandTarget *cmdtrg;
3734 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3735 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3739 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3740 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3741 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3743 IOleCommandTarget_Release(cmdtrg);
3746 static void test_IsDirty(IHTMLDocument2 *doc, HRESULT exhres)
3748 IPersistStreamInit *perinit;
3749 IPersistMoniker *permon;
3750 IPersistFile *perfile;
3753 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&perinit);
3754 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3755 if(SUCCEEDED(hres)) {
3756 hres = IPersistStreamInit_IsDirty(perinit);
3757 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3758 IPersistStreamInit_Release(perinit);
3761 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&permon);
3762 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3763 if(SUCCEEDED(hres)) {
3764 hres = IPersistMoniker_IsDirty(permon);
3765 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3766 IPersistMoniker_Release(permon);
3769 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&perfile);
3770 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3771 if(SUCCEEDED(hres)) {
3772 hres = IPersistFile_IsDirty(perfile);
3773 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3774 IPersistFile_Release(perfile);
3778 static HWND create_container_window(void)
3780 static const WCHAR wszHTMLDocumentTest[] =
3781 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3782 static WNDCLASSEXW wndclass = {
3783 sizeof(WNDCLASSEXW),
3786 0, 0, NULL, NULL, NULL, NULL, NULL,
3787 wszHTMLDocumentTest,
3791 RegisterClassExW(&wndclass);
3792 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3793 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3794 515, 530, NULL, NULL, NULL, NULL);
3797 static void test_DoVerb(IOleObject *oleobj)
3799 RECT rect = {0,0,500,500};
3802 if(!container_locked) {
3803 SET_EXPECT(GetContainer);
3804 SET_EXPECT(LockContainer);
3806 SET_EXPECT(ActivateMe);
3807 expect_LockContainer_fLock = TRUE;
3809 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3810 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3812 if(!container_locked) {
3813 CHECK_CALLED(GetContainer);
3814 CHECK_CALLED(LockContainer);
3815 container_locked = TRUE;
3817 CHECK_CALLED(ActivateMe);
3820 #define CLIENTSITE_EXPECTPATH 0x00000001
3821 #define CLIENTSITE_SETNULL 0x00000002
3822 #define CLIENTSITE_DONTSET 0x00000004
3824 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3826 IOleClientSite *clientsite;
3829 if(flags & CLIENTSITE_SETNULL) {
3830 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3831 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3833 hres = IOleObject_SetClientSite(oleobj, NULL);
3834 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3836 set_clientsite = FALSE;
3839 if(flags & CLIENTSITE_DONTSET)
3842 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3843 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3844 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3845 clientsite, set_clientsite ? &ClientSite : NULL);
3847 if(!set_clientsite) {
3848 SET_EXPECT(GetHostInfo);
3849 if(flags & CLIENTSITE_EXPECTPATH) {
3850 SET_EXPECT(GetOptionKeyPath);
3851 SET_EXPECT(GetOverrideKeyPath);
3853 SET_EXPECT(GetWindow);
3854 if(flags & CLIENTSITE_EXPECTPATH)
3855 SET_EXPECT(Exec_DOCCANNAVIGATE);
3856 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3857 SET_EXPECT(Exec_SETPROGRESSMAX);
3858 SET_EXPECT(Exec_SETPROGRESSPOS);
3859 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3860 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3861 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3862 SET_EXPECT(Invoke_AMBIENT_SILENT);
3863 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3864 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3866 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3867 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3869 CHECK_CALLED(GetHostInfo);
3870 if(flags & CLIENTSITE_EXPECTPATH) {
3871 CHECK_CALLED(GetOptionKeyPath);
3872 CHECK_CALLED(GetOverrideKeyPath);
3874 CHECK_CALLED(GetWindow);
3875 if(flags & CLIENTSITE_EXPECTPATH)
3876 CHECK_CALLED(Exec_DOCCANNAVIGATE);
3877 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3878 CHECK_CALLED(Exec_SETPROGRESSMAX);
3879 CHECK_CALLED(Exec_SETPROGRESSPOS);
3880 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3881 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3882 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3883 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3884 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3885 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3887 set_clientsite = TRUE;
3890 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3891 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3893 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3894 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3895 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3898 static void test_OnAmbientPropertyChange(IHTMLDocument2 *doc)
3900 IOleControl *control = NULL;
3903 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
3904 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3908 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3909 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3910 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3911 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3913 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3914 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3915 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3916 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3918 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3919 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3920 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3921 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3922 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3923 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3925 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3926 SET_EXPECT(Invoke_AMBIENT_SILENT);
3927 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3928 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3929 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3930 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3932 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3933 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3934 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3935 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3937 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3938 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3939 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3940 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3942 IOleControl_Release(control);
3947 static void test_OnAmbientPropertyChange2(IHTMLDocument2 *doc)
3949 IOleControl *control = NULL;
3952 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
3953 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3957 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3958 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3960 IOleControl_Release(control);
3963 static void test_Close(IHTMLDocument2 *doc, BOOL set_client)
3965 IOleObject *oleobj = NULL;
3968 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
3969 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3973 SET_EXPECT(GetContainer);
3974 SET_EXPECT(LockContainer);
3975 expect_LockContainer_fLock = FALSE;
3976 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3977 ok(hres == S_OK, "Close failed: %08x\n", hres);
3978 CHECK_CALLED(GetContainer);
3979 CHECK_CALLED(LockContainer);
3980 container_locked = FALSE;
3983 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3985 IOleObject_Release(oleobj);
3988 static void test_Advise(IHTMLDocument2 *doc)
3990 IOleObject *oleobj = NULL;
3991 IEnumSTATDATA *enum_advise = (void*)0xdeadbeef;
3995 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
3996 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4000 hres = IOleObject_Unadvise(oleobj, 0);
4001 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
4003 hres = IOleObject_EnumAdvise(oleobj, &enum_advise);
4004 ok(hres == S_OK, "EnumAdvise returned: %08x\n", hres);
4005 ok(enum_advise == NULL, "enum_advise != NULL\n");
4008 hres = IOleObject_Advise(oleobj, NULL, &conn);
4009 /* Old IE returns S_OK and sets conn to 1 */
4010 ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres);
4011 ok(conn == 0 || conn == 1, "conn = %d\n", conn);
4013 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL);
4014 ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
4016 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4017 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4018 ok(conn == 1, "conn = %d\n", conn);
4020 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4021 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4022 ok(conn == 2, "conn = %d\n", conn);
4024 hres = IOleObject_Unadvise(oleobj, 1);
4025 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4027 hres = IOleObject_Unadvise(oleobj, 1);
4028 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
4030 hres = IOleObject_Unadvise(oleobj, 2);
4031 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4033 IOleObject_Release(oleobj);
4036 static void test_OnFrameWindowActivate(IUnknown *unk)
4038 IOleInPlaceActiveObject *inplaceact;
4041 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
4042 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
4046 if(set_clientsite) {
4047 expect_OnFrameWindowActivate_fActivate = TRUE;
4048 SET_EXPECT(OnFrameWindowActivate);
4049 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4050 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4051 CHECK_CALLED(OnFrameWindowActivate);
4053 SET_EXPECT(OnFrameWindowActivate);
4054 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4055 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4056 CHECK_CALLED(OnFrameWindowActivate);
4058 expect_OnFrameWindowActivate_fActivate = FALSE;
4059 SET_EXPECT(OnFrameWindowActivate);
4060 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
4061 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4062 CHECK_CALLED(OnFrameWindowActivate);
4064 expect_OnFrameWindowActivate_fActivate = TRUE;
4065 SET_EXPECT(OnFrameWindowActivate);
4066 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4067 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4068 CHECK_CALLED(OnFrameWindowActivate);
4070 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
4071 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4073 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4074 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4077 IOleInPlaceActiveObject_Release(inplaceact);
4080 static void test_InPlaceDeactivate(IHTMLDocument2 *doc, BOOL expect_call)
4082 IOleInPlaceObjectWindowless *windowlessobj = NULL;
4085 hres = IUnknown_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless,
4086 (void**)&windowlessobj);
4087 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
4092 SET_EXPECT(OnFocus_FALSE);
4094 SET_EXPECT(OnInPlaceDeactivateEx);
4096 SET_EXPECT(OnInPlaceDeactivate);
4098 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
4099 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
4101 CHECK_CALLED(OnFocus_FALSE);
4103 CHECK_CALLED(OnInPlaceDeactivateEx);
4105 CHECK_CALLED(OnInPlaceDeactivate);
4108 IOleInPlaceObjectWindowless_Release(windowlessobj);
4111 static void test_Activate(IHTMLDocument2 *doc, DWORD flags)
4113 IOleObject *oleobj = NULL;
4114 IOleDocumentView *docview;
4121 IOleDocumentView_Release(view);
4124 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4125 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4127 hres = IOleObject_GetUserClassID(oleobj, NULL);
4128 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
4130 hres = IOleObject_GetUserClassID(oleobj, &guid);
4131 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
4132 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
4134 test_OnFrameWindowActivate((IUnknown*)doc);
4136 test_ClientSite(oleobj, flags);
4137 test_InPlaceDeactivate(doc, FALSE);
4138 test_DoVerb(oleobj);
4140 if(call_UIActivate == CallUIActivate_AfterShow) {
4141 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
4142 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
4144 SET_EXPECT(OnFocus_TRUE);
4145 SET_EXPECT(SetActiveObject);
4147 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4148 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4149 expect_status_text = NULL;
4151 hres = IOleDocumentView_UIActivate(docview, TRUE);
4152 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4154 CHECK_CALLED(OnFocus_TRUE);
4155 CHECK_CALLED(SetActiveObject);
4156 CHECK_CALLED(ShowUI);
4157 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4158 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4160 IOleDocumentView_Release(docview);
4163 IOleObject_Release(oleobj);
4165 test_OnFrameWindowActivate((IUnknown*)doc);
4168 static void test_Window(IHTMLDocument2 *doc, BOOL expect_success)
4170 IOleInPlaceActiveObject *activeobject = NULL;
4174 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
4175 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
4179 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
4181 if(expect_success) {
4182 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
4183 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
4185 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
4186 ok(IsWindow(hwnd), "hwnd is destroyed\n");
4189 IOleInPlaceActiveObject_Release(activeobject);
4192 static void test_CloseView(void)
4194 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
4200 hres = IOleDocumentView_Show(view, FALSE);
4201 ok(hres == S_OK, "Show failed: %08x\n", hres);
4203 hres = IOleDocumentView_CloseView(view, 0);
4204 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
4206 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
4207 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
4209 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
4210 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
4211 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
4214 static void test_UIDeactivate(void)
4218 if(call_UIActivate == CallUIActivate_AfterShow) {
4219 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4221 if(call_UIActivate != CallUIActivate_None) {
4222 SET_EXPECT(SetActiveObject_null);
4224 SET_EXPECT(OnUIDeactivate);
4227 hres = IOleDocumentView_UIActivate(view, FALSE);
4228 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
4230 if(call_UIActivate != CallUIActivate_None) {
4231 CHECK_CALLED(SetActiveObject_null);
4232 CHECK_CALLED(HideUI);
4233 CHECK_CALLED(OnUIDeactivate);
4235 if(call_UIActivate == CallUIActivate_AfterShow) {
4236 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4240 static void test_Hide(void)
4247 hres = IOleDocumentView_Show(view, FALSE);
4248 ok(hres == S_OK, "Show failed: %08x\n", hres);
4251 static HRESULT create_document(IHTMLDocument2 **doc)
4253 IHTMLDocument5 *doc5;
4256 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
4257 &IID_IHTMLDocument2, (void**)doc);
4258 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
4262 hres = IHTMLDocument2_QueryInterface(*doc, &IID_IHTMLDocument5, (void**)&doc5);
4263 if(SUCCEEDED(hres)) {
4264 IHTMLDocument5_Release(doc5);
4266 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
4267 IHTMLDocument2_Release(*doc);
4273 static void test_Navigate(IHTMLDocument2 *doc)
4275 IHlinkTarget *hlink;
4278 hres = IUnknown_QueryInterface(doc, &IID_IHlinkTarget, (void**)&hlink);
4279 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
4281 SET_EXPECT(ActivateMe);
4282 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
4283 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
4284 CHECK_CALLED(ActivateMe);
4286 IHlinkTarget_Release(hlink);
4289 static void test_external(IHTMLDocument2 *doc, BOOL initialized)
4291 IDispatch *external;
4292 IHTMLWindow2 *htmlwin;
4295 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
4296 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4299 SET_EXPECT(GetExternal);
4300 external = (void*)0xdeadbeef;
4301 hres = IHTMLWindow2_get_external(htmlwin, &external);
4303 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
4304 CHECK_CALLED(GetExternal);
4305 ok(external != NULL, "external == NULL\n");
4307 ok(hres == S_OK, "get_external failed: %08x\n", hres);
4308 ok(external == NULL, "external != NULL\n");
4311 IHTMLWindow2_Release(htmlwin);
4314 static void test_StreamLoad(IHTMLDocument2 *doc)
4316 IPersistStreamInit *init;
4319 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4320 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
4324 SET_EXPECT(Invoke_AMBIENT_SILENT);
4325 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4326 SET_EXPECT(Exec_ShellDocView_37);
4327 SET_EXPECT(OnChanged_READYSTATE);
4329 readystate_set_loading = TRUE;
4331 hres = IPersistStreamInit_Load(init, &Stream);
4332 ok(hres == S_OK, "Load failed: %08x\n", hres);
4334 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4335 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4336 CHECK_CALLED(Exec_ShellDocView_37);
4337 CHECK_CALLED(OnChanged_READYSTATE);
4340 test_timer(EXPECT_SETTITLE);
4341 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4343 IPersistStreamInit_Release(init);
4346 static void test_StreamInitNew(IHTMLDocument2 *doc)
4348 IPersistStreamInit *init;
4351 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4352 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
4356 SET_EXPECT(Invoke_AMBIENT_SILENT);
4357 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4358 SET_EXPECT(Exec_ShellDocView_37);
4359 SET_EXPECT(OnChanged_READYSTATE);
4360 readystate_set_loading = TRUE;
4362 hres = IPersistStreamInit_InitNew(init);
4363 ok(hres == S_OK, "Load failed: %08x\n", hres);
4365 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4366 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4367 CHECK_CALLED(Exec_ShellDocView_37);
4368 CHECK_CALLED(OnChanged_READYSTATE);
4370 test_timer(EXPECT_SETTITLE);
4371 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4373 IPersistStreamInit_Release(init);
4376 static void test_QueryInterface(IHTMLDocument2 *doc)
4381 static const IID IID_UndocumentedScriptIface =
4382 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
4384 qi = (void*)0xdeadbeef;
4385 hres = IUnknown_QueryInterface(doc, &IID_IRunnableObject, (void**)&qi);
4386 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4387 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
4389 qi = (void*)0xdeadbeef;
4390 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode, (void**)&qi);
4391 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4392 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4394 qi = (void*)0xdeadbeef;
4395 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode2, (void**)&qi);
4396 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4397 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4399 qi = (void*)0xdeadbeef;
4400 hres = IUnknown_QueryInterface(doc, &IID_IPersistPropertyBag, (void**)&qi);
4401 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4402 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4404 qi = (void*)0xdeadbeef;
4405 hres = IUnknown_QueryInterface(doc, &IID_UndocumentedScriptIface, (void**)&qi);
4406 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4407 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4409 qi = (void*)0xdeadbeef;
4410 hres = IUnknown_QueryInterface(doc, &IID_IMarshal, (void**)&qi);
4411 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4412 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4414 qi = (void*)0xdeadbeef;
4415 hres = IUnknown_QueryInterface(doc, &IID_IExternalConnection, (void**)&qi);
4416 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4417 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4419 qi = (void*)0xdeadbeef;
4420 hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi);
4421 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4422 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4425 static void init_test(enum load_state_t ls) {
4427 hwnd = last_hwnd = NULL;
4428 set_clientsite = FALSE;
4429 load_from_stream = FALSE;
4430 call_UIActivate = CallUIActivate_None;
4436 inplace_deactivated = FALSE;
4437 navigated_load = FALSE;
4440 static void test_HTMLDocument(BOOL do_load)
4442 IHTMLDocument2 *doc;
4446 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
4448 init_test(do_load ? LD_DOLOAD : LD_NO);
4450 hres = create_document(&doc);
4453 doc_unk = (IUnknown*)doc;
4455 test_QueryInterface(doc);
4457 test_IsDirty(doc, S_FALSE);
4458 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4459 test_external(doc, FALSE);
4460 test_ViewAdviseSink(doc);
4461 test_ConnectionPointContainer(doc);
4462 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4463 test_Persist(doc, &Moniker);
4465 test_OnAmbientPropertyChange2(doc);
4467 test_Activate(doc, CLIENTSITE_EXPECTPATH);
4470 test_download(DWL_CSS|DWL_TRYCSS);
4471 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4474 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4475 test_OleCommandTarget_fail(doc);
4476 test_OleCommandTarget(doc);
4477 test_OnAmbientPropertyChange(doc);
4478 test_Window(doc, TRUE);
4479 test_external(doc, TRUE);
4481 test_UIDeactivate();
4482 test_OleCommandTarget(doc);
4483 test_Window(doc, TRUE);
4484 test_InPlaceDeactivate(doc, TRUE);
4486 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
4487 * MSHTML. It doesn't with Wine. */
4489 test_Window(doc, FALSE);
4491 test_InPlaceDeactivate(doc, FALSE);
4493 test_Close(doc, FALSE);
4495 /* Activate HTMLDocument again */
4496 test_Activate(doc, CLIENTSITE_SETNULL);
4497 test_Window(doc, TRUE);
4498 test_OleCommandTarget(doc);
4499 test_UIDeactivate();
4500 test_InPlaceDeactivate(doc, TRUE);
4501 test_Close(doc, FALSE);
4503 /* Activate HTMLDocument again, this time without UIActivate */
4504 call_UIActivate = CallUIActivate_None;
4505 test_Activate(doc, CLIENTSITE_SETNULL);
4506 test_Window(doc, TRUE);
4508 test_UIDeactivate();
4509 test_InPlaceDeactivate(doc, TRUE);
4512 test_Close(doc, TRUE);
4513 test_OnAmbientPropertyChange2(doc);
4514 test_GetCurMoniker((IUnknown*)doc, do_load ? &Moniker : NULL, NULL);
4517 /* Activate HTMLDocument again, calling UIActivate after showing the window */
4518 call_UIActivate = CallUIActivate_AfterShow;
4519 test_Activate(doc, 0);
4520 test_Window(doc, TRUE);
4521 test_OleCommandTarget(doc);
4522 test_UIDeactivate();
4523 test_InPlaceDeactivate(doc, TRUE);
4524 test_Close(doc, FALSE);
4525 call_UIActivate = CallUIActivate_None;
4529 IOleDocumentView_Release(view);
4532 ok(IsWindow(hwnd), "hwnd is destroyed\n");
4534 ref = IHTMLDocument2_Release(doc);
4535 ok(ref == 0, "ref=%d, expected 0\n", ref);
4537 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
4540 static void test_HTMLDocument_hlink(void)
4542 IHTMLDocument2 *doc;
4546 trace("Testing HTMLDocument (hlink)...\n");
4548 init_test(LD_DOLOAD);
4551 hres = create_document(&doc);
4554 doc_unk = (IUnknown*)doc;
4556 test_ViewAdviseSink(doc);
4557 test_ConnectionPointContainer(doc);
4558 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4559 test_Persist(doc, &Moniker);
4562 IUnknown_Release(doc);
4566 test_download(DWL_CSS|DWL_TRYCSS);
4568 test_IsDirty(doc, S_FALSE);
4569 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4571 test_exec_onunload(doc);
4572 test_Window(doc, TRUE);
4573 test_InPlaceDeactivate(doc, TRUE);
4574 test_Close(doc, FALSE);
4575 test_IsDirty(doc, S_FALSE);
4576 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4578 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4581 IOleDocumentView_Release(view);
4584 ref = IHTMLDocument2_Release(doc);
4585 ok(ref == 0, "ref=%d, expected 0\n", ref);
4588 static void test_cookies(IHTMLDocument2 *doc)
4596 hres = IHTMLDocument2_get_cookie(doc, &str);
4597 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4599 size = sizeof(buf)/sizeof(WCHAR);
4600 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4601 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4602 ok(!lstrcmpW(buf, str), "cookie = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(buf));
4606 str = a2bstr("test=testval");
4607 hres = IHTMLDocument2_put_cookie(doc, str);
4608 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
4611 hres = IHTMLDocument2_get_cookie(doc, &str2);
4612 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4613 ok(str2 != NULL, "cookie = NULL\n");
4614 size = sizeof(buf)/sizeof(WCHAR);
4615 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4616 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4617 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
4618 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
4620 SysFreeString(str2);
4622 str = a2bstr("test=testval2");
4623 hres = IHTMLDocument2_put_cookie(doc, str);
4624 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
4627 hres = IHTMLDocument2_get_cookie(doc, &str2);
4628 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4629 ok(str2 != NULL, "cookie = NULL\n");
4630 size = sizeof(buf)/sizeof(WCHAR);
4631 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4632 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4633 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
4634 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
4636 SysFreeString(str2);
4639 static void test_HTMLDocument_http(void)
4642 IHTMLDocument2 *doc;
4646 trace("Testing HTMLDocument (http)...\n");
4648 if(!winetest_interactive && is_ie_hardened()) {
4649 win_skip("IE running in Enhanced Security Configuration\n");
4653 init_test(LD_DOLOAD);
4656 hres = create_document(&doc);
4659 doc_unk = (IUnknown*)doc;
4661 hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
4662 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
4664 test_ViewAdviseSink(doc);
4665 test_ConnectionPointContainer(doc);
4666 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4667 test_Persist(doc, http_mon);
4670 IUnknown_Release(doc);
4674 test_download(DWL_HTTP);
4676 test_IsDirty(doc, S_FALSE);
4677 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4678 test_GetCurMoniker((IUnknown*)doc, http_mon, NULL);
4682 test_InPlaceDeactivate(doc, TRUE);
4683 test_Close(doc, FALSE);
4684 test_IsDirty(doc, S_FALSE);
4685 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4688 IOleDocumentView_Release(view);
4691 ref = IHTMLDocument2_Release(doc);
4692 ok(!ref, "ref=%d, expected 0\n", ref);
4694 ref = IMoniker_Release(http_mon);
4695 ok(!ref, "ref=%d, expected 0\n", ref);
4698 static void test_QueryService(IHTMLDocument2 *doc, BOOL success)
4700 IServiceProvider *sp;
4704 hres = IUnknown_QueryInterface(doc, &IID_IServiceProvider, (void**)&sp);
4705 ok(hres == S_OK, "QueryService returned %08x\n", hres);
4707 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
4709 IHlinkFrame_Release(hf);
4711 ok(hres == (success?S_OK:E_NOINTERFACE), "QueryService returned %08x, expected %08x\n", hres, success?S_OK:E_NOINTERFACE);
4713 IServiceProvider_Release(sp);
4716 static void test_HTMLDocument_StreamLoad(void)
4718 IHTMLDocument2 *doc;
4724 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
4726 init_test(LD_DOLOAD);
4727 load_from_stream = TRUE;
4729 hres = create_document(&doc);
4732 doc_unk = (IUnknown*)doc;
4734 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4735 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4737 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4738 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4740 test_readyState((IUnknown*)doc);
4741 test_IsDirty(doc, S_FALSE);
4742 test_ViewAdviseSink(doc);
4743 test_ConnectionPointContainer(doc);
4744 test_QueryService(doc, FALSE);
4745 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4746 test_QueryService(doc, TRUE);
4747 test_DoVerb(oleobj);
4748 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4750 IOleObject_Release(oleobj);
4752 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4753 test_StreamLoad(doc);
4754 test_download(DWL_VERBDONE|DWL_TRYCSS);
4755 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4757 test_UIDeactivate();
4758 test_InPlaceDeactivate(doc, TRUE);
4759 SET_EXPECT(Advise_Close);
4760 test_Close(doc, FALSE);
4761 CHECK_CALLED(Advise_Close);
4762 test_IsDirty(doc, S_FALSE);
4765 IOleDocumentView_Release(view);
4770 ref = IHTMLDocument2_Release(doc);
4771 ok(ref == 0, "ref=%d, expected 0\n", ref);
4774 static void test_HTMLDocument_StreamInitNew(void)
4776 IHTMLDocument2 *doc;
4782 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
4784 init_test(LD_DOLOAD);
4785 load_from_stream = TRUE;
4787 hres = create_document(&doc);
4790 doc_unk = (IUnknown*)doc;
4792 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4793 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4795 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4796 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4798 test_readyState((IUnknown*)doc);
4799 test_IsDirty(doc, S_FALSE);
4800 test_ViewAdviseSink(doc);
4801 test_ConnectionPointContainer(doc);
4802 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4803 test_DoVerb(oleobj);
4804 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4806 IOleObject_Release(oleobj);
4808 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4809 test_StreamInitNew(doc);
4810 test_download(DWL_VERBDONE|DWL_TRYCSS|DWL_EMPTY);
4811 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4813 test_UIDeactivate();
4814 test_InPlaceDeactivate(doc, TRUE);
4815 SET_EXPECT(Advise_Close);
4816 test_Close(doc, FALSE);
4817 CHECK_CALLED(Advise_Close);
4818 test_IsDirty(doc, S_FALSE);
4821 IOleDocumentView_Release(view);
4826 ref = IHTMLDocument2_Release(doc);
4827 ok(ref == 0, "ref=%d, expected 0\n", ref);
4830 static void test_edit_uiactivate(IOleObject *oleobj)
4832 IOleDocumentView *docview;
4835 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
4836 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
4838 SET_EXPECT(OnFocus_TRUE);
4839 SET_EXPECT(SetActiveObject);
4841 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4842 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4843 expect_status_text = NULL;
4845 hres = IOleDocumentView_UIActivate(docview, TRUE);
4846 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4848 CHECK_CALLED(OnFocus_TRUE);
4849 CHECK_CALLED(SetActiveObject);
4850 CHECK_CALLED(ShowUI);
4851 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4852 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4854 IOleDocumentView_Release(docview);
4857 static void test_editing_mode(BOOL do_load)
4859 IHTMLDocument2 *doc;
4866 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
4868 init_test(do_load ? LD_DOLOAD : LD_NO);
4869 call_UIActivate = CallUIActivate_AfterShow;
4871 hres = create_document(&doc);
4874 unk = doc_unk = (IUnknown*)doc;
4876 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4877 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4879 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4880 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4882 test_readyState((IUnknown*)doc);
4883 test_ViewAdviseSink(doc);
4884 test_ConnectionPointContainer(doc);
4885 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4886 test_DoVerb(oleobj);
4887 test_edit_uiactivate(oleobj);
4889 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4891 test_Persist(doc, &Moniker);
4892 stream_read = protocol_read = 0;
4893 test_exec_editmode(unk, do_load);
4894 test_UIDeactivate();
4895 call_UIActivate = CallUIActivate_None;
4896 IOleObject_Release(oleobj);
4898 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4899 test_download(DWL_VERBDONE | (do_load ? DWL_CSS|DWL_TRYCSS : 0));
4901 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
4902 test_timer(EXPECT_UPDATEUI);
4903 SET_CALLED(SetStatusText);
4905 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4908 test_exec_fontname(unk, NULL, wszTimesNewRoman);
4909 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4910 test_timer(EXPECT_UPDATEUI);
4911 test_exec_fontname(unk, NULL, wszArial);
4913 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4914 test_timer(EXPECT_UPDATEUI);
4915 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4916 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4918 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4919 test_timer(EXPECT_UPDATEUI);
4920 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4921 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4922 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4923 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4925 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4926 test_timer(EXPECT_UPDATEUI);
4927 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4928 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4931 test_UIDeactivate();
4932 test_InPlaceDeactivate(doc, TRUE);
4933 SET_EXPECT(Advise_Close);
4934 test_Close(doc, FALSE);
4935 CHECK_CALLED(Advise_Close);
4938 IOleDocumentView_Release(view);
4942 ref = IUnknown_Release(unk);
4943 ok(ref == 0, "ref=%d, expected 0\n", ref);
4946 static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw)
4948 IHTMLDocument2 *doc;
4950 IOleInPlaceSite *inplacesite;
4954 trace("Running OleDocumentView_UIActivate tests (%d %d %d)\n", do_load, use_ipsex, use_ipsw);
4956 init_test(do_load ? LD_DOLOAD : LD_NO);
4958 hres = create_document(&doc);
4961 doc_unk = (IUnknown*)doc;
4966 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4967 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4969 hres = IUnknown_QueryInterface(doc, &IID_IOleDocumentView, (void**)&view);
4970 ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08x\n", hres);
4972 SET_EXPECT(Invoke_AMBIENT_USERMODE);
4973 SET_EXPECT(GetHostInfo);
4974 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4975 SET_EXPECT(Invoke_AMBIENT_SILENT);
4976 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4977 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
4978 SET_EXPECT(Invoke_AMBIENT_PALETTE);
4979 SET_EXPECT(GetOptionKeyPath);
4980 SET_EXPECT(GetOverrideKeyPath);
4981 SET_EXPECT(GetWindow);
4982 SET_EXPECT(Exec_DOCCANNAVIGATE);
4983 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
4984 SET_EXPECT(Exec_SETPROGRESSMAX);
4985 SET_EXPECT(Exec_SETPROGRESSPOS);
4987 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
4988 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4990 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4991 CHECK_CALLED(GetHostInfo);
4992 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4993 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4994 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4995 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4996 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4997 CHECK_CALLED(GetOptionKeyPath);
4998 CHECK_CALLED(GetOverrideKeyPath);
4999 CHECK_CALLED(GetWindow);
5000 CHECK_CALLED(Exec_DOCCANNAVIGATE);
5001 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
5002 CHECK_CALLED(Exec_SETPROGRESSMAX);
5003 CHECK_CALLED(Exec_SETPROGRESSPOS);
5005 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
5006 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
5007 ok(inplacesite == NULL, "inplacesite = %p, expected NULL\n", inplacesite);
5009 SET_EXPECT(GetContainer);
5010 SET_EXPECT(LockContainer);
5011 SET_EXPECT(CanInPlaceActivate);
5012 SET_EXPECT(GetWindowContext);
5013 SET_EXPECT(GetWindow);
5015 SET_EXPECT(OnInPlaceActivateEx);
5016 SET_EXPECT(RequestUIActivate);
5019 SET_EXPECT(OnInPlaceActivate);
5020 SET_EXPECT(OnUIActivate);
5021 SET_EXPECT(SetStatusText);
5022 SET_EXPECT(Exec_SETPROGRESSMAX);
5023 SET_EXPECT(Exec_SETPROGRESSPOS);
5025 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5026 SET_EXPECT(InPlaceFrame_SetBorderSpace);
5027 SET_EXPECT(OnFocus_TRUE);
5028 SET_EXPECT(SetActiveObject);
5029 expect_LockContainer_fLock = TRUE;
5031 hres = IOleDocumentView_UIActivate(view, TRUE);
5032 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5034 CHECK_CALLED(GetContainer);
5035 CHECK_CALLED(LockContainer);
5036 CHECK_CALLED(CanInPlaceActivate);
5037 CHECK_CALLED(GetWindowContext);
5038 CHECK_CALLED(GetWindow);
5040 CHECK_CALLED(OnInPlaceActivateEx);
5041 SET_EXPECT(RequestUIActivate);
5044 CHECK_CALLED(OnInPlaceActivate);
5045 CHECK_CALLED(OnUIActivate);
5046 CHECK_CALLED(SetStatusText);
5047 CHECK_CALLED(Exec_SETPROGRESSMAX);
5048 CHECK_CALLED(Exec_SETPROGRESSPOS);
5049 CHECK_CALLED(ShowUI);
5050 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5051 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
5052 CHECK_CALLED(OnFocus_TRUE);
5053 CHECK_CALLED(SetActiveObject);
5054 container_locked = TRUE;
5056 SET_EXPECT(SetActiveObject_null);
5057 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5059 SET_EXPECT(OnUIDeactivate);
5061 hres = IOleDocumentView_UIActivate(view, FALSE);
5062 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5064 CHECK_CALLED(SetActiveObject_null);
5065 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5066 CHECK_CALLED(HideUI);
5067 CHECK_CALLED(OnUIDeactivate);
5069 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
5070 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
5071 ok(inplacesite != NULL, "inplacesite = NULL\n");
5072 IOleInPlaceSite_Release(inplacesite);
5074 SET_EXPECT(OnFocus_FALSE);
5076 SET_EXPECT(OnInPlaceDeactivateEx);
5078 SET_EXPECT(OnInPlaceDeactivate);
5082 CHECK_CALLED(OnFocus_FALSE);
5084 CHECK_CALLED(OnInPlaceDeactivateEx);
5086 CHECK_CALLED(OnInPlaceDeactivate);
5088 test_Close(doc, TRUE);
5090 IOleObject_Release(oleobj);
5091 IOleDocumentView_Release(view);
5094 ref = IHTMLDocument2_Release(doc);
5095 ok(ref == 0, "ref=%d, expected 0\n", ref);
5098 static void register_protocol(void)
5100 IInternetSession *session;
5103 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
5105 hres = CoInternetGetSession(0, &session, 0);
5106 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
5108 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
5109 wsz_winetest, 0, NULL, 0);
5110 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
5112 IInternetSession_Release(session);
5115 static void test_HTMLDoc_ISupportErrorInfo(void)
5117 IHTMLDocument2 *doc;
5119 ISupportErrorInfo *sinfo;
5122 hres = create_document(&doc);
5126 hres = IUnknown_QueryInterface(doc, &IID_ISupportErrorInfo, (void**)&sinfo);
5127 ok(hres == S_OK, "got %x\n", hres);
5128 ok(sinfo != NULL, "got %p\n", sinfo);
5131 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
5132 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
5133 IUnknown_Release(sinfo);
5136 ref = IHTMLDocument2_Release(doc);
5137 ok(ref == 0, "ref=%d, expected 0\n", ref);
5140 static void test_IPersistHistory(void)
5142 IHTMLDocument2 *doc;
5145 IPersistHistory *phist;
5147 hres = create_document(&doc);
5151 hres = IUnknown_QueryInterface(doc, &IID_IPersistHistory, (void**)&phist);
5152 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
5154 IPersistHistory_Release(phist);
5156 ref = IHTMLDocument2_Release(doc);
5157 ok(ref == 0, "ref=%d, expected 0\n", ref);
5163 container_hwnd = create_container_window();
5164 register_protocol();
5166 test_HTMLDocument_hlink();
5168 test_HTMLDocument(FALSE);
5169 test_HTMLDocument(TRUE);
5170 test_HTMLDocument_StreamLoad();
5171 test_HTMLDocument_StreamInitNew();
5172 test_editing_mode(FALSE);
5173 test_editing_mode(TRUE);
5174 test_HTMLDocument_http();
5175 test_UIActivate(FALSE, FALSE, FALSE);
5176 test_UIActivate(FALSE, TRUE, FALSE);
5177 test_UIActivate(FALSE, TRUE, TRUE);
5178 test_UIActivate(TRUE, FALSE, FALSE);
5179 test_UIActivate(TRUE, TRUE, FALSE);
5180 test_UIActivate(TRUE, TRUE, TRUE);
5182 test_HTMLDoc_ISupportErrorInfo();
5183 test_IPersistHistory();
5185 DestroyWindow(container_hwnd);