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>
41 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
42 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
43 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
45 #define DEFINE_EXPECT(func) \
46 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
48 #define SET_EXPECT(func) \
49 expect_ ## func = TRUE
51 #define SET_CALLED(func) \
52 called_ ## func = TRUE
54 #define CHECK_EXPECT2(func) \
56 ok(expect_ ##func, "unexpected call " #func "\n"); \
57 called_ ## func = TRUE; \
60 #define CHECK_EXPECT(func) \
62 CHECK_EXPECT2(func); \
63 expect_ ## func = FALSE; \
66 #define CHECK_CALLED(func) \
68 ok(called_ ## func, "expected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
72 static IOleDocumentView *view = NULL;
73 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
75 DEFINE_EXPECT(LockContainer);
76 DEFINE_EXPECT(SetActiveObject);
77 DEFINE_EXPECT(SetActiveObject_null);
78 DEFINE_EXPECT(GetWindow);
79 DEFINE_EXPECT(CanInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivate);
81 DEFINE_EXPECT(OnInPlaceActivateEx);
82 DEFINE_EXPECT(OnUIActivate);
83 DEFINE_EXPECT(GetWindowContext);
84 DEFINE_EXPECT(OnUIDeactivate);
85 DEFINE_EXPECT(OnInPlaceDeactivate);
86 DEFINE_EXPECT(OnInPlaceDeactivateEx);
87 DEFINE_EXPECT(GetContainer);
88 DEFINE_EXPECT(ShowUI);
89 DEFINE_EXPECT(ActivateMe);
90 DEFINE_EXPECT(GetHostInfo);
91 DEFINE_EXPECT(HideUI);
92 DEFINE_EXPECT(GetOptionKeyPath);
93 DEFINE_EXPECT(GetOverrideKeyPath);
94 DEFINE_EXPECT(SetStatusText);
95 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
96 DEFINE_EXPECT(QueryStatus_OPEN);
97 DEFINE_EXPECT(QueryStatus_NEW);
98 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
99 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
100 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
101 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
102 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
103 DEFINE_EXPECT(Exec_ShellDocView_37);
104 DEFINE_EXPECT(Exec_ShellDocView_84);
105 DEFINE_EXPECT(Exec_ShellDocView_103);
106 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
107 DEFINE_EXPECT(Exec_SETTITLE);
108 DEFINE_EXPECT(Exec_HTTPEQUIV);
109 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
110 DEFINE_EXPECT(Exec_Explorer_69);
111 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
112 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
113 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
114 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
115 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
116 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
117 DEFINE_EXPECT(GetDropTarget);
118 DEFINE_EXPECT(UpdateUI);
119 DEFINE_EXPECT(Navigate);
120 DEFINE_EXPECT(OnFrameWindowActivate);
121 DEFINE_EXPECT(OnChanged_READYSTATE);
122 DEFINE_EXPECT(OnChanged_1005);
123 DEFINE_EXPECT(GetDisplayName);
124 DEFINE_EXPECT(BindToStorage);
125 DEFINE_EXPECT(IsSystemMoniker);
126 DEFINE_EXPECT(GetBindResult);
127 DEFINE_EXPECT(GetClassID);
128 DEFINE_EXPECT(Abort);
130 DEFINE_EXPECT(CreateInstance);
131 DEFINE_EXPECT(Start);
132 DEFINE_EXPECT(Terminate);
133 DEFINE_EXPECT(Protocol_Read);
134 DEFINE_EXPECT(LockRequest);
135 DEFINE_EXPECT(UnlockRequest);
136 DEFINE_EXPECT(OnFocus_TRUE);
137 DEFINE_EXPECT(OnFocus_FALSE);
138 DEFINE_EXPECT(RequestUIActivate);
139 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
140 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
141 DEFINE_EXPECT(GetExternal);
142 DEFINE_EXPECT(EnableModeless_TRUE);
143 DEFINE_EXPECT(EnableModeless_FALSE);
144 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
145 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
147 static IUnknown *doc_unk;
148 static BOOL expect_LockContainer_fLock;
149 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
151 static BOOL set_clientsite = FALSE, container_locked = FALSE;
152 static BOOL readystate_set_loading = FALSE, load_from_stream;
153 static BOOL editmode = FALSE, show_failed;
154 static int stream_read, protocol_read;
155 static enum load_state_t {
164 static LPCOLESTR expect_status_text = NULL;
166 static const char html_page[] =
168 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
172 static const char css_data[] = "body {color: red}";
174 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
175 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
177 static HRESULT QueryInterface(REFIID riid, void **ppv);
178 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
179 static BOOL nogecko = FALSE;
181 #define test_readyState(u) _test_readyState(__LINE__,u)
182 static void _test_readyState(unsigned,IUnknown*);
184 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
186 static const WCHAR wszTimesNewRoman[] =
187 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
188 static const WCHAR wszArial[] =
189 {'A','r','i','a','l',0};
191 static const char *debugstr_guid(REFIID riid)
195 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
196 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
197 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
198 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
203 static const char *debugstr_w(LPCWSTR str)
205 static char buf[1024];
210 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
214 #define EXPECT_UPDATEUI 1
215 #define EXPECT_SETTITLE 2
217 static void test_timer(DWORD flags)
219 BOOL *b = &called_Exec_SETTITLE;
222 if(flags & EXPECT_UPDATEUI) {
223 SET_EXPECT(UpdateUI);
224 SET_EXPECT(Exec_UPDATECOMMANDS);
225 b = &called_UpdateUI;
227 if(flags & EXPECT_SETTITLE)
228 SET_EXPECT(Exec_SETTITLE);
230 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
231 TranslateMessage(&msg);
232 DispatchMessage(&msg);
235 if(flags & EXPECT_UPDATEUI) {
236 CHECK_CALLED(UpdateUI);
237 CHECK_CALLED(Exec_UPDATECOMMANDS);
239 if(flags & EXPECT_SETTITLE)
240 CHECK_CALLED(Exec_SETTITLE);
243 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
245 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
249 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
254 if(IsEqualGUID(&IID_IProxyManager, riid))
255 return E_NOINTERFACE; /* TODO */
256 if(IsEqualGUID(&IID_IDispatchEx, riid))
257 return E_NOINTERFACE; /* TODO */
258 if(IsEqualGUID(&IID_External_unk, riid))
259 return E_NOINTERFACE; /* TODO */
261 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
262 return E_NOINTERFACE;
265 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
270 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
275 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
277 ok(0, "unexpected call\n");
281 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
284 ok(0, "unexpected call\n");
288 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
289 UINT cNames, LCID lcid, DISPID *rgDispId)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
296 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
297 EXCEPINFO *pExcepInfo, UINT *puArgErr)
299 ok(0, "unexpected call\n");
303 static const IDispatchVtbl ExternalVtbl = {
304 External_QueryInterface,
307 Dispatch_GetTypeInfoCount,
308 Dispatch_GetTypeInfo,
309 Dispatch_GetIDsOfNames,
313 static IDispatch External = { &ExternalVtbl };
315 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
317 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
323 return E_NOINTERFACE;
326 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
331 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
336 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
337 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
338 DWORD grfPI, DWORD dwReserved)
344 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
345 static const WCHAR empty_str = {0};
349 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
350 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
351 ok(!grfPI, "grfPI = %x\n", grfPI);
352 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
354 memset(&bindinfo, 0, sizeof(bindinfo));
355 bindinfo.cbSize = sizeof(bindinfo);
356 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
357 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
358 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
359 "bindf = %x\n", bindf);
361 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
362 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
363 /* TODO: test stgmedData */
364 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
365 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
366 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
367 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
368 ok(bindinfo.dwOptions == 0x80000 ||
369 bindinfo.dwOptions == 0x4080000, /* win2k3 */
370 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
371 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
372 /* TODO: test dwCodePage */
373 /* TODO: test securityAttributes */
374 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
375 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
376 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
378 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
379 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
380 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
382 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
383 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
385 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
387 hres = IInternetProtocolSink_ReportData(pOIProtSink,
388 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
389 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
391 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
392 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
397 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
398 PROTOCOLDATA *pProtocolData)
400 ok(0, "unexpected call\n");
404 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
407 ok(0, "unexpected call\n");
411 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
413 CHECK_EXPECT(Terminate);
417 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
419 ok(0, "unexpected call\n");
423 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
425 ok(0, "unexpected call\n");
429 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
430 ULONG cb, ULONG *pcbRead)
432 CHECK_EXPECT2(Protocol_Read);
434 ok(pv != NULL, "pv == NULL\n");
435 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
436 ok(pcbRead != NULL, "pcbRead == NULL\n");
437 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
442 protocol_read += *pcbRead = sizeof(css_data)-1;
443 memcpy(pv, css_data, sizeof(css_data)-1);
447 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
448 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
450 ok(0, "unexpected call\n");
454 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
456 CHECK_EXPECT(LockRequest);
460 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
462 CHECK_EXPECT(UnlockRequest);
466 static const IInternetProtocolVtbl ProtocolVtbl = {
467 Protocol_QueryInterface,
478 Protocol_LockRequest,
479 Protocol_UnlockRequest
482 static IInternetProtocol Protocol = { &ProtocolVtbl };
484 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
486 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
487 ok(0, "unexpected call\n");
488 return E_NOINTERFACE;
491 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
496 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
501 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
502 REFIID riid, void **ppv)
504 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
505 return E_NOINTERFACE;
507 CHECK_EXPECT(CreateInstance);
508 ok(ppv != NULL, "ppv == NULL\n");
514 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
516 ok(0, "unexpected call\n");
520 static const IClassFactoryVtbl ClassFactoryVtbl = {
521 ClassFactory_QueryInterface,
523 ClassFactory_Release,
524 ClassFactory_CreateInstance,
525 ClassFactory_LockServer
528 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
530 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
532 ok(0, "unexpected call\n");
536 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
541 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
546 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
547 IHlinkBrowseContext *pihlbc)
549 ok(0, "unexpected call\n");
553 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
554 IHlinkBrowseContext **ppihlbc)
556 ok(0, "unexpected call\n");
560 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
561 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
565 CHECK_EXPECT(Navigate);
567 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
568 ok(pbc != NULL, "pbc == NULL\n");
569 ok(pibsc != NULL, "pubsc == NULL\n");
570 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
573 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
574 LPWSTR location = (LPWSTR)0xdeadbeef;
576 IMoniker *mon = NULL;
577 DWORD site_data = 0xdeadbeef;
579 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
580 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
581 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
583 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
584 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
585 ok(location == NULL, "location = %p\n", location);
586 ok(mon != NULL, "mon == NULL\n");
588 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
589 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
590 ok(site == NULL, "site = %p\n, expected NULL\n", site);
591 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
597 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
598 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
600 ok(0, "unexpected call\n");
604 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
605 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
607 ok(0, "unexpected call\n");
611 static const IHlinkFrameVtbl HlinkFrameVtbl = {
612 HlinkFrame_QueryInterface,
615 HlinkFrame_SetBrowseContext,
616 HlinkFrame_GetBrowseContext,
618 HlinkFrame_OnNavigate,
619 HlinkFrame_UpdateHlink
622 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
624 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
625 REFIID riid, void**ppv)
627 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
632 ok(0, "unexpected call\n");
633 return E_NOINTERFACE;
636 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
641 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
646 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
649 case DISPID_READYSTATE:
650 CHECK_EXPECT2(OnChanged_READYSTATE);
651 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
652 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
653 ? OLECMDF_ENABLED : 0));
655 if(readystate_set_loading) {
656 readystate_set_loading = FALSE;
657 load_state = LD_LOADING;
659 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
660 test_readyState(NULL);
663 CHECK_EXPECT(OnChanged_1005);
665 test_readyState(NULL);
666 load_state = LD_INTERACTIVE;
670 ok(0, "unexpected id %d\n", dispID);
674 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
676 ok(0, "unexpected call\n");
680 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
681 PropertyNotifySink_QueryInterface,
682 PropertyNotifySink_AddRef,
683 PropertyNotifySink_Release,
684 PropertyNotifySink_OnChanged,
685 PropertyNotifySink_OnRequestEdit
688 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
690 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
692 ok(0, "unexpected call\n");
693 return E_NOINTERFACE;
696 static ULONG WINAPI Stream_AddRef(IStream *iface)
701 static ULONG WINAPI Stream_Release(IStream *iface)
706 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
707 ULONG cb, ULONG *pcbRead)
710 ok(pv != NULL, "pv == NULL\n");
711 ok(cb > sizeof(html_page), "cb = %d\n", cb);
712 ok(pcbRead != NULL, "pcbRead == NULL\n");
713 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
718 memcpy(pv, html_page, sizeof(html_page)-1);
719 stream_read += *pcbRead = sizeof(html_page)-1;
723 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
724 ULONG cb, ULONG *pcbWritten)
726 ok(0, "unexpected call\n");
730 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
731 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
733 ok(0, "unexpected call\n");
737 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
739 ok(0, "unexpected call\n");
743 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
744 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
746 ok(0, "unexpected call\n");
750 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
752 ok(0, "unexpected call\n");
756 static HRESULT WINAPI Stream_Revert(IStream *iface)
758 ok(0, "unexpected call\n");
762 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
763 ULARGE_INTEGER cb, DWORD dwLockType)
765 ok(0, "unexpected call\n");
769 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
770 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
772 ok(0, "unexpected call\n");
776 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
779 ok(0, "unexpected call\n");
783 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
785 ok(0, "unexpected call\n");
789 static const IStreamVtbl StreamVtbl = {
790 Stream_QueryInterface,
806 static IStream Stream = { &StreamVtbl };
808 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
810 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
811 return E_NOINTERFACE; /* TODO */
813 if(IsEqualGUID(&IID_IWinInetInfo, riid))
814 return E_NOINTERFACE; /* TODO */
816 ok(0, "unexpected call\n");
817 return E_NOINTERFACE;
820 static ULONG WINAPI Binding_AddRef(IBinding *iface)
825 static ULONG WINAPI Binding_Release(IBinding *iface)
830 static HRESULT WINAPI Binding_Abort(IBinding *iface)
836 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
838 ok(0, "unexpected call\n");
842 static HRESULT WINAPI Binding_Resume(IBinding *iface)
844 ok(0, "unexpected call\n");
848 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
850 ok(0, "unexpected call\n");
854 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
856 ok(0, "unexpected call\n");
860 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
861 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
863 CHECK_EXPECT(GetBindResult);
867 static const IBindingVtbl BindingVtbl = {
868 Binding_QueryInterface,
876 Binding_GetBindResult
879 static IBinding Binding = { &BindingVtbl };
881 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
882 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
884 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
888 if(IsEqualGUID(&IID_IMoniker_unk, riid))
889 return E_NOINTERFACE; /* TODO */
890 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
891 return E_NOINTERFACE; /* TODO */
893 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
894 return E_NOINTERFACE;
897 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
902 static ULONG WINAPI Moniker_Release(IMoniker *iface)
907 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
909 CHECK_EXPECT(GetClassID);
910 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
914 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
916 ok(0, "unexpected call\n");
920 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
922 ok(0, "unexpected call\n");
926 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
928 ok(0, "unexpected call\n");
932 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
934 ok(0, "unexpected call\n");
938 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
939 REFIID riidResult, void **ppvResult)
941 ok(0, "unexpected call\n");
945 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
946 REFIID riid, void **ppv)
948 IBindStatusCallback *callback = NULL;
949 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
955 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
956 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
958 CHECK_EXPECT(BindToStorage);
960 load_state = LD_LOADING;
962 ok(pbc != NULL, "pbc == NULL\n");
963 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
964 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
965 ok(ppv != NULL, "ppv == NULL\n");
966 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
968 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
969 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
970 ok(callback != NULL, "callback == NULL\n");
972 memset(&bindinfo, 0xf0, sizeof(bindinfo));
973 bindinfo.cbSize = sizeof(bindinfo);
975 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
976 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
977 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
978 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
979 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
980 /* TODO: test stgmedData */
981 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
982 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
983 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
984 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
985 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
986 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
987 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
988 /* TODO: test dwCodePage */
989 /* TODO: test securityAttributes */
990 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
991 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
992 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
994 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
995 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
997 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
999 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1001 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1002 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1003 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1006 stgmedium.tymed = TYMED_ISTREAM;
1007 U(stgmedium).pstm = &Stream;
1008 stgmedium.pUnkForRelease = (IUnknown*)iface;
1009 hres = IBindStatusCallback_OnDataAvailable(callback,
1010 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1011 sizeof(html_page)-1, &formatetc, &stgmedium);
1012 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1015 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1016 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1017 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1019 SET_EXPECT(GetBindResult);
1020 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1021 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1022 SET_CALLED(GetBindResult); /* IE7 */
1024 IBindStatusCallback_Release(callback);
1029 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1030 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1032 ok(0, "unexpected call\n");
1036 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1037 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1039 ok(0, "unexpected call\n");
1043 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1045 ok(0, "unexpected call\n");
1049 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1051 ok(0, "unexpected call\n");
1055 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1057 ok(0, "unexpected call\n");
1061 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1062 IMoniker *pmkNewlyRunning)
1064 ok(0, "unexpected call\n");
1068 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1069 IMoniker *pmkToLeft, FILETIME *pFileTime)
1071 ok(0, "unexpected call\n");
1075 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1077 ok(0, "unexpected call\n");
1081 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1082 IMoniker **ppmkPrefix)
1084 ok(0, "unexpected call\n");
1088 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1089 IMoniker **pmkRelPath)
1091 ok(0, "unexpected call\n");
1095 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1096 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1098 CHECK_EXPECT2(GetDisplayName);
1100 /* ok(pbc != NULL, "pbc == NULL\n"); */
1101 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1102 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1104 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1105 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1110 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1111 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1113 ok(0, "unexpected call\n");
1117 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1119 CHECK_EXPECT(IsSystemMoniker);
1123 static const IMonikerVtbl MonikerVtbl = {
1124 Moniker_QueryInterface,
1132 Moniker_BindToObject,
1133 Moniker_BindToStorage,
1135 Moniker_ComposeWith,
1140 Moniker_GetTimeOfLastChange,
1142 Moniker_CommonPrefixWith,
1143 Moniker_RelativePathTo,
1144 Moniker_GetDisplayName,
1145 Moniker_ParseDisplayName,
1146 Moniker_IsSystemMoniker
1149 static IMoniker Moniker = { &MonikerVtbl };
1151 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1153 return QueryInterface(riid, ppv);
1156 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1161 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1166 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1167 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1169 ok(0, "unexpected call\n");
1173 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1174 IEnumUnknown **ppenum)
1176 ok(0, "unexpected call\n");
1180 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1182 CHECK_EXPECT(LockContainer);
1183 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1187 static const IOleContainerVtbl OleContainerVtbl = {
1188 OleContainer_QueryInterface,
1189 OleContainer_AddRef,
1190 OleContainer_Release,
1191 OleContainer_ParseDisplayName,
1192 OleContainer_EnumObjects,
1193 OleContainer_LockContainer
1196 static IOleContainer OleContainer = { &OleContainerVtbl };
1198 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1200 ok(0, "unexpected call\n");
1201 return E_NOINTERFACE;
1204 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1209 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1214 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1216 ok(0, "unexpected call\n");
1220 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1222 ok(0, "unexpected call\n");
1226 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1228 ok(0, "unexpected call\n");
1232 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1233 LPCBORDERWIDTHS pborderwidths)
1235 ok(0, "unexpected call\n");
1239 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1240 LPCBORDERWIDTHS pborderwidths)
1242 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1246 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1247 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1249 static const WCHAR wszHTML_Document[] =
1250 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1252 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1254 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1255 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1256 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1257 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1260 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1261 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1263 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1267 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1268 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1270 static const WCHAR wszHTML_Document[] =
1271 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1274 CHECK_EXPECT2(SetActiveObject);
1276 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1277 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1279 CHECK_EXPECT(SetActiveObject_null);
1281 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1282 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1288 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1289 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1291 ok(0, "unexpected call\n");
1295 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1296 HOLEMENU holemenu, HWND hwndActiveObject)
1298 ok(0, "unexpected call\n");
1302 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1304 ok(0, "unexpected call\n");
1308 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1310 CHECK_EXPECT2(SetStatusText);
1311 if(!expect_status_text)
1312 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1316 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1319 CHECK_EXPECT(Frame_EnableModeless_TRUE);
1321 CHECK_EXPECT(Frame_EnableModeless_FALSE);
1325 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1327 ok(0, "unexpected call\n");
1331 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1332 InPlaceFrame_QueryInterface,
1333 InPlaceFrame_AddRef,
1334 InPlaceFrame_Release,
1335 InPlaceFrame_GetWindow,
1336 InPlaceFrame_ContextSensitiveHelp,
1337 InPlaceFrame_GetBorder,
1338 InPlaceFrame_RequestBorderSpace,
1339 InPlaceFrame_SetBorderSpace,
1340 InPlaceFrame_SetActiveObject,
1341 InPlaceFrame_InsertMenus,
1342 InPlaceFrame_SetMenu,
1343 InPlaceFrame_RemoveMenus,
1344 InPlaceFrame_SetStatusText,
1345 InPlaceFrame_EnableModeless,
1346 InPlaceFrame_TranslateAccelerator
1349 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1351 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1352 InPlaceFrame_QueryInterface,
1353 InPlaceFrame_AddRef,
1354 InPlaceFrame_Release,
1355 InPlaceFrame_GetWindow,
1356 InPlaceFrame_ContextSensitiveHelp,
1357 InPlaceFrame_GetBorder,
1358 InPlaceFrame_RequestBorderSpace,
1359 InPlaceFrame_SetBorderSpace,
1360 InPlaceUIWindow_SetActiveObject,
1363 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1365 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1367 return QueryInterface(riid, ppv);
1370 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1375 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1380 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1382 CHECK_EXPECT(GetWindow);
1383 ok(phwnd != NULL, "phwnd = NULL\n");
1384 *phwnd = container_hwnd;
1388 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1390 ok(0, "unexpected call\n");
1394 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1396 CHECK_EXPECT(CanInPlaceActivate);
1400 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1402 CHECK_EXPECT(OnInPlaceActivate);
1406 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1408 CHECK_EXPECT(OnUIActivate);
1412 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1413 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1414 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1416 static const RECT rect = {0,0,500,500};
1418 CHECK_EXPECT(GetWindowContext);
1420 ok(ppFrame != NULL, "ppFrame = NULL\n");
1422 *ppFrame = &InPlaceFrame;
1423 ok(ppDoc != NULL, "ppDoc = NULL\n");
1425 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1426 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1428 memcpy(lprcPosRect, &rect, sizeof(RECT));
1429 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1431 memcpy(lprcClipRect, &rect, sizeof(RECT));
1432 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1434 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1435 lpFrameInfo->fMDIApp = FALSE;
1436 lpFrameInfo->hwndFrame = container_hwnd;
1437 lpFrameInfo->haccel = NULL;
1438 lpFrameInfo->cAccelEntries = 0;
1444 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1446 ok(0, "unexpected call\n");
1450 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1452 CHECK_EXPECT(OnUIDeactivate);
1453 ok(!fUndoable, "fUndoable = TRUE\n");
1457 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1459 CHECK_EXPECT(OnInPlaceDeactivate);
1463 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1465 ok(0, "unexpected call\n");
1469 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1471 ok(0, "unexpected call\n");
1475 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1477 ok(0, "unexpected call\n");
1481 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1483 CHECK_EXPECT(OnInPlaceActivateEx);
1485 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1486 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1487 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1492 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1494 CHECK_EXPECT(OnInPlaceDeactivateEx);
1496 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1501 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1503 CHECK_EXPECT(RequestUIActivate);
1507 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1508 InPlaceSite_QueryInterface,
1510 InPlaceSite_Release,
1511 InPlaceSite_GetWindow,
1512 InPlaceSite_ContextSensitiveHelp,
1513 InPlaceSite_CanInPlaceActivate,
1514 InPlaceSite_OnInPlaceActivate,
1515 InPlaceSite_OnUIActivate,
1516 InPlaceSite_GetWindowContext,
1518 InPlaceSite_OnUIDeactivate,
1519 InPlaceSite_OnInPlaceDeactivate,
1520 InPlaceSite_DiscardUndoState,
1521 InPlaceSite_DeactivateAndUndo,
1522 InPlaceSite_OnPosRectChange,
1523 InPlaceSiteEx_OnInPlaceActivateEx,
1524 InPlaceSiteEx_OnInPlaceDeactivateEx,
1525 InPlaceSiteEx_RequestUIActivate
1528 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1530 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1532 return QueryInterface(riid, ppv);
1535 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1540 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1545 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1547 ok(0, "unexpected call\n");
1551 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1554 ok(0, "unexpected call\n");
1558 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1560 CHECK_EXPECT(GetContainer);
1561 ok(ppContainer != NULL, "ppContainer = NULL\n");
1562 *ppContainer = &OleContainer;
1566 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1568 ok(0, "unexpected call\n");
1572 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1574 ok(0, "unexpected call\n");
1578 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1580 ok(0, "unexpected call\n");
1584 static const IOleClientSiteVtbl ClientSiteVtbl = {
1585 ClientSite_QueryInterface,
1588 ClientSite_SaveObject,
1589 ClientSite_GetMoniker,
1590 ClientSite_GetContainer,
1591 ClientSite_ShowObject,
1592 ClientSite_OnShowWindow,
1593 ClientSite_RequestNewObjectLayout
1596 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1598 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1600 return QueryInterface(riid, ppv);
1603 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1608 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1615 CallUIActivate_None,
1616 CallUIActivate_ActivateMe,
1617 CallUIActivate_AfterShow,
1620 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1621 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1623 IOleDocument *document;
1626 CHECK_EXPECT(ActivateMe);
1627 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1629 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1630 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1632 if(SUCCEEDED(hres)) {
1633 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1634 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1636 if(SUCCEEDED(hres)) {
1637 IOleInPlaceActiveObject *activeobj = NULL;
1638 IOleInPlaceSite *inplacesite = NULL;
1639 HWND tmp_hwnd = NULL;
1640 static RECT rect = {0,0,400,500};
1642 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1643 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1644 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1645 inplacesite, &InPlaceSiteEx);
1647 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1648 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1650 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1651 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1652 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1653 inplacesite, &InPlaceSiteEx);
1655 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1656 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1659 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1660 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1661 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1664 if(call_UIActivate == CallUIActivate_ActivateMe) {
1665 SET_EXPECT(CanInPlaceActivate);
1666 SET_EXPECT(GetWindowContext);
1667 SET_EXPECT(GetWindow);
1669 SET_EXPECT(OnInPlaceActivateEx);
1671 SET_EXPECT(OnInPlaceActivate);
1672 SET_EXPECT(SetStatusText);
1673 SET_EXPECT(Exec_SETPROGRESSMAX);
1674 SET_EXPECT(Exec_SETPROGRESSPOS);
1675 SET_EXPECT(OnUIActivate);
1676 SET_EXPECT(SetActiveObject);
1678 expect_status_text = NULL;
1680 hres = IOleDocumentView_UIActivate(view, TRUE);
1681 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1683 CHECK_CALLED(CanInPlaceActivate);
1684 CHECK_CALLED(GetWindowContext);
1685 CHECK_CALLED(GetWindow);
1687 CHECK_CALLED(OnInPlaceActivateEx);
1689 CHECK_CALLED(OnInPlaceActivate);
1690 CHECK_CALLED(SetStatusText);
1691 CHECK_CALLED(Exec_SETPROGRESSMAX);
1692 CHECK_CALLED(Exec_SETPROGRESSPOS);
1693 CHECK_CALLED(OnUIActivate);
1694 CHECK_CALLED(SetActiveObject);
1695 CHECK_CALLED(ShowUI);
1698 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1699 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1700 ok(hwnd != NULL, "hwnd == NULL\n");
1702 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1705 hres = IOleDocumentView_UIActivate(view, TRUE);
1706 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1709 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1710 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1711 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1715 hres = IOleDocumentView_SetRect(view, &rect);
1716 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1718 if(call_UIActivate == CallUIActivate_ActivateMe) {
1719 hres = IOleDocumentView_Show(view, TRUE);
1720 ok(hres == S_OK, "Show failed: %08x\n", hres);
1722 SET_EXPECT(CanInPlaceActivate);
1723 SET_EXPECT(GetWindowContext);
1724 SET_EXPECT(GetWindow);
1726 SET_EXPECT(OnInPlaceActivateEx);
1728 SET_EXPECT(OnInPlaceActivate);
1729 SET_EXPECT(SetStatusText);
1730 SET_EXPECT(Exec_SETPROGRESSMAX);
1731 SET_EXPECT(Exec_SETPROGRESSPOS);
1732 SET_EXPECT(OnUIActivate);
1733 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1735 hres = IOleDocumentView_Show(view, TRUE);
1737 win_skip("Show failed\n");
1739 IOleInPlaceActiveObject_Release(activeobj);
1740 IOleDocument_Release(document);
1744 ok(hres == S_OK, "Show failed: %08x\n", hres);
1746 CHECK_CALLED(CanInPlaceActivate);
1747 CHECK_CALLED(GetWindowContext);
1748 CHECK_CALLED(GetWindow);
1750 CHECK_CALLED(OnInPlaceActivateEx);
1752 CHECK_CALLED(OnInPlaceActivate);
1753 CHECK_CALLED(SetStatusText);
1754 CHECK_CALLED(Exec_SETPROGRESSMAX);
1755 CHECK_CALLED(Exec_SETPROGRESSPOS);
1758 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1759 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1760 ok(hwnd != NULL, "hwnd == NULL\n");
1762 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1766 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1769 IOleInPlaceActiveObject_Release(activeobj);
1772 IOleDocument_Release(document);
1778 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1779 DocumentSite_QueryInterface,
1780 DocumentSite_AddRef,
1781 DocumentSite_Release,
1782 DocumentSite_ActivateMe
1785 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1787 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1789 return QueryInterface(riid, ppv);
1792 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1797 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1802 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1804 ok(0, "unexpected call\n");
1808 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1810 ok(0, "unexpected call\n");
1814 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1816 ok(0, "unexpected call\n");
1820 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1821 POINTF *pPtfContainer, DWORD dwFlags)
1823 ok(0, "unexpected call\n");
1827 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1828 MSG *pMsg, DWORD grfModifiers)
1830 ok(0, "unexpected call\n");
1834 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1837 CHECK_EXPECT(OnFocus_TRUE);
1839 CHECK_EXPECT2(OnFocus_FALSE);
1843 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1845 ok(0, "unexpected call\n");
1849 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1850 OleControlSite_QueryInterface,
1851 OleControlSite_AddRef,
1852 OleControlSite_Release,
1853 OleControlSite_OnControlInfoChanged,
1854 OleControlSite_LockInPlaceActive,
1855 OleControlSite_GetExtendedControl,
1856 OleControlSite_TransformCoords,
1857 OleControlSite_TranslateAccelerator,
1858 OleControlSite_OnFocus,
1859 OleControlSite_ShowPropertyFrame
1862 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1864 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1866 return QueryInterface(riid, ppv);
1869 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1874 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1879 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1880 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1882 ok(0, "unexpected call\n");
1886 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1888 CHECK_EXPECT(GetHostInfo);
1889 ok(pInfo != NULL, "pInfo=NULL\n");
1891 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1892 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1893 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1894 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1895 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1896 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1897 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1898 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1903 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1904 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1905 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1907 CHECK_EXPECT(ShowUI);
1910 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1912 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1913 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1914 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1915 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1916 if (expect_InPlaceUIWindow_SetActiveObject_active)
1917 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
1919 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1924 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1926 CHECK_EXPECT(HideUI);
1930 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1932 CHECK_EXPECT(UpdateUI);
1936 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1939 CHECK_EXPECT(EnableModeless_TRUE);
1941 CHECK_EXPECT(EnableModeless_FALSE);
1945 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1947 ok(0, "unexpected call\n");
1951 static BOOL expect_OnFrameWindowActivate_fActivate;
1952 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1954 CHECK_EXPECT2(OnFrameWindowActivate);
1955 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1959 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1960 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1962 ok(0, "unexpected call\n");
1966 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1967 const GUID *pguidCmdGroup, DWORD nCmdID)
1969 ok(0, "unexpected call\n");
1973 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1974 LPOLESTR *pchKey, DWORD dw)
1976 CHECK_EXPECT(GetOptionKeyPath);
1977 ok(pchKey != NULL, "pchKey = NULL\n");
1978 ok(!dw, "dw=%d, expected 0\n", dw);
1980 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1984 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1985 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1987 CHECK_EXPECT(GetDropTarget);
1992 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1994 CHECK_EXPECT(GetExternal);
1995 *ppDispatch = &External;
1999 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2000 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2002 ok(0, "unexpected call\n");
2006 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2007 IDataObject **ppPORet)
2009 ok(0, "unexpected call\n");
2013 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2014 LPOLESTR *pchKey, DWORD dw)
2016 CHECK_EXPECT(GetOverrideKeyPath);
2017 ok(pchKey != NULL, "pchKey = NULL\n");
2019 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2020 ok(!dw, "dw=%d, xepected 0\n", dw);
2024 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2025 DocHostUIHandler_QueryInterface,
2026 DocHostUIHandler_AddRef,
2027 DocHostUIHandler_Release,
2028 DocHostUIHandler_ShowContextMenu,
2029 DocHostUIHandler_GetHostInfo,
2030 DocHostUIHandler_ShowUI,
2031 DocHostUIHandler_HideUI,
2032 DocHostUIHandler_UpdateUI,
2033 DocHostUIHandler_EnableModeless,
2034 DocHostUIHandler_OnDocWindowActivate,
2035 DocHostUIHandler_OnFrameWindowActivate,
2036 DocHostUIHandler_ResizeBorder,
2037 DocHostUIHandler_TranslateAccelerator,
2038 DocHostUIHandler_GetOptionKeyPath,
2039 DocHostUIHandler_GetDropTarget,
2040 DocHostUIHandler_GetExternal,
2041 DocHostUIHandler_TranslateUrl,
2042 DocHostUIHandler_FilterDataObject,
2043 DocHostUIHandler_GetOverrideKeyPath
2046 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2048 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2049 REFIID riid, void **ppv)
2051 return QueryInterface(riid, ppv);
2054 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2059 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2064 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2065 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2067 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2068 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2069 ok(!pCmdText, "pCmdText != NULL\n");
2071 switch(prgCmds[0].cmdID) {
2072 case OLECMDID_SETPROGRESSTEXT:
2073 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2074 prgCmds[0].cmdf = OLECMDF_ENABLED;
2077 CHECK_EXPECT(QueryStatus_OPEN);
2078 prgCmds[0].cmdf = 0;
2081 CHECK_EXPECT(QueryStatus_NEW);
2082 prgCmds[0].cmdf = 0;
2085 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2091 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2092 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2094 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2095 test_readyState(NULL);
2097 if(!pguidCmdGroup) {
2099 case OLECMDID_SETPROGRESSMAX:
2100 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2101 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2102 ok(pvaIn != NULL, "pvaIn == NULL\n");
2104 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2105 if(load_state == LD_NO)
2106 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2108 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2110 case OLECMDID_SETPROGRESSPOS:
2111 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2112 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2113 ok(pvaIn != NULL, "pvaIn == NULL\n");
2115 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2116 if(load_state == LD_NO)
2117 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2119 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2121 case OLECMDID_HTTPEQUIV_DONE:
2122 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2123 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2124 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2125 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2126 load_state = LD_COMPLETE;
2128 case OLECMDID_SETDOWNLOADSTATE:
2129 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2130 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2131 ok(pvaIn != NULL, "pvaIn == NULL\n");
2132 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2134 switch(V_I4(pvaIn)) {
2136 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2137 load_state = LD_INTERACTIVE;
2140 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2143 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2147 case OLECMDID_UPDATECOMMANDS:
2148 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2149 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2150 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2151 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2153 case OLECMDID_SETTITLE:
2154 CHECK_EXPECT2(Exec_SETTITLE);
2155 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2156 ok(pvaIn != NULL, "pvaIn == NULL\n");
2157 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2158 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2159 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2161 case OLECMDID_HTTPEQUIV:
2162 CHECK_EXPECT2(Exec_HTTPEQUIV);
2163 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2167 ok(0, "unexpected command %d\n", nCmdID);
2172 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2173 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2177 CHECK_EXPECT2(Exec_ShellDocView_37);
2179 if(load_from_stream)
2180 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2182 test_GetCurMoniker(doc_unk, &Moniker, NULL);
2184 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2185 ok(pvaIn != NULL, "pvaIn == NULL\n");
2187 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2188 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2192 CHECK_EXPECT2(Exec_ShellDocView_84);
2194 ok(pvaIn == NULL, "pvaIn != NULL\n");
2195 ok(pvaOut != NULL, "pvaOut == NULL\n");
2197 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2202 CHECK_EXPECT2(Exec_ShellDocView_103);
2204 ok(pvaIn == NULL, "pvaIn != NULL\n");
2205 ok(pvaOut == NULL, "pvaOut != NULL\n");
2210 ok(0, "unexpected command %d\n", nCmdID);
2215 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2216 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2219 case IDM_PARSECOMPLETE:
2220 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2221 ok(pvaIn == NULL, "pvaIn != NULL\n");
2222 ok(pvaOut == NULL, "pvaOut != NULL\n");
2225 ok(0, "unexpected command %d\n", nCmdID);
2229 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2230 return E_FAIL; /* TODO */
2232 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2233 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2237 CHECK_EXPECT2(Exec_Explorer_69);
2238 ok(pvaIn == NULL, "pvaIn != NULL\n");
2239 ok(pvaOut != NULL, "pvaOut == NULL\n");
2242 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2247 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2249 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2250 SET_EXPECT(SetStatusText);
2251 ok(pvaIn == NULL, "pvaIn != NULL\n");
2252 ok(pvaOut == NULL, "pvaOut != NULL\n");
2255 ok(0, "unexpected command %d\n", nCmdID);
2260 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2264 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2265 OleCommandTarget_QueryInterface,
2266 OleCommandTarget_AddRef,
2267 OleCommandTarget_Release,
2268 OleCommandTarget_QueryStatus,
2269 OleCommandTarget_Exec
2272 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2274 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2276 return QueryInterface(riid, ppv);
2279 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2280 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2281 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2283 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2284 ok(pDispParams != NULL, "pDispParams == NULL\n");
2285 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2286 ok(puArgErr != NULL, "puArgErr == NULL\n");
2287 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2288 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2289 test_readyState(NULL);
2291 switch(dispIdMember) {
2292 case DISPID_AMBIENT_USERMODE:
2293 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2294 V_VT(pVarResult) = VT_BOOL;
2295 V_BOOL(pVarResult) = VARIANT_TRUE;
2297 case DISPID_AMBIENT_DLCONTROL:
2298 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2300 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2301 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2303 case DISPID_AMBIENT_SILENT:
2304 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2305 V_VT(pVarResult) = VT_BOOL;
2306 V_BOOL(pVarResult) = VARIANT_FALSE;
2308 case DISPID_AMBIENT_USERAGENT:
2309 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2311 case DISPID_AMBIENT_PALETTE:
2312 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2316 ok(0, "unexpected dispid %d\n", dispIdMember);
2320 static IDispatchVtbl DispatchVtbl = {
2321 Dispatch_QueryInterface,
2324 Dispatch_GetTypeInfoCount,
2325 Dispatch_GetTypeInfo,
2326 Dispatch_GetIDsOfNames,
2330 static IDispatch Dispatch = { &DispatchVtbl };
2332 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2333 REFIID riid, void **ppv)
2335 return QueryInterface(riid, ppv);
2338 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2343 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2348 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2349 REFIID riid, void **ppv)
2352 * Services used by HTMLDocument:
2355 * IInternetSecurityManager
2357 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2360 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2361 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2362 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2364 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2365 * IElementBehaviorFactory
2366 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2376 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2377 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2382 return E_NOINTERFACE;
2385 static const IServiceProviderVtbl ServiceProviderVtbl = {
2386 ServiceProvider_QueryInterface,
2387 ServiceProvider_AddRef,
2388 ServiceProvider_Release,
2389 ServiceProvider_QueryService
2392 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2394 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2395 DEFINE_GUID(IID_unk2, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2396 DEFINE_GUID(IID_unk3, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2398 static HRESULT QueryInterface(REFIID riid, void **ppv)
2402 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2404 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2405 *ppv = &DocumentSite;
2406 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2407 *ppv = &DocHostUIHandler;
2408 else if(IsEqualGUID(&IID_IOleContainer, riid))
2409 *ppv = &OleContainer;
2410 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2411 *ppv = &InPlaceSiteEx;
2412 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2413 *ppv = &OleCommandTarget;
2414 else if(IsEqualGUID(&IID_IDispatch, riid))
2416 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2417 *ppv = &ServiceProvider;
2418 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2419 *ppv = ipsex ? &InPlaceSiteEx : NULL;
2420 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2421 *ppv = &OleControlSite;
2422 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2423 return E_NOINTERFACE; /* TODO */
2424 else if(IsEqualGUID(&IID_IProxyManager, riid))
2425 return E_NOINTERFACE; /* ? */
2426 else if(IsEqualGUID(&IID_unk1, riid))
2427 return E_NOINTERFACE; /* HTMLWindow2 ? */
2428 else if(IsEqualGUID(&IID_unk2, riid))
2429 return E_NOINTERFACE; /* ? */
2430 else if(IsEqualGUID(&IID_unk3, riid))
2431 return E_NOINTERFACE; /* ? */
2433 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2437 return E_NOINTERFACE;
2440 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2442 return DefWindowProc(hwnd, msg, wParam, lParam);
2445 static void _test_readyState(unsigned line, IUnknown *unk)
2447 IHTMLDocument2 *htmldoc;
2448 DISPPARAMS dispparams;
2453 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2454 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2455 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2456 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2458 static const LPCWSTR expected_state[] = {
2470 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2471 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2475 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2476 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2478 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2479 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2481 (!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n",
2482 debugstr_w(state), load_state);
2483 SysFreeString(state);
2485 dispparams.cArgs = 0;
2486 dispparams.cNamedArgs = 0;
2487 dispparams.rgdispidNamedArgs = NULL;
2488 dispparams.rgvarg = NULL;
2492 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2493 &dispparams, &out, NULL, NULL);
2494 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2496 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2497 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2499 IHTMLDocument2_Release(htmldoc);
2502 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2504 IConnectionPointContainer *tmp_container = NULL;
2505 IConnectionPoint *cp;
2509 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2510 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2514 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2515 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2516 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2518 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2519 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2521 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2522 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2523 ok(tmp_container == container, "container != tmp_container\n");
2525 IConnectionPointContainer_Release(tmp_container);
2527 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2528 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2530 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2533 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2534 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2537 IConnectionPoint_Release(cp);
2540 static void test_ConnectionPointContainer(IUnknown *unk)
2542 IConnectionPointContainer *container;
2545 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2546 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2550 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2551 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2552 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2554 IConnectionPointContainer_Release(container);
2557 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2559 IHTMLDocument2 *doc;
2560 IPersistMoniker *permon;
2561 IMoniker *mon = (void*)0xdeadbeef;
2562 BSTR doc_url = (void*)0xdeadbeef;
2565 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2566 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2570 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2571 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2573 hres = IHTMLDocument2_get_URL(doc, &doc_url);
2574 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2576 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2577 IPersistMoniker_Release(permon);
2581 BOOL exb = expect_GetDisplayName;
2582 BOOL clb = called_GetDisplayName;
2584 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2585 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2587 SET_EXPECT(GetDisplayName);
2588 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2589 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2590 CHECK_CALLED(GetDisplayName);
2591 expect_GetDisplayName = exb;
2592 called_GetDisplayName = clb;
2594 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2599 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2601 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2602 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2604 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2605 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2609 ok(hres == E_UNEXPECTED,
2610 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2611 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2612 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2615 SysFreeString(doc_url);
2616 IHTMLDocument_Release(doc);
2617 if(mon && mon != (void*)0xdeadbeef)
2618 IMoniker_Release(mon);
2621 static void test_Load(IPersistMoniker *persist)
2625 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2627 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2629 test_readyState((IUnknown*)persist);
2631 CreateBindCtx(0, &bind);
2632 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2633 (IUnknown*)&ClientSite);
2635 SET_EXPECT(GetDisplayName);
2636 if(!set_clientsite) {
2637 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2638 SET_EXPECT(GetHostInfo);
2639 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2640 SET_EXPECT(Invoke_AMBIENT_SILENT);
2641 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2642 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2643 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2644 SET_EXPECT(GetOptionKeyPath);
2645 SET_EXPECT(GetOverrideKeyPath);
2646 SET_EXPECT(GetWindow);
2647 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2648 SET_EXPECT(Exec_SETPROGRESSMAX);
2649 SET_EXPECT(Exec_SETPROGRESSPOS);
2650 SET_EXPECT(Exec_ShellDocView_37);
2652 if(!container_locked) {
2653 SET_EXPECT(GetContainer);
2654 SET_EXPECT(LockContainer);
2656 SET_EXPECT(OnChanged_READYSTATE);
2657 SET_EXPECT(Exec_ShellDocView_84);
2658 SET_EXPECT(IsSystemMoniker);
2659 SET_EXPECT(BindToStorage);
2660 SET_EXPECT(SetActiveObject);
2661 if(set_clientsite) {
2662 SET_EXPECT(Invoke_AMBIENT_SILENT);
2663 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2664 SET_EXPECT(Exec_ShellDocView_37);
2666 load_state = LD_DOLOAD;
2667 expect_LockContainer_fLock = TRUE;
2668 readystate_set_loading = TRUE;
2670 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2671 ok(hres == S_OK, "Load failed: %08x\n", hres);
2673 CHECK_CALLED(GetDisplayName);
2674 if(!set_clientsite) {
2675 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2676 CHECK_CALLED(GetHostInfo);
2677 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2678 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2679 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2680 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2681 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2682 CHECK_CALLED(GetOptionKeyPath);
2683 CHECK_CALLED(GetOverrideKeyPath);
2684 CHECK_CALLED(GetWindow);
2685 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2686 CHECK_CALLED(Exec_SETPROGRESSMAX);
2687 CHECK_CALLED(Exec_SETPROGRESSPOS);
2688 CHECK_CALLED(Exec_ShellDocView_37);
2690 if(!container_locked) {
2691 CHECK_CALLED(GetContainer);
2692 CHECK_CALLED(LockContainer);
2693 container_locked = TRUE;
2695 CHECK_CALLED(OnChanged_READYSTATE);
2696 SET_CALLED(IsSystemMoniker); /* IE7 */
2697 SET_CALLED(Exec_ShellDocView_84);
2698 CHECK_CALLED(BindToStorage);
2699 SET_CALLED(SetActiveObject); /* FIXME */
2700 if(set_clientsite) {
2701 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2702 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2703 CHECK_CALLED(Exec_ShellDocView_37);
2706 set_clientsite = container_locked = TRUE;
2708 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2710 IBindCtx_Release(bind);
2712 test_readyState((IUnknown*)persist);
2715 static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
2720 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2721 ok(hwnd != NULL, "Could not find hidden window\n");
2723 test_readyState(NULL);
2726 SET_EXPECT(Exec_SETPROGRESSMAX);
2727 if(!load_from_stream)
2728 SET_EXPECT(GetHostInfo);
2730 SET_EXPECT(SetStatusText);
2731 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2732 SET_EXPECT(GetDropTarget);
2734 SET_EXPECT(Exec_ShellDocView_84);
2736 SET_EXPECT(CreateInstance);
2738 SET_EXPECT(LockRequest);
2739 SET_EXPECT(Terminate);
2740 SET_EXPECT(Protocol_Read);
2741 SET_EXPECT(UnlockRequest);
2743 SET_EXPECT(Exec_Explorer_69);
2744 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
2745 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
2746 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
2747 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
2748 SET_EXPECT(OnChanged_1005);
2749 SET_EXPECT(OnChanged_READYSTATE);
2750 SET_EXPECT(Exec_SETPROGRESSPOS);
2751 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2752 SET_EXPECT(Exec_ShellDocView_103);
2753 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2754 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2755 SET_EXPECT(SetStatusText);
2756 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2758 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2759 TranslateMessage(&msg);
2760 DispatchMessage(&msg);
2764 CHECK_CALLED(Exec_SETPROGRESSMAX);
2765 if(!load_from_stream)
2766 CHECK_CALLED(GetHostInfo);
2768 CHECK_CALLED(SetStatusText);
2769 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2770 CHECK_CALLED(GetDropTarget);
2772 SET_CALLED(Exec_ShellDocView_84);
2774 if(called_CreateInstance) {
2775 CHECK_CALLED(CreateInstance);
2776 CHECK_CALLED(Start);
2777 CHECK_CALLED(LockRequest);
2778 CHECK_CALLED(Terminate);
2779 CHECK_CALLED(Protocol_Read);
2780 CHECK_CALLED(UnlockRequest);
2782 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2784 SET_CALLED(Exec_ShellDocView_84);
2785 SET_CALLED(CreateInstance);
2787 SET_CALLED(LockRequest);
2788 SET_CALLED(Terminate);
2789 SET_CALLED(Protocol_Read);
2790 SET_CALLED(UnlockRequest);
2795 SET_CALLED(Exec_Explorer_69);
2796 SET_CALLED(EnableModeless_TRUE); /* IE7 */
2797 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
2798 SET_CALLED(EnableModeless_FALSE); /* IE7 */
2799 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
2800 CHECK_CALLED(OnChanged_1005);
2801 CHECK_CALLED(OnChanged_READYSTATE);
2802 CHECK_CALLED(Exec_SETPROGRESSPOS);
2803 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2804 SET_CALLED(Exec_ShellDocView_103);
2805 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2806 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2807 SET_CALLED(SetStatusText);
2809 load_state = LD_COMPLETE;
2811 test_readyState(NULL);
2814 static void test_Persist(IUnknown *unk)
2816 IPersistMoniker *persist_mon;
2817 IPersistFile *persist_file;
2821 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2822 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2823 if(SUCCEEDED(hres)) {
2824 hres = IPersist_GetClassID(persist_file, NULL);
2825 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2827 hres = IPersist_GetClassID(persist_file, &guid);
2828 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2829 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2831 IPersist_Release(persist_file);
2834 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2835 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2836 if(SUCCEEDED(hres)) {
2837 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2838 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2840 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2841 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2842 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2844 if(load_state == LD_DOLOAD)
2845 test_Load(persist_mon);
2847 test_readyState(unk);
2849 IPersistMoniker_Release(persist_mon);
2853 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2855 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2856 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2857 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2858 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2859 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2860 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2861 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2862 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2863 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2864 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2865 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2866 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2867 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2868 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2869 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2870 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2871 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2872 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2873 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2874 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2876 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2877 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2879 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2881 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2883 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2884 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2886 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2887 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2889 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2891 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2892 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2895 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2896 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2898 IOleCommandTarget *cmdtrg;
2899 OLECMD olecmd = {cmdid, 0};
2902 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2903 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2907 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2908 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2910 IOleCommandTarget_Release(cmdtrg);
2912 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2913 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2916 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2921 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2922 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2923 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
2924 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2925 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2926 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2927 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2928 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2929 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2930 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2931 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2932 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2933 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2934 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2935 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2936 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
2939 static void test_OleCommandTarget(IUnknown *unk)
2941 IOleCommandTarget *cmdtrg;
2942 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2946 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2947 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2951 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2952 cmds[i].cmdID = i+1;
2953 cmds[i].cmdf = 0xf0f0;
2956 SET_EXPECT(QueryStatus_OPEN);
2957 SET_EXPECT(QueryStatus_NEW);
2958 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2959 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2960 CHECK_CALLED(QueryStatus_OPEN);
2961 CHECK_CALLED(QueryStatus_NEW);
2963 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2964 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2965 if(i+1 == OLECMDID_FIND)
2967 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2968 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2971 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
2972 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
2974 IOleCommandTarget_Release(cmdtrg);
2977 static void test_OleCommandTarget_fail(IUnknown *unk)
2979 IOleCommandTarget *cmdtrg;
2984 {OLECMDID_OPEN, 0xf0f0},
2985 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2988 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2989 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2993 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2994 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2996 SET_EXPECT(QueryStatus_OPEN);
2997 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2998 CHECK_CALLED(QueryStatus_OPEN);
3000 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3001 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3002 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3003 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3004 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3005 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3006 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3008 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3009 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3010 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3012 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3013 if(!expect_cmds[i]) {
3014 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3015 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3016 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3017 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3021 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3022 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3023 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3024 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3026 IOleCommandTarget_Release(cmdtrg);
3029 static void test_exec_onunload(IUnknown *unk)
3031 IOleCommandTarget *cmdtrg;
3035 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3036 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3040 memset(&var, 0x0a, sizeof(var));
3041 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3042 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3043 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3044 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3045 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3047 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3048 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3049 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3051 IOleCommandTarget_Release(cmdtrg);
3054 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3056 IOleCommandTarget *cmdtrg;
3059 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3060 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3067 load_state = LD_DOLOAD;
3070 SET_EXPECT(GetClassID);
3071 SET_EXPECT(SetStatusText);
3072 SET_EXPECT(Exec_ShellDocView_37);
3073 SET_EXPECT(GetHostInfo);
3075 SET_EXPECT(GetDisplayName);
3076 SET_EXPECT(Invoke_AMBIENT_SILENT);
3077 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3078 SET_EXPECT(OnChanged_READYSTATE);
3079 SET_EXPECT(IsSystemMoniker);
3080 SET_EXPECT(Exec_ShellDocView_84);
3082 SET_EXPECT(BindToStorage);
3083 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3086 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3088 expect_status_text = NULL;
3089 readystate_set_loading = TRUE;
3091 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3092 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3093 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3096 CHECK_CALLED(GetClassID);
3097 CHECK_CALLED(SetStatusText);
3098 CHECK_CALLED(Exec_ShellDocView_37);
3099 CHECK_CALLED(GetHostInfo);
3101 CHECK_CALLED(GetDisplayName);
3102 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3103 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3104 CHECK_CALLED(OnChanged_READYSTATE);
3105 SET_CALLED(IsSystemMoniker); /* IE7 */
3106 SET_CALLED(Exec_ShellDocView_84);
3108 CHECK_CALLED(BindToStorage);
3109 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3110 CHECK_CALLED(HideUI);
3111 CHECK_CALLED(ShowUI);
3112 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3114 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3116 IOleCommandTarget_Release(cmdtrg);
3118 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3119 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3120 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3123 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3125 IOleCommandTarget *cmdtrg;
3126 VARIANT *in = NULL, _in, *out = NULL, _out;
3129 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3130 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3137 V_BSTR(in) = SysAllocString(name);
3143 V_I4(out) = 0xdeadbeef;
3146 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3148 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3153 if(out && !nogecko) {
3154 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3155 if(V_VT(out) == VT_BSTR) {
3157 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3158 "unexpected fontname \"%s\"\n", debugstr_w(name));
3160 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3165 IOleCommandTarget_Release(cmdtrg);
3168 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3170 IOleCommandTarget *cmdtrg;
3173 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3174 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3178 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3179 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3180 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3182 IOleCommandTarget_Release(cmdtrg);
3185 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3187 IPersistStreamInit *perinit;
3188 IPersistMoniker *permon;
3189 IPersistFile *perfile;
3192 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3193 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3194 if(SUCCEEDED(hres)) {
3195 hres = IPersistStreamInit_IsDirty(perinit);
3196 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3197 IPersistStreamInit_Release(perinit);
3200 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3201 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3202 if(SUCCEEDED(hres)) {
3203 hres = IPersistMoniker_IsDirty(permon);
3204 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3205 IPersistMoniker_Release(permon);
3208 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3209 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3210 if(SUCCEEDED(hres)) {
3211 hres = IPersistFile_IsDirty(perfile);
3212 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3213 IPersistFile_Release(perfile);
3217 static HWND create_container_window(void)
3219 static const WCHAR wszHTMLDocumentTest[] =
3220 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3221 static WNDCLASSEXW wndclass = {
3222 sizeof(WNDCLASSEXW),
3225 0, 0, NULL, NULL, NULL, NULL, NULL,
3226 wszHTMLDocumentTest,
3230 RegisterClassExW(&wndclass);
3231 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3232 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3233 515, 530, NULL, NULL, NULL, NULL);
3236 static void test_DoVerb(IOleObject *oleobj)
3238 RECT rect = {0,0,500,500};
3241 if(!container_locked) {
3242 SET_EXPECT(GetContainer);
3243 SET_EXPECT(LockContainer);
3245 SET_EXPECT(ActivateMe);
3246 expect_LockContainer_fLock = TRUE;
3248 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3249 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3251 if(!container_locked) {
3252 CHECK_CALLED(GetContainer);
3253 CHECK_CALLED(LockContainer);
3254 container_locked = TRUE;
3256 CHECK_CALLED(ActivateMe);
3259 #define CLIENTSITE_EXPECTPATH 0x00000001
3260 #define CLIENTSITE_SETNULL 0x00000002
3261 #define CLIENTSITE_DONTSET 0x00000004
3263 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3265 IOleClientSite *clientsite;
3268 if(flags & CLIENTSITE_SETNULL) {
3269 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3270 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3272 hres = IOleObject_SetClientSite(oleobj, NULL);
3273 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3275 set_clientsite = FALSE;
3278 if(flags & CLIENTSITE_DONTSET)
3281 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3282 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3283 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3284 clientsite, set_clientsite ? &ClientSite : NULL);
3286 if(!set_clientsite) {
3287 SET_EXPECT(GetHostInfo);
3288 if(flags & CLIENTSITE_EXPECTPATH) {
3289 SET_EXPECT(GetOptionKeyPath);
3290 SET_EXPECT(GetOverrideKeyPath);
3292 SET_EXPECT(GetWindow);
3293 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3294 SET_EXPECT(Exec_SETPROGRESSMAX);
3295 SET_EXPECT(Exec_SETPROGRESSPOS);
3296 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3297 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3298 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3299 SET_EXPECT(Invoke_AMBIENT_SILENT);
3300 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3301 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3303 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3304 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3306 CHECK_CALLED(GetHostInfo);
3307 if(flags & CLIENTSITE_EXPECTPATH) {
3308 CHECK_CALLED(GetOptionKeyPath);
3309 CHECK_CALLED(GetOverrideKeyPath);
3311 CHECK_CALLED(GetWindow);
3312 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3313 CHECK_CALLED(Exec_SETPROGRESSMAX);
3314 CHECK_CALLED(Exec_SETPROGRESSPOS);
3315 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3316 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3317 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3318 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3319 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3320 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3322 set_clientsite = TRUE;
3325 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3326 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3328 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3329 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3330 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3333 static void test_OnAmbientPropertyChange(IUnknown *unk)
3335 IOleControl *control = NULL;
3338 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3339 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3343 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3344 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3345 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3346 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3348 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3349 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3350 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3351 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3353 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3354 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3355 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3356 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3357 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3358 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3360 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3361 SET_EXPECT(Invoke_AMBIENT_SILENT);
3362 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3363 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3364 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3365 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3367 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3368 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3369 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3370 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3372 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3373 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3374 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3375 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3377 IOleControl_Release(control);
3382 static void test_OnAmbientPropertyChange2(IUnknown *unk)
3384 IOleControl *control = NULL;
3387 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3388 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3392 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3393 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3395 IOleControl_Release(control);
3398 static void test_Close(IUnknown *unk, BOOL set_client)
3400 IOleObject *oleobj = NULL;
3403 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3404 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3408 SET_EXPECT(GetContainer);
3409 SET_EXPECT(LockContainer);
3410 expect_LockContainer_fLock = FALSE;
3411 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3412 ok(hres == S_OK, "Close failed: %08x\n", hres);
3413 CHECK_CALLED(GetContainer);
3414 CHECK_CALLED(LockContainer);
3415 container_locked = FALSE;
3418 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3420 IOleObject_Release(oleobj);
3423 static void test_OnFrameWindowActivate(IUnknown *unk)
3425 IOleInPlaceActiveObject *inplaceact;
3428 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3429 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3433 if(set_clientsite) {
3434 expect_OnFrameWindowActivate_fActivate = TRUE;
3435 SET_EXPECT(OnFrameWindowActivate);
3436 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3437 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3438 CHECK_CALLED(OnFrameWindowActivate);
3440 SET_EXPECT(OnFrameWindowActivate);
3441 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3442 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3443 CHECK_CALLED(OnFrameWindowActivate);
3445 expect_OnFrameWindowActivate_fActivate = FALSE;
3446 SET_EXPECT(OnFrameWindowActivate);
3447 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3448 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3449 CHECK_CALLED(OnFrameWindowActivate);
3451 expect_OnFrameWindowActivate_fActivate = TRUE;
3452 SET_EXPECT(OnFrameWindowActivate);
3453 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3454 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3455 CHECK_CALLED(OnFrameWindowActivate);
3457 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3458 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3460 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3461 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3464 IOleInPlaceActiveObject_Release(inplaceact);
3467 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3469 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3472 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3473 (void**)&windowlessobj);
3474 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3479 SET_EXPECT(OnFocus_FALSE);
3481 SET_EXPECT(OnInPlaceDeactivateEx);
3483 SET_EXPECT(OnInPlaceDeactivate);
3485 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3486 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3488 CHECK_CALLED(OnFocus_FALSE);
3490 CHECK_CALLED(OnInPlaceDeactivateEx);
3492 CHECK_CALLED(OnInPlaceDeactivate);
3495 IOleInPlaceObjectWindowless_Release(windowlessobj);
3498 static void test_Activate(IUnknown *unk, DWORD flags)
3500 IOleObject *oleobj = NULL;
3501 IOleDocumentView *docview;
3508 IOleDocumentView_Release(view);
3511 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3512 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3514 hres = IOleObject_GetUserClassID(oleobj, NULL);
3515 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3517 hres = IOleObject_GetUserClassID(oleobj, &guid);
3518 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3519 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3521 test_OnFrameWindowActivate(unk);
3523 test_ClientSite(oleobj, flags);
3524 test_InPlaceDeactivate(unk, FALSE);
3525 test_DoVerb(oleobj);
3527 if(call_UIActivate == CallUIActivate_AfterShow) {
3528 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3529 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3531 SET_EXPECT(OnFocus_TRUE);
3532 SET_EXPECT(SetActiveObject);
3534 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3535 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3536 expect_status_text = NULL;
3538 hres = IOleDocumentView_UIActivate(docview, TRUE);
3539 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3541 CHECK_CALLED(OnFocus_TRUE);
3542 CHECK_CALLED(SetActiveObject);
3543 CHECK_CALLED(ShowUI);
3544 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3545 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3547 IOleDocumentView_Release(docview);
3550 IOleObject_Release(oleobj);
3552 test_OnFrameWindowActivate(unk);
3555 static void test_Window(IUnknown *unk, BOOL expect_success)
3557 IOleInPlaceActiveObject *activeobject = NULL;
3561 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3562 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3566 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3568 if(expect_success) {
3569 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3570 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3572 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3573 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3576 IOleInPlaceActiveObject_Release(activeobject);
3579 static void test_CloseView(void)
3581 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3587 hres = IOleDocumentView_Show(view, FALSE);
3588 ok(hres == S_OK, "Show failed: %08x\n", hres);
3590 hres = IOleDocumentView_CloseView(view, 0);
3591 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3593 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3594 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3596 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3597 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3598 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3601 static void test_UIDeactivate(void)
3605 if(call_UIActivate == CallUIActivate_AfterShow) {
3606 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3608 if(call_UIActivate != CallUIActivate_None) {
3609 SET_EXPECT(SetActiveObject_null);
3611 SET_EXPECT(OnUIDeactivate);
3614 hres = IOleDocumentView_UIActivate(view, FALSE);
3615 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3617 if(call_UIActivate != CallUIActivate_None) {
3618 CHECK_CALLED(SetActiveObject_null);
3619 CHECK_CALLED(HideUI);
3620 CHECK_CALLED(OnUIDeactivate);
3622 if(call_UIActivate == CallUIActivate_AfterShow) {
3623 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3627 static void test_Hide(void)
3634 hres = IOleDocumentView_Show(view, FALSE);
3635 ok(hres == S_OK, "Show failed: %08x\n", hres);
3638 static HRESULT create_document(IUnknown **unk)
3640 IHTMLDocument5 *doc5;
3643 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3644 &IID_IUnknown, (void**)unk);
3645 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3649 hres = IUnknown_QueryInterface(*unk, &IID_IHTMLDocument5, (void**)&doc5);
3650 if(SUCCEEDED(hres)) {
3651 IHTMLDocument5_Release(doc5);
3653 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
3654 IUnknown_Release(*unk);
3660 static void test_Navigate(IUnknown *unk)
3662 IHlinkTarget *hlink;
3665 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3666 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3668 SET_EXPECT(ActivateMe);
3669 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3670 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3671 CHECK_CALLED(ActivateMe);
3673 IHlinkTarget_Release(hlink);
3676 static void test_external(IUnknown *unk, BOOL initialized)
3678 IDispatch *external;
3679 IHTMLDocument2 *doc;
3680 IHTMLWindow2 *htmlwin;
3683 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3684 ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres);
3686 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
3687 IHTMLDocument2_Release(doc);
3688 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3691 SET_EXPECT(GetExternal);
3692 external = (void*)0xdeadbeef;
3693 hres = IHTMLWindow2_get_external(htmlwin, &external);
3695 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
3696 CHECK_CALLED(GetExternal);
3697 ok(external != NULL, "external == NULL\n");
3699 ok(hres == S_OK, "get_external failed: %08x\n", hres);
3700 ok(external == NULL, "external != NULL\n");
3703 IHTMLWindow2_Release(htmlwin);
3706 static void test_StreamLoad(IUnknown *unk)
3708 IPersistStreamInit *init;
3711 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3712 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3716 SET_EXPECT(Invoke_AMBIENT_SILENT);
3717 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3718 SET_EXPECT(Exec_ShellDocView_37);
3719 SET_EXPECT(OnChanged_READYSTATE);
3721 readystate_set_loading = TRUE;
3723 hres = IPersistStreamInit_Load(init, &Stream);
3724 ok(hres == S_OK, "Load failed: %08x\n", hres);
3726 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3727 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3728 CHECK_CALLED(Exec_ShellDocView_37);
3729 CHECK_CALLED(OnChanged_READYSTATE);
3732 test_timer(EXPECT_SETTITLE);
3733 test_GetCurMoniker(unk, NULL, about_blank_url);
3735 IPersistStreamInit_Release(init);
3738 static void test_QueryInterface(IUnknown *unk)
3743 static const IID IID_UndocumentedScriptIface =
3744 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
3746 qi = (void*)0xdeadbeef;
3747 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi);
3748 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3749 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
3751 qi = (void*)0xdeadbeef;
3752 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi);
3753 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3754 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3756 qi = (void*)0xdeadbeef;
3757 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi);
3758 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3759 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3761 qi = (void*)0xdeadbeef;
3762 hres = IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void**)&qi);
3763 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3764 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3766 qi = (void*)0xdeadbeef;
3767 hres = IUnknown_QueryInterface(unk, &IID_UndocumentedScriptIface, (void**)&qi);
3768 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3769 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3771 qi = (void*)0xdeadbeef;
3772 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&qi);
3773 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3774 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3777 static void init_test(enum load_state_t ls) {
3779 hwnd = last_hwnd = NULL;
3780 set_clientsite = FALSE;
3781 load_from_stream = FALSE;
3782 call_UIActivate = CallUIActivate_None;
3790 static void test_HTMLDocument(BOOL do_load)
3796 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
3798 init_test(do_load ? LD_DOLOAD : LD_NO);
3800 hres = create_document(&unk);
3805 test_QueryInterface(unk);
3806 test_IsDirty(unk, S_FALSE);
3807 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3808 test_external(unk, FALSE);
3809 test_ConnectionPointContainer(unk);
3810 test_GetCurMoniker(unk, NULL, NULL);
3813 test_OnAmbientPropertyChange2(unk);
3815 test_Activate(unk, CLIENTSITE_EXPECTPATH);
3818 test_download(FALSE, TRUE, TRUE);
3819 test_GetCurMoniker(unk, &Moniker, NULL);
3822 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3823 test_OleCommandTarget_fail(unk);
3824 test_OleCommandTarget(unk);
3825 test_OnAmbientPropertyChange(unk);
3826 test_Window(unk, TRUE);
3827 test_external(unk, TRUE);
3829 test_UIDeactivate();
3830 test_OleCommandTarget(unk);
3831 test_Window(unk, TRUE);
3832 test_InPlaceDeactivate(unk, TRUE);
3834 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
3835 * MSHTML. It doesn't with Wine. */
3837 test_Window(unk, FALSE);
3839 test_InPlaceDeactivate(unk, FALSE);
3841 test_Close(unk, FALSE);
3843 /* Activate HTMLDocument again */
3844 test_Activate(unk, CLIENTSITE_SETNULL);
3845 test_Window(unk, TRUE);
3846 test_OleCommandTarget(unk);
3847 test_UIDeactivate();
3848 test_InPlaceDeactivate(unk, TRUE);
3849 test_Close(unk, FALSE);
3851 /* Activate HTMLDocument again, this time without UIActivate */
3852 call_UIActivate = CallUIActivate_None;
3853 test_Activate(unk, CLIENTSITE_SETNULL);
3854 test_Window(unk, TRUE);
3856 test_UIDeactivate();
3857 test_InPlaceDeactivate(unk, TRUE);
3860 test_Close(unk, TRUE);
3861 test_OnAmbientPropertyChange2(unk);
3862 test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3865 /* Activate HTMLDocument again, calling UIActivate after showing the window */
3866 call_UIActivate = CallUIActivate_AfterShow;
3867 test_Activate(unk, 0);
3868 test_Window(unk, TRUE);
3869 test_OleCommandTarget(unk);
3870 test_UIDeactivate();
3871 test_InPlaceDeactivate(unk, TRUE);
3872 test_Close(unk, FALSE);
3873 call_UIActivate = CallUIActivate_None;
3877 IOleDocumentView_Release(view);
3880 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3882 ref = IUnknown_Release(unk);
3883 ok(ref == 0, "ref=%d, expected 0\n", ref);
3885 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3888 static void test_HTMLDocument_hlink(void)
3894 trace("Testing HTMLDocument (hlink)...\n");
3896 init_test(LD_DOLOAD);
3899 hres = create_document(&unk);
3904 test_ConnectionPointContainer(unk);
3905 test_GetCurMoniker(unk, NULL, NULL);
3909 IUnknown_Release(unk);
3913 test_download(FALSE, TRUE, TRUE);
3915 test_IsDirty(unk, S_FALSE);
3916 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3918 test_exec_onunload(unk);
3919 test_Window(unk, TRUE);
3920 test_InPlaceDeactivate(unk, TRUE);
3921 test_Close(unk, FALSE);
3922 test_IsDirty(unk, S_FALSE);
3923 test_GetCurMoniker(unk, &Moniker, NULL);
3926 IOleDocumentView_Release(view);
3929 ref = IUnknown_Release(unk);
3930 ok(ref == 0, "ref=%d, expected 0\n", ref);
3933 static void test_HTMLDocument_StreamLoad(void)
3940 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3942 init_test(LD_DOLOAD);
3943 load_from_stream = TRUE;
3945 hres = create_document(&unk);
3950 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3951 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3953 test_readyState(unk);
3954 test_IsDirty(unk, S_FALSE);
3955 test_ConnectionPointContainer(unk);
3956 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3957 test_DoVerb(oleobj);
3958 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3960 IOleObject_Release(oleobj);
3962 test_GetCurMoniker(unk, NULL, NULL);
3963 test_StreamLoad(unk);
3964 test_download(TRUE, FALSE, TRUE);
3965 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3967 test_UIDeactivate();
3968 test_InPlaceDeactivate(unk, TRUE);
3969 test_Close(unk, FALSE);
3970 test_IsDirty(unk, S_FALSE);
3973 IOleDocumentView_Release(view);
3978 ref = IUnknown_Release(unk);
3979 ok(ref == 0, "ref=%d, expected 0\n", ref);
3982 static void test_edit_uiactivate(IOleObject *oleobj)
3984 IOleDocumentView *docview;
3987 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3988 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3990 SET_EXPECT(OnFocus_TRUE);
3991 SET_EXPECT(SetActiveObject);
3993 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3994 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3995 expect_status_text = NULL;
3997 hres = IOleDocumentView_UIActivate(docview, TRUE);
3998 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4000 CHECK_CALLED(OnFocus_TRUE);
4001 CHECK_CALLED(SetActiveObject);
4002 CHECK_CALLED(ShowUI);
4003 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4004 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4006 IOleDocumentView_Release(docview);
4009 static void test_editing_mode(BOOL do_load)
4016 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
4018 init_test(do_load ? LD_DOLOAD : LD_NO);
4019 call_UIActivate = CallUIActivate_AfterShow;
4021 hres = create_document(&unk);
4026 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
4027 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4029 test_readyState(unk);
4030 test_ConnectionPointContainer(unk);
4031 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4032 test_DoVerb(oleobj);
4033 test_edit_uiactivate(oleobj);
4035 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4038 stream_read = protocol_read = 0;
4039 test_exec_editmode(unk, do_load);
4040 test_UIDeactivate();
4041 call_UIActivate = CallUIActivate_None;
4042 IOleObject_Release(oleobj);
4044 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4045 test_download(TRUE, do_load, do_load);
4047 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
4048 test_timer(EXPECT_UPDATEUI);
4049 SET_CALLED(SetStatusText);
4051 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4054 test_exec_fontname(unk, NULL, wszTimesNewRoman);
4055 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4056 test_timer(EXPECT_UPDATEUI);
4057 test_exec_fontname(unk, NULL, wszArial);
4059 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4060 test_timer(EXPECT_UPDATEUI);
4062 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4063 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4065 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4066 test_timer(EXPECT_UPDATEUI);
4067 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4068 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4070 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4071 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4073 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4074 test_timer(EXPECT_UPDATEUI);
4075 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4076 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4079 test_UIDeactivate();
4080 test_InPlaceDeactivate(unk, TRUE);
4081 test_Close(unk, FALSE);
4084 IOleDocumentView_Release(view);
4088 ref = IUnknown_Release(unk);
4089 ok(ref == 0, "ref=%d, expected 0\n", ref);
4092 static void register_protocol(void)
4094 IInternetSession *session;
4097 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
4099 hres = CoInternetGetSession(0, &session, 0);
4100 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
4102 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
4103 wsz_winetest, 0, NULL, 0);
4104 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
4106 IInternetSession_Release(session);
4109 static void gecko_installer_workaround(BOOL disable)
4114 static BOOL has_url = FALSE;
4115 static char url[2048];
4117 if(!disable && !has_url)
4120 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4121 if(res != ERROR_SUCCESS)
4125 DWORD type, size = sizeof(url);
4127 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4128 if(res == ERROR_SUCCESS && type == REG_SZ)
4131 RegDeleteValue(hkey, "GeckoUrl");
4133 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4139 static void test_HTMLDoc_ISupportErrorInfo(void)
4143 ISupportErrorInfo *sinfo;
4146 hres = create_document(&unk);
4150 hres = IUnknown_QueryInterface(unk, &IID_ISupportErrorInfo, (void**)&sinfo);
4151 ok(hres == S_OK, "got %x\n", hres);
4152 ok(sinfo != NULL, "got %p\n", sinfo);
4155 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
4156 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
4157 IUnknown_Release(sinfo);
4160 ref = IUnknown_Release(unk);
4161 ok(ref == 0, "ref=%d, expected 0\n", ref);
4164 static void test_IPersistHistory(void)
4169 IPersistHistory *phist;
4171 hres = create_document(&unk);
4175 hres = IUnknown_QueryInterface(unk, &IID_IPersistHistory, (void**)&phist);
4176 todo_wine ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
4178 IPersistHistory_Release(phist);
4180 ref = IUnknown_Release(unk);
4181 ok(ref == 0, "ref=%d, expected 0\n", ref);
4186 gecko_installer_workaround(TRUE);
4189 container_hwnd = create_container_window();
4190 register_protocol();
4192 test_HTMLDocument_hlink();
4194 test_HTMLDocument(FALSE);
4195 test_HTMLDocument(TRUE);
4196 test_HTMLDocument_StreamLoad();
4197 test_editing_mode(FALSE);
4198 test_editing_mode(TRUE);
4200 test_HTMLDoc_ISupportErrorInfo();
4201 test_IPersistHistory();
4203 DestroyWindow(container_hwnd);
4206 gecko_installer_workaround(FALSE);