2 * Copyright 2005-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
40 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
41 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
42 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
44 #define DEFINE_EXPECT(func) \
45 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
47 #define SET_EXPECT(func) \
48 expect_ ## func = TRUE
50 #define SET_CALLED(func) \
51 called_ ## func = TRUE
53 #define CHECK_EXPECT2(func) \
55 ok(expect_ ##func, "unexpected call " #func "\n"); \
56 called_ ## func = TRUE; \
59 #define CHECK_EXPECT(func) \
61 CHECK_EXPECT2(func); \
62 expect_ ## func = FALSE; \
65 #define CHECK_CALLED(func) \
67 ok(called_ ## func, "expected " #func "\n"); \
68 expect_ ## func = called_ ## func = FALSE; \
71 static IOleDocumentView *view = NULL;
72 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
74 DEFINE_EXPECT(LockContainer);
75 DEFINE_EXPECT(SetActiveObject);
76 DEFINE_EXPECT(SetActiveObject_null);
77 DEFINE_EXPECT(GetWindow);
78 DEFINE_EXPECT(CanInPlaceActivate);
79 DEFINE_EXPECT(OnInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivateEx);
81 DEFINE_EXPECT(OnUIActivate);
82 DEFINE_EXPECT(GetWindowContext);
83 DEFINE_EXPECT(OnUIDeactivate);
84 DEFINE_EXPECT(OnInPlaceDeactivate);
85 DEFINE_EXPECT(OnInPlaceDeactivateEx);
86 DEFINE_EXPECT(GetContainer);
87 DEFINE_EXPECT(ShowUI);
88 DEFINE_EXPECT(ActivateMe);
89 DEFINE_EXPECT(GetHostInfo);
90 DEFINE_EXPECT(HideUI);
91 DEFINE_EXPECT(GetOptionKeyPath);
92 DEFINE_EXPECT(GetOverrideKeyPath);
93 DEFINE_EXPECT(SetStatusText);
94 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
95 DEFINE_EXPECT(QueryStatus_OPEN);
96 DEFINE_EXPECT(QueryStatus_NEW);
97 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
98 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
99 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
100 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
101 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
102 DEFINE_EXPECT(Exec_ShellDocView_37);
103 DEFINE_EXPECT(Exec_ShellDocView_84);
104 DEFINE_EXPECT(Exec_ShellDocView_103);
105 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
106 DEFINE_EXPECT(Exec_SETTITLE);
107 DEFINE_EXPECT(Exec_HTTPEQUIV);
108 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
109 DEFINE_EXPECT(Exec_Explorer_69);
110 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
111 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
112 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
113 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
114 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
115 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
116 DEFINE_EXPECT(GetDropTarget);
117 DEFINE_EXPECT(UpdateUI);
118 DEFINE_EXPECT(Navigate);
119 DEFINE_EXPECT(OnFrameWindowActivate);
120 DEFINE_EXPECT(OnChanged_READYSTATE);
121 DEFINE_EXPECT(OnChanged_1005);
122 DEFINE_EXPECT(GetDisplayName);
123 DEFINE_EXPECT(BindToStorage);
124 DEFINE_EXPECT(IsSystemMoniker);
125 DEFINE_EXPECT(GetBindResult);
126 DEFINE_EXPECT(GetClassID);
127 DEFINE_EXPECT(Abort);
129 DEFINE_EXPECT(CreateInstance);
130 DEFINE_EXPECT(Start);
131 DEFINE_EXPECT(Terminate);
132 DEFINE_EXPECT(Protocol_Read);
133 DEFINE_EXPECT(LockRequest);
134 DEFINE_EXPECT(UnlockRequest);
135 DEFINE_EXPECT(OnFocus_TRUE);
136 DEFINE_EXPECT(OnFocus_FALSE);
137 DEFINE_EXPECT(RequestUIActivate);
138 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
139 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
140 DEFINE_EXPECT(GetExternal);
141 DEFINE_EXPECT(EnableModeless_TRUE);
142 DEFINE_EXPECT(EnableModeless_FALSE);
143 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
144 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
146 static IUnknown *doc_unk;
147 static BOOL expect_LockContainer_fLock;
148 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
150 static BOOL set_clientsite = FALSE, container_locked = FALSE;
151 static BOOL readystate_set_loading = FALSE, load_from_stream;
152 static BOOL editmode = FALSE, show_failed;
153 static int stream_read, protocol_read;
154 static enum load_state_t {
163 static LPCOLESTR expect_status_text = NULL;
165 static const char html_page[] =
167 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
171 static const char css_data[] = "body {color: red}";
173 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
174 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
176 static HRESULT QueryInterface(REFIID riid, void **ppv);
177 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
178 static BOOL nogecko = FALSE;
180 #define test_readyState(u) _test_readyState(__LINE__,u)
181 static void _test_readyState(unsigned,IUnknown*);
183 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
185 static const WCHAR wszTimesNewRoman[] =
186 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
187 static const WCHAR wszArial[] =
188 {'A','r','i','a','l',0};
190 static const char *debugstr_guid(REFIID riid)
194 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
195 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
196 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
197 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
202 static const char *debugstr_w(LPCWSTR str)
204 static char buf[1024];
209 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
213 #define EXPECT_UPDATEUI 1
214 #define EXPECT_SETTITLE 2
216 static void test_timer(DWORD flags)
218 BOOL *b = &called_Exec_SETTITLE;
221 if(flags & EXPECT_UPDATEUI) {
222 SET_EXPECT(UpdateUI);
223 SET_EXPECT(Exec_UPDATECOMMANDS);
224 b = &called_UpdateUI;
226 if(flags & EXPECT_SETTITLE)
227 SET_EXPECT(Exec_SETTITLE);
229 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
230 TranslateMessage(&msg);
231 DispatchMessage(&msg);
234 if(flags & EXPECT_UPDATEUI) {
235 CHECK_CALLED(UpdateUI);
236 CHECK_CALLED(Exec_UPDATECOMMANDS);
238 if(flags & EXPECT_SETTITLE)
239 CHECK_CALLED(Exec_SETTITLE);
242 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
244 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
248 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
253 if(IsEqualGUID(&IID_IProxyManager, riid))
254 return E_NOINTERFACE; /* TODO */
255 if(IsEqualGUID(&IID_IDispatchEx, riid))
256 return E_NOINTERFACE; /* TODO */
257 if(IsEqualGUID(&IID_External_unk, riid))
258 return E_NOINTERFACE; /* TODO */
260 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
261 return E_NOINTERFACE;
264 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
269 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
274 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
276 ok(0, "unexpected call\n");
280 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
283 ok(0, "unexpected call\n");
287 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
288 UINT cNames, LCID lcid, DISPID *rgDispId)
290 ok(0, "unexpected call\n");
294 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
295 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
296 EXCEPINFO *pExcepInfo, UINT *puArgErr)
298 ok(0, "unexpected call\n");
302 static const IDispatchVtbl ExternalVtbl = {
303 External_QueryInterface,
306 Dispatch_GetTypeInfoCount,
307 Dispatch_GetTypeInfo,
308 Dispatch_GetIDsOfNames,
312 static IDispatch External = { &ExternalVtbl };
314 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
316 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
322 return E_NOINTERFACE;
325 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
330 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
335 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
336 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
337 DWORD grfPI, DWORD dwReserved)
343 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
344 static const WCHAR empty_str = {0};
348 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
349 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
350 ok(!grfPI, "grfPI = %x\n", grfPI);
351 ok(!dwReserved, "dwReserved = %d\n", dwReserved);
353 memset(&bindinfo, 0, sizeof(bindinfo));
354 bindinfo.cbSize = sizeof(bindinfo);
355 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
356 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
357 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
358 "bindf = %x\n", bindf);
360 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
361 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
362 /* TODO: test stgmedData */
363 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
364 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
365 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
366 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
367 ok(bindinfo.dwOptions == 0x80000 ||
368 bindinfo.dwOptions == 0x4080000, /* win2k3 */
369 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
370 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
371 /* TODO: test dwCodePage */
372 /* TODO: test securityAttributes */
373 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
374 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
375 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
377 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
378 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
379 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
381 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
382 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
384 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
386 hres = IInternetProtocolSink_ReportData(pOIProtSink,
387 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
388 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
390 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
391 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
396 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
397 PROTOCOLDATA *pProtocolData)
399 ok(0, "unexpected call\n");
403 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
406 ok(0, "unexpected call\n");
410 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
412 CHECK_EXPECT(Terminate);
416 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
418 ok(0, "unexpected call\n");
422 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
424 ok(0, "unexpected call\n");
428 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
429 ULONG cb, ULONG *pcbRead)
431 CHECK_EXPECT2(Protocol_Read);
433 ok(pv != NULL, "pv == NULL\n");
434 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
435 ok(pcbRead != NULL, "pcbRead == NULL\n");
436 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
441 protocol_read += *pcbRead = sizeof(css_data)-1;
442 memcpy(pv, css_data, sizeof(css_data)-1);
446 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
447 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
449 ok(0, "unexpected call\n");
453 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
455 CHECK_EXPECT(LockRequest);
459 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
461 CHECK_EXPECT(UnlockRequest);
465 static const IInternetProtocolVtbl ProtocolVtbl = {
466 Protocol_QueryInterface,
477 Protocol_LockRequest,
478 Protocol_UnlockRequest
481 static IInternetProtocol Protocol = { &ProtocolVtbl };
483 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
485 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
486 ok(0, "unexpected call\n");
487 return E_NOINTERFACE;
490 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
495 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
500 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
501 REFIID riid, void **ppv)
503 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
504 return E_NOINTERFACE;
506 CHECK_EXPECT(CreateInstance);
507 ok(ppv != NULL, "ppv == NULL\n");
513 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
515 ok(0, "unexpected call\n");
519 static const IClassFactoryVtbl ClassFactoryVtbl = {
520 ClassFactory_QueryInterface,
522 ClassFactory_Release,
523 ClassFactory_CreateInstance,
524 ClassFactory_LockServer
527 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
529 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
531 ok(0, "unexpected call\n");
535 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
540 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
545 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
546 IHlinkBrowseContext *pihlbc)
548 ok(0, "unexpected call\n");
552 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
553 IHlinkBrowseContext **ppihlbc)
555 ok(0, "unexpected call\n");
559 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
560 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
564 CHECK_EXPECT(Navigate);
566 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
567 ok(pbc != NULL, "pbc == NULL\n");
568 ok(pibsc != NULL, "pubsc == NULL\n");
569 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
572 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
573 LPWSTR location = (LPWSTR)0xdeadbeef;
575 IMoniker *mon = NULL;
576 DWORD site_data = 0xdeadbeef;
578 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
579 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
580 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
582 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
583 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
584 ok(location == NULL, "location = %p\n", location);
585 ok(mon != NULL, "mon == NULL\n");
587 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
588 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
589 ok(site == NULL, "site = %p\n, expected NULL\n", site);
590 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
596 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
597 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
599 ok(0, "unexpected call\n");
603 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
604 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
606 ok(0, "unexpected call\n");
610 static const IHlinkFrameVtbl HlinkFrameVtbl = {
611 HlinkFrame_QueryInterface,
614 HlinkFrame_SetBrowseContext,
615 HlinkFrame_GetBrowseContext,
617 HlinkFrame_OnNavigate,
618 HlinkFrame_UpdateHlink
621 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
623 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
624 REFIID riid, void**ppv)
626 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
631 ok(0, "unexpected call\n");
632 return E_NOINTERFACE;
635 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
640 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
645 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
648 case DISPID_READYSTATE:
649 CHECK_EXPECT2(OnChanged_READYSTATE);
650 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
651 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
652 ? OLECMDF_ENABLED : 0));
654 if(readystate_set_loading) {
655 readystate_set_loading = FALSE;
656 load_state = LD_LOADING;
658 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
659 test_readyState(NULL);
662 CHECK_EXPECT(OnChanged_1005);
664 test_readyState(NULL);
665 load_state = LD_INTERACTIVE;
669 ok(0, "unexpected id %d\n", dispID);
673 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
675 ok(0, "unexpected call\n");
679 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
680 PropertyNotifySink_QueryInterface,
681 PropertyNotifySink_AddRef,
682 PropertyNotifySink_Release,
683 PropertyNotifySink_OnChanged,
684 PropertyNotifySink_OnRequestEdit
687 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
689 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
691 ok(0, "unexpected call\n");
692 return E_NOINTERFACE;
695 static ULONG WINAPI Stream_AddRef(IStream *iface)
700 static ULONG WINAPI Stream_Release(IStream *iface)
705 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
706 ULONG cb, ULONG *pcbRead)
709 ok(pv != NULL, "pv == NULL\n");
710 ok(cb > sizeof(html_page), "cb = %d\n", cb);
711 ok(pcbRead != NULL, "pcbRead == NULL\n");
712 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
717 memcpy(pv, html_page, sizeof(html_page)-1);
718 stream_read += *pcbRead = sizeof(html_page)-1;
722 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
723 ULONG cb, ULONG *pcbWritten)
725 ok(0, "unexpected call\n");
729 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
730 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
732 ok(0, "unexpected call\n");
736 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
738 ok(0, "unexpected call\n");
742 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
743 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
745 ok(0, "unexpected call\n");
749 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
751 ok(0, "unexpected call\n");
755 static HRESULT WINAPI Stream_Revert(IStream *iface)
757 ok(0, "unexpected call\n");
761 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
762 ULARGE_INTEGER cb, DWORD dwLockType)
764 ok(0, "unexpected call\n");
768 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
769 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
771 ok(0, "unexpected call\n");
775 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
778 ok(0, "unexpected call\n");
782 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
784 ok(0, "unexpected call\n");
788 static const IStreamVtbl StreamVtbl = {
789 Stream_QueryInterface,
805 static IStream Stream = { &StreamVtbl };
807 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
809 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
810 return E_NOINTERFACE; /* TODO */
812 if(IsEqualGUID(&IID_IWinInetInfo, riid))
813 return E_NOINTERFACE; /* TODO */
815 ok(0, "unexpected call\n");
816 return E_NOINTERFACE;
819 static ULONG WINAPI Binding_AddRef(IBinding *iface)
824 static ULONG WINAPI Binding_Release(IBinding *iface)
829 static HRESULT WINAPI Binding_Abort(IBinding *iface)
835 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
837 ok(0, "unexpected call\n");
841 static HRESULT WINAPI Binding_Resume(IBinding *iface)
843 ok(0, "unexpected call\n");
847 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
849 ok(0, "unexpected call\n");
853 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
855 ok(0, "unexpected call\n");
859 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
860 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
862 CHECK_EXPECT(GetBindResult);
866 static const IBindingVtbl BindingVtbl = {
867 Binding_QueryInterface,
875 Binding_GetBindResult
878 static IBinding Binding = { &BindingVtbl };
880 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
881 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
883 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
887 if(IsEqualGUID(&IID_IMoniker_unk, riid))
888 return E_NOINTERFACE; /* TODO */
889 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
890 return E_NOINTERFACE; /* TODO */
892 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
893 return E_NOINTERFACE;
896 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
901 static ULONG WINAPI Moniker_Release(IMoniker *iface)
906 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
908 CHECK_EXPECT(GetClassID);
909 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
913 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
915 ok(0, "unexpected call\n");
919 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
921 ok(0, "unexpected call\n");
925 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
927 ok(0, "unexpected call\n");
931 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
933 ok(0, "unexpected call\n");
937 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
938 REFIID riidResult, void **ppvResult)
940 ok(0, "unexpected call\n");
944 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
945 REFIID riid, void **ppv)
947 IBindStatusCallback *callback = NULL;
948 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
954 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
955 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
957 CHECK_EXPECT(BindToStorage);
959 load_state = LD_LOADING;
961 ok(pbc != NULL, "pbc == NULL\n");
962 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
963 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
964 ok(ppv != NULL, "ppv == NULL\n");
965 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
967 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
968 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
969 ok(callback != NULL, "callback == NULL\n");
971 memset(&bindinfo, 0xf0, sizeof(bindinfo));
972 bindinfo.cbSize = sizeof(bindinfo);
974 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
975 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
976 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
977 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
978 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
979 /* TODO: test stgmedData */
980 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
981 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
982 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
983 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
984 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
985 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
986 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
987 /* TODO: test dwCodePage */
988 /* TODO: test securityAttributes */
989 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
990 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
991 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
993 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
994 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
996 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
998 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1000 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1001 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1002 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1005 stgmedium.tymed = TYMED_ISTREAM;
1006 U(stgmedium).pstm = &Stream;
1007 stgmedium.pUnkForRelease = (IUnknown*)iface;
1008 hres = IBindStatusCallback_OnDataAvailable(callback,
1009 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1010 sizeof(html_page)-1, &formatetc, &stgmedium);
1011 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1014 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1015 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1016 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1018 SET_EXPECT(GetBindResult);
1019 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1020 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1021 SET_CALLED(GetBindResult); /* IE7 */
1023 IBindStatusCallback_Release(callback);
1028 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1029 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1031 ok(0, "unexpected call\n");
1035 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1036 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1038 ok(0, "unexpected call\n");
1042 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1044 ok(0, "unexpected call\n");
1048 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1050 ok(0, "unexpected call\n");
1054 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1056 ok(0, "unexpected call\n");
1060 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1061 IMoniker *pmkNewlyRunning)
1063 ok(0, "unexpected call\n");
1067 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1068 IMoniker *pmkToLeft, FILETIME *pFileTime)
1070 ok(0, "unexpected call\n");
1074 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1076 ok(0, "unexpected call\n");
1080 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1081 IMoniker **ppmkPrefix)
1083 ok(0, "unexpected call\n");
1087 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1088 IMoniker **pmkRelPath)
1090 ok(0, "unexpected call\n");
1094 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1095 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1097 CHECK_EXPECT2(GetDisplayName);
1099 /* ok(pbc != NULL, "pbc == NULL\n"); */
1100 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1101 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1103 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1104 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1109 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1110 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1112 ok(0, "unexpected call\n");
1116 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1118 CHECK_EXPECT(IsSystemMoniker);
1122 static const IMonikerVtbl MonikerVtbl = {
1123 Moniker_QueryInterface,
1131 Moniker_BindToObject,
1132 Moniker_BindToStorage,
1134 Moniker_ComposeWith,
1139 Moniker_GetTimeOfLastChange,
1141 Moniker_CommonPrefixWith,
1142 Moniker_RelativePathTo,
1143 Moniker_GetDisplayName,
1144 Moniker_ParseDisplayName,
1145 Moniker_IsSystemMoniker
1148 static IMoniker Moniker = { &MonikerVtbl };
1150 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1152 return QueryInterface(riid, ppv);
1155 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1160 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1165 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1166 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1168 ok(0, "unexpected call\n");
1172 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1173 IEnumUnknown **ppenum)
1175 ok(0, "unexpected call\n");
1179 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1181 CHECK_EXPECT(LockContainer);
1182 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1186 static const IOleContainerVtbl OleContainerVtbl = {
1187 OleContainer_QueryInterface,
1188 OleContainer_AddRef,
1189 OleContainer_Release,
1190 OleContainer_ParseDisplayName,
1191 OleContainer_EnumObjects,
1192 OleContainer_LockContainer
1195 static IOleContainer OleContainer = { &OleContainerVtbl };
1197 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1199 ok(0, "unexpected call\n");
1200 return E_NOINTERFACE;
1203 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1208 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1213 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1215 ok(0, "unexpected call\n");
1219 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1221 ok(0, "unexpected call\n");
1225 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1227 ok(0, "unexpected call\n");
1231 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1232 LPCBORDERWIDTHS pborderwidths)
1234 ok(0, "unexpected call\n");
1238 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1239 LPCBORDERWIDTHS pborderwidths)
1241 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1245 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1246 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1248 static const WCHAR wszHTML_Document[] =
1249 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1251 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1253 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1254 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1255 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1256 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1259 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1260 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1262 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1266 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1267 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1269 static const WCHAR wszHTML_Document[] =
1270 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1273 CHECK_EXPECT2(SetActiveObject);
1275 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1276 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1278 CHECK_EXPECT(SetActiveObject_null);
1280 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1281 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1287 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1288 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1290 ok(0, "unexpected call\n");
1294 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1295 HOLEMENU holemenu, HWND hwndActiveObject)
1297 ok(0, "unexpected call\n");
1301 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1303 ok(0, "unexpected call\n");
1307 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1309 CHECK_EXPECT2(SetStatusText);
1310 if(!expect_status_text)
1311 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1315 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1318 CHECK_EXPECT(Frame_EnableModeless_TRUE);
1320 CHECK_EXPECT(Frame_EnableModeless_FALSE);
1324 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1326 ok(0, "unexpected call\n");
1330 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1331 InPlaceFrame_QueryInterface,
1332 InPlaceFrame_AddRef,
1333 InPlaceFrame_Release,
1334 InPlaceFrame_GetWindow,
1335 InPlaceFrame_ContextSensitiveHelp,
1336 InPlaceFrame_GetBorder,
1337 InPlaceFrame_RequestBorderSpace,
1338 InPlaceFrame_SetBorderSpace,
1339 InPlaceFrame_SetActiveObject,
1340 InPlaceFrame_InsertMenus,
1341 InPlaceFrame_SetMenu,
1342 InPlaceFrame_RemoveMenus,
1343 InPlaceFrame_SetStatusText,
1344 InPlaceFrame_EnableModeless,
1345 InPlaceFrame_TranslateAccelerator
1348 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1350 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1351 InPlaceFrame_QueryInterface,
1352 InPlaceFrame_AddRef,
1353 InPlaceFrame_Release,
1354 InPlaceFrame_GetWindow,
1355 InPlaceFrame_ContextSensitiveHelp,
1356 InPlaceFrame_GetBorder,
1357 InPlaceFrame_RequestBorderSpace,
1358 InPlaceFrame_SetBorderSpace,
1359 InPlaceUIWindow_SetActiveObject,
1362 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1364 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1366 return QueryInterface(riid, ppv);
1369 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1374 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1379 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1381 CHECK_EXPECT(GetWindow);
1382 ok(phwnd != NULL, "phwnd = NULL\n");
1383 *phwnd = container_hwnd;
1387 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1389 ok(0, "unexpected call\n");
1393 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1395 CHECK_EXPECT(CanInPlaceActivate);
1399 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1401 CHECK_EXPECT(OnInPlaceActivate);
1405 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1407 CHECK_EXPECT(OnUIActivate);
1411 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1412 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1413 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1415 static const RECT rect = {0,0,500,500};
1417 CHECK_EXPECT(GetWindowContext);
1419 ok(ppFrame != NULL, "ppFrame = NULL\n");
1421 *ppFrame = &InPlaceFrame;
1422 ok(ppDoc != NULL, "ppDoc = NULL\n");
1424 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1425 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1427 memcpy(lprcPosRect, &rect, sizeof(RECT));
1428 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1430 memcpy(lprcClipRect, &rect, sizeof(RECT));
1431 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1433 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1434 lpFrameInfo->fMDIApp = FALSE;
1435 lpFrameInfo->hwndFrame = container_hwnd;
1436 lpFrameInfo->haccel = NULL;
1437 lpFrameInfo->cAccelEntries = 0;
1443 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1445 ok(0, "unexpected call\n");
1449 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1451 CHECK_EXPECT(OnUIDeactivate);
1452 ok(!fUndoable, "fUndoable = TRUE\n");
1456 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1458 CHECK_EXPECT(OnInPlaceDeactivate);
1462 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1464 ok(0, "unexpected call\n");
1468 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1470 ok(0, "unexpected call\n");
1474 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1476 ok(0, "unexpected call\n");
1480 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1482 CHECK_EXPECT(OnInPlaceActivateEx);
1484 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1485 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1486 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1491 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1493 CHECK_EXPECT(OnInPlaceDeactivateEx);
1495 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1500 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1502 CHECK_EXPECT(RequestUIActivate);
1506 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1507 InPlaceSite_QueryInterface,
1509 InPlaceSite_Release,
1510 InPlaceSite_GetWindow,
1511 InPlaceSite_ContextSensitiveHelp,
1512 InPlaceSite_CanInPlaceActivate,
1513 InPlaceSite_OnInPlaceActivate,
1514 InPlaceSite_OnUIActivate,
1515 InPlaceSite_GetWindowContext,
1517 InPlaceSite_OnUIDeactivate,
1518 InPlaceSite_OnInPlaceDeactivate,
1519 InPlaceSite_DiscardUndoState,
1520 InPlaceSite_DeactivateAndUndo,
1521 InPlaceSite_OnPosRectChange,
1522 InPlaceSiteEx_OnInPlaceActivateEx,
1523 InPlaceSiteEx_OnInPlaceDeactivateEx,
1524 InPlaceSiteEx_RequestUIActivate
1527 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1529 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1531 return QueryInterface(riid, ppv);
1534 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1539 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1544 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1546 ok(0, "unexpected call\n");
1550 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1553 ok(0, "unexpected call\n");
1557 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1559 CHECK_EXPECT(GetContainer);
1560 ok(ppContainer != NULL, "ppContainer = NULL\n");
1561 *ppContainer = &OleContainer;
1565 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1567 ok(0, "unexpected call\n");
1571 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1573 ok(0, "unexpected call\n");
1577 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1579 ok(0, "unexpected call\n");
1583 static const IOleClientSiteVtbl ClientSiteVtbl = {
1584 ClientSite_QueryInterface,
1587 ClientSite_SaveObject,
1588 ClientSite_GetMoniker,
1589 ClientSite_GetContainer,
1590 ClientSite_ShowObject,
1591 ClientSite_OnShowWindow,
1592 ClientSite_RequestNewObjectLayout
1595 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1597 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1599 return QueryInterface(riid, ppv);
1602 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1607 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1614 CallUIActivate_None,
1615 CallUIActivate_ActivateMe,
1616 CallUIActivate_AfterShow,
1619 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1620 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1622 IOleDocument *document;
1625 CHECK_EXPECT(ActivateMe);
1626 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1628 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1629 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1631 if(SUCCEEDED(hres)) {
1632 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1633 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1635 if(SUCCEEDED(hres)) {
1636 IOleInPlaceActiveObject *activeobj = NULL;
1637 IOleInPlaceSite *inplacesite = NULL;
1638 HWND tmp_hwnd = NULL;
1639 static RECT rect = {0,0,400,500};
1641 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1642 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1643 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1644 inplacesite, &InPlaceSiteEx);
1646 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1647 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1649 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1650 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1651 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1652 inplacesite, &InPlaceSiteEx);
1654 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1655 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1658 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1659 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1660 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1663 if(call_UIActivate == CallUIActivate_ActivateMe) {
1664 SET_EXPECT(CanInPlaceActivate);
1665 SET_EXPECT(GetWindowContext);
1666 SET_EXPECT(GetWindow);
1668 SET_EXPECT(OnInPlaceActivateEx);
1670 SET_EXPECT(OnInPlaceActivate);
1671 SET_EXPECT(SetStatusText);
1672 SET_EXPECT(Exec_SETPROGRESSMAX);
1673 SET_EXPECT(Exec_SETPROGRESSPOS);
1674 SET_EXPECT(OnUIActivate);
1675 SET_EXPECT(SetActiveObject);
1677 expect_status_text = NULL;
1679 hres = IOleDocumentView_UIActivate(view, TRUE);
1680 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1682 CHECK_CALLED(CanInPlaceActivate);
1683 CHECK_CALLED(GetWindowContext);
1684 CHECK_CALLED(GetWindow);
1686 CHECK_CALLED(OnInPlaceActivateEx);
1688 CHECK_CALLED(OnInPlaceActivate);
1689 CHECK_CALLED(SetStatusText);
1690 CHECK_CALLED(Exec_SETPROGRESSMAX);
1691 CHECK_CALLED(Exec_SETPROGRESSPOS);
1692 CHECK_CALLED(OnUIActivate);
1693 CHECK_CALLED(SetActiveObject);
1694 CHECK_CALLED(ShowUI);
1697 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1698 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1699 ok(hwnd != NULL, "hwnd == NULL\n");
1701 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1704 hres = IOleDocumentView_UIActivate(view, TRUE);
1705 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1708 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1709 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1710 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1714 hres = IOleDocumentView_SetRect(view, &rect);
1715 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1717 if(call_UIActivate == CallUIActivate_ActivateMe) {
1718 hres = IOleDocumentView_Show(view, TRUE);
1719 ok(hres == S_OK, "Show failed: %08x\n", hres);
1721 SET_EXPECT(CanInPlaceActivate);
1722 SET_EXPECT(GetWindowContext);
1723 SET_EXPECT(GetWindow);
1725 SET_EXPECT(OnInPlaceActivateEx);
1727 SET_EXPECT(OnInPlaceActivate);
1728 SET_EXPECT(SetStatusText);
1729 SET_EXPECT(Exec_SETPROGRESSMAX);
1730 SET_EXPECT(Exec_SETPROGRESSPOS);
1731 SET_EXPECT(OnUIActivate);
1732 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1734 hres = IOleDocumentView_Show(view, TRUE);
1736 win_skip("Show failed\n");
1738 IOleInPlaceActiveObject_Release(activeobj);
1739 IOleDocument_Release(document);
1743 ok(hres == S_OK, "Show failed: %08x\n", hres);
1745 CHECK_CALLED(CanInPlaceActivate);
1746 CHECK_CALLED(GetWindowContext);
1747 CHECK_CALLED(GetWindow);
1749 CHECK_CALLED(OnInPlaceActivateEx);
1751 CHECK_CALLED(OnInPlaceActivate);
1752 CHECK_CALLED(SetStatusText);
1753 CHECK_CALLED(Exec_SETPROGRESSMAX);
1754 CHECK_CALLED(Exec_SETPROGRESSPOS);
1757 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1758 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1759 ok(hwnd != NULL, "hwnd == NULL\n");
1761 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1765 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1768 IOleInPlaceActiveObject_Release(activeobj);
1771 IOleDocument_Release(document);
1777 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1778 DocumentSite_QueryInterface,
1779 DocumentSite_AddRef,
1780 DocumentSite_Release,
1781 DocumentSite_ActivateMe
1784 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1786 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1788 return QueryInterface(riid, ppv);
1791 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1796 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1801 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1803 ok(0, "unexpected call\n");
1807 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1809 ok(0, "unexpected call\n");
1813 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1815 ok(0, "unexpected call\n");
1819 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1820 POINTF *pPtfContainer, DWORD dwFlags)
1822 ok(0, "unexpected call\n");
1826 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1827 MSG *pMsg, DWORD grfModifiers)
1829 ok(0, "unexpected call\n");
1833 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1836 CHECK_EXPECT(OnFocus_TRUE);
1838 CHECK_EXPECT2(OnFocus_FALSE);
1842 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1844 ok(0, "unexpected call\n");
1848 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1849 OleControlSite_QueryInterface,
1850 OleControlSite_AddRef,
1851 OleControlSite_Release,
1852 OleControlSite_OnControlInfoChanged,
1853 OleControlSite_LockInPlaceActive,
1854 OleControlSite_GetExtendedControl,
1855 OleControlSite_TransformCoords,
1856 OleControlSite_TranslateAccelerator,
1857 OleControlSite_OnFocus,
1858 OleControlSite_ShowPropertyFrame
1861 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1863 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1865 return QueryInterface(riid, ppv);
1868 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1873 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1878 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1879 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1881 ok(0, "unexpected call\n");
1885 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1887 CHECK_EXPECT(GetHostInfo);
1888 ok(pInfo != NULL, "pInfo=NULL\n");
1890 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1891 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1892 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1893 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1894 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1895 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1896 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1897 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1902 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1903 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1904 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1906 CHECK_EXPECT(ShowUI);
1909 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1911 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1912 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1913 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1914 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1915 if (expect_InPlaceUIWindow_SetActiveObject_active)
1916 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
1918 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1923 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1925 CHECK_EXPECT(HideUI);
1929 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1931 CHECK_EXPECT(UpdateUI);
1935 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1938 CHECK_EXPECT(EnableModeless_TRUE);
1940 CHECK_EXPECT(EnableModeless_FALSE);
1944 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1946 ok(0, "unexpected call\n");
1950 static BOOL expect_OnFrameWindowActivate_fActivate;
1951 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1953 CHECK_EXPECT2(OnFrameWindowActivate);
1954 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1958 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1959 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1961 ok(0, "unexpected call\n");
1965 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1966 const GUID *pguidCmdGroup, DWORD nCmdID)
1968 ok(0, "unexpected call\n");
1972 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1973 LPOLESTR *pchKey, DWORD dw)
1975 CHECK_EXPECT(GetOptionKeyPath);
1976 ok(pchKey != NULL, "pchKey = NULL\n");
1977 ok(!dw, "dw=%d, expected 0\n", dw);
1979 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1983 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1984 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1986 CHECK_EXPECT(GetDropTarget);
1991 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1993 CHECK_EXPECT(GetExternal);
1994 *ppDispatch = &External;
1998 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1999 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2001 ok(0, "unexpected call\n");
2005 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2006 IDataObject **ppPORet)
2008 ok(0, "unexpected call\n");
2012 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2013 LPOLESTR *pchKey, DWORD dw)
2015 CHECK_EXPECT(GetOverrideKeyPath);
2016 ok(pchKey != NULL, "pchKey = NULL\n");
2018 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2019 ok(!dw, "dw=%d, xepected 0\n", dw);
2023 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2024 DocHostUIHandler_QueryInterface,
2025 DocHostUIHandler_AddRef,
2026 DocHostUIHandler_Release,
2027 DocHostUIHandler_ShowContextMenu,
2028 DocHostUIHandler_GetHostInfo,
2029 DocHostUIHandler_ShowUI,
2030 DocHostUIHandler_HideUI,
2031 DocHostUIHandler_UpdateUI,
2032 DocHostUIHandler_EnableModeless,
2033 DocHostUIHandler_OnDocWindowActivate,
2034 DocHostUIHandler_OnFrameWindowActivate,
2035 DocHostUIHandler_ResizeBorder,
2036 DocHostUIHandler_TranslateAccelerator,
2037 DocHostUIHandler_GetOptionKeyPath,
2038 DocHostUIHandler_GetDropTarget,
2039 DocHostUIHandler_GetExternal,
2040 DocHostUIHandler_TranslateUrl,
2041 DocHostUIHandler_FilterDataObject,
2042 DocHostUIHandler_GetOverrideKeyPath
2045 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2047 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2048 REFIID riid, void **ppv)
2050 return QueryInterface(riid, ppv);
2053 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2058 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2063 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2064 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2066 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2067 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2068 ok(!pCmdText, "pCmdText != NULL\n");
2070 switch(prgCmds[0].cmdID) {
2071 case OLECMDID_SETPROGRESSTEXT:
2072 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2073 prgCmds[0].cmdf = OLECMDF_ENABLED;
2076 CHECK_EXPECT(QueryStatus_OPEN);
2077 prgCmds[0].cmdf = 0;
2080 CHECK_EXPECT(QueryStatus_NEW);
2081 prgCmds[0].cmdf = 0;
2084 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2090 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2091 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2093 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2094 test_readyState(NULL);
2096 if(!pguidCmdGroup) {
2098 case OLECMDID_SETPROGRESSMAX:
2099 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2100 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2101 ok(pvaIn != NULL, "pvaIn == NULL\n");
2103 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2104 if(load_state == LD_NO)
2105 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2107 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2109 case OLECMDID_SETPROGRESSPOS:
2110 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2111 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2112 ok(pvaIn != NULL, "pvaIn == NULL\n");
2114 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2115 if(load_state == LD_NO)
2116 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2118 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2120 case OLECMDID_HTTPEQUIV_DONE:
2121 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2122 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2123 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2124 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2125 load_state = LD_COMPLETE;
2127 case OLECMDID_SETDOWNLOADSTATE:
2128 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2129 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2130 ok(pvaIn != NULL, "pvaIn == NULL\n");
2131 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2133 switch(V_I4(pvaIn)) {
2135 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2136 load_state = LD_INTERACTIVE;
2139 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2142 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2146 case OLECMDID_UPDATECOMMANDS:
2147 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2148 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2149 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2150 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2152 case OLECMDID_SETTITLE:
2153 CHECK_EXPECT2(Exec_SETTITLE);
2154 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2155 ok(pvaIn != NULL, "pvaIn == NULL\n");
2156 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2157 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2158 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2160 case OLECMDID_HTTPEQUIV:
2161 CHECK_EXPECT2(Exec_HTTPEQUIV);
2162 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2166 ok(0, "unexpected command %d\n", nCmdID);
2171 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2172 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2176 CHECK_EXPECT2(Exec_ShellDocView_37);
2178 if(load_from_stream)
2179 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2181 test_GetCurMoniker(doc_unk, &Moniker, NULL);
2183 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2184 ok(pvaIn != NULL, "pvaIn == NULL\n");
2186 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2187 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2191 CHECK_EXPECT2(Exec_ShellDocView_84);
2193 ok(pvaIn == NULL, "pvaIn != NULL\n");
2194 ok(pvaOut != NULL, "pvaOut == NULL\n");
2196 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2201 CHECK_EXPECT2(Exec_ShellDocView_103);
2203 ok(pvaIn == NULL, "pvaIn != NULL\n");
2204 ok(pvaOut == NULL, "pvaOut != NULL\n");
2209 ok(0, "unexpected command %d\n", nCmdID);
2214 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2215 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2218 case IDM_PARSECOMPLETE:
2219 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2220 ok(pvaIn == NULL, "pvaIn != NULL\n");
2221 ok(pvaOut == NULL, "pvaOut != NULL\n");
2224 ok(0, "unexpected command %d\n", nCmdID);
2228 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2229 return E_FAIL; /* TODO */
2231 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2232 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2236 CHECK_EXPECT2(Exec_Explorer_69);
2237 ok(pvaIn == NULL, "pvaIn != NULL\n");
2238 ok(pvaOut != NULL, "pvaOut == NULL\n");
2241 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2246 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2248 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2249 SET_EXPECT(SetStatusText);
2250 ok(pvaIn == NULL, "pvaIn != NULL\n");
2251 ok(pvaOut == NULL, "pvaOut != NULL\n");
2254 ok(0, "unexpected command %d\n", nCmdID);
2259 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2263 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2264 OleCommandTarget_QueryInterface,
2265 OleCommandTarget_AddRef,
2266 OleCommandTarget_Release,
2267 OleCommandTarget_QueryStatus,
2268 OleCommandTarget_Exec
2271 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2273 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2275 return QueryInterface(riid, ppv);
2278 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2279 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2280 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2282 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2283 ok(pDispParams != NULL, "pDispParams == NULL\n");
2284 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2285 ok(puArgErr != NULL, "puArgErr == NULL\n");
2286 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2287 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2288 test_readyState(NULL);
2290 switch(dispIdMember) {
2291 case DISPID_AMBIENT_USERMODE:
2292 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2293 V_VT(pVarResult) = VT_BOOL;
2294 V_BOOL(pVarResult) = VARIANT_TRUE;
2296 case DISPID_AMBIENT_DLCONTROL:
2297 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2299 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2300 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2302 case DISPID_AMBIENT_SILENT:
2303 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2304 V_VT(pVarResult) = VT_BOOL;
2305 V_BOOL(pVarResult) = VARIANT_FALSE;
2307 case DISPID_AMBIENT_USERAGENT:
2308 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2310 case DISPID_AMBIENT_PALETTE:
2311 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2315 ok(0, "unexpected dispid %d\n", dispIdMember);
2319 static IDispatchVtbl DispatchVtbl = {
2320 Dispatch_QueryInterface,
2323 Dispatch_GetTypeInfoCount,
2324 Dispatch_GetTypeInfo,
2325 Dispatch_GetIDsOfNames,
2329 static IDispatch Dispatch = { &DispatchVtbl };
2331 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2332 REFIID riid, void **ppv)
2334 return QueryInterface(riid, ppv);
2337 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2342 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2347 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2348 REFIID riid, void **ppv)
2351 * Services used by HTMLDocument:
2354 * IInternetSecurityManager
2356 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2359 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2360 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2361 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2363 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2364 * IElementBehaviorFactory
2365 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2375 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2376 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2381 return E_NOINTERFACE;
2384 static const IServiceProviderVtbl ServiceProviderVtbl = {
2385 ServiceProvider_QueryInterface,
2386 ServiceProvider_AddRef,
2387 ServiceProvider_Release,
2388 ServiceProvider_QueryService
2391 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2393 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2394 DEFINE_GUID(IID_unk2, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2395 DEFINE_GUID(IID_unk3, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2397 static HRESULT QueryInterface(REFIID riid, void **ppv)
2401 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2403 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2404 *ppv = &DocumentSite;
2405 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2406 *ppv = &DocHostUIHandler;
2407 else if(IsEqualGUID(&IID_IOleContainer, riid))
2408 *ppv = &OleContainer;
2409 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2410 *ppv = &InPlaceSiteEx;
2411 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2412 *ppv = &OleCommandTarget;
2413 else if(IsEqualGUID(&IID_IDispatch, riid))
2415 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2416 *ppv = &ServiceProvider;
2417 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2418 *ppv = ipsex ? &InPlaceSiteEx : NULL;
2419 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2420 *ppv = &OleControlSite;
2421 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2422 return E_NOINTERFACE; /* TODO */
2423 else if(IsEqualGUID(&IID_IProxyManager, riid))
2424 return E_NOINTERFACE; /* ? */
2425 else if(IsEqualGUID(&IID_unk1, riid))
2426 return E_NOINTERFACE; /* HTMLWindow2 ? */
2427 else if(IsEqualGUID(&IID_unk2, riid))
2428 return E_NOINTERFACE; /* ? */
2429 else if(IsEqualGUID(&IID_unk3, riid))
2430 return E_NOINTERFACE; /* ? */
2432 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2436 return E_NOINTERFACE;
2439 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2441 return DefWindowProc(hwnd, msg, wParam, lParam);
2444 static void _test_readyState(unsigned line, IUnknown *unk)
2446 IHTMLDocument2 *htmldoc;
2447 DISPPARAMS dispparams;
2452 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2453 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2454 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2455 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2457 static const LPCWSTR expected_state[] = {
2469 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2470 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2474 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2475 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2477 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2478 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2480 (!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n",
2481 debugstr_w(state), load_state);
2482 SysFreeString(state);
2484 dispparams.cArgs = 0;
2485 dispparams.cNamedArgs = 0;
2486 dispparams.rgdispidNamedArgs = NULL;
2487 dispparams.rgvarg = NULL;
2491 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2492 &dispparams, &out, NULL, NULL);
2493 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2495 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2496 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2498 IHTMLDocument2_Release(htmldoc);
2501 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2503 IConnectionPointContainer *tmp_container = NULL;
2504 IConnectionPoint *cp;
2508 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2509 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2513 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2514 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2515 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2517 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2518 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2520 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2521 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2522 ok(tmp_container == container, "container != tmp_container\n");
2524 IConnectionPointContainer_Release(tmp_container);
2526 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2527 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2529 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2532 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2533 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2536 IConnectionPoint_Release(cp);
2539 static void test_ConnectionPointContainer(IUnknown *unk)
2541 IConnectionPointContainer *container;
2544 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2545 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2549 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2550 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2551 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2553 IConnectionPointContainer_Release(container);
2556 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2558 IHTMLDocument2 *doc;
2559 IPersistMoniker *permon;
2560 IMoniker *mon = (void*)0xdeadbeef;
2561 BSTR doc_url = (void*)0xdeadbeef;
2564 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2565 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2569 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2570 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2572 hres = IHTMLDocument2_get_URL(doc, &doc_url);
2573 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2575 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2576 IPersistMoniker_Release(permon);
2580 BOOL exb = expect_GetDisplayName;
2581 BOOL clb = called_GetDisplayName;
2583 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2584 ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2586 SET_EXPECT(GetDisplayName);
2587 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2588 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2589 CHECK_CALLED(GetDisplayName);
2590 expect_GetDisplayName = exb;
2591 called_GetDisplayName = clb;
2593 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2598 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2600 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2601 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2603 ok(!lstrcmpW(url, exurl), "unexpected url\n");
2604 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2608 ok(hres == E_UNEXPECTED,
2609 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2610 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2611 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2614 SysFreeString(doc_url);
2615 IHTMLDocument_Release(doc);
2616 if(mon && mon != (void*)0xdeadbeef)
2617 IMoniker_Release(mon);
2620 static void test_Load(IPersistMoniker *persist)
2624 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2626 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2628 test_readyState((IUnknown*)persist);
2630 CreateBindCtx(0, &bind);
2631 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2632 (IUnknown*)&ClientSite);
2634 SET_EXPECT(GetDisplayName);
2635 if(!set_clientsite) {
2636 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2637 SET_EXPECT(GetHostInfo);
2638 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2639 SET_EXPECT(Invoke_AMBIENT_SILENT);
2640 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2641 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2642 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2643 SET_EXPECT(GetOptionKeyPath);
2644 SET_EXPECT(GetOverrideKeyPath);
2645 SET_EXPECT(GetWindow);
2646 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2647 SET_EXPECT(Exec_SETPROGRESSMAX);
2648 SET_EXPECT(Exec_SETPROGRESSPOS);
2649 SET_EXPECT(Exec_ShellDocView_37);
2651 if(!container_locked) {
2652 SET_EXPECT(GetContainer);
2653 SET_EXPECT(LockContainer);
2655 SET_EXPECT(OnChanged_READYSTATE);
2656 SET_EXPECT(Exec_ShellDocView_84);
2657 SET_EXPECT(IsSystemMoniker);
2658 SET_EXPECT(BindToStorage);
2659 SET_EXPECT(SetActiveObject);
2660 if(set_clientsite) {
2661 SET_EXPECT(Invoke_AMBIENT_SILENT);
2662 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2663 SET_EXPECT(Exec_ShellDocView_37);
2665 load_state = LD_DOLOAD;
2666 expect_LockContainer_fLock = TRUE;
2667 readystate_set_loading = TRUE;
2669 hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2670 ok(hres == S_OK, "Load failed: %08x\n", hres);
2672 CHECK_CALLED(GetDisplayName);
2673 if(!set_clientsite) {
2674 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2675 CHECK_CALLED(GetHostInfo);
2676 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2677 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2678 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2679 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2680 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2681 CHECK_CALLED(GetOptionKeyPath);
2682 CHECK_CALLED(GetOverrideKeyPath);
2683 CHECK_CALLED(GetWindow);
2684 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2685 CHECK_CALLED(Exec_SETPROGRESSMAX);
2686 CHECK_CALLED(Exec_SETPROGRESSPOS);
2687 CHECK_CALLED(Exec_ShellDocView_37);
2689 if(!container_locked) {
2690 CHECK_CALLED(GetContainer);
2691 CHECK_CALLED(LockContainer);
2692 container_locked = TRUE;
2694 CHECK_CALLED(OnChanged_READYSTATE);
2695 SET_CALLED(IsSystemMoniker); /* IE7 */
2696 SET_CALLED(Exec_ShellDocView_84);
2697 CHECK_CALLED(BindToStorage);
2698 SET_CALLED(SetActiveObject); /* FIXME */
2699 if(set_clientsite) {
2700 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2701 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2702 CHECK_CALLED(Exec_ShellDocView_37);
2705 set_clientsite = container_locked = TRUE;
2707 test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2709 IBindCtx_Release(bind);
2711 test_readyState((IUnknown*)persist);
2714 static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
2719 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2720 ok(hwnd != NULL, "Could not find hidden window\n");
2722 test_readyState(NULL);
2725 SET_EXPECT(Exec_SETPROGRESSMAX);
2726 if(!load_from_stream)
2727 SET_EXPECT(GetHostInfo);
2729 SET_EXPECT(SetStatusText);
2730 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2731 SET_EXPECT(GetDropTarget);
2733 SET_EXPECT(Exec_ShellDocView_84);
2735 SET_EXPECT(CreateInstance);
2737 SET_EXPECT(LockRequest);
2738 SET_EXPECT(Terminate);
2739 SET_EXPECT(Protocol_Read);
2740 SET_EXPECT(UnlockRequest);
2742 SET_EXPECT(Exec_Explorer_69);
2743 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
2744 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
2745 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
2746 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
2747 SET_EXPECT(OnChanged_1005);
2748 SET_EXPECT(OnChanged_READYSTATE);
2749 SET_EXPECT(Exec_SETPROGRESSPOS);
2750 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2751 SET_EXPECT(Exec_ShellDocView_103);
2752 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2753 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2754 SET_EXPECT(SetStatusText);
2755 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2757 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2758 TranslateMessage(&msg);
2759 DispatchMessage(&msg);
2763 CHECK_CALLED(Exec_SETPROGRESSMAX);
2764 if(!load_from_stream)
2765 CHECK_CALLED(GetHostInfo);
2767 CHECK_CALLED(SetStatusText);
2768 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2769 CHECK_CALLED(GetDropTarget);
2771 SET_CALLED(Exec_ShellDocView_84);
2773 if(called_CreateInstance) {
2774 CHECK_CALLED(CreateInstance);
2775 CHECK_CALLED(Start);
2776 CHECK_CALLED(LockRequest);
2777 CHECK_CALLED(Terminate);
2778 CHECK_CALLED(Protocol_Read);
2779 CHECK_CALLED(UnlockRequest);
2781 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2783 SET_CALLED(Exec_ShellDocView_84);
2784 SET_CALLED(CreateInstance);
2786 SET_CALLED(LockRequest);
2787 SET_CALLED(Terminate);
2788 SET_CALLED(Protocol_Read);
2789 SET_CALLED(UnlockRequest);
2794 SET_CALLED(Exec_Explorer_69);
2795 SET_CALLED(EnableModeless_TRUE); /* IE7 */
2796 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
2797 SET_CALLED(EnableModeless_FALSE); /* IE7 */
2798 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
2799 CHECK_CALLED(OnChanged_1005);
2800 CHECK_CALLED(OnChanged_READYSTATE);
2801 CHECK_CALLED(Exec_SETPROGRESSPOS);
2802 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2803 SET_CALLED(Exec_ShellDocView_103);
2804 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2805 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2806 SET_CALLED(SetStatusText);
2808 load_state = LD_COMPLETE;
2810 test_readyState(NULL);
2813 static void test_Persist(IUnknown *unk)
2815 IPersistMoniker *persist_mon;
2816 IPersistFile *persist_file;
2820 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2821 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2822 if(SUCCEEDED(hres)) {
2823 hres = IPersist_GetClassID(persist_file, NULL);
2824 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2826 hres = IPersist_GetClassID(persist_file, &guid);
2827 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2828 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2830 IPersist_Release(persist_file);
2833 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2834 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2835 if(SUCCEEDED(hres)) {
2836 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2837 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2839 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2840 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2841 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2843 if(load_state == LD_DOLOAD)
2844 test_Load(persist_mon);
2846 test_readyState(unk);
2848 IPersistMoniker_Release(persist_mon);
2852 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2854 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2855 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2856 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2857 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2858 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2859 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2860 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2861 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2862 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2863 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2864 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2865 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2866 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2867 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2868 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2869 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2870 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2871 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2872 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2873 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2875 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2876 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2878 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2880 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2882 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2883 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2885 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2886 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2888 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2890 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2891 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2894 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2895 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2897 IOleCommandTarget *cmdtrg;
2898 OLECMD olecmd = {cmdid, 0};
2901 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2902 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2906 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2907 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2909 IOleCommandTarget_Release(cmdtrg);
2911 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2912 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2915 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2920 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2921 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2922 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
2923 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2924 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2925 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2926 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2927 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2928 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2929 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2930 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2931 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2932 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2933 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2934 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2935 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
2938 static void test_OleCommandTarget(IUnknown *unk)
2940 IOleCommandTarget *cmdtrg;
2941 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2945 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2946 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2950 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2951 cmds[i].cmdID = i+1;
2952 cmds[i].cmdf = 0xf0f0;
2955 SET_EXPECT(QueryStatus_OPEN);
2956 SET_EXPECT(QueryStatus_NEW);
2957 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2958 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2959 CHECK_CALLED(QueryStatus_OPEN);
2960 CHECK_CALLED(QueryStatus_NEW);
2962 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2963 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2964 if(i+1 == OLECMDID_FIND)
2966 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2967 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2970 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
2971 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
2973 IOleCommandTarget_Release(cmdtrg);
2976 static void test_OleCommandTarget_fail(IUnknown *unk)
2978 IOleCommandTarget *cmdtrg;
2983 {OLECMDID_OPEN, 0xf0f0},
2984 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2987 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2988 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2992 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2993 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2995 SET_EXPECT(QueryStatus_OPEN);
2996 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2997 CHECK_CALLED(QueryStatus_OPEN);
2999 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3000 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3001 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3002 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3003 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3004 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3005 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3007 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3008 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3009 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3011 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3012 if(!expect_cmds[i]) {
3013 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3014 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3015 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3016 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3020 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3021 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3022 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3023 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3025 IOleCommandTarget_Release(cmdtrg);
3028 static void test_exec_onunload(IUnknown *unk)
3030 IOleCommandTarget *cmdtrg;
3034 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3035 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3039 memset(&var, 0x0a, sizeof(var));
3040 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3041 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3042 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3043 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3044 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3046 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3047 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3048 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3050 IOleCommandTarget_Release(cmdtrg);
3053 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3055 IOleCommandTarget *cmdtrg;
3058 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3059 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3066 load_state = LD_DOLOAD;
3069 SET_EXPECT(GetClassID);
3070 SET_EXPECT(SetStatusText);
3071 SET_EXPECT(Exec_ShellDocView_37);
3072 SET_EXPECT(GetHostInfo);
3074 SET_EXPECT(GetDisplayName);
3075 SET_EXPECT(Invoke_AMBIENT_SILENT);
3076 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3077 SET_EXPECT(OnChanged_READYSTATE);
3078 SET_EXPECT(IsSystemMoniker);
3079 SET_EXPECT(Exec_ShellDocView_84);
3081 SET_EXPECT(BindToStorage);
3082 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3085 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3087 expect_status_text = NULL;
3088 readystate_set_loading = TRUE;
3090 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3091 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3092 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3095 CHECK_CALLED(GetClassID);
3096 CHECK_CALLED(SetStatusText);
3097 CHECK_CALLED(Exec_ShellDocView_37);
3098 CHECK_CALLED(GetHostInfo);
3100 CHECK_CALLED(GetDisplayName);
3101 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3102 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3103 CHECK_CALLED(OnChanged_READYSTATE);
3104 SET_CALLED(IsSystemMoniker); /* IE7 */
3105 SET_CALLED(Exec_ShellDocView_84);
3107 CHECK_CALLED(BindToStorage);
3108 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3109 CHECK_CALLED(HideUI);
3110 CHECK_CALLED(ShowUI);
3111 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3113 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3115 IOleCommandTarget_Release(cmdtrg);
3117 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3118 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3119 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3122 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3124 IOleCommandTarget *cmdtrg;
3125 VARIANT *in = NULL, _in, *out = NULL, _out;
3128 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3129 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3136 V_BSTR(in) = SysAllocString(name);
3142 V_I4(out) = 0xdeadbeef;
3145 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3147 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3152 if(out && !nogecko) {
3153 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3154 if(V_VT(out) == VT_BSTR) {
3156 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3157 "unexpected fontname \"%s\"\n", debugstr_w(name));
3159 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3164 IOleCommandTarget_Release(cmdtrg);
3167 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3169 IOleCommandTarget *cmdtrg;
3172 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3173 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3177 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3178 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3179 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3181 IOleCommandTarget_Release(cmdtrg);
3184 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3186 IPersistStreamInit *perinit;
3187 IPersistMoniker *permon;
3188 IPersistFile *perfile;
3191 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3192 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3193 if(SUCCEEDED(hres)) {
3194 hres = IPersistStreamInit_IsDirty(perinit);
3195 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3196 IPersistStreamInit_Release(perinit);
3199 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3200 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3201 if(SUCCEEDED(hres)) {
3202 hres = IPersistMoniker_IsDirty(permon);
3203 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3204 IPersistMoniker_Release(permon);
3207 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3208 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3209 if(SUCCEEDED(hres)) {
3210 hres = IPersistFile_IsDirty(perfile);
3211 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3212 IPersistFile_Release(perfile);
3216 static HWND create_container_window(void)
3218 static const WCHAR wszHTMLDocumentTest[] =
3219 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3220 static WNDCLASSEXW wndclass = {
3221 sizeof(WNDCLASSEXW),
3224 0, 0, NULL, NULL, NULL, NULL, NULL,
3225 wszHTMLDocumentTest,
3229 RegisterClassExW(&wndclass);
3230 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3231 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3232 515, 530, NULL, NULL, NULL, NULL);
3235 static void test_DoVerb(IOleObject *oleobj)
3237 RECT rect = {0,0,500,500};
3240 if(!container_locked) {
3241 SET_EXPECT(GetContainer);
3242 SET_EXPECT(LockContainer);
3244 SET_EXPECT(ActivateMe);
3245 expect_LockContainer_fLock = TRUE;
3247 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3248 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3250 if(!container_locked) {
3251 CHECK_CALLED(GetContainer);
3252 CHECK_CALLED(LockContainer);
3253 container_locked = TRUE;
3255 CHECK_CALLED(ActivateMe);
3258 #define CLIENTSITE_EXPECTPATH 0x00000001
3259 #define CLIENTSITE_SETNULL 0x00000002
3260 #define CLIENTSITE_DONTSET 0x00000004
3262 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3264 IOleClientSite *clientsite;
3267 if(flags & CLIENTSITE_SETNULL) {
3268 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3269 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3271 hres = IOleObject_SetClientSite(oleobj, NULL);
3272 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3274 set_clientsite = FALSE;
3277 if(flags & CLIENTSITE_DONTSET)
3280 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3281 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3282 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3283 clientsite, set_clientsite ? &ClientSite : NULL);
3285 if(!set_clientsite) {
3286 SET_EXPECT(GetHostInfo);
3287 if(flags & CLIENTSITE_EXPECTPATH) {
3288 SET_EXPECT(GetOptionKeyPath);
3289 SET_EXPECT(GetOverrideKeyPath);
3291 SET_EXPECT(GetWindow);
3292 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3293 SET_EXPECT(Exec_SETPROGRESSMAX);
3294 SET_EXPECT(Exec_SETPROGRESSPOS);
3295 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3296 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3297 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3298 SET_EXPECT(Invoke_AMBIENT_SILENT);
3299 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3300 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3302 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3303 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3305 CHECK_CALLED(GetHostInfo);
3306 if(flags & CLIENTSITE_EXPECTPATH) {
3307 CHECK_CALLED(GetOptionKeyPath);
3308 CHECK_CALLED(GetOverrideKeyPath);
3310 CHECK_CALLED(GetWindow);
3311 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3312 CHECK_CALLED(Exec_SETPROGRESSMAX);
3313 CHECK_CALLED(Exec_SETPROGRESSPOS);
3314 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3315 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3316 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3317 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3318 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3319 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3321 set_clientsite = TRUE;
3324 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3325 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3327 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3328 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3329 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3332 static void test_OnAmbientPropertyChange(IUnknown *unk)
3334 IOleControl *control = NULL;
3337 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3338 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3342 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3343 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3344 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3345 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3347 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3348 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3349 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3350 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3352 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3353 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3354 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3355 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3356 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3357 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3359 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3360 SET_EXPECT(Invoke_AMBIENT_SILENT);
3361 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3362 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3363 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3364 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3366 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3367 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3368 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3369 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3371 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3372 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3373 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3374 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3376 IOleControl_Release(control);
3381 static void test_OnAmbientPropertyChange2(IUnknown *unk)
3383 IOleControl *control = NULL;
3386 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3387 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3391 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3392 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3394 IOleControl_Release(control);
3397 static void test_Close(IUnknown *unk, BOOL set_client)
3399 IOleObject *oleobj = NULL;
3402 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3403 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3407 SET_EXPECT(GetContainer);
3408 SET_EXPECT(LockContainer);
3409 expect_LockContainer_fLock = FALSE;
3410 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3411 ok(hres == S_OK, "Close failed: %08x\n", hres);
3412 CHECK_CALLED(GetContainer);
3413 CHECK_CALLED(LockContainer);
3414 container_locked = FALSE;
3417 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3419 IOleObject_Release(oleobj);
3422 static void test_OnFrameWindowActivate(IUnknown *unk)
3424 IOleInPlaceActiveObject *inplaceact;
3427 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3428 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3432 if(set_clientsite) {
3433 expect_OnFrameWindowActivate_fActivate = TRUE;
3434 SET_EXPECT(OnFrameWindowActivate);
3435 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3436 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3437 CHECK_CALLED(OnFrameWindowActivate);
3439 SET_EXPECT(OnFrameWindowActivate);
3440 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3441 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3442 CHECK_CALLED(OnFrameWindowActivate);
3444 expect_OnFrameWindowActivate_fActivate = FALSE;
3445 SET_EXPECT(OnFrameWindowActivate);
3446 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3447 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3448 CHECK_CALLED(OnFrameWindowActivate);
3450 expect_OnFrameWindowActivate_fActivate = TRUE;
3451 SET_EXPECT(OnFrameWindowActivate);
3452 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3453 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3454 CHECK_CALLED(OnFrameWindowActivate);
3456 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3457 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3459 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3460 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3463 IOleInPlaceActiveObject_Release(inplaceact);
3466 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3468 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3471 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3472 (void**)&windowlessobj);
3473 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3478 SET_EXPECT(OnFocus_FALSE);
3480 SET_EXPECT(OnInPlaceDeactivateEx);
3482 SET_EXPECT(OnInPlaceDeactivate);
3484 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3485 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3487 CHECK_CALLED(OnFocus_FALSE);
3489 CHECK_CALLED(OnInPlaceDeactivateEx);
3491 CHECK_CALLED(OnInPlaceDeactivate);
3494 IOleInPlaceObjectWindowless_Release(windowlessobj);
3497 static void test_Activate(IUnknown *unk, DWORD flags)
3499 IOleObject *oleobj = NULL;
3500 IOleDocumentView *docview;
3507 IOleDocumentView_Release(view);
3510 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3511 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3513 hres = IOleObject_GetUserClassID(oleobj, NULL);
3514 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3516 hres = IOleObject_GetUserClassID(oleobj, &guid);
3517 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3518 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3520 test_OnFrameWindowActivate(unk);
3522 test_ClientSite(oleobj, flags);
3523 test_InPlaceDeactivate(unk, FALSE);
3524 test_DoVerb(oleobj);
3526 if(call_UIActivate == CallUIActivate_AfterShow) {
3527 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3528 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3530 SET_EXPECT(OnFocus_TRUE);
3531 SET_EXPECT(SetActiveObject);
3533 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3534 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3535 expect_status_text = NULL;
3537 hres = IOleDocumentView_UIActivate(docview, TRUE);
3538 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3540 CHECK_CALLED(OnFocus_TRUE);
3541 CHECK_CALLED(SetActiveObject);
3542 CHECK_CALLED(ShowUI);
3543 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3544 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3546 IOleDocumentView_Release(docview);
3549 IOleObject_Release(oleobj);
3551 test_OnFrameWindowActivate(unk);
3554 static void test_Window(IUnknown *unk, BOOL expect_success)
3556 IOleInPlaceActiveObject *activeobject = NULL;
3560 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3561 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3565 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3567 if(expect_success) {
3568 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3569 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3571 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3572 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3575 IOleInPlaceActiveObject_Release(activeobject);
3578 static void test_CloseView(void)
3580 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3586 hres = IOleDocumentView_Show(view, FALSE);
3587 ok(hres == S_OK, "Show failed: %08x\n", hres);
3589 hres = IOleDocumentView_CloseView(view, 0);
3590 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3592 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3593 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3595 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3596 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3597 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3600 static void test_UIDeactivate(void)
3604 if(call_UIActivate == CallUIActivate_AfterShow) {
3605 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3607 if(call_UIActivate != CallUIActivate_None) {
3608 SET_EXPECT(SetActiveObject_null);
3610 SET_EXPECT(OnUIDeactivate);
3613 hres = IOleDocumentView_UIActivate(view, FALSE);
3614 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3616 if(call_UIActivate != CallUIActivate_None) {
3617 CHECK_CALLED(SetActiveObject_null);
3618 CHECK_CALLED(HideUI);
3619 CHECK_CALLED(OnUIDeactivate);
3621 if(call_UIActivate == CallUIActivate_AfterShow) {
3622 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3626 static void test_Hide(void)
3633 hres = IOleDocumentView_Show(view, FALSE);
3634 ok(hres == S_OK, "Show failed: %08x\n", hres);
3637 static HRESULT create_document(IUnknown **unk)
3639 IHTMLDocument5 *doc5;
3642 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3643 &IID_IUnknown, (void**)unk);
3644 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3648 hres = IUnknown_QueryInterface(*unk, &IID_IHTMLDocument5, (void**)&doc5);
3649 if(SUCCEEDED(hres)) {
3650 IHTMLDocument5_Release(doc5);
3652 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
3653 IUnknown_Release(*unk);
3659 static void test_Navigate(IUnknown *unk)
3661 IHlinkTarget *hlink;
3664 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3665 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3667 SET_EXPECT(ActivateMe);
3668 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3669 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3670 CHECK_CALLED(ActivateMe);
3672 IHlinkTarget_Release(hlink);
3675 static void test_external(IUnknown *unk, BOOL initialized)
3677 IDispatch *external;
3678 IHTMLDocument2 *doc;
3679 IHTMLWindow2 *htmlwin;
3682 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3683 ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres);
3685 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
3686 IHTMLDocument2_Release(doc);
3687 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3690 SET_EXPECT(GetExternal);
3691 external = (void*)0xdeadbeef;
3692 hres = IHTMLWindow2_get_external(htmlwin, &external);
3694 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
3695 CHECK_CALLED(GetExternal);
3696 ok(external != NULL, "external == NULL\n");
3698 ok(hres == S_OK, "get_external failed: %08x\n", hres);
3699 ok(external == NULL, "external != NULL\n");
3702 IHTMLWindow2_Release(htmlwin);
3705 static void test_StreamLoad(IUnknown *unk)
3707 IPersistStreamInit *init;
3710 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3711 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3715 SET_EXPECT(Invoke_AMBIENT_SILENT);
3716 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3717 SET_EXPECT(Exec_ShellDocView_37);
3718 SET_EXPECT(OnChanged_READYSTATE);
3720 readystate_set_loading = TRUE;
3722 hres = IPersistStreamInit_Load(init, &Stream);
3723 ok(hres == S_OK, "Load failed: %08x\n", hres);
3725 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3726 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3727 CHECK_CALLED(Exec_ShellDocView_37);
3728 CHECK_CALLED(OnChanged_READYSTATE);
3731 test_timer(EXPECT_SETTITLE);
3732 test_GetCurMoniker(unk, NULL, about_blank_url);
3734 IPersistStreamInit_Release(init);
3737 static void test_QueryInterface(IUnknown *unk)
3742 static const IID IID_UndocumentedScriptIface =
3743 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
3745 qi = (void*)0xdeadbeef;
3746 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi);
3747 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3748 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
3750 qi = (void*)0xdeadbeef;
3751 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi);
3752 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3753 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3755 qi = (void*)0xdeadbeef;
3756 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi);
3757 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3758 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3760 qi = (void*)0xdeadbeef;
3761 hres = IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void**)&qi);
3762 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3763 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3765 qi = (void*)0xdeadbeef;
3766 hres = IUnknown_QueryInterface(unk, &IID_UndocumentedScriptIface, (void**)&qi);
3767 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3768 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3770 qi = (void*)0xdeadbeef;
3771 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&qi);
3772 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3773 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3776 static void init_test(enum load_state_t ls) {
3778 hwnd = last_hwnd = NULL;
3779 set_clientsite = FALSE;
3780 load_from_stream = FALSE;
3781 call_UIActivate = CallUIActivate_None;
3789 static void test_HTMLDocument(BOOL do_load)
3795 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
3797 init_test(do_load ? LD_DOLOAD : LD_NO);
3799 hres = create_document(&unk);
3804 test_QueryInterface(unk);
3805 test_IsDirty(unk, S_FALSE);
3806 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3807 test_external(unk, FALSE);
3808 test_ConnectionPointContainer(unk);
3809 test_GetCurMoniker(unk, NULL, NULL);
3812 test_OnAmbientPropertyChange2(unk);
3814 test_Activate(unk, CLIENTSITE_EXPECTPATH);
3817 test_download(FALSE, TRUE, TRUE);
3818 test_GetCurMoniker(unk, &Moniker, NULL);
3821 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3822 test_OleCommandTarget_fail(unk);
3823 test_OleCommandTarget(unk);
3824 test_OnAmbientPropertyChange(unk);
3825 test_Window(unk, TRUE);
3826 test_external(unk, TRUE);
3828 test_UIDeactivate();
3829 test_OleCommandTarget(unk);
3830 test_Window(unk, TRUE);
3831 test_InPlaceDeactivate(unk, TRUE);
3833 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
3834 * MSHTML. It doesn't with Wine. */
3836 test_Window(unk, FALSE);
3838 test_InPlaceDeactivate(unk, FALSE);
3840 test_Close(unk, FALSE);
3842 /* Activate HTMLDocument again */
3843 test_Activate(unk, CLIENTSITE_SETNULL);
3844 test_Window(unk, TRUE);
3845 test_OleCommandTarget(unk);
3846 test_UIDeactivate();
3847 test_InPlaceDeactivate(unk, TRUE);
3848 test_Close(unk, FALSE);
3850 /* Activate HTMLDocument again, this time without UIActivate */
3851 call_UIActivate = CallUIActivate_None;
3852 test_Activate(unk, CLIENTSITE_SETNULL);
3853 test_Window(unk, TRUE);
3855 test_UIDeactivate();
3856 test_InPlaceDeactivate(unk, TRUE);
3859 test_Close(unk, TRUE);
3860 test_OnAmbientPropertyChange2(unk);
3861 test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3864 /* Activate HTMLDocument again, calling UIActivate after showing the window */
3865 call_UIActivate = CallUIActivate_AfterShow;
3866 test_Activate(unk, 0);
3867 test_Window(unk, TRUE);
3868 test_OleCommandTarget(unk);
3869 test_UIDeactivate();
3870 test_InPlaceDeactivate(unk, TRUE);
3871 test_Close(unk, FALSE);
3872 call_UIActivate = CallUIActivate_None;
3876 IOleDocumentView_Release(view);
3879 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3881 ref = IUnknown_Release(unk);
3882 ok(ref == 0, "ref=%d, expected 0\n", ref);
3884 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3887 static void test_HTMLDocument_hlink(void)
3893 trace("Testing HTMLDocument (hlink)...\n");
3895 init_test(LD_DOLOAD);
3898 hres = create_document(&unk);
3903 test_ConnectionPointContainer(unk);
3904 test_GetCurMoniker(unk, NULL, NULL);
3908 IUnknown_Release(unk);
3912 test_download(FALSE, TRUE, TRUE);
3914 test_IsDirty(unk, S_FALSE);
3915 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3917 test_exec_onunload(unk);
3918 test_Window(unk, TRUE);
3919 test_InPlaceDeactivate(unk, TRUE);
3920 test_Close(unk, FALSE);
3921 test_IsDirty(unk, S_FALSE);
3922 test_GetCurMoniker(unk, &Moniker, NULL);
3925 IOleDocumentView_Release(view);
3928 ref = IUnknown_Release(unk);
3929 ok(ref == 0, "ref=%d, expected 0\n", ref);
3932 static void test_HTMLDocument_StreamLoad(void)
3939 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3941 init_test(LD_DOLOAD);
3942 load_from_stream = TRUE;
3944 hres = create_document(&unk);
3949 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3950 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3952 test_readyState(unk);
3953 test_IsDirty(unk, S_FALSE);
3954 test_ConnectionPointContainer(unk);
3955 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3956 test_DoVerb(oleobj);
3957 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3959 IOleObject_Release(oleobj);
3961 test_GetCurMoniker(unk, NULL, NULL);
3962 test_StreamLoad(unk);
3963 test_download(TRUE, FALSE, TRUE);
3964 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3966 test_UIDeactivate();
3967 test_InPlaceDeactivate(unk, TRUE);
3968 test_Close(unk, FALSE);
3969 test_IsDirty(unk, S_FALSE);
3972 IOleDocumentView_Release(view);
3977 ref = IUnknown_Release(unk);
3978 ok(ref == 0, "ref=%d, expected 0\n", ref);
3981 static void test_edit_uiactivate(IOleObject *oleobj)
3983 IOleDocumentView *docview;
3986 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3987 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3989 SET_EXPECT(OnFocus_TRUE);
3990 SET_EXPECT(SetActiveObject);
3992 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3993 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3994 expect_status_text = NULL;
3996 hres = IOleDocumentView_UIActivate(docview, TRUE);
3997 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3999 CHECK_CALLED(OnFocus_TRUE);
4000 CHECK_CALLED(SetActiveObject);
4001 CHECK_CALLED(ShowUI);
4002 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4003 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4005 IOleDocumentView_Release(docview);
4008 static void test_editing_mode(BOOL do_load)
4015 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
4017 init_test(do_load ? LD_DOLOAD : LD_NO);
4018 call_UIActivate = CallUIActivate_AfterShow;
4020 hres = create_document(&unk);
4025 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
4026 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4028 test_readyState(unk);
4029 test_ConnectionPointContainer(unk);
4030 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4031 test_DoVerb(oleobj);
4032 test_edit_uiactivate(oleobj);
4034 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4037 stream_read = protocol_read = 0;
4038 test_exec_editmode(unk, do_load);
4039 test_UIDeactivate();
4040 call_UIActivate = CallUIActivate_None;
4041 IOleObject_Release(oleobj);
4043 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4044 test_download(TRUE, do_load, do_load);
4046 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
4047 test_timer(EXPECT_UPDATEUI);
4048 SET_CALLED(SetStatusText);
4050 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4053 test_exec_fontname(unk, NULL, wszTimesNewRoman);
4054 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4055 test_timer(EXPECT_UPDATEUI);
4056 test_exec_fontname(unk, NULL, wszArial);
4058 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4059 test_timer(EXPECT_UPDATEUI);
4061 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4062 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4064 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4065 test_timer(EXPECT_UPDATEUI);
4066 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4067 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4069 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4070 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4072 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4073 test_timer(EXPECT_UPDATEUI);
4074 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4075 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4078 test_UIDeactivate();
4079 test_InPlaceDeactivate(unk, TRUE);
4080 test_Close(unk, FALSE);
4083 IOleDocumentView_Release(view);
4087 ref = IUnknown_Release(unk);
4088 ok(ref == 0, "ref=%d, expected 0\n", ref);
4091 static void register_protocol(void)
4093 IInternetSession *session;
4096 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
4098 hres = CoInternetGetSession(0, &session, 0);
4099 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
4101 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
4102 wsz_winetest, 0, NULL, 0);
4103 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
4105 IInternetSession_Release(session);
4108 static void gecko_installer_workaround(BOOL disable)
4113 static BOOL has_url = FALSE;
4114 static char url[2048];
4116 if(!disable && !has_url)
4119 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4120 if(res != ERROR_SUCCESS)
4124 DWORD type, size = sizeof(url);
4126 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4127 if(res == ERROR_SUCCESS && type == REG_SZ)
4130 RegDeleteValue(hkey, "GeckoUrl");
4132 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4138 static void test_HTMLDoc_ISupportErrorInfo(void)
4142 ISupportErrorInfo *sinfo;
4145 hres = create_document(&unk);
4149 hres = IUnknown_QueryInterface(unk, &IID_ISupportErrorInfo, (void**)&sinfo);
4150 ok(hres == S_OK, "got %x\n", hres);
4151 ok(sinfo != NULL, "got %p\n", sinfo);
4154 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
4155 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
4156 IUnknown_Release(sinfo);
4159 ref = IUnknown_Release(unk);
4160 ok(ref == 0, "ref=%d, expected 0\n", ref);
4165 gecko_installer_workaround(TRUE);
4168 container_hwnd = create_container_window();
4169 register_protocol();
4171 test_HTMLDocument_hlink();
4173 test_HTMLDocument(FALSE);
4174 test_HTMLDocument(TRUE);
4175 test_HTMLDocument_StreamLoad();
4176 test_editing_mode(FALSE);
4177 test_editing_mode(TRUE);
4179 test_HTMLDoc_ISupportErrorInfo();
4181 DestroyWindow(container_hwnd);
4184 gecko_installer_workaround(FALSE);