2 * Copyright 2005-2007 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>
40 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
41 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
42 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
44 #define DEFINE_EXPECT(func) \
45 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
47 #define SET_EXPECT(func) \
48 expect_ ## func = TRUE
50 #define SET_CALLED(func) \
51 called_ ## func = TRUE
53 #define CHECK_EXPECT2(func) \
55 ok(expect_ ##func, "unexpected call " #func "\n"); \
56 called_ ## func = TRUE; \
59 #define CHECK_EXPECT(func) \
61 CHECK_EXPECT2(func); \
62 expect_ ## func = FALSE; \
65 #define CHECK_CALLED(func) \
67 ok(called_ ## func, "expected " #func "\n"); \
68 expect_ ## func = called_ ## func = FALSE; \
71 static IOleDocumentView *view = NULL;
72 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
74 DEFINE_EXPECT(LockContainer);
75 DEFINE_EXPECT(SetActiveObject);
76 DEFINE_EXPECT(SetActiveObject_null);
77 DEFINE_EXPECT(GetWindow);
78 DEFINE_EXPECT(CanInPlaceActivate);
79 DEFINE_EXPECT(OnInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivateEx);
81 DEFINE_EXPECT(OnUIActivate);
82 DEFINE_EXPECT(GetWindowContext);
83 DEFINE_EXPECT(OnUIDeactivate);
84 DEFINE_EXPECT(OnInPlaceDeactivate);
85 DEFINE_EXPECT(OnInPlaceDeactivateEx);
86 DEFINE_EXPECT(GetContainer);
87 DEFINE_EXPECT(ShowUI);
88 DEFINE_EXPECT(ActivateMe);
89 DEFINE_EXPECT(GetHostInfo);
90 DEFINE_EXPECT(HideUI);
91 DEFINE_EXPECT(GetOptionKeyPath);
92 DEFINE_EXPECT(GetOverrideKeyPath);
93 DEFINE_EXPECT(SetStatusText);
94 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
95 DEFINE_EXPECT(QueryStatus_OPEN);
96 DEFINE_EXPECT(QueryStatus_NEW);
97 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
98 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
99 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
100 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
101 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
102 DEFINE_EXPECT(Exec_ShellDocView_37);
103 DEFINE_EXPECT(Exec_ShellDocView_84);
104 DEFINE_EXPECT(Exec_ShellDocView_103);
105 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
106 DEFINE_EXPECT(Exec_SETTITLE);
107 DEFINE_EXPECT(Exec_HTTPEQUIV);
108 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
109 DEFINE_EXPECT(Exec_Explorer_69);
110 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
111 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
112 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
113 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
114 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
115 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
116 DEFINE_EXPECT(GetDropTarget);
117 DEFINE_EXPECT(UpdateUI);
118 DEFINE_EXPECT(Navigate);
119 DEFINE_EXPECT(OnFrameWindowActivate);
120 DEFINE_EXPECT(OnChanged_READYSTATE);
121 DEFINE_EXPECT(OnChanged_1005);
122 DEFINE_EXPECT(GetDisplayName);
123 DEFINE_EXPECT(BindToStorage);
124 DEFINE_EXPECT(IsSystemMoniker);
125 DEFINE_EXPECT(GetBindResult);
126 DEFINE_EXPECT(GetClassID);
127 DEFINE_EXPECT(Abort);
129 DEFINE_EXPECT(CreateInstance);
130 DEFINE_EXPECT(Start);
131 DEFINE_EXPECT(Terminate);
132 DEFINE_EXPECT(Protocol_Read);
133 DEFINE_EXPECT(LockRequest);
134 DEFINE_EXPECT(UnlockRequest);
135 DEFINE_EXPECT(OnFocus_TRUE);
136 DEFINE_EXPECT(OnFocus_FALSE);
137 DEFINE_EXPECT(RequestUIActivate);
138 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
139 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
140 DEFINE_EXPECT(GetExternal);
142 static IUnknown *doc_unk;
143 static BOOL expect_LockContainer_fLock;
144 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
146 static BOOL set_clientsite = FALSE, container_locked = FALSE;
147 static BOOL readystate_set_loading = FALSE, load_from_stream;
148 static BOOL editmode = FALSE;
149 static int stream_read, protocol_read;
150 static enum load_state_t {
159 static LPCOLESTR expect_status_text = NULL;
161 static const char html_page[] =
163 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
167 static const char css_data[] = "body {color: red}";
169 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
170 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
172 static HRESULT QueryInterface(REFIID riid, void **ppv);
173 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
174 static BOOL nogecko = FALSE;
176 #define test_readyState(u) _test_readyState(__LINE__,u)
177 static void _test_readyState(unsigned,IUnknown*);
179 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
181 static const WCHAR wszTimesNewRoman[] =
182 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
183 static const WCHAR wszArial[] =
184 {'A','r','i','a','l',0};
186 static const char *debugstr_guid(REFIID riid)
190 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
191 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
192 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
193 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
198 static const char *debugstr_w(LPCWSTR str)
200 static char buf[1024];
205 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
209 #define EXPECT_UPDATEUI 1
210 #define EXPECT_SETTITLE 2
212 static void test_timer(DWORD flags)
214 BOOL *b = &called_Exec_SETTITLE;
217 if(flags & EXPECT_UPDATEUI) {
218 SET_EXPECT(UpdateUI);
219 SET_EXPECT(Exec_UPDATECOMMANDS);
220 b = &called_UpdateUI;
222 if(flags & EXPECT_SETTITLE)
223 SET_EXPECT(Exec_SETTITLE);
225 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
226 TranslateMessage(&msg);
227 DispatchMessage(&msg);
230 if(flags & EXPECT_UPDATEUI) {
231 CHECK_CALLED(UpdateUI);
232 CHECK_CALLED(Exec_UPDATECOMMANDS);
234 if(flags & EXPECT_SETTITLE)
235 CHECK_CALLED(Exec_SETTITLE);
238 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
240 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
244 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
249 if(IsEqualGUID(&IID_IProxyManager, riid))
250 return E_NOINTERFACE; /* TODO */
251 if(IsEqualGUID(&IID_IDispatchEx, riid))
252 return E_NOINTERFACE; /* TODO */
253 if(IsEqualGUID(&IID_External_unk, riid))
254 return E_NOINTERFACE; /* TODO */
256 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
257 return E_NOINTERFACE;
260 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
265 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
270 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
272 ok(0, "unexpected call\n");
276 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
279 ok(0, "unexpected call\n");
283 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
284 UINT cNames, LCID lcid, DISPID *rgDispId)
286 ok(0, "unexpected call\n");
290 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
291 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
292 EXCEPINFO *pExcepInfo, UINT *puArgErr)
294 ok(0, "unexpected call\n");
298 static const IDispatchVtbl ExternalVtbl = {
299 External_QueryInterface,
302 Dispatch_GetTypeInfoCount,
303 Dispatch_GetTypeInfo,
304 Dispatch_GetIDsOfNames,
308 static IDispatch External = { &ExternalVtbl };
310 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
312 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
318 return E_NOINTERFACE;
321 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
326 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
331 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
332 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
333 DWORD grfPI, DWORD dwReserved)
339 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
340 static const WCHAR empty_str = {0};
344 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
345 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
346 ok(!grfPI, "grfPI = %x\n", grfPI);
347 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
349 memset(&bindinfo, 0, sizeof(bindinfo));
350 bindinfo.cbSize = sizeof(bindinfo);
351 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
352 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
353 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
354 "bindf = %x\n", bindf);
356 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
357 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
358 /* TODO: test stgmedData */
359 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
360 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
361 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
362 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
363 ok(bindinfo.dwOptions == 0x80000 ||
364 bindinfo.dwOptions == 0x4080000, /* win2k3 */
365 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
366 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
367 /* TODO: test dwCodePage */
368 /* TODO: test securityAttributes */
369 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
370 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
371 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
373 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
374 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
375 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
377 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
378 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
380 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
382 hres = IInternetProtocolSink_ReportData(pOIProtSink,
383 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
384 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
386 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
387 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
392 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
393 PROTOCOLDATA *pProtocolData)
395 ok(0, "unexpected call\n");
399 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
402 ok(0, "unexpected call\n");
406 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
408 CHECK_EXPECT(Terminate);
412 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
414 ok(0, "unexpected call\n");
418 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
420 ok(0, "unexpected call\n");
424 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
425 ULONG cb, ULONG *pcbRead)
427 CHECK_EXPECT2(Protocol_Read);
429 ok(pv != NULL, "pv == NULL\n");
430 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
431 ok(pcbRead != NULL, "pcbRead == NULL\n");
432 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
437 protocol_read += *pcbRead = sizeof(css_data)-1;
438 memcpy(pv, css_data, sizeof(css_data)-1);
442 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
443 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
445 ok(0, "unexpected call\n");
449 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
451 CHECK_EXPECT(LockRequest);
455 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
457 CHECK_EXPECT(UnlockRequest);
461 static const IInternetProtocolVtbl ProtocolVtbl = {
462 Protocol_QueryInterface,
473 Protocol_LockRequest,
474 Protocol_UnlockRequest
477 static IInternetProtocol Protocol = { &ProtocolVtbl };
479 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
481 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
482 ok(0, "unexpected call\n");
483 return E_NOINTERFACE;
486 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
491 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
496 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
497 REFIID riid, void **ppv)
499 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
500 return E_NOINTERFACE;
502 CHECK_EXPECT(CreateInstance);
503 ok(ppv != NULL, "ppv == NULL\n");
509 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
511 ok(0, "unexpected call\n");
515 static const IClassFactoryVtbl ClassFactoryVtbl = {
516 ClassFactory_QueryInterface,
518 ClassFactory_Release,
519 ClassFactory_CreateInstance,
520 ClassFactory_LockServer
523 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
525 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
527 ok(0, "unexpected call\n");
531 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
536 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
541 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
542 IHlinkBrowseContext *pihlbc)
544 ok(0, "unexpected call\n");
548 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
549 IHlinkBrowseContext **ppihlbc)
551 ok(0, "unexpected call\n");
555 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
556 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
560 CHECK_EXPECT(Navigate);
562 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
563 ok(pbc != NULL, "pbc == NULL\n");
564 ok(pibsc != NULL, "pubsc == NULL\n");
565 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
568 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
569 LPWSTR location = (LPWSTR)0xdeadbeef;
571 IMoniker *mon = NULL;
572 DWORD site_data = 0xdeadbeef;
574 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
575 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
576 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
578 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
579 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
580 ok(location == NULL, "location = %p\n", location);
581 ok(mon != NULL, "mon == NULL\n");
583 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
584 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
585 ok(site == NULL, "site = %p\n, expected NULL\n", site);
586 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
592 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
593 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
595 ok(0, "unexpected call\n");
599 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
600 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
602 ok(0, "unexpected call\n");
606 static const IHlinkFrameVtbl HlinkFrameVtbl = {
607 HlinkFrame_QueryInterface,
610 HlinkFrame_SetBrowseContext,
611 HlinkFrame_GetBrowseContext,
613 HlinkFrame_OnNavigate,
614 HlinkFrame_UpdateHlink
617 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
619 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
620 REFIID riid, void**ppv)
622 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
627 ok(0, "unexpected call\n");
628 return E_NOINTERFACE;
631 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
636 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
641 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
644 case DISPID_READYSTATE:
645 CHECK_EXPECT2(OnChanged_READYSTATE);
646 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
647 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
648 ? OLECMDF_ENABLED : 0));
650 if(readystate_set_loading) {
651 readystate_set_loading = FALSE;
652 load_state = LD_LOADING;
654 test_readyState(NULL);
657 CHECK_EXPECT(OnChanged_1005);
658 test_readyState(NULL);
659 load_state = LD_INTERACTIVE;
663 ok(0, "unexpected id %d\n", dispID);
667 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
669 ok(0, "unexpected call\n");
673 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
674 PropertyNotifySink_QueryInterface,
675 PropertyNotifySink_AddRef,
676 PropertyNotifySink_Release,
677 PropertyNotifySink_OnChanged,
678 PropertyNotifySink_OnRequestEdit
681 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
683 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
685 ok(0, "unexpected call\n");
686 return E_NOINTERFACE;
689 static ULONG WINAPI Stream_AddRef(IStream *iface)
694 static ULONG WINAPI Stream_Release(IStream *iface)
699 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
700 ULONG cb, ULONG *pcbRead)
703 ok(pv != NULL, "pv == NULL\n");
704 ok(cb > sizeof(html_page), "cb = %d\n", cb);
705 ok(pcbRead != NULL, "pcbRead == NULL\n");
706 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
711 memcpy(pv, html_page, sizeof(html_page)-1);
712 stream_read += *pcbRead = sizeof(html_page)-1;
716 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
717 ULONG cb, ULONG *pcbWritten)
719 ok(0, "unexpected call\n");
723 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
724 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
726 ok(0, "unexpected call\n");
730 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
732 ok(0, "unexpected call\n");
736 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
737 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
739 ok(0, "unexpected call\n");
743 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
745 ok(0, "unexpected call\n");
749 static HRESULT WINAPI Stream_Revert(IStream *iface)
751 ok(0, "unexpected call\n");
755 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
756 ULARGE_INTEGER cb, DWORD dwLockType)
758 ok(0, "unexpected call\n");
762 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
763 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
765 ok(0, "unexpected call\n");
769 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
772 ok(0, "unexpected call\n");
776 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
778 ok(0, "unexpected call\n");
782 static const IStreamVtbl StreamVtbl = {
783 Stream_QueryInterface,
799 static IStream Stream = { &StreamVtbl };
801 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
803 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
804 return E_NOINTERFACE; /* TODO */
806 if(IsEqualGUID(&IID_IWinInetInfo, riid))
807 return E_NOINTERFACE; /* TODO */
809 ok(0, "unexpected call\n");
810 return E_NOINTERFACE;
813 static ULONG WINAPI Binding_AddRef(IBinding *iface)
818 static ULONG WINAPI Binding_Release(IBinding *iface)
823 static HRESULT WINAPI Binding_Abort(IBinding *iface)
829 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
831 ok(0, "unexpected call\n");
835 static HRESULT WINAPI Binding_Resume(IBinding *iface)
837 ok(0, "unexpected call\n");
841 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
843 ok(0, "unexpected call\n");
847 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
849 ok(0, "unexpected call\n");
853 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
854 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
856 CHECK_EXPECT(GetBindResult);
860 static const IBindingVtbl BindingVtbl = {
861 Binding_QueryInterface,
869 Binding_GetBindResult
872 static IBinding Binding = { &BindingVtbl };
874 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
875 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
877 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
881 if(IsEqualGUID(&IID_IMoniker_unk, riid))
882 return E_NOINTERFACE; /* TODO */
883 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
884 return E_NOINTERFACE; /* TODO */
886 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
887 return E_NOINTERFACE;
890 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
895 static ULONG WINAPI Moniker_Release(IMoniker *iface)
900 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
902 CHECK_EXPECT(GetClassID);
903 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
907 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
909 ok(0, "unexpected call\n");
913 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
915 ok(0, "unexpected call\n");
919 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
921 ok(0, "unexpected call\n");
925 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
927 ok(0, "unexpected call\n");
931 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
932 REFIID riidResult, void **ppvResult)
934 ok(0, "unexpected call\n");
938 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
939 REFIID riid, void **ppv)
941 IBindStatusCallback *callback = NULL;
942 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
948 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
949 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
951 CHECK_EXPECT(BindToStorage);
953 load_state = LD_LOADING;
955 ok(pbc != NULL, "pbc == NULL\n");
956 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
957 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
958 ok(ppv != NULL, "ppv == NULL\n");
959 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
961 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
962 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
963 ok(callback != NULL, "callback == NULL\n");
965 memset(&bindinfo, 0xf0, sizeof(bindinfo));
966 bindinfo.cbSize = sizeof(bindinfo);
968 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
969 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
970 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
971 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
972 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
973 /* TODO: test stgmedData */
974 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
975 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
976 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
977 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
978 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
979 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
980 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
981 /* TODO: test dwCodePage */
982 /* TODO: test securityAttributes */
983 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
984 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
985 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
987 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
988 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
990 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
992 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
994 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
995 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
996 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
999 stgmedium.tymed = TYMED_ISTREAM;
1000 U(stgmedium).pstm = &Stream;
1001 stgmedium.pUnkForRelease = (IUnknown*)iface;
1002 hres = IBindStatusCallback_OnDataAvailable(callback,
1003 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1004 sizeof(html_page)-1, &formatetc, &stgmedium);
1005 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1008 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1009 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1010 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1012 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1013 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1015 IBindStatusCallback_Release(callback);
1020 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1021 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1023 ok(0, "unexpected call\n");
1027 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1028 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1030 ok(0, "unexpected call\n");
1034 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1036 ok(0, "unexpected call\n");
1040 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1042 ok(0, "unexpected call\n");
1046 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1048 ok(0, "unexpected call\n");
1052 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1053 IMoniker *pmkNewlyRunning)
1055 ok(0, "unexpected call\n");
1059 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1060 IMoniker *pmkToLeft, FILETIME *pFileTime)
1062 ok(0, "unexpected call\n");
1066 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1068 ok(0, "unexpected call\n");
1072 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1073 IMoniker **ppmkPrefix)
1075 ok(0, "unexpected call\n");
1079 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1080 IMoniker **pmkRelPath)
1082 ok(0, "unexpected call\n");
1086 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1087 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1089 CHECK_EXPECT2(GetDisplayName);
1091 /* ok(pbc != NULL, "pbc == NULL\n"); */
1092 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1093 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1095 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1096 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1101 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1102 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1104 ok(0, "unexpected call\n");
1108 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1110 CHECK_EXPECT(IsSystemMoniker);
1114 static const IMonikerVtbl MonikerVtbl = {
1115 Moniker_QueryInterface,
1123 Moniker_BindToObject,
1124 Moniker_BindToStorage,
1126 Moniker_ComposeWith,
1131 Moniker_GetTimeOfLastChange,
1133 Moniker_CommonPrefixWith,
1134 Moniker_RelativePathTo,
1135 Moniker_GetDisplayName,
1136 Moniker_ParseDisplayName,
1137 Moniker_IsSystemMoniker
1140 static IMoniker Moniker = { &MonikerVtbl };
1142 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1144 return QueryInterface(riid, ppv);
1147 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1152 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1157 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1158 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1160 ok(0, "unexpected call\n");
1164 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1165 IEnumUnknown **ppenum)
1167 ok(0, "unexpected call\n");
1171 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1173 CHECK_EXPECT(LockContainer);
1174 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1178 static const IOleContainerVtbl OleContainerVtbl = {
1179 OleContainer_QueryInterface,
1180 OleContainer_AddRef,
1181 OleContainer_Release,
1182 OleContainer_ParseDisplayName,
1183 OleContainer_EnumObjects,
1184 OleContainer_LockContainer
1187 static IOleContainer OleContainer = { &OleContainerVtbl };
1189 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1191 ok(0, "unexpected call\n");
1192 return E_NOINTERFACE;
1195 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1200 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1205 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1207 ok(0, "unexpected call\n");
1211 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1213 ok(0, "unexpected call\n");
1217 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1219 ok(0, "unexpected call\n");
1223 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1224 LPCBORDERWIDTHS pborderwidths)
1226 ok(0, "unexpected call\n");
1230 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1231 LPCBORDERWIDTHS pborderwidths)
1233 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1237 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1238 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1240 static const WCHAR wszHTML_Document[] =
1241 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1243 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1245 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1246 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1247 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1248 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1251 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1252 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1254 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1258 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1259 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1261 static const WCHAR wszHTML_Document[] =
1262 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1265 CHECK_EXPECT2(SetActiveObject);
1267 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1268 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1270 CHECK_EXPECT(SetActiveObject_null);
1272 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1273 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1279 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1280 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1282 ok(0, "unexpected call\n");
1286 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1287 HOLEMENU holemenu, HWND hwndActiveObject)
1289 ok(0, "unexpected call\n");
1293 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1295 ok(0, "unexpected call\n");
1299 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1301 CHECK_EXPECT2(SetStatusText);
1302 if(!expect_status_text)
1303 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1307 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1309 ok(0, "unexpected call\n");
1313 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1315 ok(0, "unexpected call\n");
1319 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1320 InPlaceFrame_QueryInterface,
1321 InPlaceFrame_AddRef,
1322 InPlaceFrame_Release,
1323 InPlaceFrame_GetWindow,
1324 InPlaceFrame_ContextSensitiveHelp,
1325 InPlaceFrame_GetBorder,
1326 InPlaceFrame_RequestBorderSpace,
1327 InPlaceFrame_SetBorderSpace,
1328 InPlaceFrame_SetActiveObject,
1329 InPlaceFrame_InsertMenus,
1330 InPlaceFrame_SetMenu,
1331 InPlaceFrame_RemoveMenus,
1332 InPlaceFrame_SetStatusText,
1333 InPlaceFrame_EnableModeless,
1334 InPlaceFrame_TranslateAccelerator
1337 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1339 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1340 InPlaceFrame_QueryInterface,
1341 InPlaceFrame_AddRef,
1342 InPlaceFrame_Release,
1343 InPlaceFrame_GetWindow,
1344 InPlaceFrame_ContextSensitiveHelp,
1345 InPlaceFrame_GetBorder,
1346 InPlaceFrame_RequestBorderSpace,
1347 InPlaceFrame_SetBorderSpace,
1348 InPlaceUIWindow_SetActiveObject,
1351 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1353 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1355 return QueryInterface(riid, ppv);
1358 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1363 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1368 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1370 CHECK_EXPECT(GetWindow);
1371 ok(phwnd != NULL, "phwnd = NULL\n");
1372 *phwnd = container_hwnd;
1376 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1378 ok(0, "unexpected call\n");
1382 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1384 CHECK_EXPECT(CanInPlaceActivate);
1388 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1390 CHECK_EXPECT(OnInPlaceActivate);
1394 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1396 CHECK_EXPECT(OnUIActivate);
1400 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1401 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1402 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1404 static const RECT rect = {0,0,500,500};
1406 CHECK_EXPECT(GetWindowContext);
1408 ok(ppFrame != NULL, "ppFrame = NULL\n");
1410 *ppFrame = &InPlaceFrame;
1411 ok(ppDoc != NULL, "ppDoc = NULL\n");
1413 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1414 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1416 memcpy(lprcPosRect, &rect, sizeof(RECT));
1417 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1419 memcpy(lprcClipRect, &rect, sizeof(RECT));
1420 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1422 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1423 lpFrameInfo->fMDIApp = FALSE;
1424 lpFrameInfo->hwndFrame = container_hwnd;
1425 lpFrameInfo->haccel = NULL;
1426 lpFrameInfo->cAccelEntries = 0;
1432 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1434 ok(0, "unexpected call\n");
1438 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1440 CHECK_EXPECT(OnUIDeactivate);
1441 ok(!fUndoable, "fUndoable = TRUE\n");
1445 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1447 CHECK_EXPECT(OnInPlaceDeactivate);
1451 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1453 ok(0, "unexpected call\n");
1457 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1459 ok(0, "unexpected call\n");
1463 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1465 ok(0, "unexpected call\n");
1469 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1471 CHECK_EXPECT(OnInPlaceActivateEx);
1473 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1474 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1475 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1480 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1482 CHECK_EXPECT(OnInPlaceDeactivateEx);
1484 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1489 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1491 CHECK_EXPECT(RequestUIActivate);
1495 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1496 InPlaceSite_QueryInterface,
1498 InPlaceSite_Release,
1499 InPlaceSite_GetWindow,
1500 InPlaceSite_ContextSensitiveHelp,
1501 InPlaceSite_CanInPlaceActivate,
1502 InPlaceSite_OnInPlaceActivate,
1503 InPlaceSite_OnUIActivate,
1504 InPlaceSite_GetWindowContext,
1506 InPlaceSite_OnUIDeactivate,
1507 InPlaceSite_OnInPlaceDeactivate,
1508 InPlaceSite_DiscardUndoState,
1509 InPlaceSite_DeactivateAndUndo,
1510 InPlaceSite_OnPosRectChange,
1511 InPlaceSiteEx_OnInPlaceActivateEx,
1512 InPlaceSiteEx_OnInPlaceDeactivateEx,
1513 InPlaceSiteEx_RequestUIActivate
1516 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1518 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1520 return QueryInterface(riid, ppv);
1523 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1528 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1533 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1535 ok(0, "unexpected call\n");
1539 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1542 ok(0, "unexpected call\n");
1546 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1548 CHECK_EXPECT(GetContainer);
1549 ok(ppContainer != NULL, "ppContainer = NULL\n");
1550 *ppContainer = &OleContainer;
1554 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1556 ok(0, "unexpected call\n");
1560 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1562 ok(0, "unexpected call\n");
1566 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1568 ok(0, "unexpected call\n");
1572 static const IOleClientSiteVtbl ClientSiteVtbl = {
1573 ClientSite_QueryInterface,
1576 ClientSite_SaveObject,
1577 ClientSite_GetMoniker,
1578 ClientSite_GetContainer,
1579 ClientSite_ShowObject,
1580 ClientSite_OnShowWindow,
1581 ClientSite_RequestNewObjectLayout
1584 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1586 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1588 return QueryInterface(riid, ppv);
1591 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1596 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1603 CallUIActivate_None,
1604 CallUIActivate_ActivateMe,
1605 CallUIActivate_AfterShow,
1608 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1609 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1611 IOleDocument *document;
1614 CHECK_EXPECT(ActivateMe);
1615 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1617 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1618 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1620 if(SUCCEEDED(hres)) {
1621 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1622 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1624 if(SUCCEEDED(hres)) {
1625 IOleInPlaceActiveObject *activeobj = NULL;
1626 IOleInPlaceSite *inplacesite = NULL;
1627 HWND tmp_hwnd = NULL;
1628 static RECT rect = {0,0,400,500};
1630 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1631 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1632 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1633 inplacesite, &InPlaceSiteEx);
1635 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1636 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1638 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1639 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1640 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1641 inplacesite, &InPlaceSiteEx);
1643 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1644 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1647 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1648 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1649 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1652 if(call_UIActivate == CallUIActivate_ActivateMe) {
1653 SET_EXPECT(CanInPlaceActivate);
1654 SET_EXPECT(GetWindowContext);
1655 SET_EXPECT(GetWindow);
1657 SET_EXPECT(OnInPlaceActivateEx);
1659 SET_EXPECT(OnInPlaceActivate);
1660 SET_EXPECT(SetStatusText);
1661 SET_EXPECT(Exec_SETPROGRESSMAX);
1662 SET_EXPECT(Exec_SETPROGRESSPOS);
1663 SET_EXPECT(OnUIActivate);
1664 SET_EXPECT(SetActiveObject);
1666 expect_status_text = NULL;
1668 hres = IOleDocumentView_UIActivate(view, TRUE);
1671 skip("UIActivate failed: %08x\n", hres);
1674 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1676 CHECK_CALLED(CanInPlaceActivate);
1677 CHECK_CALLED(GetWindowContext);
1678 CHECK_CALLED(GetWindow);
1680 CHECK_CALLED(OnInPlaceActivateEx);
1682 CHECK_CALLED(OnInPlaceActivate);
1683 CHECK_CALLED(SetStatusText);
1684 CHECK_CALLED(Exec_SETPROGRESSMAX);
1685 CHECK_CALLED(Exec_SETPROGRESSPOS);
1686 CHECK_CALLED(OnUIActivate);
1687 CHECK_CALLED(SetActiveObject);
1688 CHECK_CALLED(ShowUI);
1691 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1692 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1693 ok(hwnd != NULL, "hwnd == NULL\n");
1695 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1698 hres = IOleDocumentView_UIActivate(view, TRUE);
1699 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1702 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1703 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1704 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1708 hres = IOleDocumentView_SetRect(view, &rect);
1709 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1711 if(call_UIActivate == CallUIActivate_ActivateMe) {
1712 hres = IOleDocumentView_Show(view, TRUE);
1713 ok(hres == S_OK, "Show failed: %08x\n", hres);
1715 SET_EXPECT(CanInPlaceActivate);
1716 SET_EXPECT(GetWindowContext);
1717 SET_EXPECT(GetWindow);
1719 SET_EXPECT(OnInPlaceActivateEx);
1721 SET_EXPECT(OnInPlaceActivate);
1722 SET_EXPECT(SetStatusText);
1723 SET_EXPECT(Exec_SETPROGRESSMAX);
1724 SET_EXPECT(Exec_SETPROGRESSPOS);
1725 SET_EXPECT(OnUIActivate);
1726 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1728 hres = IOleDocumentView_Show(view, TRUE);
1729 ok(hres == S_OK, "Show failed: %08x\n", hres);
1731 CHECK_CALLED(CanInPlaceActivate);
1732 CHECK_CALLED(GetWindowContext);
1733 CHECK_CALLED(GetWindow);
1735 CHECK_CALLED(OnInPlaceActivateEx);
1737 CHECK_CALLED(OnInPlaceActivate);
1738 CHECK_CALLED(SetStatusText);
1739 CHECK_CALLED(Exec_SETPROGRESSMAX);
1740 CHECK_CALLED(Exec_SETPROGRESSPOS);
1743 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1744 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1745 ok(hwnd != NULL, "hwnd == NULL\n");
1747 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1751 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1754 IOleInPlaceActiveObject_Release(activeobj);
1757 IOleDocument_Release(document);
1763 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1764 DocumentSite_QueryInterface,
1765 DocumentSite_AddRef,
1766 DocumentSite_Release,
1767 DocumentSite_ActivateMe
1770 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1772 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1774 return QueryInterface(riid, ppv);
1777 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1782 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1787 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1789 ok(0, "unexpected call\n");
1793 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1795 ok(0, "unexpected call\n");
1799 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1801 ok(0, "unexpected call\n");
1805 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1806 POINTF *pPtfContainer, DWORD dwFlags)
1808 ok(0, "unexpected call\n");
1812 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1813 MSG *pMsg, DWORD grfModifiers)
1815 ok(0, "unexpected call\n");
1819 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1822 CHECK_EXPECT(OnFocus_TRUE);
1824 CHECK_EXPECT2(OnFocus_FALSE);
1828 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1830 ok(0, "unexpected call\n");
1834 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1835 OleControlSite_QueryInterface,
1836 OleControlSite_AddRef,
1837 OleControlSite_Release,
1838 OleControlSite_OnControlInfoChanged,
1839 OleControlSite_LockInPlaceActive,
1840 OleControlSite_GetExtendedControl,
1841 OleControlSite_TransformCoords,
1842 OleControlSite_TranslateAccelerator,
1843 OleControlSite_OnFocus,
1844 OleControlSite_ShowPropertyFrame
1847 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1849 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1851 return QueryInterface(riid, ppv);
1854 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1859 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1864 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1865 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1867 ok(0, "unexpected call\n");
1871 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1873 CHECK_EXPECT(GetHostInfo);
1874 ok(pInfo != NULL, "pInfo=NULL\n");
1876 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1877 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1878 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1879 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1880 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1881 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1882 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1883 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1888 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1889 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1890 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1892 CHECK_EXPECT(ShowUI);
1895 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1897 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1898 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1899 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1900 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1901 if (expect_InPlaceUIWindow_SetActiveObject_active)
1902 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
1904 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1909 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1911 CHECK_EXPECT(HideUI);
1915 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1917 CHECK_EXPECT(UpdateUI);
1921 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1923 ok(0, "unexpected call\n");
1927 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1929 ok(0, "unexpected call\n");
1933 static BOOL expect_OnFrameWindowActivate_fActivate;
1934 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1936 CHECK_EXPECT2(OnFrameWindowActivate);
1937 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1941 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1942 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1944 ok(0, "unexpected call\n");
1948 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1949 const GUID *pguidCmdGroup, DWORD nCmdID)
1951 ok(0, "unexpected call\n");
1955 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1956 LPOLESTR *pchKey, DWORD dw)
1958 CHECK_EXPECT(GetOptionKeyPath);
1959 ok(pchKey != NULL, "pchKey = NULL\n");
1960 ok(!dw, "dw=%d, expected 0\n", dw);
1962 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1966 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1967 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1969 CHECK_EXPECT(GetDropTarget);
1974 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1976 CHECK_EXPECT(GetExternal);
1977 *ppDispatch = &External;
1981 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1982 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1984 ok(0, "unexpected call\n");
1988 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1989 IDataObject **ppPORet)
1991 ok(0, "unexpected call\n");
1995 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1996 LPOLESTR *pchKey, DWORD dw)
1998 CHECK_EXPECT(GetOverrideKeyPath);
1999 ok(pchKey != NULL, "pchKey = NULL\n");
2001 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2002 ok(!dw, "dw=%d, xepected 0\n", dw);
2006 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2007 DocHostUIHandler_QueryInterface,
2008 DocHostUIHandler_AddRef,
2009 DocHostUIHandler_Release,
2010 DocHostUIHandler_ShowContextMenu,
2011 DocHostUIHandler_GetHostInfo,
2012 DocHostUIHandler_ShowUI,
2013 DocHostUIHandler_HideUI,
2014 DocHostUIHandler_UpdateUI,
2015 DocHostUIHandler_EnableModeless,
2016 DocHostUIHandler_OnDocWindowActivate,
2017 DocHostUIHandler_OnFrameWindowActivate,
2018 DocHostUIHandler_ResizeBorder,
2019 DocHostUIHandler_TranslateAccelerator,
2020 DocHostUIHandler_GetOptionKeyPath,
2021 DocHostUIHandler_GetDropTarget,
2022 DocHostUIHandler_GetExternal,
2023 DocHostUIHandler_TranslateUrl,
2024 DocHostUIHandler_FilterDataObject,
2025 DocHostUIHandler_GetOverrideKeyPath
2028 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2030 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2031 REFIID riid, void **ppv)
2033 return QueryInterface(riid, ppv);
2036 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2041 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2046 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2047 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2049 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2050 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2051 ok(!pCmdText, "pCmdText != NULL\n");
2053 switch(prgCmds[0].cmdID) {
2054 case OLECMDID_SETPROGRESSTEXT:
2055 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2056 prgCmds[0].cmdf = OLECMDF_ENABLED;
2059 CHECK_EXPECT(QueryStatus_OPEN);
2060 prgCmds[0].cmdf = 0;
2063 CHECK_EXPECT(QueryStatus_NEW);
2064 prgCmds[0].cmdf = 0;
2067 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2073 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2074 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2076 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2077 test_readyState(NULL);
2079 if(!pguidCmdGroup) {
2081 case OLECMDID_SETPROGRESSMAX:
2082 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2083 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2084 ok(pvaIn != NULL, "pvaIn == NULL\n");
2086 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2087 if(load_state == LD_NO)
2088 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2090 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2092 case OLECMDID_SETPROGRESSPOS:
2093 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2094 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2095 ok(pvaIn != NULL, "pvaIn == NULL\n");
2097 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2098 if(load_state == LD_NO)
2099 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2101 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2103 case OLECMDID_HTTPEQUIV_DONE:
2104 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2105 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2106 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2107 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2108 load_state = LD_COMPLETE;
2110 case OLECMDID_SETDOWNLOADSTATE:
2111 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2112 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2113 ok(pvaIn != NULL, "pvaIn == NULL\n");
2114 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2116 switch(V_I4(pvaIn)) {
2118 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2119 load_state = LD_INTERACTIVE;
2122 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2125 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2129 case OLECMDID_UPDATECOMMANDS:
2130 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2131 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2132 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2133 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2135 case OLECMDID_SETTITLE:
2136 CHECK_EXPECT2(Exec_SETTITLE);
2137 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2138 ok(pvaIn != NULL, "pvaIn == NULL\n");
2139 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2140 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2141 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2143 case OLECMDID_HTTPEQUIV:
2144 CHECK_EXPECT2(Exec_HTTPEQUIV);
2145 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2149 ok(0, "unexpected command %d\n", nCmdID);
2154 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2155 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2159 CHECK_EXPECT2(Exec_ShellDocView_37);
2161 if(load_from_stream)
2162 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2164 test_GetCurMoniker(doc_unk, &Moniker, NULL);
2166 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2167 ok(pvaIn != NULL, "pvaIn == NULL\n");
2169 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2170 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2174 CHECK_EXPECT2(Exec_ShellDocView_84);
2176 ok(pvaIn == NULL, "pvaIn != NULL\n");
2177 ok(pvaOut != NULL, "pvaOut == NULL\n");
2179 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2184 CHECK_EXPECT2(Exec_ShellDocView_103);
2186 ok(pvaIn == NULL, "pvaIn != NULL\n");
2187 ok(pvaOut == NULL, "pvaOut != NULL\n");
2192 ok(0, "unexpected command %d\n", nCmdID);
2197 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2198 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2201 case IDM_PARSECOMPLETE:
2202 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2203 ok(pvaIn == NULL, "pvaIn != NULL\n");
2204 ok(pvaOut == NULL, "pvaOut != NULL\n");
2207 ok(0, "unexpected command %d\n", nCmdID);
2211 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2212 return E_FAIL; /* TODO */
2214 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2215 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2219 CHECK_EXPECT2(Exec_Explorer_69);
2220 ok(pvaIn == NULL, "pvaIn != NULL\n");
2221 ok(pvaOut != NULL, "pvaOut == NULL\n");
2224 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2229 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2231 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2232 SET_EXPECT(SetStatusText);
2233 ok(pvaIn == NULL, "pvaIn != NULL\n");
2234 ok(pvaOut == NULL, "pvaOut != NULL\n");
2237 ok(0, "unexpected command %d\n", nCmdID);
2242 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2246 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2247 OleCommandTarget_QueryInterface,
2248 OleCommandTarget_AddRef,
2249 OleCommandTarget_Release,
2250 OleCommandTarget_QueryStatus,
2251 OleCommandTarget_Exec
2254 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2256 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2258 return QueryInterface(riid, ppv);
2261 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2262 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2263 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2265 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2266 ok(pDispParams != NULL, "pDispParams == NULL\n");
2267 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2268 ok(puArgErr != NULL, "puArgErr == NULL\n");
2269 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2270 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2271 test_readyState(NULL);
2273 switch(dispIdMember) {
2274 case DISPID_AMBIENT_USERMODE:
2275 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2276 V_VT(pVarResult) = VT_BOOL;
2277 V_BOOL(pVarResult) = VARIANT_TRUE;
2279 case DISPID_AMBIENT_DLCONTROL:
2280 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2282 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2283 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2285 case DISPID_AMBIENT_SILENT:
2286 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2287 V_VT(pVarResult) = VT_BOOL;
2288 V_BOOL(pVarResult) = VARIANT_FALSE;
2290 case DISPID_AMBIENT_USERAGENT:
2291 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2293 case DISPID_AMBIENT_PALETTE:
2294 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2298 ok(0, "unexpected dispid %d\n", dispIdMember);
2302 static IDispatchVtbl DispatchVtbl = {
2303 Dispatch_QueryInterface,
2306 Dispatch_GetTypeInfoCount,
2307 Dispatch_GetTypeInfo,
2308 Dispatch_GetIDsOfNames,
2312 static IDispatch Dispatch = { &DispatchVtbl };
2314 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2315 REFIID riid, void **ppv)
2317 return QueryInterface(riid, ppv);
2320 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2325 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2330 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2331 REFIID riid, void **ppv)
2334 * Services used by HTMLDocument:
2337 * IInternetSecurityManager
2339 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2342 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2343 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2344 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2346 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2347 * IElementBehaviorFactory
2348 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2358 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2359 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2364 return E_NOINTERFACE;
2367 static const IServiceProviderVtbl ServiceProviderVtbl = {
2368 ServiceProvider_QueryInterface,
2369 ServiceProvider_AddRef,
2370 ServiceProvider_Release,
2371 ServiceProvider_QueryService
2374 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2376 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2377 DEFINE_GUID(IID_unk2, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2378 DEFINE_GUID(IID_unk3, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2380 static HRESULT QueryInterface(REFIID riid, void **ppv)
2384 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2386 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2387 *ppv = &DocumentSite;
2388 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2389 *ppv = &DocHostUIHandler;
2390 else if(IsEqualGUID(&IID_IOleContainer, riid))
2391 *ppv = &OleContainer;
2392 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2393 *ppv = &InPlaceSiteEx;
2394 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2395 *ppv = &OleCommandTarget;
2396 else if(IsEqualGUID(&IID_IDispatch, riid))
2398 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2399 *ppv = &ServiceProvider;
2400 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2401 *ppv = ipsex ? &InPlaceSiteEx : NULL;
2402 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2403 *ppv = &OleControlSite;
2404 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2405 return E_NOINTERFACE; /* TODO */
2406 else if(IsEqualGUID(&IID_IProxyManager, riid))
2407 return E_NOINTERFACE; /* ? */
2408 else if(IsEqualGUID(&IID_unk1, riid))
2409 return E_NOINTERFACE; /* HTMLWindow2 ? */
2410 else if(IsEqualGUID(&IID_unk2, riid))
2411 return E_NOINTERFACE; /* ? */
2412 else if(IsEqualGUID(&IID_unk3, riid))
2413 return E_NOINTERFACE; /* ? */
2415 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2419 return E_NOINTERFACE;
2422 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2424 return DefWindowProc(hwnd, msg, wParam, lParam);
2427 static void _test_readyState(unsigned line, IUnknown *unk)
2429 IHTMLDocument2 *htmldoc;
2430 DISPPARAMS dispparams;
2435 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2436 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2437 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2438 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2440 static const LPCWSTR expected_state[] = {
2452 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2453 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2457 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2458 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2460 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2461 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2463 (!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n",
2464 debugstr_w(state), load_state);
2465 SysFreeString(state);
2467 dispparams.cArgs = 0;
2468 dispparams.cNamedArgs = 0;
2469 dispparams.rgdispidNamedArgs = NULL;
2470 dispparams.rgvarg = NULL;
2474 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2475 &dispparams, &out, NULL, NULL);
2476 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2478 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2479 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2481 IHTMLDocument2_Release(htmldoc);
2484 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2486 IConnectionPointContainer *tmp_container = NULL;
2487 IConnectionPoint *cp;
2491 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2492 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2496 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2497 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2498 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2500 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2501 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2503 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2504 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2505 ok(tmp_container == container, "container != tmp_container\n");
2507 IConnectionPointContainer_Release(tmp_container);
2509 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2510 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2512 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2515 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2516 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2519 IConnectionPoint_Release(cp);
2522 static void test_ConnectionPointContainer(IUnknown *unk)
2524 IConnectionPointContainer *container;
2527 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2528 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2532 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2533 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2534 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2536 IConnectionPointContainer_Release(container);
2539 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2541 IHTMLDocument2 *doc;
2542 IPersistMoniker *permon;
2543 IMoniker *mon = (void*)0xdeadbeef;
2544 BSTR doc_url = (void*)0xdeadbeef;
2547 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2548 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2552 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2553 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2555 hres = IHTMLDocument2_get_URL(doc, &doc_url);
2556 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2558 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2559 IPersistMoniker_Release(permon);
2563 BOOL exb = expect_GetDisplayName;
2564 BOOL clb = called_GetDisplayName;
2566 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2567 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2569 SET_EXPECT(GetDisplayName);
2570 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2571 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2572 CHECK_CALLED(GetDisplayName);
2573 expect_GetDisplayName = exb;
2574 called_GetDisplayName = clb;
2576 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2581 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2583 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2584 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2586 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2587 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2591 ok(hres == E_UNEXPECTED,
2592 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2593 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2594 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2597 SysFreeString(doc_url);
2598 IHTMLDocument_Release(doc);
2599 if(mon && mon != (void*)0xdeadbeef)
2600 IMoniker_Release(mon);
2603 static void test_Load(IPersistMoniker *persist)
2607 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2609 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2611 test_readyState((IUnknown*)persist);
2613 CreateBindCtx(0, &bind);
2614 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2615 (IUnknown*)&ClientSite);
2617 SET_EXPECT(GetDisplayName);
2618 if(!set_clientsite) {
2619 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2620 SET_EXPECT(GetHostInfo);
2621 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2622 SET_EXPECT(Invoke_AMBIENT_SILENT);
2623 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2624 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2625 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2626 SET_EXPECT(GetOptionKeyPath);
2627 SET_EXPECT(GetOverrideKeyPath);
2628 SET_EXPECT(GetWindow);
2629 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2630 SET_EXPECT(Exec_SETPROGRESSMAX);
2631 SET_EXPECT(Exec_SETPROGRESSPOS);
2632 SET_EXPECT(Exec_ShellDocView_37);
2634 if(!container_locked) {
2635 SET_EXPECT(GetContainer);
2636 SET_EXPECT(LockContainer);
2638 SET_EXPECT(OnChanged_READYSTATE);
2639 SET_EXPECT(Exec_ShellDocView_84);
2640 SET_EXPECT(BindToStorage);
2641 SET_EXPECT(SetActiveObject);
2642 if(set_clientsite) {
2643 SET_EXPECT(Invoke_AMBIENT_SILENT);
2644 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2645 SET_EXPECT(Exec_ShellDocView_37);
2647 load_state = LD_DOLOAD;
2648 expect_LockContainer_fLock = TRUE;
2649 readystate_set_loading = TRUE;
2651 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2652 ok(hres == S_OK, "Load failed: %08x\n", hres);
2654 CHECK_CALLED(GetDisplayName);
2655 if(!set_clientsite) {
2656 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2657 CHECK_CALLED(GetHostInfo);
2658 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2659 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2660 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2661 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2662 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2663 CHECK_CALLED(GetOptionKeyPath);
2664 CHECK_CALLED(GetOverrideKeyPath);
2665 CHECK_CALLED(GetWindow);
2666 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2667 CHECK_CALLED(Exec_SETPROGRESSMAX);
2668 CHECK_CALLED(Exec_SETPROGRESSPOS);
2669 CHECK_CALLED(Exec_ShellDocView_37);
2671 if(!container_locked) {
2672 CHECK_CALLED(GetContainer);
2673 CHECK_CALLED(LockContainer);
2674 container_locked = TRUE;
2676 CHECK_CALLED(OnChanged_READYSTATE);
2677 SET_CALLED(Exec_ShellDocView_84);
2678 CHECK_CALLED(BindToStorage);
2679 SET_CALLED(SetActiveObject); /* FIXME */
2680 if(set_clientsite) {
2681 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2682 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2683 CHECK_CALLED(Exec_ShellDocView_37);
2686 set_clientsite = container_locked = TRUE;
2688 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2690 IBindCtx_Release(bind);
2692 test_readyState((IUnknown*)persist);
2695 static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
2700 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2701 ok(hwnd != NULL, "Could not find hidden window\n");
2703 test_readyState(NULL);
2706 SET_EXPECT(Exec_SETPROGRESSMAX);
2707 if(!load_from_stream)
2708 SET_EXPECT(GetHostInfo);
2710 SET_EXPECT(SetStatusText);
2711 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2712 SET_EXPECT(GetDropTarget);
2714 SET_EXPECT(Exec_ShellDocView_84);
2716 SET_EXPECT(CreateInstance);
2718 SET_EXPECT(LockRequest);
2719 SET_EXPECT(Terminate);
2720 SET_EXPECT(Protocol_Read);
2721 SET_EXPECT(UnlockRequest);
2723 SET_EXPECT(Exec_Explorer_69);
2724 SET_EXPECT(OnChanged_1005);
2725 SET_EXPECT(OnChanged_READYSTATE);
2726 SET_EXPECT(Exec_SETPROGRESSPOS);
2727 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2728 SET_EXPECT(Exec_ShellDocView_103);
2729 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2730 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2731 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2733 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2734 TranslateMessage(&msg);
2735 DispatchMessage(&msg);
2739 CHECK_CALLED(Exec_SETPROGRESSMAX);
2740 if(!load_from_stream)
2741 CHECK_CALLED(GetHostInfo);
2743 CHECK_CALLED(SetStatusText);
2744 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2745 CHECK_CALLED(GetDropTarget);
2747 SET_CALLED(Exec_ShellDocView_84);
2749 if(called_CreateInstance) {
2750 CHECK_CALLED(CreateInstance);
2751 CHECK_CALLED(Start);
2752 CHECK_CALLED(LockRequest);
2753 CHECK_CALLED(Terminate);
2754 CHECK_CALLED(Protocol_Read);
2755 CHECK_CALLED(UnlockRequest);
2757 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2759 SET_CALLED(Exec_ShellDocView_84);
2760 SET_CALLED(CreateInstance);
2762 SET_CALLED(LockRequest);
2763 SET_CALLED(Terminate);
2764 SET_CALLED(Protocol_Read);
2765 SET_CALLED(UnlockRequest);
2770 SET_CALLED(Exec_Explorer_69);
2771 CHECK_CALLED(OnChanged_1005);
2772 CHECK_CALLED(OnChanged_READYSTATE);
2773 CHECK_CALLED(Exec_SETPROGRESSPOS);
2774 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2775 SET_CALLED(Exec_ShellDocView_103);
2776 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2777 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2779 load_state = LD_COMPLETE;
2781 test_readyState(NULL);
2784 static void test_Persist(IUnknown *unk)
2786 IPersistMoniker *persist_mon;
2787 IPersistFile *persist_file;
2791 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2792 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2793 if(SUCCEEDED(hres)) {
2794 hres = IPersist_GetClassID(persist_file, NULL);
2795 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2797 hres = IPersist_GetClassID(persist_file, &guid);
2798 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2799 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2801 IPersist_Release(persist_file);
2804 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2805 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2806 if(SUCCEEDED(hres)) {
2807 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2808 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2810 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2811 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2812 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2814 if(load_state == LD_DOLOAD)
2815 test_Load(persist_mon);
2817 test_readyState(unk);
2819 IPersistMoniker_Release(persist_mon);
2823 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2825 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2826 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2827 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2828 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2829 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2830 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2831 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2832 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2833 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2834 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2835 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2836 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2837 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2838 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2839 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2840 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2841 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2842 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2843 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2844 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2846 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2847 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2849 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2851 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2853 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2854 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2856 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2857 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2859 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2861 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2862 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2865 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2866 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2868 IOleCommandTarget *cmdtrg;
2869 OLECMD olecmd = {cmdid, 0};
2872 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2873 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2877 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2878 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2880 IOleCommandTarget_Release(cmdtrg);
2882 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2883 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2886 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2891 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2892 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2893 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
2894 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2895 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2896 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2897 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2898 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2899 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2900 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2901 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2902 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2903 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2904 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2905 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2906 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
2909 static void test_OleCommandTarget(IUnknown *unk)
2911 IOleCommandTarget *cmdtrg;
2912 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2916 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2917 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2921 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2922 cmds[i].cmdID = i+1;
2923 cmds[i].cmdf = 0xf0f0;
2926 SET_EXPECT(QueryStatus_OPEN);
2927 SET_EXPECT(QueryStatus_NEW);
2928 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2929 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2930 CHECK_CALLED(QueryStatus_OPEN);
2931 CHECK_CALLED(QueryStatus_NEW);
2933 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2934 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2935 if(i+1 == OLECMDID_FIND)
2937 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2938 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2941 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
2942 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
2944 IOleCommandTarget_Release(cmdtrg);
2947 static void test_OleCommandTarget_fail(IUnknown *unk)
2949 IOleCommandTarget *cmdtrg;
2954 {OLECMDID_OPEN, 0xf0f0},
2955 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2958 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2959 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2963 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2964 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2966 SET_EXPECT(QueryStatus_OPEN);
2967 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2968 CHECK_CALLED(QueryStatus_OPEN);
2970 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2971 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2972 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
2973 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
2974 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
2975 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
2976 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
2978 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
2979 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
2980 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
2982 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2983 if(!expect_cmds[i]) {
2984 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
2985 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2986 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2987 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2991 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
2992 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2993 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2994 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2996 IOleCommandTarget_Release(cmdtrg);
2999 static void test_exec_onunload(IUnknown *unk)
3001 IOleCommandTarget *cmdtrg;
3005 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3006 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3010 memset(&var, 0x0a, sizeof(var));
3011 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3012 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3013 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3014 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3015 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3017 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3018 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3019 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3021 IOleCommandTarget_Release(cmdtrg);
3024 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3026 IOleCommandTarget *cmdtrg;
3029 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3030 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3037 load_state = LD_DOLOAD;
3040 SET_EXPECT(GetClassID);
3041 SET_EXPECT(SetStatusText);
3042 SET_EXPECT(Exec_ShellDocView_37);
3043 SET_EXPECT(GetHostInfo);
3045 SET_EXPECT(GetDisplayName);
3046 SET_EXPECT(Invoke_AMBIENT_SILENT);
3047 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3048 SET_EXPECT(OnChanged_READYSTATE);
3049 SET_EXPECT(Exec_ShellDocView_84);
3051 SET_EXPECT(BindToStorage);
3052 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3055 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3057 expect_status_text = NULL;
3058 readystate_set_loading = TRUE;
3060 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3061 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3062 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3065 CHECK_CALLED(GetClassID);
3066 CHECK_CALLED(SetStatusText);
3067 CHECK_CALLED(Exec_ShellDocView_37);
3068 CHECK_CALLED(GetHostInfo);
3070 CHECK_CALLED(GetDisplayName);
3071 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3072 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3073 CHECK_CALLED(OnChanged_READYSTATE);
3074 SET_CALLED(Exec_ShellDocView_84);
3076 CHECK_CALLED(BindToStorage);
3077 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3078 CHECK_CALLED(HideUI);
3079 CHECK_CALLED(ShowUI);
3080 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3082 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3084 IOleCommandTarget_Release(cmdtrg);
3086 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3087 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3088 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3091 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3093 IOleCommandTarget *cmdtrg;
3094 VARIANT *in = NULL, _in, *out = NULL, _out;
3097 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3098 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3105 V_BSTR(in) = SysAllocString(name);
3111 V_I4(out) = 0xdeadbeef;
3114 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3116 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3121 if(out && !nogecko) {
3122 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3123 if(V_VT(out) == VT_BSTR) {
3125 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3126 "unexpected fontname \"%s\"\n", debugstr_w(name));
3128 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3133 IOleCommandTarget_Release(cmdtrg);
3136 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3138 IOleCommandTarget *cmdtrg;
3141 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3142 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3146 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3147 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3148 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3150 IOleCommandTarget_Release(cmdtrg);
3153 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3155 IPersistStreamInit *perinit;
3156 IPersistMoniker *permon;
3157 IPersistFile *perfile;
3160 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3161 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3162 if(SUCCEEDED(hres)) {
3163 hres = IPersistStreamInit_IsDirty(perinit);
3164 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3165 IPersistStreamInit_Release(perinit);
3168 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3169 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3170 if(SUCCEEDED(hres)) {
3171 hres = IPersistMoniker_IsDirty(permon);
3172 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3173 IPersistMoniker_Release(permon);
3176 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3177 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3178 if(SUCCEEDED(hres)) {
3179 hres = IPersistFile_IsDirty(perfile);
3180 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3181 IPersistFile_Release(perfile);
3185 static HWND create_container_window(void)
3187 static const WCHAR wszHTMLDocumentTest[] =
3188 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3189 static WNDCLASSEXW wndclass = {
3190 sizeof(WNDCLASSEXW),
3193 0, 0, NULL, NULL, NULL, NULL, NULL,
3194 wszHTMLDocumentTest,
3198 RegisterClassExW(&wndclass);
3199 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3200 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3201 515, 530, NULL, NULL, NULL, NULL);
3204 static HRESULT test_DoVerb(IOleObject *oleobj)
3206 RECT rect = {0,0,500,500};
3209 if(!container_locked) {
3210 SET_EXPECT(GetContainer);
3211 SET_EXPECT(LockContainer);
3213 SET_EXPECT(ActivateMe);
3214 expect_LockContainer_fLock = TRUE;
3216 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3219 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3221 if(!container_locked) {
3222 CHECK_CALLED(GetContainer);
3223 CHECK_CALLED(LockContainer);
3224 container_locked = TRUE;
3226 CHECK_CALLED(ActivateMe);
3231 #define CLIENTSITE_EXPECTPATH 0x00000001
3232 #define CLIENTSITE_SETNULL 0x00000002
3233 #define CLIENTSITE_DONTSET 0x00000004
3235 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3237 IOleClientSite *clientsite;
3240 if(flags & CLIENTSITE_SETNULL) {
3241 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3242 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3244 hres = IOleObject_SetClientSite(oleobj, NULL);
3245 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3247 set_clientsite = FALSE;
3250 if(flags & CLIENTSITE_DONTSET)
3253 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3254 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3255 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3256 clientsite, set_clientsite ? &ClientSite : NULL);
3258 if(!set_clientsite) {
3259 SET_EXPECT(GetHostInfo);
3260 if(flags & CLIENTSITE_EXPECTPATH) {
3261 SET_EXPECT(GetOptionKeyPath);
3262 SET_EXPECT(GetOverrideKeyPath);
3264 SET_EXPECT(GetWindow);
3265 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3266 SET_EXPECT(Exec_SETPROGRESSMAX);
3267 SET_EXPECT(Exec_SETPROGRESSPOS);
3268 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3269 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3270 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3271 SET_EXPECT(Invoke_AMBIENT_SILENT);
3272 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3273 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3275 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3276 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3278 CHECK_CALLED(GetHostInfo);
3279 if(flags & CLIENTSITE_EXPECTPATH) {
3280 CHECK_CALLED(GetOptionKeyPath);
3281 CHECK_CALLED(GetOverrideKeyPath);
3283 CHECK_CALLED(GetWindow);
3284 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3285 CHECK_CALLED(Exec_SETPROGRESSMAX);
3286 CHECK_CALLED(Exec_SETPROGRESSPOS);
3287 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3288 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3289 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3290 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3291 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3292 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3294 set_clientsite = TRUE;
3297 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3298 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3300 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3301 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3302 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3305 static void test_OnAmbientPropertyChange(IUnknown *unk)
3307 IOleControl *control = NULL;
3310 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3311 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3315 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3316 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3317 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3318 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3320 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3321 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3322 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3323 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3325 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3326 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3327 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3328 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3329 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3330 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3332 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3333 SET_EXPECT(Invoke_AMBIENT_SILENT);
3334 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3335 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3336 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3337 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3339 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3340 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3341 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3342 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3344 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3345 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3346 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3347 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3349 IOleControl_Release(control);
3354 static void test_OnAmbientPropertyChange2(IUnknown *unk)
3356 IOleControl *control = NULL;
3359 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3360 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3364 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3365 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3367 IOleControl_Release(control);
3370 static void test_Close(IUnknown *unk, BOOL set_client)
3372 IOleObject *oleobj = NULL;
3375 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3376 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3380 SET_EXPECT(GetContainer);
3381 SET_EXPECT(LockContainer);
3382 expect_LockContainer_fLock = FALSE;
3383 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3384 ok(hres == S_OK, "Close failed: %08x\n", hres);
3385 CHECK_CALLED(GetContainer);
3386 CHECK_CALLED(LockContainer);
3387 container_locked = FALSE;
3390 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3392 IOleObject_Release(oleobj);
3395 static void test_OnFrameWindowActivate(IUnknown *unk)
3397 IOleInPlaceActiveObject *inplaceact;
3400 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3401 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3405 if(set_clientsite) {
3406 expect_OnFrameWindowActivate_fActivate = TRUE;
3407 SET_EXPECT(OnFrameWindowActivate);
3408 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3409 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3410 CHECK_CALLED(OnFrameWindowActivate);
3412 SET_EXPECT(OnFrameWindowActivate);
3413 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3414 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3415 CHECK_CALLED(OnFrameWindowActivate);
3417 expect_OnFrameWindowActivate_fActivate = FALSE;
3418 SET_EXPECT(OnFrameWindowActivate);
3419 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3420 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3421 CHECK_CALLED(OnFrameWindowActivate);
3423 expect_OnFrameWindowActivate_fActivate = TRUE;
3424 SET_EXPECT(OnFrameWindowActivate);
3425 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3426 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3427 CHECK_CALLED(OnFrameWindowActivate);
3429 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3430 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3432 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3433 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3436 IOleInPlaceActiveObject_Release(inplaceact);
3439 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3441 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3444 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3445 (void**)&windowlessobj);
3446 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3451 SET_EXPECT(OnFocus_FALSE);
3453 SET_EXPECT(OnInPlaceDeactivateEx);
3455 SET_EXPECT(OnInPlaceDeactivate);
3457 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3458 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3460 CHECK_CALLED(OnFocus_FALSE);
3462 CHECK_CALLED(OnInPlaceDeactivateEx);
3464 CHECK_CALLED(OnInPlaceDeactivate);
3467 IOleInPlaceObjectWindowless_Release(windowlessobj);
3470 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
3472 IOleObject *oleobj = NULL;
3473 IOleDocumentView *docview;
3480 IOleDocumentView_Release(view);
3483 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3484 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3488 hres = IOleObject_GetUserClassID(oleobj, NULL);
3489 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3491 hres = IOleObject_GetUserClassID(oleobj, &guid);
3492 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3493 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3495 test_OnFrameWindowActivate(unk);
3497 test_ClientSite(oleobj, flags);
3498 test_InPlaceDeactivate(unk, FALSE);
3500 hres = test_DoVerb(oleobj);
3502 if(call_UIActivate == CallUIActivate_AfterShow) {
3503 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3504 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3506 SET_EXPECT(OnFocus_TRUE);
3507 SET_EXPECT(SetActiveObject);
3509 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3510 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3511 expect_status_text = NULL;
3513 hres = IOleDocumentView_UIActivate(docview, TRUE);
3514 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3516 CHECK_CALLED(OnFocus_TRUE);
3517 CHECK_CALLED(SetActiveObject);
3518 CHECK_CALLED(ShowUI);
3519 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3520 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3522 IOleDocumentView_Release(docview);
3525 IOleObject_Release(oleobj);
3527 test_OnFrameWindowActivate(unk);
3532 static void test_Window(IUnknown *unk, BOOL expect_success)
3534 IOleInPlaceActiveObject *activeobject = NULL;
3538 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3539 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3543 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3545 if(expect_success) {
3546 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3547 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3549 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3550 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3553 IOleInPlaceActiveObject_Release(activeobject);
3556 static void test_CloseView(void)
3558 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3564 hres = IOleDocumentView_Show(view, FALSE);
3565 ok(hres == S_OK, "Show failed: %08x\n", hres);
3567 hres = IOleDocumentView_CloseView(view, 0);
3568 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3570 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3571 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3573 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3574 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3575 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3578 static void test_UIDeactivate(void)
3582 if(call_UIActivate == CallUIActivate_AfterShow) {
3583 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3585 if(call_UIActivate != CallUIActivate_None) {
3586 SET_EXPECT(SetActiveObject_null);
3588 SET_EXPECT(OnUIDeactivate);
3591 hres = IOleDocumentView_UIActivate(view, FALSE);
3592 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3594 if(call_UIActivate != CallUIActivate_None) {
3595 CHECK_CALLED(SetActiveObject_null);
3596 CHECK_CALLED(HideUI);
3597 CHECK_CALLED(OnUIDeactivate);
3599 if(call_UIActivate == CallUIActivate_AfterShow) {
3600 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3604 static void test_Hide(void)
3611 hres = IOleDocumentView_Show(view, FALSE);
3612 ok(hres == S_OK, "Show failed: %08x\n", hres);
3615 static HRESULT create_document(IUnknown **unk)
3617 HRESULT hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3618 &IID_IUnknown, (void**)unk);
3619 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3623 static void test_Navigate(IUnknown *unk)
3625 IHlinkTarget *hlink;
3628 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3629 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3631 SET_EXPECT(ActivateMe);
3632 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3633 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3634 CHECK_CALLED(ActivateMe);
3636 IHlinkTarget_Release(hlink);
3639 static void test_external(IUnknown *unk, BOOL initialized)
3641 IDispatch *external;
3642 IHTMLDocument2 *doc;
3643 IHTMLWindow2 *htmlwin;
3646 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3647 ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres);
3649 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
3650 IHTMLDocument2_Release(doc);
3651 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3654 SET_EXPECT(GetExternal);
3655 external = (void*)0xdeadbeef;
3656 hres = IHTMLWindow2_get_external(htmlwin, &external);
3658 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
3659 CHECK_CALLED(GetExternal);
3660 ok(external != NULL, "external == NULL\n");
3662 ok(hres == S_OK, "get_external failed: %08x\n", hres);
3663 ok(external == NULL, "external != NULL\n");
3666 IHTMLWindow2_Release(htmlwin);
3669 static void test_StreamLoad(IUnknown *unk)
3671 IPersistStreamInit *init;
3674 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3675 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3679 SET_EXPECT(Invoke_AMBIENT_SILENT);
3680 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3681 SET_EXPECT(Exec_ShellDocView_37);
3682 SET_EXPECT(OnChanged_READYSTATE);
3684 readystate_set_loading = TRUE;
3686 hres = IPersistStreamInit_Load(init, &Stream);
3687 ok(hres == S_OK, "Load failed: %08x\n", hres);
3689 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3690 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3691 CHECK_CALLED(Exec_ShellDocView_37);
3692 CHECK_CALLED(OnChanged_READYSTATE);
3695 test_timer(EXPECT_SETTITLE);
3696 test_GetCurMoniker(unk, NULL, about_blank_url);
3698 IPersistStreamInit_Release(init);
3701 static void test_QueryInterface(IUnknown *unk)
3706 static const IID IID_UndocumentedScriptIface =
3707 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
3709 qi = (void*)0xdeadbeef;
3710 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi);
3711 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3712 ok(qi == NULL, "qirunnable=%p, ezpected NULL\n", qi);
3714 qi = (void*)0xdeadbeef;
3715 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi);
3716 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3717 ok(qi == NULL, "qi=%p, ezpected NULL\n", qi);
3719 qi = (void*)0xdeadbeef;
3720 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi);
3721 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3722 ok(qi == NULL, "qi=%p, ezpected NULL\n", qi);
3724 qi = (void*)0xdeadbeef;
3725 hres = IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void**)&qi);
3726 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3727 ok(qi == NULL, "qi=%p, ezpected NULL\n", qi);
3729 qi = (void*)0xdeadbeef;
3730 hres = IUnknown_QueryInterface(unk, &IID_UndocumentedScriptIface, (void**)&qi);
3731 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3732 ok(qi == NULL, "qi=%p, ezpected NULL\n", qi);
3735 static void init_test(enum load_state_t ls) {
3737 hwnd = last_hwnd = NULL;
3738 set_clientsite = FALSE;
3739 load_from_stream = FALSE;
3740 call_UIActivate = CallUIActivate_None;
3748 static void test_HTMLDocument(BOOL do_load)
3754 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
3756 init_test(do_load ? LD_DOLOAD : LD_NO);
3758 hres = create_document(&unk);
3763 test_QueryInterface(unk);
3764 test_IsDirty(unk, S_FALSE);
3765 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3766 test_external(unk, FALSE);
3767 test_ConnectionPointContainer(unk);
3768 test_GetCurMoniker(unk, NULL, NULL);
3771 test_OnAmbientPropertyChange2(unk);
3773 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
3775 IUnknown_Release(unk);
3780 test_download(FALSE, TRUE, TRUE);
3781 test_GetCurMoniker(unk, &Moniker, NULL);
3784 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3785 test_OleCommandTarget_fail(unk);
3786 test_OleCommandTarget(unk);
3787 test_OnAmbientPropertyChange(unk);
3788 test_Window(unk, TRUE);
3789 test_external(unk, TRUE);
3791 test_UIDeactivate();
3792 test_OleCommandTarget(unk);
3793 test_Window(unk, TRUE);
3794 test_InPlaceDeactivate(unk, TRUE);
3796 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
3797 * MSHTML. It doesn't with Wine. */
3799 test_Window(unk, FALSE);
3801 test_InPlaceDeactivate(unk, FALSE);
3803 test_Close(unk, FALSE);
3805 /* Activate HTMLDocument again */
3806 test_Activate(unk, CLIENTSITE_SETNULL);
3807 test_Window(unk, TRUE);
3808 test_OleCommandTarget(unk);
3809 test_UIDeactivate();
3810 test_InPlaceDeactivate(unk, TRUE);
3811 test_Close(unk, FALSE);
3813 /* Activate HTMLDocument again, this time without UIActivate */
3814 call_UIActivate = CallUIActivate_None;
3815 test_Activate(unk, CLIENTSITE_SETNULL);
3816 test_Window(unk, TRUE);
3818 test_UIDeactivate();
3819 test_InPlaceDeactivate(unk, TRUE);
3822 test_Close(unk, TRUE);
3823 test_OnAmbientPropertyChange2(unk);
3824 test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3827 /* Activate HTMLDocument again, calling UIActivate after showing the window */
3828 call_UIActivate = CallUIActivate_AfterShow;
3829 test_Activate(unk, 0);
3830 test_Window(unk, TRUE);
3831 test_OleCommandTarget(unk);
3832 test_UIDeactivate();
3833 test_InPlaceDeactivate(unk, TRUE);
3834 test_Close(unk, FALSE);
3835 call_UIActivate = CallUIActivate_None;
3839 IOleDocumentView_Release(view);
3842 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3844 ref = IUnknown_Release(unk);
3845 ok(ref == 0, "ref=%d, expected 0\n", ref);
3847 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3850 static void test_HTMLDocument_hlink(void)
3856 trace("Testing HTMLDocument (hlink)...\n");
3858 init_test(LD_DOLOAD);
3861 hres = create_document(&unk);
3866 test_ConnectionPointContainer(unk);
3867 test_GetCurMoniker(unk, NULL, NULL);
3871 test_download(FALSE, TRUE, TRUE);
3873 test_IsDirty(unk, S_FALSE);
3874 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3876 test_exec_onunload(unk);
3877 test_Window(unk, TRUE);
3878 test_InPlaceDeactivate(unk, TRUE);
3879 test_Close(unk, FALSE);
3880 test_IsDirty(unk, S_FALSE);
3881 test_GetCurMoniker(unk, &Moniker, NULL);
3884 IOleDocumentView_Release(view);
3887 ref = IUnknown_Release(unk);
3888 ok(ref == 0, "ref=%d, expected 0\n", ref);
3891 static void test_HTMLDocument_StreamLoad(void)
3898 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3900 init_test(LD_DOLOAD);
3901 load_from_stream = TRUE;
3903 hres = create_document(&unk);
3908 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3909 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3911 test_readyState(unk);
3912 test_IsDirty(unk, S_FALSE);
3913 test_ConnectionPointContainer(unk);
3914 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3915 test_DoVerb(oleobj);
3916 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3918 IOleObject_Release(oleobj);
3920 test_GetCurMoniker(unk, NULL, NULL);
3921 test_StreamLoad(unk);
3922 test_download(TRUE, FALSE, TRUE);
3923 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3925 test_UIDeactivate();
3926 test_InPlaceDeactivate(unk, TRUE);
3927 test_Close(unk, FALSE);
3928 test_IsDirty(unk, S_FALSE);
3931 IOleDocumentView_Release(view);
3936 ref = IUnknown_Release(unk);
3937 ok(ref == 0, "ref=%d, expected 0\n", ref);
3940 static void test_edit_uiactivate(IOleObject *oleobj)
3942 IOleDocumentView *docview;
3945 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3946 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3948 SET_EXPECT(OnFocus_TRUE);
3949 SET_EXPECT(SetActiveObject);
3951 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3952 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3953 expect_status_text = NULL;
3955 hres = IOleDocumentView_UIActivate(docview, TRUE);
3956 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3958 CHECK_CALLED(OnFocus_TRUE);
3959 CHECK_CALLED(SetActiveObject);
3960 CHECK_CALLED(ShowUI);
3961 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3962 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3964 IOleDocumentView_Release(docview);
3967 static void test_editing_mode(BOOL do_load)
3974 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
3976 init_test(do_load ? LD_DOLOAD : LD_NO);
3977 call_UIActivate = CallUIActivate_AfterShow;
3979 hres = create_document(&unk);
3984 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3985 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3987 test_readyState(unk);
3988 test_ConnectionPointContainer(unk);
3989 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3990 test_DoVerb(oleobj);
3991 test_edit_uiactivate(oleobj);
3993 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3996 stream_read = protocol_read = 0;
3997 test_exec_editmode(unk, do_load);
3998 test_UIDeactivate();
3999 call_UIActivate = CallUIActivate_None;
4000 IOleObject_Release(oleobj);
4002 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4003 test_download(TRUE, do_load, do_load);
4004 test_timer(EXPECT_UPDATEUI);
4005 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4008 test_exec_fontname(unk, NULL, wszTimesNewRoman);
4009 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4010 test_timer(EXPECT_UPDATEUI);
4011 test_exec_fontname(unk, NULL, wszArial);
4013 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4014 test_timer(EXPECT_UPDATEUI);
4016 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4017 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4019 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4020 test_timer(EXPECT_UPDATEUI);
4021 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4022 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4024 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4025 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4027 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4028 test_timer(EXPECT_UPDATEUI);
4029 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4030 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4033 test_UIDeactivate();
4034 test_InPlaceDeactivate(unk, TRUE);
4035 test_Close(unk, FALSE);
4038 IOleDocumentView_Release(view);
4042 ref = IUnknown_Release(unk);
4043 ok(ref == 0, "ref=%d, expected 0\n", ref);
4046 static void register_protocol(void)
4048 IInternetSession *session;
4051 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
4053 hres = CoInternetGetSession(0, &session, 0);
4054 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
4056 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
4057 wsz_winetest, 0, NULL, 0);
4058 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
4060 IInternetSession_Release(session);
4063 static void gecko_installer_workaround(BOOL disable)
4068 static BOOL has_url = FALSE;
4069 static char url[2048];
4071 if(!disable && !has_url)
4074 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4075 if(res != ERROR_SUCCESS)
4079 DWORD type, size = sizeof(url);
4081 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4082 if(res == ERROR_SUCCESS && type == REG_SZ)
4085 RegDeleteValue(hkey, "GeckoUrl");
4087 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4095 gecko_installer_workaround(TRUE);
4098 container_hwnd = create_container_window();
4099 register_protocol();
4101 test_HTMLDocument(FALSE);
4102 test_HTMLDocument(TRUE);
4103 test_HTMLDocument_hlink();
4104 test_HTMLDocument_StreamLoad();
4105 test_editing_mode(FALSE);
4106 test_editing_mode(TRUE);
4108 DestroyWindow(container_hwnd);
4111 gecko_installer_workaround(FALSE);