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 const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
3410 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
3411 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
3412 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
3413 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
3414 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
3415 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
3416 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
3417 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
3418 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
3419 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
3420 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
3421 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
3422 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
3423 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
3424 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
3425 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
3426 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
3427 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
3428 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
3429 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
3431 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
3432 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
3434 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
3436 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
3438 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
3439 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
3441 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
3442 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
3444 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
3446 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
3447 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
3450 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
3451 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
3453 IOleCommandTarget *cmdtrg;
3454 OLECMD olecmd = {cmdid, 0};
3457 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3458 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3462 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
3463 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
3465 IOleCommandTarget_Release(cmdtrg);
3467 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
3468 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
3471 static void test_MSHTML_QueryStatus(IHTMLDocument2 *doc, DWORD cmdf)
3473 IUnknown *unk = doc ? (IUnknown*)doc : doc_unk;
3475 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
3476 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
3477 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
3478 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
3479 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
3480 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
3481 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
3482 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
3483 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
3484 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
3485 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
3486 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
3487 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
3488 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
3489 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
3490 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
3493 static void test_OleCommandTarget(IHTMLDocument2 *doc)
3495 IOleCommandTarget *cmdtrg;
3496 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
3500 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3501 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3505 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3506 cmds[i].cmdID = i+1;
3507 cmds[i].cmdf = 0xf0f0;
3510 SET_EXPECT(QueryStatus_OPEN);
3511 SET_EXPECT(QueryStatus_NEW);
3512 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
3513 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3514 CHECK_CALLED(QueryStatus_OPEN);
3515 CHECK_CALLED(QueryStatus_NEW);
3517 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3518 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
3519 if(i+1 == OLECMDID_FIND)
3521 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
3522 i+1, cmds[i].cmdf, expect_cmds[i+1]);
3525 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
3526 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
3528 IOleCommandTarget_Release(cmdtrg);
3531 static void test_OleCommandTarget_fail(IHTMLDocument2 *doc)
3533 IOleCommandTarget *cmdtrg;
3538 {OLECMDID_OPEN, 0xf0f0},
3539 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
3542 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3543 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
3547 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
3548 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3550 SET_EXPECT(QueryStatus_OPEN);
3551 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
3552 CHECK_CALLED(QueryStatus_OPEN);
3554 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3555 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3556 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3557 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3558 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3559 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3560 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3562 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3563 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3564 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3566 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3567 if(!expect_cmds[i]) {
3568 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3569 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3570 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3571 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3575 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3576 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3577 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3578 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3580 IOleCommandTarget_Release(cmdtrg);
3583 static void test_exec_onunload(IHTMLDocument2 *doc)
3585 IOleCommandTarget *cmdtrg;
3589 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
3590 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3594 memset(&var, 0x0a, sizeof(var));
3595 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3596 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3597 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3598 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3599 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3601 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3602 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3603 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3605 IOleCommandTarget_Release(cmdtrg);
3608 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3610 IOleCommandTarget *cmdtrg;
3613 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3614 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3621 load_state = LD_DOLOAD;
3624 SET_EXPECT(GetClassID);
3625 SET_EXPECT(SetStatusText);
3626 SET_EXPECT(Exec_ShellDocView_37);
3627 SET_EXPECT(GetHostInfo);
3629 SET_EXPECT(GetDisplayName);
3630 SET_EXPECT(Invoke_AMBIENT_SILENT);
3631 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3632 SET_EXPECT(OnChanged_READYSTATE);
3633 SET_EXPECT(IsSystemMoniker);
3634 SET_EXPECT(Exec_ShellDocView_84);
3636 SET_EXPECT(BindToStorage);
3637 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3640 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3642 expect_status_text = NULL;
3643 readystate_set_loading = TRUE;
3645 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3646 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3647 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3650 CHECK_CALLED(GetClassID);
3651 CHECK_CALLED(SetStatusText);
3652 CHECK_CALLED(Exec_ShellDocView_37);
3653 CHECK_CALLED(GetHostInfo);
3655 CHECK_CALLED(GetDisplayName);
3656 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3657 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3658 CHECK_CALLED(OnChanged_READYSTATE);
3659 SET_CALLED(IsSystemMoniker); /* IE7 */
3660 SET_CALLED(Exec_ShellDocView_84);
3662 CHECK_CALLED(BindToStorage);
3663 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3664 CHECK_CALLED(HideUI);
3665 CHECK_CALLED(ShowUI);
3666 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3668 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3670 IOleCommandTarget_Release(cmdtrg);
3672 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3673 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3674 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3677 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3679 IOleCommandTarget *cmdtrg;
3680 VARIANT *in = NULL, _in, *out = NULL, _out;
3683 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3684 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3691 V_BSTR(in) = SysAllocString(name);
3697 V_I4(out) = 0xdeadbeef;
3700 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3701 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3707 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3708 if(V_VT(out) == VT_BSTR) {
3710 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3711 "unexpected fontname %s\n", wine_dbgstr_w(name));
3713 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3718 IOleCommandTarget_Release(cmdtrg);
3721 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3723 IOleCommandTarget *cmdtrg;
3726 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3727 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3731 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3732 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3733 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3735 IOleCommandTarget_Release(cmdtrg);
3738 static void test_IsDirty(IHTMLDocument2 *doc, HRESULT exhres)
3740 IPersistStreamInit *perinit;
3741 IPersistMoniker *permon;
3742 IPersistFile *perfile;
3745 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&perinit);
3746 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3747 if(SUCCEEDED(hres)) {
3748 hres = IPersistStreamInit_IsDirty(perinit);
3749 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3750 IPersistStreamInit_Release(perinit);
3753 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&permon);
3754 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3755 if(SUCCEEDED(hres)) {
3756 hres = IPersistMoniker_IsDirty(permon);
3757 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3758 IPersistMoniker_Release(permon);
3761 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&perfile);
3762 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3763 if(SUCCEEDED(hres)) {
3764 hres = IPersistFile_IsDirty(perfile);
3765 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3766 IPersistFile_Release(perfile);
3770 static HWND create_container_window(void)
3772 static const WCHAR wszHTMLDocumentTest[] =
3773 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3774 static WNDCLASSEXW wndclass = {
3775 sizeof(WNDCLASSEXW),
3778 0, 0, NULL, NULL, NULL, NULL, NULL,
3779 wszHTMLDocumentTest,
3783 RegisterClassExW(&wndclass);
3784 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3785 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3786 515, 530, NULL, NULL, NULL, NULL);
3789 static void test_DoVerb(IOleObject *oleobj)
3791 RECT rect = {0,0,500,500};
3794 if(!container_locked) {
3795 SET_EXPECT(GetContainer);
3796 SET_EXPECT(LockContainer);
3798 SET_EXPECT(ActivateMe);
3799 expect_LockContainer_fLock = TRUE;
3801 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3802 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3804 if(!container_locked) {
3805 CHECK_CALLED(GetContainer);
3806 CHECK_CALLED(LockContainer);
3807 container_locked = TRUE;
3809 CHECK_CALLED(ActivateMe);
3812 #define CLIENTSITE_EXPECTPATH 0x00000001
3813 #define CLIENTSITE_SETNULL 0x00000002
3814 #define CLIENTSITE_DONTSET 0x00000004
3816 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3818 IOleClientSite *clientsite;
3821 if(flags & CLIENTSITE_SETNULL) {
3822 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3823 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3825 hres = IOleObject_SetClientSite(oleobj, NULL);
3826 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3828 set_clientsite = FALSE;
3831 if(flags & CLIENTSITE_DONTSET)
3834 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3835 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3836 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3837 clientsite, set_clientsite ? &ClientSite : NULL);
3839 if(!set_clientsite) {
3840 SET_EXPECT(GetHostInfo);
3841 if(flags & CLIENTSITE_EXPECTPATH) {
3842 SET_EXPECT(GetOptionKeyPath);
3843 SET_EXPECT(GetOverrideKeyPath);
3845 SET_EXPECT(GetWindow);
3846 if(flags & CLIENTSITE_EXPECTPATH)
3847 SET_EXPECT(Exec_DOCCANNAVIGATE);
3848 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3849 SET_EXPECT(Exec_SETPROGRESSMAX);
3850 SET_EXPECT(Exec_SETPROGRESSPOS);
3851 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3852 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3853 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3854 SET_EXPECT(Invoke_AMBIENT_SILENT);
3855 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3856 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3858 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3859 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3861 CHECK_CALLED(GetHostInfo);
3862 if(flags & CLIENTSITE_EXPECTPATH) {
3863 CHECK_CALLED(GetOptionKeyPath);
3864 CHECK_CALLED(GetOverrideKeyPath);
3866 CHECK_CALLED(GetWindow);
3867 if(flags & CLIENTSITE_EXPECTPATH)
3868 CHECK_CALLED(Exec_DOCCANNAVIGATE);
3869 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3870 CHECK_CALLED(Exec_SETPROGRESSMAX);
3871 CHECK_CALLED(Exec_SETPROGRESSPOS);
3872 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3873 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3874 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3875 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3876 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3877 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3879 set_clientsite = TRUE;
3882 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3883 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3885 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3886 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3887 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3890 static void test_OnAmbientPropertyChange(IHTMLDocument2 *doc)
3892 IOleControl *control = NULL;
3895 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
3896 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3900 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3901 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3902 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3903 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3905 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3906 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3907 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3908 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3910 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3911 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3912 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3913 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3914 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3915 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3917 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3918 SET_EXPECT(Invoke_AMBIENT_SILENT);
3919 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3920 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3921 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3922 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3924 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3925 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3926 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3927 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3929 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3930 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3931 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3932 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3934 IOleControl_Release(control);
3939 static void test_OnAmbientPropertyChange2(IHTMLDocument2 *doc)
3941 IOleControl *control = NULL;
3944 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
3945 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3949 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3950 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3952 IOleControl_Release(control);
3955 static void test_Close(IHTMLDocument2 *doc, BOOL set_client)
3957 IOleObject *oleobj = NULL;
3960 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
3961 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3965 SET_EXPECT(GetContainer);
3966 SET_EXPECT(LockContainer);
3967 expect_LockContainer_fLock = FALSE;
3968 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3969 ok(hres == S_OK, "Close failed: %08x\n", hres);
3970 CHECK_CALLED(GetContainer);
3971 CHECK_CALLED(LockContainer);
3972 container_locked = FALSE;
3975 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3977 IOleObject_Release(oleobj);
3980 static void test_Advise(IHTMLDocument2 *doc)
3982 IOleObject *oleobj = NULL;
3983 IEnumSTATDATA *enum_advise = (void*)0xdeadbeef;
3987 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
3988 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3992 hres = IOleObject_Unadvise(oleobj, 0);
3993 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
3995 hres = IOleObject_EnumAdvise(oleobj, &enum_advise);
3996 ok(hres == S_OK, "EnumAdvise returned: %08x\n", hres);
3997 ok(enum_advise == NULL, "enum_advise != NULL\n");
4000 hres = IOleObject_Advise(oleobj, NULL, &conn);
4001 /* Old IE returns S_OK and sets conn to 1 */
4002 ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres);
4003 ok(conn == 0 || conn == 1, "conn = %d\n", conn);
4005 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL);
4006 ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
4008 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4009 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4010 ok(conn == 1, "conn = %d\n", conn);
4012 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4013 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4014 ok(conn == 2, "conn = %d\n", conn);
4016 hres = IOleObject_Unadvise(oleobj, 1);
4017 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4019 hres = IOleObject_Unadvise(oleobj, 1);
4020 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
4022 hres = IOleObject_Unadvise(oleobj, 2);
4023 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4025 IOleObject_Release(oleobj);
4028 static void test_OnFrameWindowActivate(IUnknown *unk)
4030 IOleInPlaceActiveObject *inplaceact;
4033 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
4034 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
4038 if(set_clientsite) {
4039 expect_OnFrameWindowActivate_fActivate = TRUE;
4040 SET_EXPECT(OnFrameWindowActivate);
4041 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4042 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4043 CHECK_CALLED(OnFrameWindowActivate);
4045 SET_EXPECT(OnFrameWindowActivate);
4046 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4047 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4048 CHECK_CALLED(OnFrameWindowActivate);
4050 expect_OnFrameWindowActivate_fActivate = FALSE;
4051 SET_EXPECT(OnFrameWindowActivate);
4052 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
4053 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4054 CHECK_CALLED(OnFrameWindowActivate);
4056 expect_OnFrameWindowActivate_fActivate = TRUE;
4057 SET_EXPECT(OnFrameWindowActivate);
4058 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4059 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4060 CHECK_CALLED(OnFrameWindowActivate);
4062 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
4063 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4065 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
4066 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
4069 IOleInPlaceActiveObject_Release(inplaceact);
4072 static void test_InPlaceDeactivate(IHTMLDocument2 *doc, BOOL expect_call)
4074 IOleInPlaceObjectWindowless *windowlessobj = NULL;
4077 hres = IUnknown_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless,
4078 (void**)&windowlessobj);
4079 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
4084 SET_EXPECT(OnFocus_FALSE);
4086 SET_EXPECT(OnInPlaceDeactivateEx);
4088 SET_EXPECT(OnInPlaceDeactivate);
4090 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
4091 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
4093 CHECK_CALLED(OnFocus_FALSE);
4095 CHECK_CALLED(OnInPlaceDeactivateEx);
4097 CHECK_CALLED(OnInPlaceDeactivate);
4100 IOleInPlaceObjectWindowless_Release(windowlessobj);
4103 static void test_Activate(IHTMLDocument2 *doc, DWORD flags)
4105 IOleObject *oleobj = NULL;
4106 IOleDocumentView *docview;
4113 IOleDocumentView_Release(view);
4116 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4117 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4119 hres = IOleObject_GetUserClassID(oleobj, NULL);
4120 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
4122 hres = IOleObject_GetUserClassID(oleobj, &guid);
4123 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
4124 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
4126 test_OnFrameWindowActivate((IUnknown*)doc);
4128 test_ClientSite(oleobj, flags);
4129 test_InPlaceDeactivate(doc, FALSE);
4130 test_DoVerb(oleobj);
4132 if(call_UIActivate == CallUIActivate_AfterShow) {
4133 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
4134 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
4136 SET_EXPECT(OnFocus_TRUE);
4137 SET_EXPECT(SetActiveObject);
4139 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4140 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4141 expect_status_text = NULL;
4143 hres = IOleDocumentView_UIActivate(docview, TRUE);
4144 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4146 CHECK_CALLED(OnFocus_TRUE);
4147 CHECK_CALLED(SetActiveObject);
4148 CHECK_CALLED(ShowUI);
4149 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4150 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4152 IOleDocumentView_Release(docview);
4155 IOleObject_Release(oleobj);
4157 test_OnFrameWindowActivate((IUnknown*)doc);
4160 static void test_Window(IHTMLDocument2 *doc, BOOL expect_success)
4162 IOleInPlaceActiveObject *activeobject = NULL;
4166 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
4167 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
4171 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
4173 if(expect_success) {
4174 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
4175 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
4177 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
4178 ok(IsWindow(hwnd), "hwnd is destroyed\n");
4181 IOleInPlaceActiveObject_Release(activeobject);
4184 static void test_CloseView(void)
4186 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
4192 hres = IOleDocumentView_Show(view, FALSE);
4193 ok(hres == S_OK, "Show failed: %08x\n", hres);
4195 hres = IOleDocumentView_CloseView(view, 0);
4196 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
4198 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
4199 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
4201 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
4202 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
4203 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
4206 static void test_UIDeactivate(void)
4210 if(call_UIActivate == CallUIActivate_AfterShow) {
4211 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4213 if(call_UIActivate != CallUIActivate_None) {
4214 SET_EXPECT(SetActiveObject_null);
4216 SET_EXPECT(OnUIDeactivate);
4219 hres = IOleDocumentView_UIActivate(view, FALSE);
4220 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
4222 if(call_UIActivate != CallUIActivate_None) {
4223 CHECK_CALLED(SetActiveObject_null);
4224 CHECK_CALLED(HideUI);
4225 CHECK_CALLED(OnUIDeactivate);
4227 if(call_UIActivate == CallUIActivate_AfterShow) {
4228 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4232 static void test_Hide(void)
4239 hres = IOleDocumentView_Show(view, FALSE);
4240 ok(hres == S_OK, "Show failed: %08x\n", hres);
4243 static HRESULT create_document(IHTMLDocument2 **doc)
4245 IHTMLDocument5 *doc5;
4248 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
4249 &IID_IHTMLDocument2, (void**)doc);
4250 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
4254 hres = IHTMLDocument2_QueryInterface(*doc, &IID_IHTMLDocument5, (void**)&doc5);
4255 if(SUCCEEDED(hres)) {
4256 IHTMLDocument5_Release(doc5);
4258 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
4259 IHTMLDocument2_Release(*doc);
4265 static void test_Navigate(IHTMLDocument2 *doc)
4267 IHlinkTarget *hlink;
4270 hres = IUnknown_QueryInterface(doc, &IID_IHlinkTarget, (void**)&hlink);
4271 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
4273 SET_EXPECT(ActivateMe);
4274 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
4275 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
4276 CHECK_CALLED(ActivateMe);
4278 IHlinkTarget_Release(hlink);
4281 static void test_external(IHTMLDocument2 *doc, BOOL initialized)
4283 IDispatch *external;
4284 IHTMLWindow2 *htmlwin;
4287 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
4288 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4291 SET_EXPECT(GetExternal);
4292 external = (void*)0xdeadbeef;
4293 hres = IHTMLWindow2_get_external(htmlwin, &external);
4295 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
4296 CHECK_CALLED(GetExternal);
4297 ok(external != NULL, "external == NULL\n");
4299 ok(hres == S_OK, "get_external failed: %08x\n", hres);
4300 ok(external == NULL, "external != NULL\n");
4303 IHTMLWindow2_Release(htmlwin);
4306 static void test_StreamLoad(IHTMLDocument2 *doc)
4308 IPersistStreamInit *init;
4311 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4312 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
4316 SET_EXPECT(Invoke_AMBIENT_SILENT);
4317 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4318 SET_EXPECT(Exec_ShellDocView_37);
4319 SET_EXPECT(OnChanged_READYSTATE);
4321 readystate_set_loading = TRUE;
4323 hres = IPersistStreamInit_Load(init, &Stream);
4324 ok(hres == S_OK, "Load failed: %08x\n", hres);
4326 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4327 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4328 CHECK_CALLED(Exec_ShellDocView_37);
4329 CHECK_CALLED(OnChanged_READYSTATE);
4332 test_timer(EXPECT_SETTITLE);
4333 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4335 IPersistStreamInit_Release(init);
4338 static void test_StreamInitNew(IHTMLDocument2 *doc)
4340 IPersistStreamInit *init;
4343 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
4344 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
4348 SET_EXPECT(Invoke_AMBIENT_SILENT);
4349 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4350 SET_EXPECT(Exec_ShellDocView_37);
4351 SET_EXPECT(OnChanged_READYSTATE);
4352 readystate_set_loading = TRUE;
4354 hres = IPersistStreamInit_InitNew(init);
4355 ok(hres == S_OK, "Load failed: %08x\n", hres);
4357 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4358 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4359 CHECK_CALLED(Exec_ShellDocView_37);
4360 CHECK_CALLED(OnChanged_READYSTATE);
4362 test_timer(EXPECT_SETTITLE);
4363 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4365 IPersistStreamInit_Release(init);
4368 static void test_QueryInterface(IHTMLDocument2 *doc)
4373 static const IID IID_UndocumentedScriptIface =
4374 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
4376 qi = (void*)0xdeadbeef;
4377 hres = IUnknown_QueryInterface(doc, &IID_IRunnableObject, (void**)&qi);
4378 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4379 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
4381 qi = (void*)0xdeadbeef;
4382 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode, (void**)&qi);
4383 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4384 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4386 qi = (void*)0xdeadbeef;
4387 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode2, (void**)&qi);
4388 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4389 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4391 qi = (void*)0xdeadbeef;
4392 hres = IUnknown_QueryInterface(doc, &IID_IPersistPropertyBag, (void**)&qi);
4393 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4394 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4396 qi = (void*)0xdeadbeef;
4397 hres = IUnknown_QueryInterface(doc, &IID_UndocumentedScriptIface, (void**)&qi);
4398 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4399 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4401 qi = (void*)0xdeadbeef;
4402 hres = IUnknown_QueryInterface(doc, &IID_IMarshal, (void**)&qi);
4403 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4404 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4406 qi = (void*)0xdeadbeef;
4407 hres = IUnknown_QueryInterface(doc, &IID_IExternalConnection, (void**)&qi);
4408 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4409 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4411 qi = (void*)0xdeadbeef;
4412 hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi);
4413 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
4414 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
4417 static void init_test(enum load_state_t ls) {
4419 hwnd = last_hwnd = NULL;
4420 set_clientsite = FALSE;
4421 load_from_stream = FALSE;
4422 call_UIActivate = CallUIActivate_None;
4428 inplace_deactivated = FALSE;
4429 navigated_load = FALSE;
4432 static void test_HTMLDocument(BOOL do_load)
4434 IHTMLDocument2 *doc;
4438 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
4440 init_test(do_load ? LD_DOLOAD : LD_NO);
4442 hres = create_document(&doc);
4445 doc_unk = (IUnknown*)doc;
4447 test_QueryInterface(doc);
4449 test_IsDirty(doc, S_FALSE);
4450 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4451 test_external(doc, FALSE);
4452 test_ViewAdviseSink(doc);
4453 test_ConnectionPointContainer(doc);
4454 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4455 test_Persist(doc, &Moniker);
4457 test_OnAmbientPropertyChange2(doc);
4459 test_Activate(doc, CLIENTSITE_EXPECTPATH);
4462 test_download(DWL_CSS|DWL_TRYCSS);
4463 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4466 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4467 test_OleCommandTarget_fail(doc);
4468 test_OleCommandTarget(doc);
4469 test_OnAmbientPropertyChange(doc);
4470 test_Window(doc, TRUE);
4471 test_external(doc, TRUE);
4473 test_UIDeactivate();
4474 test_OleCommandTarget(doc);
4475 test_Window(doc, TRUE);
4476 test_InPlaceDeactivate(doc, TRUE);
4478 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
4479 * MSHTML. It doesn't with Wine. */
4481 test_Window(doc, FALSE);
4483 test_InPlaceDeactivate(doc, FALSE);
4485 test_Close(doc, FALSE);
4487 /* Activate HTMLDocument again */
4488 test_Activate(doc, CLIENTSITE_SETNULL);
4489 test_Window(doc, TRUE);
4490 test_OleCommandTarget(doc);
4491 test_UIDeactivate();
4492 test_InPlaceDeactivate(doc, TRUE);
4493 test_Close(doc, FALSE);
4495 /* Activate HTMLDocument again, this time without UIActivate */
4496 call_UIActivate = CallUIActivate_None;
4497 test_Activate(doc, CLIENTSITE_SETNULL);
4498 test_Window(doc, TRUE);
4500 test_UIDeactivate();
4501 test_InPlaceDeactivate(doc, TRUE);
4504 test_Close(doc, TRUE);
4505 test_OnAmbientPropertyChange2(doc);
4506 test_GetCurMoniker((IUnknown*)doc, do_load ? &Moniker : NULL, NULL);
4509 /* Activate HTMLDocument again, calling UIActivate after showing the window */
4510 call_UIActivate = CallUIActivate_AfterShow;
4511 test_Activate(doc, 0);
4512 test_Window(doc, TRUE);
4513 test_OleCommandTarget(doc);
4514 test_UIDeactivate();
4515 test_InPlaceDeactivate(doc, TRUE);
4516 test_Close(doc, FALSE);
4517 call_UIActivate = CallUIActivate_None;
4521 IOleDocumentView_Release(view);
4524 ok(IsWindow(hwnd), "hwnd is destroyed\n");
4526 ref = IHTMLDocument2_Release(doc);
4527 ok(ref == 0, "ref=%d, expected 0\n", ref);
4529 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
4532 static void test_HTMLDocument_hlink(void)
4534 IHTMLDocument2 *doc;
4538 trace("Testing HTMLDocument (hlink)...\n");
4540 init_test(LD_DOLOAD);
4543 hres = create_document(&doc);
4546 doc_unk = (IUnknown*)doc;
4548 test_ViewAdviseSink(doc);
4549 test_ConnectionPointContainer(doc);
4550 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4551 test_Persist(doc, &Moniker);
4554 IUnknown_Release(doc);
4558 test_download(DWL_CSS|DWL_TRYCSS);
4560 test_IsDirty(doc, S_FALSE);
4561 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4563 test_exec_onunload(doc);
4564 test_Window(doc, TRUE);
4565 test_InPlaceDeactivate(doc, TRUE);
4566 test_Close(doc, FALSE);
4567 test_IsDirty(doc, S_FALSE);
4568 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
4571 IOleDocumentView_Release(view);
4574 ref = IHTMLDocument2_Release(doc);
4575 ok(ref == 0, "ref=%d, expected 0\n", ref);
4578 static void test_cookies(IHTMLDocument2 *doc)
4586 hres = IHTMLDocument2_get_cookie(doc, &str);
4587 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4589 size = sizeof(buf)/sizeof(WCHAR);
4590 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4591 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4592 ok(!lstrcmpW(buf, str), "cookie = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(buf));
4596 str = a2bstr("test=testval");
4597 hres = IHTMLDocument2_put_cookie(doc, str);
4598 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
4601 hres = IHTMLDocument2_get_cookie(doc, &str2);
4602 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4603 ok(str2 != NULL, "cookie = NULL\n");
4604 size = sizeof(buf)/sizeof(WCHAR);
4605 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4606 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4607 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
4608 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
4610 SysFreeString(str2);
4612 str = a2bstr("test=testval2");
4613 hres = IHTMLDocument2_put_cookie(doc, str);
4614 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
4617 hres = IHTMLDocument2_get_cookie(doc, &str2);
4618 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
4619 ok(str2 != NULL, "cookie = NULL\n");
4620 size = sizeof(buf)/sizeof(WCHAR);
4621 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
4622 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
4623 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
4624 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
4626 SysFreeString(str2);
4629 static void test_HTMLDocument_http(void)
4632 IHTMLDocument2 *doc;
4636 trace("Testing HTMLDocument (http)...\n");
4638 if(!winetest_interactive && is_ie_hardened()) {
4639 win_skip("IE running in Enhanced Security Configuration\n");
4643 init_test(LD_DOLOAD);
4646 hres = create_document(&doc);
4649 doc_unk = (IUnknown*)doc;
4651 hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
4652 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
4654 test_ViewAdviseSink(doc);
4655 test_ConnectionPointContainer(doc);
4656 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4657 test_Persist(doc, http_mon);
4660 IUnknown_Release(doc);
4664 test_download(DWL_HTTP);
4666 test_IsDirty(doc, S_FALSE);
4667 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4668 test_GetCurMoniker((IUnknown*)doc, http_mon, NULL);
4672 test_InPlaceDeactivate(doc, TRUE);
4673 test_Close(doc, FALSE);
4674 test_IsDirty(doc, S_FALSE);
4675 test_GetCurMoniker((IUnknown*)doc, NULL, about_blank_url);
4678 IOleDocumentView_Release(view);
4681 ref = IHTMLDocument2_Release(doc);
4682 ok(!ref, "ref=%d, expected 0\n", ref);
4684 ref = IMoniker_Release(http_mon);
4685 ok(!ref, "ref=%d, expected 0\n", ref);
4688 static void test_QueryService(IHTMLDocument2 *doc, BOOL success)
4690 IServiceProvider *sp;
4694 hres = IUnknown_QueryInterface(doc, &IID_IServiceProvider, (void**)&sp);
4695 ok(hres == S_OK, "QueryService returned %08x\n", hres);
4697 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
4699 IHlinkFrame_Release(hf);
4701 ok(hres == (success?S_OK:E_NOINTERFACE), "QueryService returned %08x, expected %08x\n", hres, success?S_OK:E_NOINTERFACE);
4703 IServiceProvider_Release(sp);
4706 static void test_HTMLDocument_StreamLoad(void)
4708 IHTMLDocument2 *doc;
4714 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
4716 init_test(LD_DOLOAD);
4717 load_from_stream = TRUE;
4719 hres = create_document(&doc);
4722 doc_unk = (IUnknown*)doc;
4724 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4725 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4727 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4728 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4730 test_readyState((IUnknown*)doc);
4731 test_IsDirty(doc, S_FALSE);
4732 test_ViewAdviseSink(doc);
4733 test_ConnectionPointContainer(doc);
4734 test_QueryService(doc, FALSE);
4735 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4736 test_QueryService(doc, TRUE);
4737 test_DoVerb(oleobj);
4738 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4740 IOleObject_Release(oleobj);
4742 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4743 test_StreamLoad(doc);
4744 test_download(DWL_VERBDONE|DWL_TRYCSS);
4745 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4747 test_UIDeactivate();
4748 test_InPlaceDeactivate(doc, TRUE);
4749 SET_EXPECT(Advise_Close);
4750 test_Close(doc, FALSE);
4751 CHECK_CALLED(Advise_Close);
4752 test_IsDirty(doc, S_FALSE);
4755 IOleDocumentView_Release(view);
4760 ref = IHTMLDocument2_Release(doc);
4761 ok(ref == 0, "ref=%d, expected 0\n", ref);
4764 static void test_HTMLDocument_StreamInitNew(void)
4766 IHTMLDocument2 *doc;
4772 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
4774 init_test(LD_DOLOAD);
4775 load_from_stream = TRUE;
4777 hres = create_document(&doc);
4780 doc_unk = (IUnknown*)doc;
4782 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4783 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4785 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4786 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4788 test_readyState((IUnknown*)doc);
4789 test_IsDirty(doc, S_FALSE);
4790 test_ViewAdviseSink(doc);
4791 test_ConnectionPointContainer(doc);
4792 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4793 test_DoVerb(oleobj);
4794 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4796 IOleObject_Release(oleobj);
4798 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
4799 test_StreamInitNew(doc);
4800 test_download(DWL_VERBDONE|DWL_TRYCSS|DWL_EMPTY);
4801 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4803 test_UIDeactivate();
4804 test_InPlaceDeactivate(doc, TRUE);
4805 SET_EXPECT(Advise_Close);
4806 test_Close(doc, FALSE);
4807 CHECK_CALLED(Advise_Close);
4808 test_IsDirty(doc, S_FALSE);
4811 IOleDocumentView_Release(view);
4816 ref = IHTMLDocument2_Release(doc);
4817 ok(ref == 0, "ref=%d, expected 0\n", ref);
4820 static void test_edit_uiactivate(IOleObject *oleobj)
4822 IOleDocumentView *docview;
4825 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
4826 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
4828 SET_EXPECT(OnFocus_TRUE);
4829 SET_EXPECT(SetActiveObject);
4831 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4832 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4833 expect_status_text = NULL;
4835 hres = IOleDocumentView_UIActivate(docview, TRUE);
4836 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4838 CHECK_CALLED(OnFocus_TRUE);
4839 CHECK_CALLED(SetActiveObject);
4840 CHECK_CALLED(ShowUI);
4841 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4842 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4844 IOleDocumentView_Release(docview);
4847 static void test_editing_mode(BOOL do_load)
4849 IHTMLDocument2 *doc;
4856 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
4858 init_test(do_load ? LD_DOLOAD : LD_NO);
4859 call_UIActivate = CallUIActivate_AfterShow;
4861 hres = create_document(&doc);
4864 unk = doc_unk = (IUnknown*)doc;
4866 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4867 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4869 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4870 ok(hres == S_OK, "Advise failed: %08x\n", hres);
4872 test_readyState((IUnknown*)doc);
4873 test_ViewAdviseSink(doc);
4874 test_ConnectionPointContainer(doc);
4875 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4876 test_DoVerb(oleobj);
4877 test_edit_uiactivate(oleobj);
4879 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4881 test_Persist(doc, &Moniker);
4882 stream_read = protocol_read = 0;
4883 test_exec_editmode(unk, do_load);
4884 test_UIDeactivate();
4885 call_UIActivate = CallUIActivate_None;
4886 IOleObject_Release(oleobj);
4888 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
4889 test_download(DWL_VERBDONE | (do_load ? DWL_CSS|DWL_TRYCSS : 0));
4891 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
4892 test_timer(EXPECT_UPDATEUI);
4893 SET_CALLED(SetStatusText);
4895 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4898 test_exec_fontname(unk, NULL, wszTimesNewRoman);
4899 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4900 test_timer(EXPECT_UPDATEUI);
4901 test_exec_fontname(unk, NULL, wszArial);
4903 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4904 test_timer(EXPECT_UPDATEUI);
4905 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4906 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4908 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4909 test_timer(EXPECT_UPDATEUI);
4910 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4911 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4912 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4913 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4915 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4916 test_timer(EXPECT_UPDATEUI);
4917 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4918 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4921 test_UIDeactivate();
4922 test_InPlaceDeactivate(doc, TRUE);
4923 SET_EXPECT(Advise_Close);
4924 test_Close(doc, FALSE);
4925 CHECK_CALLED(Advise_Close);
4928 IOleDocumentView_Release(view);
4932 ref = IUnknown_Release(unk);
4933 ok(ref == 0, "ref=%d, expected 0\n", ref);
4936 static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw)
4938 IHTMLDocument2 *doc;
4940 IOleInPlaceSite *inplacesite;
4944 trace("Running OleDocumentView_UIActivate tests (%d %d %d)\n", do_load, use_ipsex, use_ipsw);
4946 init_test(do_load ? LD_DOLOAD : LD_NO);
4948 hres = create_document(&doc);
4951 doc_unk = (IUnknown*)doc;
4956 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4957 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4959 hres = IUnknown_QueryInterface(doc, &IID_IOleDocumentView, (void**)&view);
4960 ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08x\n", hres);
4962 SET_EXPECT(Invoke_AMBIENT_USERMODE);
4963 SET_EXPECT(GetHostInfo);
4964 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4965 SET_EXPECT(Invoke_AMBIENT_SILENT);
4966 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4967 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
4968 SET_EXPECT(Invoke_AMBIENT_PALETTE);
4969 SET_EXPECT(GetOptionKeyPath);
4970 SET_EXPECT(GetOverrideKeyPath);
4971 SET_EXPECT(GetWindow);
4972 SET_EXPECT(Exec_DOCCANNAVIGATE);
4973 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
4974 SET_EXPECT(Exec_SETPROGRESSMAX);
4975 SET_EXPECT(Exec_SETPROGRESSPOS);
4977 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
4978 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4980 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4981 CHECK_CALLED(GetHostInfo);
4982 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4983 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4984 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4985 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4986 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4987 CHECK_CALLED(GetOptionKeyPath);
4988 CHECK_CALLED(GetOverrideKeyPath);
4989 CHECK_CALLED(GetWindow);
4990 CHECK_CALLED(Exec_DOCCANNAVIGATE);
4991 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
4992 CHECK_CALLED(Exec_SETPROGRESSMAX);
4993 CHECK_CALLED(Exec_SETPROGRESSPOS);
4995 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
4996 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
4997 ok(inplacesite == NULL, "inplacesite = %p, expected NULL\n", inplacesite);
4999 SET_EXPECT(GetContainer);
5000 SET_EXPECT(LockContainer);
5001 SET_EXPECT(CanInPlaceActivate);
5002 SET_EXPECT(GetWindowContext);
5003 SET_EXPECT(GetWindow);
5005 SET_EXPECT(OnInPlaceActivateEx);
5006 SET_EXPECT(RequestUIActivate);
5009 SET_EXPECT(OnInPlaceActivate);
5010 SET_EXPECT(OnUIActivate);
5011 SET_EXPECT(SetStatusText);
5012 SET_EXPECT(Exec_SETPROGRESSMAX);
5013 SET_EXPECT(Exec_SETPROGRESSPOS);
5015 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5016 SET_EXPECT(InPlaceFrame_SetBorderSpace);
5017 SET_EXPECT(OnFocus_TRUE);
5018 SET_EXPECT(SetActiveObject);
5019 expect_LockContainer_fLock = TRUE;
5021 hres = IOleDocumentView_UIActivate(view, TRUE);
5022 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5024 CHECK_CALLED(GetContainer);
5025 CHECK_CALLED(LockContainer);
5026 CHECK_CALLED(CanInPlaceActivate);
5027 CHECK_CALLED(GetWindowContext);
5028 CHECK_CALLED(GetWindow);
5030 CHECK_CALLED(OnInPlaceActivateEx);
5031 SET_EXPECT(RequestUIActivate);
5034 CHECK_CALLED(OnInPlaceActivate);
5035 CHECK_CALLED(OnUIActivate);
5036 CHECK_CALLED(SetStatusText);
5037 CHECK_CALLED(Exec_SETPROGRESSMAX);
5038 CHECK_CALLED(Exec_SETPROGRESSPOS);
5039 CHECK_CALLED(ShowUI);
5040 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5041 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
5042 CHECK_CALLED(OnFocus_TRUE);
5043 CHECK_CALLED(SetActiveObject);
5044 container_locked = TRUE;
5046 SET_EXPECT(SetActiveObject_null);
5047 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5049 SET_EXPECT(OnUIDeactivate);
5051 hres = IOleDocumentView_UIActivate(view, FALSE);
5052 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5054 CHECK_CALLED(SetActiveObject_null);
5055 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5056 CHECK_CALLED(HideUI);
5057 CHECK_CALLED(OnUIDeactivate);
5059 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
5060 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
5061 ok(inplacesite != NULL, "inplacesite = NULL\n");
5062 IOleInPlaceSite_Release(inplacesite);
5064 SET_EXPECT(OnFocus_FALSE);
5066 SET_EXPECT(OnInPlaceDeactivateEx);
5068 SET_EXPECT(OnInPlaceDeactivate);
5072 CHECK_CALLED(OnFocus_FALSE);
5074 CHECK_CALLED(OnInPlaceDeactivateEx);
5076 CHECK_CALLED(OnInPlaceDeactivate);
5078 test_Close(doc, TRUE);
5080 IOleObject_Release(oleobj);
5081 IOleDocumentView_Release(view);
5084 ref = IHTMLDocument2_Release(doc);
5085 ok(ref == 0, "ref=%d, expected 0\n", ref);
5088 static void register_protocol(void)
5090 IInternetSession *session;
5093 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
5095 hres = CoInternetGetSession(0, &session, 0);
5096 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
5098 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
5099 wsz_winetest, 0, NULL, 0);
5100 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
5102 IInternetSession_Release(session);
5105 static void test_HTMLDoc_ISupportErrorInfo(void)
5107 IHTMLDocument2 *doc;
5109 ISupportErrorInfo *sinfo;
5112 hres = create_document(&doc);
5116 hres = IUnknown_QueryInterface(doc, &IID_ISupportErrorInfo, (void**)&sinfo);
5117 ok(hres == S_OK, "got %x\n", hres);
5118 ok(sinfo != NULL, "got %p\n", sinfo);
5121 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
5122 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
5123 IUnknown_Release(sinfo);
5126 ref = IHTMLDocument2_Release(doc);
5127 ok(ref == 0, "ref=%d, expected 0\n", ref);
5130 static void test_IPersistHistory(void)
5132 IHTMLDocument2 *doc;
5135 IPersistHistory *phist;
5137 hres = create_document(&doc);
5141 hres = IUnknown_QueryInterface(doc, &IID_IPersistHistory, (void**)&phist);
5142 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
5144 IPersistHistory_Release(phist);
5146 ref = IHTMLDocument2_Release(doc);
5147 ok(ref == 0, "ref=%d, expected 0\n", ref);
5153 container_hwnd = create_container_window();
5154 register_protocol();
5156 test_HTMLDocument_hlink();
5158 test_HTMLDocument(FALSE);
5159 test_HTMLDocument(TRUE);
5160 test_HTMLDocument_StreamLoad();
5161 test_HTMLDocument_StreamInitNew();
5162 test_editing_mode(FALSE);
5163 test_editing_mode(TRUE);
5164 test_HTMLDocument_http();
5165 test_UIActivate(FALSE, FALSE, FALSE);
5166 test_UIActivate(FALSE, TRUE, FALSE);
5167 test_UIActivate(FALSE, TRUE, TRUE);
5168 test_UIActivate(TRUE, FALSE, FALSE);
5169 test_UIActivate(TRUE, TRUE, FALSE);
5170 test_UIActivate(TRUE, TRUE, TRUE);
5172 test_HTMLDoc_ISupportErrorInfo();
5173 test_IPersistHistory();
5175 DestroyWindow(container_hwnd);