2 * Copyright 2005-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
40 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
45 #define SET_EXPECT(func) \
46 expect_ ## func = TRUE
48 #define SET_CALLED(func) \
49 called_ ## func = TRUE
51 #define CHECK_EXPECT2(func) \
53 ok(expect_ ##func, "unexpected call " #func "\n"); \
54 called_ ## func = TRUE; \
57 #define CHECK_EXPECT(func) \
59 CHECK_EXPECT2(func); \
60 expect_ ## func = FALSE; \
63 #define CHECK_CALLED(func) \
65 ok(called_ ## func, "expected " #func "\n"); \
66 expect_ ## func = called_ ## func = FALSE; \
69 static IOleDocumentView *view = NULL;
70 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
72 DEFINE_EXPECT(LockContainer);
73 DEFINE_EXPECT(SetActiveObject);
74 DEFINE_EXPECT(SetActiveObject_null);
75 DEFINE_EXPECT(GetWindow);
76 DEFINE_EXPECT(CanInPlaceActivate);
77 DEFINE_EXPECT(OnInPlaceActivate);
78 DEFINE_EXPECT(OnInPlaceActivateEx);
79 DEFINE_EXPECT(OnUIActivate);
80 DEFINE_EXPECT(GetWindowContext);
81 DEFINE_EXPECT(OnUIDeactivate);
82 DEFINE_EXPECT(OnInPlaceDeactivate);
83 DEFINE_EXPECT(OnInPlaceDeactivateEx);
84 DEFINE_EXPECT(GetContainer);
85 DEFINE_EXPECT(ShowUI);
86 DEFINE_EXPECT(ActivateMe);
87 DEFINE_EXPECT(GetHostInfo);
88 DEFINE_EXPECT(HideUI);
89 DEFINE_EXPECT(GetOptionKeyPath);
90 DEFINE_EXPECT(GetOverrideKeyPath);
91 DEFINE_EXPECT(SetStatusText);
92 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
93 DEFINE_EXPECT(QueryStatus_OPEN);
94 DEFINE_EXPECT(QueryStatus_NEW);
95 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
96 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
97 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
98 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
99 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
100 DEFINE_EXPECT(Exec_ShellDocView_37);
101 DEFINE_EXPECT(Exec_ShellDocView_84);
102 DEFINE_EXPECT(Exec_ShellDocView_103);
103 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
104 DEFINE_EXPECT(Exec_SETTITLE);
105 DEFINE_EXPECT(Exec_HTTPEQUIV);
106 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
107 DEFINE_EXPECT(Exec_Explorer_69);
108 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
109 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
110 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
111 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
112 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
113 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
114 DEFINE_EXPECT(GetDropTarget);
115 DEFINE_EXPECT(UpdateUI);
116 DEFINE_EXPECT(Navigate);
117 DEFINE_EXPECT(OnFrameWindowActivate);
118 DEFINE_EXPECT(OnChanged_READYSTATE);
119 DEFINE_EXPECT(OnChanged_1005);
120 DEFINE_EXPECT(GetDisplayName);
121 DEFINE_EXPECT(BindToStorage);
122 DEFINE_EXPECT(IsSystemMoniker);
123 DEFINE_EXPECT(GetBindResult);
124 DEFINE_EXPECT(GetClassID);
125 DEFINE_EXPECT(Abort);
127 DEFINE_EXPECT(CreateInstance);
128 DEFINE_EXPECT(Start);
129 DEFINE_EXPECT(Terminate);
130 DEFINE_EXPECT(Protocol_Read);
131 DEFINE_EXPECT(LockRequest);
132 DEFINE_EXPECT(UnlockRequest);
133 DEFINE_EXPECT(OnFocus_TRUE);
134 DEFINE_EXPECT(OnFocus_FALSE);
135 DEFINE_EXPECT(RequestUIActivate);
136 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
137 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
138 DEFINE_EXPECT(GetExternal);
140 static IUnknown *doc_unk;
141 static BOOL expect_LockContainer_fLock;
142 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
144 static BOOL set_clientsite = FALSE, container_locked = FALSE;
145 static BOOL readystate_set_loading = FALSE, load_from_stream;
146 static BOOL editmode = FALSE;
147 static int stream_read, protocol_read;
148 static enum load_state_t {
157 static LPCOLESTR expect_status_text = NULL;
159 static const char html_page[] =
161 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
165 static const char css_data[] = "body {color: red}";
167 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
168 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
170 static HRESULT QueryInterface(REFIID riid, void **ppv);
171 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
172 static BOOL nogecko = FALSE;
174 #define test_readyState(u) _test_readyState(__LINE__,u)
175 static void _test_readyState(unsigned,IUnknown*);
177 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
179 static const WCHAR wszTimesNewRoman[] =
180 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
181 static const WCHAR wszArial[] =
182 {'A','r','i','a','l',0};
184 static const char *debugstr_guid(REFIID riid)
188 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
189 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
190 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
191 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
196 static const char *debugstr_w(LPCWSTR str)
198 static char buf[1024];
203 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
207 #define EXPECT_UPDATEUI 1
208 #define EXPECT_SETTITLE 2
210 static void test_timer(DWORD flags)
212 BOOL *b = &called_Exec_SETTITLE;
215 if(flags & EXPECT_UPDATEUI) {
216 SET_EXPECT(UpdateUI);
217 SET_EXPECT(Exec_UPDATECOMMANDS);
218 b = &called_UpdateUI;
220 if(flags & EXPECT_SETTITLE)
221 SET_EXPECT(Exec_SETTITLE);
223 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
224 TranslateMessage(&msg);
225 DispatchMessage(&msg);
228 if(flags & EXPECT_UPDATEUI) {
229 CHECK_CALLED(UpdateUI);
230 CHECK_CALLED(Exec_UPDATECOMMANDS);
232 if(flags & EXPECT_SETTITLE)
233 CHECK_CALLED(Exec_SETTITLE);
236 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
238 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
242 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
247 if(IsEqualGUID(&IID_IProxyManager, riid))
248 return E_NOINTERFACE; /* TODO */
249 if(IsEqualGUID(&IID_IDispatchEx, riid))
250 return E_NOINTERFACE; /* TODO */
251 if(IsEqualGUID(&IID_External_unk, riid))
252 return E_NOINTERFACE; /* TODO */
254 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
255 return E_NOINTERFACE;
258 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
263 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
268 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
270 ok(0, "unexpected call\n");
274 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
277 ok(0, "unexpected call\n");
281 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
282 UINT cNames, LCID lcid, DISPID *rgDispId)
284 ok(0, "unexpected call\n");
288 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
289 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
290 EXCEPINFO *pExcepInfo, UINT *puArgErr)
292 ok(0, "unexpected call\n");
296 static const IDispatchVtbl ExternalVtbl = {
297 External_QueryInterface,
300 Dispatch_GetTypeInfoCount,
301 Dispatch_GetTypeInfo,
302 Dispatch_GetIDsOfNames,
306 static IDispatch External = { &ExternalVtbl };
308 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
310 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
316 return E_NOINTERFACE;
319 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
324 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
329 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
330 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
331 DWORD grfPI, DWORD dwReserved)
337 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
338 static const WCHAR empty_str = {0};
342 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
343 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
344 ok(!grfPI, "grfPI = %x\n", grfPI);
345 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
347 memset(&bindinfo, 0, sizeof(bindinfo));
348 bindinfo.cbSize = sizeof(bindinfo);
349 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
350 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
351 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
352 "bindf = %x\n", bindf);
354 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
355 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
356 /* TODO: test stgmedData */
357 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
358 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
359 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
360 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
361 ok(bindinfo.dwOptions == 0x80000 ||
362 bindinfo.dwOptions == 0x4080000, /* win2k3 */
363 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
364 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
365 /* TODO: test dwCodePage */
366 /* TODO: test securityAttributes */
367 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
368 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
369 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
371 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
372 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
373 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
375 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
376 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
378 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
380 hres = IInternetProtocolSink_ReportData(pOIProtSink,
381 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
382 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
384 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
385 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
390 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
391 PROTOCOLDATA *pProtocolData)
393 ok(0, "unexpected call\n");
397 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
400 ok(0, "unexpected call\n");
404 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
406 CHECK_EXPECT(Terminate);
410 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
412 ok(0, "unexpected call\n");
416 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
418 ok(0, "unexpected call\n");
422 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
423 ULONG cb, ULONG *pcbRead)
425 CHECK_EXPECT2(Protocol_Read);
427 ok(pv != NULL, "pv == NULL\n");
428 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
429 ok(pcbRead != NULL, "pcbRead == NULL\n");
430 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
435 protocol_read += *pcbRead = sizeof(css_data)-1;
436 memcpy(pv, css_data, sizeof(css_data)-1);
440 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
441 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
443 ok(0, "unexpected call\n");
447 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
449 CHECK_EXPECT(LockRequest);
453 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
455 CHECK_EXPECT(UnlockRequest);
459 static const IInternetProtocolVtbl ProtocolVtbl = {
460 Protocol_QueryInterface,
471 Protocol_LockRequest,
472 Protocol_UnlockRequest
475 static IInternetProtocol Protocol = { &ProtocolVtbl };
477 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
479 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
480 ok(0, "unexpected call\n");
481 return E_NOINTERFACE;
484 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
489 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
494 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
495 REFIID riid, void **ppv)
497 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
498 return E_NOINTERFACE;
500 CHECK_EXPECT(CreateInstance);
501 ok(ppv != NULL, "ppv == NULL\n");
507 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
509 ok(0, "unexpected call\n");
513 static const IClassFactoryVtbl ClassFactoryVtbl = {
514 ClassFactory_QueryInterface,
516 ClassFactory_Release,
517 ClassFactory_CreateInstance,
518 ClassFactory_LockServer
521 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
523 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
525 ok(0, "unexpected call\n");
529 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
534 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
539 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
540 IHlinkBrowseContext *pihlbc)
542 ok(0, "unexpected call\n");
546 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
547 IHlinkBrowseContext **ppihlbc)
549 ok(0, "unexpected call\n");
553 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
554 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
558 CHECK_EXPECT(Navigate);
560 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
561 ok(pbc != NULL, "pbc == NULL\n");
562 ok(pibsc != NULL, "pubsc == NULL\n");
563 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
566 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
567 LPWSTR location = (LPWSTR)0xdeadbeef;
569 IMoniker *mon = NULL;
570 DWORD site_data = 0xdeadbeef;
572 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
573 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
574 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
576 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
577 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
578 ok(location == NULL, "location = %p\n", location);
579 ok(mon != NULL, "mon == NULL\n");
581 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
582 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
583 ok(site == NULL, "site = %p\n, expected NULL\n", site);
584 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
590 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
591 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
593 ok(0, "unexpected call\n");
597 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
598 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
600 ok(0, "unexpected call\n");
604 static const IHlinkFrameVtbl HlinkFrameVtbl = {
605 HlinkFrame_QueryInterface,
608 HlinkFrame_SetBrowseContext,
609 HlinkFrame_GetBrowseContext,
611 HlinkFrame_OnNavigate,
612 HlinkFrame_UpdateHlink
615 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
617 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
618 REFIID riid, void**ppv)
620 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
625 ok(0, "unexpected call\n");
626 return E_NOINTERFACE;
629 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
634 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
639 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
642 case DISPID_READYSTATE:
643 CHECK_EXPECT2(OnChanged_READYSTATE);
644 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
645 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
646 ? OLECMDF_ENABLED : 0));
648 if(readystate_set_loading) {
649 readystate_set_loading = FALSE;
650 load_state = LD_LOADING;
652 test_readyState(NULL);
655 CHECK_EXPECT(OnChanged_1005);
656 test_readyState(NULL);
657 load_state = LD_INTERACTIVE;
661 ok(0, "unexpected id %d\n", dispID);
665 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
667 ok(0, "unexpected call\n");
671 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
672 PropertyNotifySink_QueryInterface,
673 PropertyNotifySink_AddRef,
674 PropertyNotifySink_Release,
675 PropertyNotifySink_OnChanged,
676 PropertyNotifySink_OnRequestEdit
679 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
681 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
683 ok(0, "unexpected call\n");
684 return E_NOINTERFACE;
687 static ULONG WINAPI Stream_AddRef(IStream *iface)
692 static ULONG WINAPI Stream_Release(IStream *iface)
697 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
698 ULONG cb, ULONG *pcbRead)
701 ok(pv != NULL, "pv == NULL\n");
702 ok(cb > sizeof(html_page), "cb = %d\n", cb);
703 ok(pcbRead != NULL, "pcbRead == NULL\n");
704 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
709 memcpy(pv, html_page, sizeof(html_page)-1);
710 stream_read += *pcbRead = sizeof(html_page)-1;
714 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
715 ULONG cb, ULONG *pcbWritten)
717 ok(0, "unexpected call\n");
721 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
722 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
724 ok(0, "unexpected call\n");
728 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
730 ok(0, "unexpected call\n");
734 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
735 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
737 ok(0, "unexpected call\n");
741 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
743 ok(0, "unexpected call\n");
747 static HRESULT WINAPI Stream_Revert(IStream *iface)
749 ok(0, "unexpected call\n");
753 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
754 ULARGE_INTEGER cb, DWORD dwLockType)
756 ok(0, "unexpected call\n");
760 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
761 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
763 ok(0, "unexpected call\n");
767 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
770 ok(0, "unexpected call\n");
774 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
776 ok(0, "unexpected call\n");
780 static const IStreamVtbl StreamVtbl = {
781 Stream_QueryInterface,
797 static IStream Stream = { &StreamVtbl };
799 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
801 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
802 return E_NOINTERFACE; /* TODO */
804 if(IsEqualGUID(&IID_IWinInetInfo, riid))
805 return E_NOINTERFACE; /* TODO */
807 ok(0, "unexpected call\n");
808 return E_NOINTERFACE;
811 static ULONG WINAPI Binding_AddRef(IBinding *iface)
816 static ULONG WINAPI Binding_Release(IBinding *iface)
821 static HRESULT WINAPI Binding_Abort(IBinding *iface)
827 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
829 ok(0, "unexpected call\n");
833 static HRESULT WINAPI Binding_Resume(IBinding *iface)
835 ok(0, "unexpected call\n");
839 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
841 ok(0, "unexpected call\n");
845 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
847 ok(0, "unexpected call\n");
851 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
852 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
854 CHECK_EXPECT(GetBindResult);
858 static const IBindingVtbl BindingVtbl = {
859 Binding_QueryInterface,
867 Binding_GetBindResult
870 static IBinding Binding = { &BindingVtbl };
872 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
873 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
875 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
879 if(IsEqualGUID(&IID_IMoniker_unk, riid))
880 return E_NOINTERFACE; /* TODO */
881 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
882 return E_NOINTERFACE; /* TODO */
884 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
885 return E_NOINTERFACE;
888 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
893 static ULONG WINAPI Moniker_Release(IMoniker *iface)
898 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
900 CHECK_EXPECT(GetClassID);
901 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
905 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
907 ok(0, "unexpected call\n");
911 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
913 ok(0, "unexpected call\n");
917 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
919 ok(0, "unexpected call\n");
923 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
925 ok(0, "unexpected call\n");
929 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
930 REFIID riidResult, void **ppvResult)
932 ok(0, "unexpected call\n");
936 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
937 REFIID riid, void **ppv)
939 IBindStatusCallback *callback = NULL;
940 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
946 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
947 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
949 CHECK_EXPECT(BindToStorage);
951 load_state = LD_LOADING;
953 ok(pbc != NULL, "pbc == NULL\n");
954 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
955 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
956 ok(ppv != NULL, "ppv == NULL\n");
957 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
959 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
960 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
961 ok(callback != NULL, "callback == NULL\n");
963 memset(&bindinfo, 0xf0, sizeof(bindinfo));
964 bindinfo.cbSize = sizeof(bindinfo);
966 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
967 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
968 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
969 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
970 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
971 /* TODO: test stgmedData */
972 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
973 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
974 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
975 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
976 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
977 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
978 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
979 /* TODO: test dwCodePage */
980 /* TODO: test securityAttributes */
981 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
982 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
983 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
985 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
986 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
988 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
990 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
992 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
993 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
994 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
997 stgmedium.tymed = TYMED_ISTREAM;
998 U(stgmedium).pstm = &Stream;
999 stgmedium.pUnkForRelease = (IUnknown*)iface;
1000 hres = IBindStatusCallback_OnDataAvailable(callback,
1001 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1002 sizeof(html_page)-1, &formatetc, &stgmedium);
1003 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1006 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1007 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1008 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1010 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1011 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1013 IBindStatusCallback_Release(callback);
1018 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1019 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1021 ok(0, "unexpected call\n");
1025 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1026 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1028 ok(0, "unexpected call\n");
1032 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1034 ok(0, "unexpected call\n");
1038 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1040 ok(0, "unexpected call\n");
1044 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1046 ok(0, "unexpected call\n");
1050 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1051 IMoniker *pmkNewlyRunning)
1053 ok(0, "unexpected call\n");
1057 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1058 IMoniker *pmkToLeft, FILETIME *pFileTime)
1060 ok(0, "unexpected call\n");
1064 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1066 ok(0, "unexpected call\n");
1070 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1071 IMoniker **ppmkPrefix)
1073 ok(0, "unexpected call\n");
1077 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1078 IMoniker **pmkRelPath)
1080 ok(0, "unexpected call\n");
1084 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1085 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1087 CHECK_EXPECT2(GetDisplayName);
1089 /* ok(pbc != NULL, "pbc == NULL\n"); */
1090 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1091 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1093 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1094 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1099 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1100 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1102 ok(0, "unexpected call\n");
1106 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1108 CHECK_EXPECT(IsSystemMoniker);
1112 static const IMonikerVtbl MonikerVtbl = {
1113 Moniker_QueryInterface,
1121 Moniker_BindToObject,
1122 Moniker_BindToStorage,
1124 Moniker_ComposeWith,
1129 Moniker_GetTimeOfLastChange,
1131 Moniker_CommonPrefixWith,
1132 Moniker_RelativePathTo,
1133 Moniker_GetDisplayName,
1134 Moniker_ParseDisplayName,
1135 Moniker_IsSystemMoniker
1138 static IMoniker Moniker = { &MonikerVtbl };
1140 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1142 return QueryInterface(riid, ppv);
1145 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1150 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1155 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1156 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1158 ok(0, "unexpected call\n");
1162 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1163 IEnumUnknown **ppenum)
1165 ok(0, "unexpected call\n");
1169 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1171 CHECK_EXPECT(LockContainer);
1172 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1176 static const IOleContainerVtbl OleContainerVtbl = {
1177 OleContainer_QueryInterface,
1178 OleContainer_AddRef,
1179 OleContainer_Release,
1180 OleContainer_ParseDisplayName,
1181 OleContainer_EnumObjects,
1182 OleContainer_LockContainer
1185 static IOleContainer OleContainer = { &OleContainerVtbl };
1187 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1189 ok(0, "unexpected call\n");
1190 return E_NOINTERFACE;
1193 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1198 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1203 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1205 ok(0, "unexpected call\n");
1209 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1211 ok(0, "unexpected call\n");
1215 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1217 ok(0, "unexpected call\n");
1221 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1222 LPCBORDERWIDTHS pborderwidths)
1224 ok(0, "unexpected call\n");
1228 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1229 LPCBORDERWIDTHS pborderwidths)
1231 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1235 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1236 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1238 static const WCHAR wszHTML_Document[] =
1239 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1241 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1243 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1244 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1245 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1246 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1249 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1250 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1252 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1256 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1257 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1259 static const WCHAR wszHTML_Document[] =
1260 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1263 CHECK_EXPECT2(SetActiveObject);
1265 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1266 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1268 CHECK_EXPECT(SetActiveObject_null);
1270 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1271 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1277 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1278 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1280 ok(0, "unexpected call\n");
1284 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1285 HOLEMENU holemenu, HWND hwndActiveObject)
1287 ok(0, "unexpected call\n");
1291 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1293 ok(0, "unexpected call\n");
1297 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1299 CHECK_EXPECT2(SetStatusText);
1300 if(!expect_status_text)
1301 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1305 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1307 ok(0, "unexpected call\n");
1311 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1313 ok(0, "unexpected call\n");
1317 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1318 InPlaceFrame_QueryInterface,
1319 InPlaceFrame_AddRef,
1320 InPlaceFrame_Release,
1321 InPlaceFrame_GetWindow,
1322 InPlaceFrame_ContextSensitiveHelp,
1323 InPlaceFrame_GetBorder,
1324 InPlaceFrame_RequestBorderSpace,
1325 InPlaceFrame_SetBorderSpace,
1326 InPlaceFrame_SetActiveObject,
1327 InPlaceFrame_InsertMenus,
1328 InPlaceFrame_SetMenu,
1329 InPlaceFrame_RemoveMenus,
1330 InPlaceFrame_SetStatusText,
1331 InPlaceFrame_EnableModeless,
1332 InPlaceFrame_TranslateAccelerator
1335 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1337 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1338 InPlaceFrame_QueryInterface,
1339 InPlaceFrame_AddRef,
1340 InPlaceFrame_Release,
1341 InPlaceFrame_GetWindow,
1342 InPlaceFrame_ContextSensitiveHelp,
1343 InPlaceFrame_GetBorder,
1344 InPlaceFrame_RequestBorderSpace,
1345 InPlaceFrame_SetBorderSpace,
1346 InPlaceUIWindow_SetActiveObject,
1349 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1351 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1353 return QueryInterface(riid, ppv);
1356 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1361 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1366 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1368 CHECK_EXPECT(GetWindow);
1369 ok(phwnd != NULL, "phwnd = NULL\n");
1370 *phwnd = container_hwnd;
1374 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1376 ok(0, "unexpected call\n");
1380 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1382 CHECK_EXPECT(CanInPlaceActivate);
1386 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1388 CHECK_EXPECT(OnInPlaceActivate);
1392 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1394 CHECK_EXPECT(OnUIActivate);
1398 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1399 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1400 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1402 static const RECT rect = {0,0,500,500};
1404 CHECK_EXPECT(GetWindowContext);
1406 ok(ppFrame != NULL, "ppFrame = NULL\n");
1408 *ppFrame = &InPlaceFrame;
1409 ok(ppDoc != NULL, "ppDoc = NULL\n");
1411 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1412 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1414 memcpy(lprcPosRect, &rect, sizeof(RECT));
1415 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1417 memcpy(lprcClipRect, &rect, sizeof(RECT));
1418 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1420 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1421 lpFrameInfo->fMDIApp = FALSE;
1422 lpFrameInfo->hwndFrame = container_hwnd;
1423 lpFrameInfo->haccel = NULL;
1424 lpFrameInfo->cAccelEntries = 0;
1430 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1432 ok(0, "unexpected call\n");
1436 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1438 CHECK_EXPECT(OnUIDeactivate);
1439 ok(!fUndoable, "fUndoable = TRUE\n");
1443 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1445 CHECK_EXPECT(OnInPlaceDeactivate);
1449 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1451 ok(0, "unexpected call\n");
1455 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1457 ok(0, "unexpected call\n");
1461 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1463 ok(0, "unexpected call\n");
1467 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1469 CHECK_EXPECT(OnInPlaceActivateEx);
1471 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1472 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1473 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1478 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1480 CHECK_EXPECT(OnInPlaceDeactivateEx);
1482 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1487 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1489 CHECK_EXPECT(RequestUIActivate);
1493 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1494 InPlaceSite_QueryInterface,
1496 InPlaceSite_Release,
1497 InPlaceSite_GetWindow,
1498 InPlaceSite_ContextSensitiveHelp,
1499 InPlaceSite_CanInPlaceActivate,
1500 InPlaceSite_OnInPlaceActivate,
1501 InPlaceSite_OnUIActivate,
1502 InPlaceSite_GetWindowContext,
1504 InPlaceSite_OnUIDeactivate,
1505 InPlaceSite_OnInPlaceDeactivate,
1506 InPlaceSite_DiscardUndoState,
1507 InPlaceSite_DeactivateAndUndo,
1508 InPlaceSite_OnPosRectChange,
1509 InPlaceSiteEx_OnInPlaceActivateEx,
1510 InPlaceSiteEx_OnInPlaceDeactivateEx,
1511 InPlaceSiteEx_RequestUIActivate
1514 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1516 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1518 return QueryInterface(riid, ppv);
1521 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1526 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1531 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1533 ok(0, "unexpected call\n");
1537 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1540 ok(0, "unexpected call\n");
1544 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1546 CHECK_EXPECT(GetContainer);
1547 ok(ppContainer != NULL, "ppContainer = NULL\n");
1548 *ppContainer = &OleContainer;
1552 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1554 ok(0, "unexpected call\n");
1558 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1560 ok(0, "unexpected call\n");
1564 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1566 ok(0, "unexpected call\n");
1570 static const IOleClientSiteVtbl ClientSiteVtbl = {
1571 ClientSite_QueryInterface,
1574 ClientSite_SaveObject,
1575 ClientSite_GetMoniker,
1576 ClientSite_GetContainer,
1577 ClientSite_ShowObject,
1578 ClientSite_OnShowWindow,
1579 ClientSite_RequestNewObjectLayout
1582 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1584 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1586 return QueryInterface(riid, ppv);
1589 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1594 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1601 CallUIActivate_None,
1602 CallUIActivate_ActivateMe,
1603 CallUIActivate_AfterShow,
1606 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1607 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1609 IOleDocument *document;
1612 CHECK_EXPECT(ActivateMe);
1613 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1615 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1616 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1618 if(SUCCEEDED(hres)) {
1619 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1620 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1622 if(SUCCEEDED(hres)) {
1623 IOleInPlaceActiveObject *activeobj = NULL;
1624 IOleInPlaceSite *inplacesite = NULL;
1625 HWND tmp_hwnd = NULL;
1626 static RECT rect = {0,0,400,500};
1628 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1629 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1630 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1631 inplacesite, &InPlaceSiteEx);
1633 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1634 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1636 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1637 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1638 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1639 inplacesite, &InPlaceSiteEx);
1641 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1642 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1645 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1646 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1647 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1650 if(call_UIActivate == CallUIActivate_ActivateMe) {
1651 SET_EXPECT(CanInPlaceActivate);
1652 SET_EXPECT(GetWindowContext);
1653 SET_EXPECT(GetWindow);
1655 SET_EXPECT(OnInPlaceActivateEx);
1657 SET_EXPECT(OnInPlaceActivate);
1658 SET_EXPECT(SetStatusText);
1659 SET_EXPECT(Exec_SETPROGRESSMAX);
1660 SET_EXPECT(Exec_SETPROGRESSPOS);
1661 SET_EXPECT(OnUIActivate);
1662 SET_EXPECT(SetActiveObject);
1664 expect_status_text = NULL;
1666 hres = IOleDocumentView_UIActivate(view, TRUE);
1669 skip("UIActivate failed: %08x\n", hres);
1672 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1674 CHECK_CALLED(CanInPlaceActivate);
1675 CHECK_CALLED(GetWindowContext);
1676 CHECK_CALLED(GetWindow);
1678 CHECK_CALLED(OnInPlaceActivateEx);
1680 CHECK_CALLED(OnInPlaceActivate);
1681 CHECK_CALLED(SetStatusText);
1682 CHECK_CALLED(Exec_SETPROGRESSMAX);
1683 CHECK_CALLED(Exec_SETPROGRESSPOS);
1684 CHECK_CALLED(OnUIActivate);
1685 CHECK_CALLED(SetActiveObject);
1686 CHECK_CALLED(ShowUI);
1689 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1690 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1691 ok(hwnd != NULL, "hwnd == NULL\n");
1693 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1696 hres = IOleDocumentView_UIActivate(view, TRUE);
1697 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1700 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1701 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1702 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1706 hres = IOleDocumentView_SetRect(view, &rect);
1707 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1709 if(call_UIActivate == CallUIActivate_ActivateMe) {
1710 hres = IOleDocumentView_Show(view, TRUE);
1711 ok(hres == S_OK, "Show failed: %08x\n", hres);
1713 SET_EXPECT(CanInPlaceActivate);
1714 SET_EXPECT(GetWindowContext);
1715 SET_EXPECT(GetWindow);
1717 SET_EXPECT(OnInPlaceActivateEx);
1719 SET_EXPECT(OnInPlaceActivate);
1720 SET_EXPECT(SetStatusText);
1721 SET_EXPECT(Exec_SETPROGRESSMAX);
1722 SET_EXPECT(Exec_SETPROGRESSPOS);
1723 SET_EXPECT(OnUIActivate);
1724 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1726 hres = IOleDocumentView_Show(view, TRUE);
1727 ok(hres == S_OK, "Show failed: %08x\n", hres);
1729 CHECK_CALLED(CanInPlaceActivate);
1730 CHECK_CALLED(GetWindowContext);
1731 CHECK_CALLED(GetWindow);
1733 CHECK_CALLED(OnInPlaceActivateEx);
1735 CHECK_CALLED(OnInPlaceActivate);
1736 CHECK_CALLED(SetStatusText);
1737 CHECK_CALLED(Exec_SETPROGRESSMAX);
1738 CHECK_CALLED(Exec_SETPROGRESSPOS);
1741 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1742 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1743 ok(hwnd != NULL, "hwnd == NULL\n");
1745 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1749 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1752 IOleInPlaceActiveObject_Release(activeobj);
1755 IOleDocument_Release(document);
1761 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1762 DocumentSite_QueryInterface,
1763 DocumentSite_AddRef,
1764 DocumentSite_Release,
1765 DocumentSite_ActivateMe
1768 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1770 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1772 return QueryInterface(riid, ppv);
1775 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1780 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1785 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1787 ok(0, "unexpected call\n");
1791 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1793 ok(0, "unexpected call\n");
1797 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1799 ok(0, "unexpected call\n");
1803 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1804 POINTF *pPtfContainer, DWORD dwFlags)
1806 ok(0, "unexpected call\n");
1810 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1811 MSG *pMsg, DWORD grfModifiers)
1813 ok(0, "unexpected call\n");
1817 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1820 CHECK_EXPECT(OnFocus_TRUE);
1822 CHECK_EXPECT2(OnFocus_FALSE);
1826 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1828 ok(0, "unexpected call\n");
1832 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1833 OleControlSite_QueryInterface,
1834 OleControlSite_AddRef,
1835 OleControlSite_Release,
1836 OleControlSite_OnControlInfoChanged,
1837 OleControlSite_LockInPlaceActive,
1838 OleControlSite_GetExtendedControl,
1839 OleControlSite_TransformCoords,
1840 OleControlSite_TranslateAccelerator,
1841 OleControlSite_OnFocus,
1842 OleControlSite_ShowPropertyFrame
1845 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1847 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1849 return QueryInterface(riid, ppv);
1852 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1857 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1862 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1863 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1865 ok(0, "unexpected call\n");
1869 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1871 CHECK_EXPECT(GetHostInfo);
1872 ok(pInfo != NULL, "pInfo=NULL\n");
1874 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1875 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1876 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1877 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1878 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1879 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1880 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1881 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1886 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1887 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1888 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1890 CHECK_EXPECT(ShowUI);
1893 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1895 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1896 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1897 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1898 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1899 if (expect_InPlaceUIWindow_SetActiveObject_active)
1900 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
1902 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1907 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1909 CHECK_EXPECT(HideUI);
1913 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1915 CHECK_EXPECT(UpdateUI);
1919 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1921 ok(0, "unexpected call\n");
1925 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1927 ok(0, "unexpected call\n");
1931 static BOOL expect_OnFrameWindowActivate_fActivate;
1932 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1934 CHECK_EXPECT2(OnFrameWindowActivate);
1935 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1939 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1940 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1942 ok(0, "unexpected call\n");
1946 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1947 const GUID *pguidCmdGroup, DWORD nCmdID)
1949 ok(0, "unexpected call\n");
1953 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1954 LPOLESTR *pchKey, DWORD dw)
1956 CHECK_EXPECT(GetOptionKeyPath);
1957 ok(pchKey != NULL, "pchKey = NULL\n");
1958 ok(!dw, "dw=%d, expected 0\n", dw);
1960 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1964 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1965 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1967 CHECK_EXPECT(GetDropTarget);
1972 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1974 CHECK_EXPECT(GetExternal);
1975 *ppDispatch = &External;
1979 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1980 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
1982 ok(0, "unexpected call\n");
1986 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
1987 IDataObject **ppPORet)
1989 ok(0, "unexpected call\n");
1993 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
1994 LPOLESTR *pchKey, DWORD dw)
1996 CHECK_EXPECT(GetOverrideKeyPath);
1997 ok(pchKey != NULL, "pchKey = NULL\n");
1999 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2000 ok(!dw, "dw=%d, xepected 0\n", dw);
2004 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2005 DocHostUIHandler_QueryInterface,
2006 DocHostUIHandler_AddRef,
2007 DocHostUIHandler_Release,
2008 DocHostUIHandler_ShowContextMenu,
2009 DocHostUIHandler_GetHostInfo,
2010 DocHostUIHandler_ShowUI,
2011 DocHostUIHandler_HideUI,
2012 DocHostUIHandler_UpdateUI,
2013 DocHostUIHandler_EnableModeless,
2014 DocHostUIHandler_OnDocWindowActivate,
2015 DocHostUIHandler_OnFrameWindowActivate,
2016 DocHostUIHandler_ResizeBorder,
2017 DocHostUIHandler_TranslateAccelerator,
2018 DocHostUIHandler_GetOptionKeyPath,
2019 DocHostUIHandler_GetDropTarget,
2020 DocHostUIHandler_GetExternal,
2021 DocHostUIHandler_TranslateUrl,
2022 DocHostUIHandler_FilterDataObject,
2023 DocHostUIHandler_GetOverrideKeyPath
2026 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2028 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2029 REFIID riid, void **ppv)
2031 return QueryInterface(riid, ppv);
2034 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2039 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2044 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2045 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2047 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2048 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2049 ok(!pCmdText, "pCmdText != NULL\n");
2051 switch(prgCmds[0].cmdID) {
2052 case OLECMDID_SETPROGRESSTEXT:
2053 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2054 prgCmds[0].cmdf = OLECMDF_ENABLED;
2057 CHECK_EXPECT(QueryStatus_OPEN);
2058 prgCmds[0].cmdf = 0;
2061 CHECK_EXPECT(QueryStatus_NEW);
2062 prgCmds[0].cmdf = 0;
2065 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2071 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2072 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2074 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2075 test_readyState(NULL);
2077 if(!pguidCmdGroup) {
2079 case OLECMDID_SETPROGRESSMAX:
2080 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2081 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2082 ok(pvaIn != NULL, "pvaIn == NULL\n");
2084 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2085 if(load_state == LD_NO)
2086 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2088 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2090 case OLECMDID_SETPROGRESSPOS:
2091 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2092 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2093 ok(pvaIn != NULL, "pvaIn == NULL\n");
2095 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2096 if(load_state == LD_NO)
2097 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2099 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2101 case OLECMDID_HTTPEQUIV_DONE:
2102 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2103 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2104 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2105 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2106 load_state = LD_COMPLETE;
2108 case OLECMDID_SETDOWNLOADSTATE:
2109 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2110 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2111 ok(pvaIn != NULL, "pvaIn == NULL\n");
2112 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2114 switch(V_I4(pvaIn)) {
2116 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2117 load_state = LD_INTERACTIVE;
2120 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2123 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2127 case OLECMDID_UPDATECOMMANDS:
2128 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2129 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2130 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2131 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2133 case OLECMDID_SETTITLE:
2134 CHECK_EXPECT2(Exec_SETTITLE);
2135 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2136 ok(pvaIn != NULL, "pvaIn == NULL\n");
2137 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2138 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2139 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2141 case OLECMDID_HTTPEQUIV:
2142 CHECK_EXPECT2(Exec_HTTPEQUIV);
2143 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2147 ok(0, "unexpected command %d\n", nCmdID);
2152 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2153 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2157 CHECK_EXPECT2(Exec_ShellDocView_37);
2159 if(load_from_stream)
2160 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2162 test_GetCurMoniker(doc_unk, &Moniker, NULL);
2164 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2165 ok(pvaIn != NULL, "pvaIn == NULL\n");
2167 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2168 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2172 CHECK_EXPECT2(Exec_ShellDocView_84);
2174 ok(pvaIn == NULL, "pvaIn != NULL\n");
2175 ok(pvaOut != NULL, "pvaOut == NULL\n");
2177 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2182 CHECK_EXPECT2(Exec_ShellDocView_103);
2184 ok(pvaIn == NULL, "pvaIn != NULL\n");
2185 ok(pvaOut == NULL, "pvaOut != NULL\n");
2190 ok(0, "unexpected command %d\n", nCmdID);
2195 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2196 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2199 case IDM_PARSECOMPLETE:
2200 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2201 ok(pvaIn == NULL, "pvaIn != NULL\n");
2202 ok(pvaOut == NULL, "pvaOut != NULL\n");
2205 ok(0, "unexpected command %d\n", nCmdID);
2209 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2210 return E_FAIL; /* TODO */
2212 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2213 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2217 CHECK_EXPECT2(Exec_Explorer_69);
2218 ok(pvaIn == NULL, "pvaIn != NULL\n");
2219 ok(pvaOut != NULL, "pvaOut == NULL\n");
2222 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2227 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2229 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2230 SET_EXPECT(SetStatusText);
2231 ok(pvaIn == NULL, "pvaIn != NULL\n");
2232 ok(pvaOut == NULL, "pvaOut != NULL\n");
2235 ok(0, "unexpected command %d\n", nCmdID);
2240 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2244 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2245 OleCommandTarget_QueryInterface,
2246 OleCommandTarget_AddRef,
2247 OleCommandTarget_Release,
2248 OleCommandTarget_QueryStatus,
2249 OleCommandTarget_Exec
2252 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2254 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2256 return QueryInterface(riid, ppv);
2259 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2260 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2261 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2263 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2264 ok(pDispParams != NULL, "pDispParams == NULL\n");
2265 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2266 ok(puArgErr != NULL, "puArgErr == NULL\n");
2267 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2268 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2269 test_readyState(NULL);
2271 switch(dispIdMember) {
2272 case DISPID_AMBIENT_USERMODE:
2273 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2274 V_VT(pVarResult) = VT_BOOL;
2275 V_BOOL(pVarResult) = VARIANT_TRUE;
2277 case DISPID_AMBIENT_DLCONTROL:
2278 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2280 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2281 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2283 case DISPID_AMBIENT_SILENT:
2284 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2285 V_VT(pVarResult) = VT_BOOL;
2286 V_BOOL(pVarResult) = VARIANT_FALSE;
2288 case DISPID_AMBIENT_USERAGENT:
2289 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2291 case DISPID_AMBIENT_PALETTE:
2292 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2296 ok(0, "unexpected dispid %d\n", dispIdMember);
2300 static IDispatchVtbl DispatchVtbl = {
2301 Dispatch_QueryInterface,
2304 Dispatch_GetTypeInfoCount,
2305 Dispatch_GetTypeInfo,
2306 Dispatch_GetIDsOfNames,
2310 static IDispatch Dispatch = { &DispatchVtbl };
2312 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2313 REFIID riid, void **ppv)
2315 return QueryInterface(riid, ppv);
2318 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2323 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2328 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2329 REFIID riid, void **ppv)
2332 * Services used by HTMLDocument:
2335 * IInternetSecurityManager
2337 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2340 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2341 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2342 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2344 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2345 * IElementBehaviorFactory
2346 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2356 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2357 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2362 return E_NOINTERFACE;
2365 static const IServiceProviderVtbl ServiceProviderVtbl = {
2366 ServiceProvider_QueryInterface,
2367 ServiceProvider_AddRef,
2368 ServiceProvider_Release,
2369 ServiceProvider_QueryService
2372 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2374 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2375 DEFINE_GUID(IID_unk2, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2376 DEFINE_GUID(IID_unk3, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2378 static HRESULT QueryInterface(REFIID riid, void **ppv)
2382 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2384 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2385 *ppv = &DocumentSite;
2386 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2387 *ppv = &DocHostUIHandler;
2388 else if(IsEqualGUID(&IID_IOleContainer, riid))
2389 *ppv = &OleContainer;
2390 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2391 *ppv = &InPlaceSiteEx;
2392 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2393 *ppv = &OleCommandTarget;
2394 else if(IsEqualGUID(&IID_IDispatch, riid))
2396 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2397 *ppv = &ServiceProvider;
2398 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2399 *ppv = ipsex ? &InPlaceSiteEx : NULL;
2400 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2401 *ppv = &OleControlSite;
2402 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2403 return E_NOINTERFACE; /* TODO */
2404 else if(IsEqualGUID(&IID_IProxyManager, riid))
2405 return E_NOINTERFACE; /* ? */
2406 else if(IsEqualGUID(&IID_unk1, riid))
2407 return E_NOINTERFACE; /* HTMLWindow2 ? */
2408 else if(IsEqualGUID(&IID_unk2, riid))
2409 return E_NOINTERFACE; /* ? */
2410 else if(IsEqualGUID(&IID_unk3, riid))
2411 return E_NOINTERFACE; /* ? */
2413 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2417 return E_NOINTERFACE;
2420 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2422 return DefWindowProc(hwnd, msg, wParam, lParam);
2425 static void _test_readyState(unsigned line, IUnknown *unk)
2427 IHTMLDocument2 *htmldoc;
2428 DISPPARAMS dispparams;
2433 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2434 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2435 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2436 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2438 static const LPCWSTR expected_state[] = {
2450 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2451 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2455 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2456 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2458 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2459 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2461 (!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n",
2462 debugstr_w(state), load_state);
2463 SysFreeString(state);
2465 dispparams.cArgs = 0;
2466 dispparams.cNamedArgs = 0;
2467 dispparams.rgdispidNamedArgs = NULL;
2468 dispparams.rgvarg = NULL;
2472 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2473 &dispparams, &out, NULL, NULL);
2474 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2476 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2477 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2479 IHTMLDocument2_Release(htmldoc);
2482 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2484 IConnectionPointContainer *tmp_container = NULL;
2485 IConnectionPoint *cp;
2489 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2490 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2494 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2495 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2496 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2498 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2499 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2501 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2502 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2503 ok(tmp_container == container, "container != tmp_container\n");
2505 IConnectionPointContainer_Release(tmp_container);
2507 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2508 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2510 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2513 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2514 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2517 IConnectionPoint_Release(cp);
2520 static void test_ConnectionPointContainer(IUnknown *unk)
2522 IConnectionPointContainer *container;
2525 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2526 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2530 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2531 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2532 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2534 IConnectionPointContainer_Release(container);
2537 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2539 IHTMLDocument2 *doc;
2540 IPersistMoniker *permon;
2541 IMoniker *mon = (void*)0xdeadbeef;
2542 BSTR doc_url = (void*)0xdeadbeef;
2545 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2546 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2550 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2551 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2553 hres = IHTMLDocument2_get_URL(doc, &doc_url);
2554 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2556 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2557 IPersistMoniker_Release(permon);
2561 BOOL exb = expect_GetDisplayName;
2562 BOOL clb = called_GetDisplayName;
2564 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2565 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2567 SET_EXPECT(GetDisplayName);
2568 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2569 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2570 CHECK_CALLED(GetDisplayName);
2571 expect_GetDisplayName = exb;
2572 called_GetDisplayName = clb;
2574 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2579 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2581 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2582 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2584 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2585 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2589 ok(hres == E_UNEXPECTED,
2590 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2591 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2592 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2595 SysFreeString(doc_url);
2596 IHTMLDocument_Release(doc);
2597 if(mon && mon != (void*)0xdeadbeef)
2598 IMoniker_Release(mon);
2601 static void test_Load(IPersistMoniker *persist)
2605 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2607 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2609 test_readyState((IUnknown*)persist);
2611 CreateBindCtx(0, &bind);
2612 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2613 (IUnknown*)&ClientSite);
2615 SET_EXPECT(GetDisplayName);
2616 if(!set_clientsite) {
2617 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2618 SET_EXPECT(GetHostInfo);
2619 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2620 SET_EXPECT(Invoke_AMBIENT_SILENT);
2621 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2622 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2623 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2624 SET_EXPECT(GetOptionKeyPath);
2625 SET_EXPECT(GetOverrideKeyPath);
2626 SET_EXPECT(GetWindow);
2627 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2628 SET_EXPECT(Exec_SETPROGRESSMAX);
2629 SET_EXPECT(Exec_SETPROGRESSPOS);
2630 SET_EXPECT(Exec_ShellDocView_37);
2632 if(!container_locked) {
2633 SET_EXPECT(GetContainer);
2634 SET_EXPECT(LockContainer);
2636 SET_EXPECT(OnChanged_READYSTATE);
2637 SET_EXPECT(Exec_ShellDocView_84);
2638 SET_EXPECT(BindToStorage);
2639 SET_EXPECT(SetActiveObject);
2640 if(set_clientsite) {
2641 SET_EXPECT(Invoke_AMBIENT_SILENT);
2642 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2643 SET_EXPECT(Exec_ShellDocView_37);
2645 load_state = LD_DOLOAD;
2646 expect_LockContainer_fLock = TRUE;
2647 readystate_set_loading = TRUE;
2649 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2650 ok(hres == S_OK, "Load failed: %08x\n", hres);
2652 CHECK_CALLED(GetDisplayName);
2653 if(!set_clientsite) {
2654 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2655 CHECK_CALLED(GetHostInfo);
2656 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2657 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2658 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2659 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2660 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2661 CHECK_CALLED(GetOptionKeyPath);
2662 CHECK_CALLED(GetOverrideKeyPath);
2663 CHECK_CALLED(GetWindow);
2664 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2665 CHECK_CALLED(Exec_SETPROGRESSMAX);
2666 CHECK_CALLED(Exec_SETPROGRESSPOS);
2667 CHECK_CALLED(Exec_ShellDocView_37);
2669 if(!container_locked) {
2670 CHECK_CALLED(GetContainer);
2671 CHECK_CALLED(LockContainer);
2672 container_locked = TRUE;
2674 CHECK_CALLED(OnChanged_READYSTATE);
2675 SET_CALLED(Exec_ShellDocView_84);
2676 CHECK_CALLED(BindToStorage);
2677 SET_CALLED(SetActiveObject); /* FIXME */
2678 if(set_clientsite) {
2679 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2680 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2681 CHECK_CALLED(Exec_ShellDocView_37);
2684 set_clientsite = container_locked = TRUE;
2686 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2688 IBindCtx_Release(bind);
2690 test_readyState((IUnknown*)persist);
2693 static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
2698 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2699 ok(hwnd != NULL, "Could not find hidden window\n");
2701 test_readyState(NULL);
2704 SET_EXPECT(Exec_SETPROGRESSMAX);
2705 if(!load_from_stream)
2706 SET_EXPECT(GetHostInfo);
2708 SET_EXPECT(SetStatusText);
2709 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2710 SET_EXPECT(GetDropTarget);
2712 SET_EXPECT(Exec_ShellDocView_84);
2714 SET_EXPECT(CreateInstance);
2716 SET_EXPECT(LockRequest);
2717 SET_EXPECT(Terminate);
2718 SET_EXPECT(Protocol_Read);
2719 SET_EXPECT(UnlockRequest);
2721 SET_EXPECT(Exec_Explorer_69);
2722 SET_EXPECT(OnChanged_1005);
2723 SET_EXPECT(OnChanged_READYSTATE);
2724 SET_EXPECT(Exec_SETPROGRESSPOS);
2725 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2726 SET_EXPECT(Exec_ShellDocView_103);
2727 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2728 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2729 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2731 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2732 TranslateMessage(&msg);
2733 DispatchMessage(&msg);
2737 CHECK_CALLED(Exec_SETPROGRESSMAX);
2738 if(!load_from_stream)
2739 CHECK_CALLED(GetHostInfo);
2741 CHECK_CALLED(SetStatusText);
2742 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2743 CHECK_CALLED(GetDropTarget);
2745 SET_CALLED(Exec_ShellDocView_84);
2747 if(called_CreateInstance) {
2748 CHECK_CALLED(CreateInstance);
2749 CHECK_CALLED(Start);
2750 CHECK_CALLED(LockRequest);
2751 CHECK_CALLED(Terminate);
2752 CHECK_CALLED(Protocol_Read);
2753 CHECK_CALLED(UnlockRequest);
2755 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2757 SET_CALLED(Exec_ShellDocView_84);
2758 SET_CALLED(CreateInstance);
2760 SET_CALLED(LockRequest);
2761 SET_CALLED(Terminate);
2762 SET_CALLED(Protocol_Read);
2763 SET_CALLED(UnlockRequest);
2768 SET_CALLED(Exec_Explorer_69);
2769 CHECK_CALLED(OnChanged_1005);
2770 CHECK_CALLED(OnChanged_READYSTATE);
2771 CHECK_CALLED(Exec_SETPROGRESSPOS);
2772 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2773 SET_CALLED(Exec_ShellDocView_103);
2774 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2775 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2777 load_state = LD_COMPLETE;
2779 test_readyState(NULL);
2782 static void test_Persist(IUnknown *unk)
2784 IPersistMoniker *persist_mon;
2785 IPersistFile *persist_file;
2789 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2790 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2791 if(SUCCEEDED(hres)) {
2792 hres = IPersist_GetClassID(persist_file, NULL);
2793 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2795 hres = IPersist_GetClassID(persist_file, &guid);
2796 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2797 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2799 IPersist_Release(persist_file);
2802 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2803 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2804 if(SUCCEEDED(hres)) {
2805 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2806 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2808 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2809 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2810 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2812 if(load_state == LD_DOLOAD)
2813 test_Load(persist_mon);
2815 test_readyState(unk);
2817 IPersistMoniker_Release(persist_mon);
2821 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2823 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2824 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2825 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2826 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2827 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2828 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2829 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2830 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2831 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2832 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2833 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2834 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2835 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2836 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2837 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2838 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2839 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2840 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2841 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2842 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2844 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2845 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2847 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2849 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2851 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2852 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2854 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2855 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2857 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2859 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2860 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2863 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2864 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2866 IOleCommandTarget *cmdtrg;
2867 OLECMD olecmd = {cmdid, 0};
2870 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2871 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2875 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2876 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2878 IOleCommandTarget_Release(cmdtrg);
2880 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2881 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2884 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2889 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2890 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2891 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
2892 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2893 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2894 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2895 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2896 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2897 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2898 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2899 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2900 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2901 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2902 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2903 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2904 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
2907 static void test_OleCommandTarget(IUnknown *unk)
2909 IOleCommandTarget *cmdtrg;
2910 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2914 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2915 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2919 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2920 cmds[i].cmdID = i+1;
2921 cmds[i].cmdf = 0xf0f0;
2924 SET_EXPECT(QueryStatus_OPEN);
2925 SET_EXPECT(QueryStatus_NEW);
2926 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2927 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2928 CHECK_CALLED(QueryStatus_OPEN);
2929 CHECK_CALLED(QueryStatus_NEW);
2931 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2932 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2933 if(i+1 == OLECMDID_FIND)
2935 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2936 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2939 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
2940 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
2942 IOleCommandTarget_Release(cmdtrg);
2945 static void test_OleCommandTarget_fail(IUnknown *unk)
2947 IOleCommandTarget *cmdtrg;
2952 {OLECMDID_OPEN, 0xf0f0},
2953 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2956 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2957 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2961 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2962 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2964 SET_EXPECT(QueryStatus_OPEN);
2965 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2966 CHECK_CALLED(QueryStatus_OPEN);
2968 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2969 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2970 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
2971 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
2972 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
2973 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
2974 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
2976 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
2977 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
2978 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
2980 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2981 if(!expect_cmds[i]) {
2982 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
2983 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2984 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2985 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2989 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
2990 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
2991 ok(hres == OLECMDERR_E_NOTSUPPORTED,
2992 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
2994 IOleCommandTarget_Release(cmdtrg);
2997 static void test_exec_onunload(IUnknown *unk)
2999 IOleCommandTarget *cmdtrg;
3003 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3004 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3008 memset(&var, 0x0a, sizeof(var));
3009 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3010 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3011 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3012 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3013 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3015 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3016 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3017 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3019 IOleCommandTarget_Release(cmdtrg);
3022 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3024 IOleCommandTarget *cmdtrg;
3027 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3028 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3035 load_state = LD_DOLOAD;
3038 SET_EXPECT(GetClassID);
3039 SET_EXPECT(SetStatusText);
3040 SET_EXPECT(Exec_ShellDocView_37);
3041 SET_EXPECT(GetHostInfo);
3043 SET_EXPECT(GetDisplayName);
3044 SET_EXPECT(Invoke_AMBIENT_SILENT);
3045 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3046 SET_EXPECT(OnChanged_READYSTATE);
3047 SET_EXPECT(Exec_ShellDocView_84);
3049 SET_EXPECT(BindToStorage);
3050 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3053 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3055 expect_status_text = NULL;
3056 readystate_set_loading = TRUE;
3058 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3059 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3060 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3063 CHECK_CALLED(GetClassID);
3064 CHECK_CALLED(SetStatusText);
3065 CHECK_CALLED(Exec_ShellDocView_37);
3066 CHECK_CALLED(GetHostInfo);
3068 CHECK_CALLED(GetDisplayName);
3069 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3070 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3071 CHECK_CALLED(OnChanged_READYSTATE);
3072 SET_CALLED(Exec_ShellDocView_84);
3074 CHECK_CALLED(BindToStorage);
3075 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3076 CHECK_CALLED(HideUI);
3077 CHECK_CALLED(ShowUI);
3078 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3080 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3082 IOleCommandTarget_Release(cmdtrg);
3084 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3085 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3086 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3089 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3091 IOleCommandTarget *cmdtrg;
3092 VARIANT *in = NULL, _in, *out = NULL, _out;
3095 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3096 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3103 V_BSTR(in) = SysAllocString(name);
3109 V_I4(out) = 0xdeadbeef;
3112 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3114 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3119 if(out && !nogecko) {
3120 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3121 if(V_VT(out) == VT_BSTR) {
3123 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3124 "unexpected fontname \"%s\"\n", debugstr_w(name));
3126 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3131 IOleCommandTarget_Release(cmdtrg);
3134 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3136 IOleCommandTarget *cmdtrg;
3139 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3140 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3144 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3145 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3146 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3148 IOleCommandTarget_Release(cmdtrg);
3151 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3153 IPersistStreamInit *perinit;
3154 IPersistMoniker *permon;
3155 IPersistFile *perfile;
3158 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3159 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3160 if(SUCCEEDED(hres)) {
3161 hres = IPersistStreamInit_IsDirty(perinit);
3162 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3163 IPersistStreamInit_Release(perinit);
3166 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3167 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3168 if(SUCCEEDED(hres)) {
3169 hres = IPersistMoniker_IsDirty(permon);
3170 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3171 IPersistMoniker_Release(permon);
3174 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3175 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3176 if(SUCCEEDED(hres)) {
3177 hres = IPersistFile_IsDirty(perfile);
3178 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3179 IPersistFile_Release(perfile);
3183 static HWND create_container_window(void)
3185 static const WCHAR wszHTMLDocumentTest[] =
3186 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3187 static WNDCLASSEXW wndclass = {
3188 sizeof(WNDCLASSEXW),
3191 0, 0, NULL, NULL, NULL, NULL, NULL,
3192 wszHTMLDocumentTest,
3196 RegisterClassExW(&wndclass);
3197 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3198 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3199 515, 530, NULL, NULL, NULL, NULL);
3202 static HRESULT test_DoVerb(IOleObject *oleobj)
3204 RECT rect = {0,0,500,500};
3207 if(!container_locked) {
3208 SET_EXPECT(GetContainer);
3209 SET_EXPECT(LockContainer);
3211 SET_EXPECT(ActivateMe);
3212 expect_LockContainer_fLock = TRUE;
3214 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3217 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3219 if(!container_locked) {
3220 CHECK_CALLED(GetContainer);
3221 CHECK_CALLED(LockContainer);
3222 container_locked = TRUE;
3224 CHECK_CALLED(ActivateMe);
3229 #define CLIENTSITE_EXPECTPATH 0x00000001
3230 #define CLIENTSITE_SETNULL 0x00000002
3231 #define CLIENTSITE_DONTSET 0x00000004
3233 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3235 IOleClientSite *clientsite;
3238 if(flags & CLIENTSITE_SETNULL) {
3239 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3240 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3242 hres = IOleObject_SetClientSite(oleobj, NULL);
3243 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3245 set_clientsite = FALSE;
3248 if(flags & CLIENTSITE_DONTSET)
3251 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3252 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3253 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3254 clientsite, set_clientsite ? &ClientSite : NULL);
3256 if(!set_clientsite) {
3257 SET_EXPECT(GetHostInfo);
3258 if(flags & CLIENTSITE_EXPECTPATH) {
3259 SET_EXPECT(GetOptionKeyPath);
3260 SET_EXPECT(GetOverrideKeyPath);
3262 SET_EXPECT(GetWindow);
3263 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3264 SET_EXPECT(Exec_SETPROGRESSMAX);
3265 SET_EXPECT(Exec_SETPROGRESSPOS);
3266 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3267 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3268 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3269 SET_EXPECT(Invoke_AMBIENT_SILENT);
3270 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3271 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3273 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3274 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3276 CHECK_CALLED(GetHostInfo);
3277 if(flags & CLIENTSITE_EXPECTPATH) {
3278 CHECK_CALLED(GetOptionKeyPath);
3279 CHECK_CALLED(GetOverrideKeyPath);
3281 CHECK_CALLED(GetWindow);
3282 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3283 CHECK_CALLED(Exec_SETPROGRESSMAX);
3284 CHECK_CALLED(Exec_SETPROGRESSPOS);
3285 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3286 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3287 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3288 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3289 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3290 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3292 set_clientsite = TRUE;
3295 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3296 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3298 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3299 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3300 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3303 static void test_OnAmbientPropertyChange(IUnknown *unk)
3305 IOleControl *control = NULL;
3308 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3309 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3313 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3314 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3315 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3316 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3318 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3319 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3320 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3321 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3323 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3324 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3325 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3326 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3327 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3328 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3330 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3331 SET_EXPECT(Invoke_AMBIENT_SILENT);
3332 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3333 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3334 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3335 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3337 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3338 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3339 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3340 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3342 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3343 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3344 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3345 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3347 IOleControl_Release(control);
3352 static void test_OnAmbientPropertyChange2(IUnknown *unk)
3354 IOleControl *control = NULL;
3357 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3358 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3362 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3363 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3365 IOleControl_Release(control);
3368 static void test_Close(IUnknown *unk, BOOL set_client)
3370 IOleObject *oleobj = NULL;
3373 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3374 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3378 SET_EXPECT(GetContainer);
3379 SET_EXPECT(LockContainer);
3380 expect_LockContainer_fLock = FALSE;
3381 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3382 ok(hres == S_OK, "Close failed: %08x\n", hres);
3383 CHECK_CALLED(GetContainer);
3384 CHECK_CALLED(LockContainer);
3385 container_locked = FALSE;
3388 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3390 IOleObject_Release(oleobj);
3393 static void test_OnFrameWindowActivate(IUnknown *unk)
3395 IOleInPlaceActiveObject *inplaceact;
3398 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3399 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3403 if(set_clientsite) {
3404 expect_OnFrameWindowActivate_fActivate = TRUE;
3405 SET_EXPECT(OnFrameWindowActivate);
3406 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3407 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3408 CHECK_CALLED(OnFrameWindowActivate);
3410 SET_EXPECT(OnFrameWindowActivate);
3411 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3412 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3413 CHECK_CALLED(OnFrameWindowActivate);
3415 expect_OnFrameWindowActivate_fActivate = FALSE;
3416 SET_EXPECT(OnFrameWindowActivate);
3417 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3418 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3419 CHECK_CALLED(OnFrameWindowActivate);
3421 expect_OnFrameWindowActivate_fActivate = TRUE;
3422 SET_EXPECT(OnFrameWindowActivate);
3423 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3424 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3425 CHECK_CALLED(OnFrameWindowActivate);
3427 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3428 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3430 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3431 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3434 IOleInPlaceActiveObject_Release(inplaceact);
3437 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3439 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3442 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3443 (void**)&windowlessobj);
3444 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3449 SET_EXPECT(OnFocus_FALSE);
3451 SET_EXPECT(OnInPlaceDeactivateEx);
3453 SET_EXPECT(OnInPlaceDeactivate);
3455 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3456 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3458 CHECK_CALLED(OnFocus_FALSE);
3460 CHECK_CALLED(OnInPlaceDeactivateEx);
3462 CHECK_CALLED(OnInPlaceDeactivate);
3465 IOleInPlaceObjectWindowless_Release(windowlessobj);
3468 static HRESULT test_Activate(IUnknown *unk, DWORD flags)
3470 IOleObject *oleobj = NULL;
3471 IOleDocumentView *docview;
3478 IOleDocumentView_Release(view);
3481 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3482 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3486 hres = IOleObject_GetUserClassID(oleobj, NULL);
3487 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3489 hres = IOleObject_GetUserClassID(oleobj, &guid);
3490 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3491 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3493 test_OnFrameWindowActivate(unk);
3495 test_ClientSite(oleobj, flags);
3496 test_InPlaceDeactivate(unk, FALSE);
3498 hres = test_DoVerb(oleobj);
3500 if(call_UIActivate == CallUIActivate_AfterShow) {
3501 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3502 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3504 SET_EXPECT(OnFocus_TRUE);
3505 SET_EXPECT(SetActiveObject);
3507 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3508 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3509 expect_status_text = NULL;
3511 hres = IOleDocumentView_UIActivate(docview, TRUE);
3512 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3514 CHECK_CALLED(OnFocus_TRUE);
3515 CHECK_CALLED(SetActiveObject);
3516 CHECK_CALLED(ShowUI);
3517 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3518 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3520 IOleDocumentView_Release(docview);
3523 IOleObject_Release(oleobj);
3525 test_OnFrameWindowActivate(unk);
3530 static void test_Window(IUnknown *unk, BOOL expect_success)
3532 IOleInPlaceActiveObject *activeobject = NULL;
3536 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3537 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3541 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3543 if(expect_success) {
3544 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3545 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3547 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3548 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3551 IOleInPlaceActiveObject_Release(activeobject);
3554 static void test_CloseView(void)
3556 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3562 hres = IOleDocumentView_Show(view, FALSE);
3563 ok(hres == S_OK, "Show failed: %08x\n", hres);
3565 hres = IOleDocumentView_CloseView(view, 0);
3566 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3568 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3569 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3571 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3572 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3573 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3576 static void test_UIDeactivate(void)
3580 if(call_UIActivate == CallUIActivate_AfterShow) {
3581 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3583 if(call_UIActivate != CallUIActivate_None) {
3584 SET_EXPECT(SetActiveObject_null);
3586 SET_EXPECT(OnUIDeactivate);
3589 hres = IOleDocumentView_UIActivate(view, FALSE);
3590 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3592 if(call_UIActivate != CallUIActivate_None) {
3593 CHECK_CALLED(SetActiveObject_null);
3594 CHECK_CALLED(HideUI);
3595 CHECK_CALLED(OnUIDeactivate);
3597 if(call_UIActivate == CallUIActivate_AfterShow) {
3598 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3602 static void test_Hide(void)
3609 hres = IOleDocumentView_Show(view, FALSE);
3610 ok(hres == S_OK, "Show failed: %08x\n", hres);
3613 static HRESULT create_document(IUnknown **unk)
3615 HRESULT hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3616 &IID_IUnknown, (void**)unk);
3617 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3621 static void test_Navigate(IUnknown *unk)
3623 IHlinkTarget *hlink;
3626 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3627 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3629 SET_EXPECT(ActivateMe);
3630 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3631 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3632 CHECK_CALLED(ActivateMe);
3634 IHlinkTarget_Release(hlink);
3637 static void test_external(IUnknown *unk, BOOL initialized)
3639 IDispatch *external;
3640 IHTMLDocument2 *doc;
3641 IHTMLWindow2 *htmlwin;
3644 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3645 ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres);
3647 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
3648 IHTMLDocument2_Release(doc);
3649 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3652 SET_EXPECT(GetExternal);
3653 external = (void*)0xdeadbeef;
3654 hres = IHTMLWindow2_get_external(htmlwin, &external);
3656 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
3657 CHECK_CALLED(GetExternal);
3658 ok(external != NULL, "external == NULL\n");
3660 ok(hres == S_OK, "get_external failed: %08x\n", hres);
3661 ok(external == NULL, "external != NULL\n");
3664 IHTMLWindow2_Release(htmlwin);
3667 static void test_StreamLoad(IUnknown *unk)
3669 IPersistStreamInit *init;
3672 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3673 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3677 SET_EXPECT(Invoke_AMBIENT_SILENT);
3678 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3679 SET_EXPECT(Exec_ShellDocView_37);
3680 SET_EXPECT(OnChanged_READYSTATE);
3682 readystate_set_loading = TRUE;
3684 hres = IPersistStreamInit_Load(init, &Stream);
3685 ok(hres == S_OK, "Load failed: %08x\n", hres);
3687 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3688 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3689 CHECK_CALLED(Exec_ShellDocView_37);
3690 CHECK_CALLED(OnChanged_READYSTATE);
3693 test_timer(EXPECT_SETTITLE);
3694 test_GetCurMoniker(unk, NULL, about_blank_url);
3696 IPersistStreamInit_Release(init);
3699 static void test_QueryInterface(IUnknown *unk)
3704 qi = (void*)0xdeadbeef;
3705 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi);
3706 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3707 ok(qi == NULL, "runnable=%p, ezpected NULL\n", qi);
3709 qi = (void*)0xdeadbeef;
3710 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi);
3711 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3712 ok(qi == NULL, "runnable=%p, ezpected NULL\n", qi);
3714 qi = (void*)0xdeadbeef;
3715 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi);
3716 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3717 ok(qi == NULL, "runnable=%p, ezpected NULL\n", qi);
3720 static void init_test(enum load_state_t ls) {
3722 hwnd = last_hwnd = NULL;
3723 set_clientsite = FALSE;
3724 load_from_stream = FALSE;
3725 call_UIActivate = CallUIActivate_None;
3733 static void test_HTMLDocument(BOOL do_load)
3739 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
3741 init_test(do_load ? LD_DOLOAD : LD_NO);
3743 hres = create_document(&unk);
3748 test_QueryInterface(unk);
3749 test_IsDirty(unk, S_FALSE);
3750 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3751 test_external(unk, FALSE);
3752 test_ConnectionPointContainer(unk);
3753 test_GetCurMoniker(unk, NULL, NULL);
3756 test_OnAmbientPropertyChange2(unk);
3758 hres = test_Activate(unk, CLIENTSITE_EXPECTPATH);
3760 IUnknown_Release(unk);
3765 test_download(FALSE, TRUE, TRUE);
3766 test_GetCurMoniker(unk, &Moniker, NULL);
3769 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3770 test_OleCommandTarget_fail(unk);
3771 test_OleCommandTarget(unk);
3772 test_OnAmbientPropertyChange(unk);
3773 test_Window(unk, TRUE);
3774 test_external(unk, TRUE);
3776 test_UIDeactivate();
3777 test_OleCommandTarget(unk);
3778 test_Window(unk, TRUE);
3779 test_InPlaceDeactivate(unk, TRUE);
3781 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
3782 * MSHTML. It doesn't with Wine. */
3784 test_Window(unk, FALSE);
3786 test_InPlaceDeactivate(unk, FALSE);
3788 test_Close(unk, FALSE);
3790 /* Activate HTMLDocument again */
3791 test_Activate(unk, CLIENTSITE_SETNULL);
3792 test_Window(unk, TRUE);
3793 test_OleCommandTarget(unk);
3794 test_UIDeactivate();
3795 test_InPlaceDeactivate(unk, TRUE);
3796 test_Close(unk, FALSE);
3798 /* Activate HTMLDocument again, this time without UIActivate */
3799 call_UIActivate = CallUIActivate_None;
3800 test_Activate(unk, CLIENTSITE_SETNULL);
3801 test_Window(unk, TRUE);
3803 test_UIDeactivate();
3804 test_InPlaceDeactivate(unk, TRUE);
3807 test_Close(unk, TRUE);
3808 test_OnAmbientPropertyChange2(unk);
3809 test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3812 /* Activate HTMLDocument again, calling UIActivate after showing the window */
3813 call_UIActivate = CallUIActivate_AfterShow;
3814 test_Activate(unk, 0);
3815 test_Window(unk, TRUE);
3816 test_OleCommandTarget(unk);
3817 test_UIDeactivate();
3818 test_InPlaceDeactivate(unk, TRUE);
3819 test_Close(unk, FALSE);
3820 call_UIActivate = CallUIActivate_None;
3824 IOleDocumentView_Release(view);
3827 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3829 ref = IUnknown_Release(unk);
3830 ok(ref == 0, "ref=%d, expected 0\n", ref);
3832 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3835 static void test_HTMLDocument_hlink(void)
3841 trace("Testing HTMLDocument (hlink)...\n");
3843 init_test(LD_DOLOAD);
3846 hres = create_document(&unk);
3851 test_ConnectionPointContainer(unk);
3852 test_GetCurMoniker(unk, NULL, NULL);
3856 test_download(FALSE, TRUE, TRUE);
3858 test_IsDirty(unk, S_FALSE);
3859 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3861 test_exec_onunload(unk);
3862 test_Window(unk, TRUE);
3863 test_InPlaceDeactivate(unk, TRUE);
3864 test_Close(unk, FALSE);
3865 test_IsDirty(unk, S_FALSE);
3866 test_GetCurMoniker(unk, &Moniker, NULL);
3869 IOleDocumentView_Release(view);
3872 ref = IUnknown_Release(unk);
3873 ok(ref == 0, "ref=%d, expected 0\n", ref);
3876 static void test_HTMLDocument_StreamLoad(void)
3883 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3885 init_test(LD_DOLOAD);
3886 load_from_stream = TRUE;
3888 hres = create_document(&unk);
3893 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3894 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3896 test_readyState(unk);
3897 test_IsDirty(unk, S_FALSE);
3898 test_ConnectionPointContainer(unk);
3899 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3900 test_DoVerb(oleobj);
3901 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3903 IOleObject_Release(oleobj);
3905 test_GetCurMoniker(unk, NULL, NULL);
3906 test_StreamLoad(unk);
3907 test_download(TRUE, FALSE, TRUE);
3908 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3910 test_UIDeactivate();
3911 test_InPlaceDeactivate(unk, TRUE);
3912 test_Close(unk, FALSE);
3913 test_IsDirty(unk, S_FALSE);
3916 IOleDocumentView_Release(view);
3921 ref = IUnknown_Release(unk);
3922 ok(ref == 0, "ref=%d, expected 0\n", ref);
3925 static void test_edit_uiactivate(IOleObject *oleobj)
3927 IOleDocumentView *docview;
3930 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3931 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3933 SET_EXPECT(OnFocus_TRUE);
3934 SET_EXPECT(SetActiveObject);
3936 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3937 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3938 expect_status_text = NULL;
3940 hres = IOleDocumentView_UIActivate(docview, TRUE);
3941 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3943 CHECK_CALLED(OnFocus_TRUE);
3944 CHECK_CALLED(SetActiveObject);
3945 CHECK_CALLED(ShowUI);
3946 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3947 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3949 IOleDocumentView_Release(docview);
3952 static void test_editing_mode(BOOL do_load)
3959 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
3961 init_test(do_load ? LD_DOLOAD : LD_NO);
3962 call_UIActivate = CallUIActivate_AfterShow;
3964 hres = create_document(&unk);
3969 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3970 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3972 test_readyState(unk);
3973 test_ConnectionPointContainer(unk);
3974 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3975 test_DoVerb(oleobj);
3976 test_edit_uiactivate(oleobj);
3978 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3981 stream_read = protocol_read = 0;
3982 test_exec_editmode(unk, do_load);
3983 test_UIDeactivate();
3984 call_UIActivate = CallUIActivate_None;
3985 IOleObject_Release(oleobj);
3987 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3988 test_download(TRUE, do_load, do_load);
3989 test_timer(EXPECT_UPDATEUI);
3990 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
3993 test_exec_fontname(unk, NULL, wszTimesNewRoman);
3994 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
3995 test_timer(EXPECT_UPDATEUI);
3996 test_exec_fontname(unk, NULL, wszArial);
3998 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
3999 test_timer(EXPECT_UPDATEUI);
4001 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4002 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4004 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4005 test_timer(EXPECT_UPDATEUI);
4006 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4007 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4009 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4010 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4012 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4013 test_timer(EXPECT_UPDATEUI);
4014 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4015 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4018 test_UIDeactivate();
4019 test_InPlaceDeactivate(unk, TRUE);
4020 test_Close(unk, FALSE);
4023 IOleDocumentView_Release(view);
4027 ref = IUnknown_Release(unk);
4028 ok(ref == 0, "ref=%d, expected 0\n", ref);
4031 static void register_protocol(void)
4033 IInternetSession *session;
4036 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
4038 hres = CoInternetGetSession(0, &session, 0);
4039 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
4041 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
4042 wsz_winetest, 0, NULL, 0);
4043 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
4045 IInternetSession_Release(session);
4048 static void gecko_installer_workaround(BOOL disable)
4053 static BOOL has_url = FALSE;
4054 static char url[2048];
4056 if(!disable && !has_url)
4059 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4060 if(res != ERROR_SUCCESS)
4064 DWORD type, size = sizeof(url);
4066 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4067 if(res == ERROR_SUCCESS && type == REG_SZ)
4070 RegDeleteValue(hkey, "GeckoUrl");
4072 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4080 gecko_installer_workaround(TRUE);
4083 container_hwnd = create_container_window();
4084 register_protocol();
4086 test_HTMLDocument(FALSE);
4087 test_HTMLDocument(TRUE);
4088 test_HTMLDocument_hlink();
4089 test_HTMLDocument_StreamLoad();
4090 test_editing_mode(FALSE);
4091 test_editing_mode(TRUE);
4093 DestroyWindow(container_hwnd);
4096 gecko_installer_workaround(FALSE);