msvcrt/tests: Remove a space before a '\n'.
[wine/gsoc-2012-control.git] / dlls / mshtml / tests / htmldoc.c
blobe4ae14498753f29aad5d3b867c783840bc666ced
1 /*
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
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "mshtml.h"
31 #include "docobj.h"
32 #include "mshtmhst.h"
33 #include "mshtmdid.h"
34 #include "mshtmcid.h"
35 #include "hlink.h"
36 #include "dispex.h"
37 #include "idispids.h"
38 #include "shlguid.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) \
54 do { \
55 ok(expect_ ##func, "unexpected call " #func "\n"); \
56 called_ ## func = TRUE; \
57 }while(0)
59 #define CHECK_EXPECT(func) \
60 do { \
61 CHECK_EXPECT2(func); \
62 expect_ ## func = FALSE; \
63 }while(0)
65 #define CHECK_CALLED(func) \
66 do { \
67 ok(called_ ## func, "expected " #func "\n"); \
68 expect_ ## func = called_ ## func = FALSE; \
69 }while(0)
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);
128 DEFINE_EXPECT(Read);
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;
149 static BOOL ipsex;
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 {
155 LD_DOLOAD,
156 LD_LOADING,
157 LD_LOADED,
158 LD_INTERACTIVE,
159 LD_COMPLETE,
160 LD_NO
161 } load_state;
163 static LPCOLESTR expect_status_text = NULL;
165 static const char html_page[] =
166 "<html>"
167 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
168 "<body>test</body>"
169 "</html>";
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)
192 static char buf[50];
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]);
199 return buf;
202 static const char *debugstr_w(LPCWSTR str)
204 static char buf[1024];
206 if(!str)
207 return "(null)";
209 WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
210 return buf;
213 #define EXPECT_UPDATEUI 1
214 #define EXPECT_SETTITLE 2
216 static void test_timer(DWORD flags)
218 BOOL *b = &called_Exec_SETTITLE;
219 MSG msg;
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)
246 *ppv = NULL;
248 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
249 *ppv = iface;
250 return S_OK;
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)
266 return 2;
269 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
271 return 1;
274 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
276 ok(0, "unexpected call\n");
277 return E_NOTIMPL;
280 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
281 ITypeInfo **ppTInfo)
283 ok(0, "unexpected call\n");
284 return E_NOTIMPL;
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");
291 return E_NOTIMPL;
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");
299 return E_NOTIMPL;
302 static const IDispatchVtbl ExternalVtbl = {
303 External_QueryInterface,
304 Dispatch_AddRef,
305 Dispatch_Release,
306 Dispatch_GetTypeInfoCount,
307 Dispatch_GetTypeInfo,
308 Dispatch_GetIDsOfNames,
309 External_Invoke
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)) {
317 *ppv = iface;
318 return S_OK;
321 *ppv = NULL;
322 return E_NOINTERFACE;
325 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
327 return 2;
330 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
332 return 1;
335 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
336 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
337 DWORD grfPI, DWORD dwReserved)
339 BINDINFO bindinfo;
340 DWORD bindf = 0;
341 HRESULT hres;
343 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
344 static const WCHAR empty_str = {0};
346 CHECK_EXPECT(Start);
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);
383 ok(hres == S_OK,
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);
393 return S_OK;
396 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
397 PROTOCOLDATA *pProtocolData)
399 ok(0, "unexpected call\n");
400 return E_NOTIMPL;
403 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
404 DWORD dwOptions)
406 ok(0, "unexpected call\n");
407 return E_NOTIMPL;
410 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
412 CHECK_EXPECT(Terminate);
413 return S_OK;
416 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
418 ok(0, "unexpected call\n");
419 return E_NOTIMPL;
422 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
424 ok(0, "unexpected call\n");
425 return E_NOTIMPL;
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);
438 if(protocol_read)
439 return S_FALSE;
441 protocol_read += *pcbRead = sizeof(css_data)-1;
442 memcpy(pv, css_data, sizeof(css_data)-1);
443 return S_OK;
446 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
447 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
449 ok(0, "unexpected call\n");
450 return E_NOTIMPL;
453 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
455 CHECK_EXPECT(LockRequest);
456 return S_OK;
459 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
461 CHECK_EXPECT(UnlockRequest);
462 return S_OK;
465 static const IInternetProtocolVtbl ProtocolVtbl = {
466 Protocol_QueryInterface,
467 Protocol_AddRef,
468 Protocol_Release,
469 Protocol_Start,
470 Protocol_Continue,
471 Protocol_Abort,
472 Protocol_Terminate,
473 Protocol_Suspend,
474 Protocol_Resume,
475 Protocol_Read,
476 Protocol_Seek,
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)
492 return 2;
495 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
497 return 1;
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");
509 *ppv = &Protocol;
510 return S_OK;
513 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
515 ok(0, "unexpected call\n");
516 return S_OK;
519 static const IClassFactoryVtbl ClassFactoryVtbl = {
520 ClassFactory_QueryInterface,
521 ClassFactory_AddRef,
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");
532 return E_NOTIMPL;
535 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
537 return 2;
540 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
542 return 1;
545 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
546 IHlinkBrowseContext *pihlbc)
548 ok(0, "unexpected call\n");
549 return E_NOTIMPL;
552 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
553 IHlinkBrowseContext **ppihlbc)
555 ok(0, "unexpected call\n");
556 return E_NOTIMPL;
559 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
560 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
562 HRESULT hres;
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");
571 if(pihlNavigate) {
572 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
573 LPWSTR location = (LPWSTR)0xdeadbeef;
574 IHlinkSite *site;
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);
593 return S_OK;
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");
600 return E_NOTIMPL;
603 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
604 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
606 ok(0, "unexpected call\n");
607 return E_NOTIMPL;
610 static const IHlinkFrameVtbl HlinkFrameVtbl = {
611 HlinkFrame_QueryInterface,
612 HlinkFrame_AddRef,
613 HlinkFrame_Release,
614 HlinkFrame_SetBrowseContext,
615 HlinkFrame_GetBrowseContext,
616 HlinkFrame_Navigate,
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)) {
627 *ppv = iface;
628 return S_OK;
631 ok(0, "unexpected call\n");
632 return E_NOINTERFACE;
635 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
637 return 2;
640 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
642 return 1;
645 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
647 switch(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);
660 return S_OK;
661 case 1005:
662 CHECK_EXPECT(OnChanged_1005);
663 if(!editmode)
664 test_readyState(NULL);
665 load_state = LD_INTERACTIVE;
666 return S_OK;
669 ok(0, "unexpected id %d\n", dispID);
670 return E_NOTIMPL;
673 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
675 ok(0, "unexpected call\n");
676 return E_NOTIMPL;
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)
697 return 2;
700 static ULONG WINAPI Stream_Release(IStream *iface)
702 return 1;
705 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
706 ULONG cb, ULONG *pcbRead)
708 CHECK_EXPECT2(Read);
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);
714 if(stream_read)
715 return S_FALSE;
717 memcpy(pv, html_page, sizeof(html_page)-1);
718 stream_read += *pcbRead = sizeof(html_page)-1;
719 return S_OK;
722 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
723 ULONG cb, ULONG *pcbWritten)
725 ok(0, "unexpected call\n");
726 return E_NOTIMPL;
729 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
730 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
732 ok(0, "unexpected call\n");
733 return E_NOTIMPL;
736 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
738 ok(0, "unexpected call\n");
739 return E_NOTIMPL;
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");
746 return E_NOTIMPL;
749 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
751 ok(0, "unexpected call\n");
752 return E_NOTIMPL;
755 static HRESULT WINAPI Stream_Revert(IStream *iface)
757 ok(0, "unexpected call\n");
758 return E_NOTIMPL;
761 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
762 ULARGE_INTEGER cb, DWORD dwLockType)
764 ok(0, "unexpected call\n");
765 return E_NOTIMPL;
768 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
769 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
771 ok(0, "unexpected call\n");
772 return E_NOTIMPL;
775 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
776 DWORD dwStatFlag)
778 ok(0, "unexpected call\n");
779 return E_NOTIMPL;
782 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
784 ok(0, "unexpected call\n");
785 return E_NOTIMPL;
788 static const IStreamVtbl StreamVtbl = {
789 Stream_QueryInterface,
790 Stream_AddRef,
791 Stream_Release,
792 Stream_Read,
793 Stream_Write,
794 Stream_Seek,
795 Stream_SetSize,
796 Stream_CopyTo,
797 Stream_Commit,
798 Stream_Revert,
799 Stream_LockRegion,
800 Stream_UnlockRegion,
801 Stream_Stat,
802 Stream_Clone
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)
821 return 2;
824 static ULONG WINAPI Binding_Release(IBinding *iface)
826 return 1;
829 static HRESULT WINAPI Binding_Abort(IBinding *iface)
831 CHECK_EXPECT(Abort);
832 return S_OK;
835 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
837 ok(0, "unexpected call\n");
838 return E_NOTIMPL;
841 static HRESULT WINAPI Binding_Resume(IBinding *iface)
843 ok(0, "unexpected call\n");
844 return E_NOTIMPL;
847 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
849 ok(0, "unexpected call\n");
850 return E_NOTIMPL;
853 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
855 ok(0, "unexpected call\n");
856 return E_NOTIMPL;
859 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
860 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
862 CHECK_EXPECT(GetBindResult);
863 return E_NOTIMPL;
866 static const IBindingVtbl BindingVtbl = {
867 Binding_QueryInterface,
868 Binding_AddRef,
869 Binding_Release,
870 Binding_Abort,
871 Binding_Suspend,
872 Binding_Resume,
873 Binding_SetPriority,
874 Binding_GetPriority,
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)
885 *ppv = NULL;
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)
898 return 2;
901 static ULONG WINAPI Moniker_Release(IMoniker *iface)
903 return 1;
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));
910 return E_FAIL;
913 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
915 ok(0, "unexpected call\n");
916 return E_NOTIMPL;
919 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
921 ok(0, "unexpected call\n");
922 return E_NOTIMPL;
925 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
927 ok(0, "unexpected call\n");
928 return E_NOTIMPL;
931 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
933 ok(0, "unexpected call\n");
934 return E_NOTIMPL;
937 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
938 REFIID riidResult, void **ppvResult)
940 ok(0, "unexpected call\n");
941 return E_NOTIMPL;
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};
949 STGMEDIUM stgmedium;
950 BINDINFO bindinfo;
951 DWORD bindf;
952 HRESULT hres;
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,
997 wszTextHtml);
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);
1004 SET_EXPECT(Read);
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);
1012 CHECK_CALLED(Read);
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);
1025 return S_OK;
1028 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1029 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1031 ok(0, "unexpected call\n");
1032 return E_NOTIMPL;
1035 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1036 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1038 ok(0, "unexpected call\n");
1039 return E_NOTIMPL;
1042 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1044 ok(0, "unexpected call\n");
1045 return E_NOTIMPL;
1048 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1050 ok(0, "unexpected call\n");
1051 return E_NOTIMPL;
1054 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1056 ok(0, "unexpected call\n");
1057 return E_NOTIMPL;
1060 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1061 IMoniker *pmkNewlyRunning)
1063 ok(0, "unexpected call\n");
1064 return E_NOTIMPL;
1067 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1068 IMoniker *pmkToLeft, FILETIME *pFileTime)
1070 ok(0, "unexpected call\n");
1071 return E_NOTIMPL;
1074 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1076 ok(0, "unexpected call\n");
1077 return E_NOTIMPL;
1080 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1081 IMoniker **ppmkPrefix)
1083 ok(0, "unexpected call\n");
1084 return E_NOTIMPL;
1087 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1088 IMoniker **pmkRelPath)
1090 ok(0, "unexpected call\n");
1091 return E_NOTIMPL;
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));
1106 return S_OK;
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");
1113 return E_NOTIMPL;
1116 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1118 CHECK_EXPECT(IsSystemMoniker);
1119 return E_NOTIMPL;
1122 static const IMonikerVtbl MonikerVtbl = {
1123 Moniker_QueryInterface,
1124 Moniker_AddRef,
1125 Moniker_Release,
1126 Moniker_GetClassID,
1127 Moniker_IsDirty,
1128 Moniker_Load,
1129 Moniker_Save,
1130 Moniker_GetSizeMax,
1131 Moniker_BindToObject,
1132 Moniker_BindToStorage,
1133 Moniker_Reduce,
1134 Moniker_ComposeWith,
1135 Moniker_Enum,
1136 Moniker_IsEqual,
1137 Moniker_Hash,
1138 Moniker_IsRunning,
1139 Moniker_GetTimeOfLastChange,
1140 Moniker_Inverse,
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)
1157 return 2;
1160 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1162 return 1;
1165 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1166 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1168 ok(0, "unexpected call\n");
1169 return E_NOTIMPL;
1172 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1173 IEnumUnknown **ppenum)
1175 ok(0, "unexpected call\n");
1176 return E_NOTIMPL;
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);
1183 return S_OK;
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)
1205 return 2;
1208 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1210 return 1;
1213 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1215 ok(0, "unexpected call\n");
1216 return E_NOTIMPL;
1219 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1221 ok(0, "unexpected call\n");
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1227 ok(0, "unexpected call\n");
1228 return E_NOTIMPL;
1231 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1232 LPCBORDERWIDTHS pborderwidths)
1234 ok(0, "unexpected call\n");
1235 return E_NOTIMPL;
1238 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1239 LPCBORDERWIDTHS pborderwidths)
1241 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1242 return S_OK;
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");
1258 else {
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;
1263 return S_OK;
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};
1272 if(pActiveObject) {
1273 CHECK_EXPECT2(SetActiveObject);
1275 if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1276 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1277 }else {
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);
1284 return S_OK;
1287 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1288 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1290 ok(0, "unexpected call\n");
1291 return E_NOTIMPL;
1294 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1295 HOLEMENU holemenu, HWND hwndActiveObject)
1297 ok(0, "unexpected call\n");
1298 return E_NOTIMPL;
1301 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1303 ok(0, "unexpected call\n");
1304 return E_NOTIMPL;
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);
1312 return S_OK;
1315 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1317 if(fEnable)
1318 CHECK_EXPECT(Frame_EnableModeless_TRUE);
1319 else
1320 CHECK_EXPECT(Frame_EnableModeless_FALSE);
1321 return E_NOTIMPL;
1324 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1326 ok(0, "unexpected call\n");
1327 return E_NOTIMPL;
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)
1371 return 2;
1374 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1376 return 1;
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;
1384 return S_OK;
1387 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1389 ok(0, "unexpected call\n");
1390 return E_NOTIMPL;
1393 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1395 CHECK_EXPECT(CanInPlaceActivate);
1396 return S_OK;
1399 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1401 CHECK_EXPECT(OnInPlaceActivate);
1402 return S_OK;
1405 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1407 CHECK_EXPECT(OnUIActivate);
1408 return S_OK;
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");
1420 if(ppFrame)
1421 *ppFrame = &InPlaceFrame;
1422 ok(ppDoc != NULL, "ppDoc = NULL\n");
1423 if(ppDoc)
1424 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1425 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1426 if(lprcPosRect)
1427 memcpy(lprcPosRect, &rect, sizeof(RECT));
1428 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1429 if(lprcClipRect)
1430 memcpy(lprcClipRect, &rect, sizeof(RECT));
1431 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1432 if(lpFrameInfo) {
1433 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1434 lpFrameInfo->fMDIApp = FALSE;
1435 lpFrameInfo->hwndFrame = container_hwnd;
1436 lpFrameInfo->haccel = NULL;
1437 lpFrameInfo->cAccelEntries = 0;
1440 return S_OK;
1443 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1445 ok(0, "unexpected call\n");
1446 return E_NOTIMPL;
1449 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1451 CHECK_EXPECT(OnUIDeactivate);
1452 ok(!fUndoable, "fUndoable = TRUE\n");
1453 return S_OK;
1456 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1458 CHECK_EXPECT(OnInPlaceDeactivate);
1459 return S_OK;
1462 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1464 ok(0, "unexpected call\n");
1465 return E_NOTIMPL;
1468 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1470 ok(0, "unexpected call\n");
1471 return E_NOTIMPL;
1474 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1476 ok(0, "unexpected call\n");
1477 return E_NOTIMPL;
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);
1488 return S_OK;
1491 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1493 CHECK_EXPECT(OnInPlaceDeactivateEx);
1495 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1497 return S_OK;
1500 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1502 CHECK_EXPECT(RequestUIActivate);
1503 return S_OK;
1506 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1507 InPlaceSite_QueryInterface,
1508 InPlaceSite_AddRef,
1509 InPlaceSite_Release,
1510 InPlaceSite_GetWindow,
1511 InPlaceSite_ContextSensitiveHelp,
1512 InPlaceSite_CanInPlaceActivate,
1513 InPlaceSite_OnInPlaceActivate,
1514 InPlaceSite_OnUIActivate,
1515 InPlaceSite_GetWindowContext,
1516 InPlaceSite_Scroll,
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)
1536 return 2;
1539 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1541 return 1;
1544 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1546 ok(0, "unexpected call\n");
1547 return E_NOTIMPL;
1550 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1551 IMoniker **ppmon)
1553 ok(0, "unexpected call\n");
1554 return E_NOTIMPL;
1557 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1559 CHECK_EXPECT(GetContainer);
1560 ok(ppContainer != NULL, "ppContainer = NULL\n");
1561 *ppContainer = &OleContainer;
1562 return S_OK;
1565 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1567 ok(0, "unexpected call\n");
1568 return E_NOTIMPL;
1571 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1573 ok(0, "unexpected call\n");
1574 return E_NOTIMPL;
1577 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1579 ok(0, "unexpected call\n");
1580 return E_NOTIMPL;
1583 static const IOleClientSiteVtbl ClientSiteVtbl = {
1584 ClientSite_QueryInterface,
1585 ClientSite_AddRef,
1586 ClientSite_Release,
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)
1604 return 2;
1607 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1609 return 1;
1612 typedef enum
1614 CallUIActivate_None,
1615 CallUIActivate_ActivateMe,
1616 CallUIActivate_AfterShow,
1617 } CallUIActivate;
1619 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1620 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1622 IOleDocument *document;
1623 HRESULT hres;
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);
1657 if(activeobj) {
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);
1667 if(ipsex)
1668 SET_EXPECT(OnInPlaceActivateEx);
1669 else
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);
1676 SET_EXPECT(ShowUI);
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);
1685 if(ipsex)
1686 CHECK_CALLED(OnInPlaceActivateEx);
1687 else
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);
1696 if(activeobj) {
1697 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1698 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1699 ok(hwnd != NULL, "hwnd == NULL\n");
1700 if(last_hwnd)
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);
1707 if(activeobj) {
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);
1720 }else {
1721 SET_EXPECT(CanInPlaceActivate);
1722 SET_EXPECT(GetWindowContext);
1723 SET_EXPECT(GetWindow);
1724 if(ipsex)
1725 SET_EXPECT(OnInPlaceActivateEx);
1726 else
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);
1735 if(FAILED(hres)) {
1736 win_skip("Show failed\n");
1737 if(activeobj)
1738 IOleInPlaceActiveObject_Release(activeobj);
1739 IOleDocument_Release(document);
1740 show_failed = TRUE;
1741 return S_OK;
1743 ok(hres == S_OK, "Show failed: %08x\n", hres);
1745 CHECK_CALLED(CanInPlaceActivate);
1746 CHECK_CALLED(GetWindowContext);
1747 CHECK_CALLED(GetWindow);
1748 if(ipsex)
1749 CHECK_CALLED(OnInPlaceActivateEx);
1750 else
1751 CHECK_CALLED(OnInPlaceActivate);
1752 CHECK_CALLED(SetStatusText);
1753 CHECK_CALLED(Exec_SETPROGRESSMAX);
1754 CHECK_CALLED(Exec_SETPROGRESSPOS);
1756 if(activeobj) {
1757 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1758 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1759 ok(hwnd != NULL, "hwnd == NULL\n");
1760 if(last_hwnd)
1761 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1765 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1767 if(activeobj)
1768 IOleInPlaceActiveObject_Release(activeobj);
1771 IOleDocument_Release(document);
1774 return S_OK;
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)
1793 return 2;
1796 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1798 return 1;
1801 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1803 ok(0, "unexpected call\n");
1804 return E_NOTIMPL;
1807 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1809 ok(0, "unexpected call\n");
1810 return E_NOTIMPL;
1813 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1815 ok(0, "unexpected call\n");
1816 return E_NOTIMPL;
1819 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1820 POINTF *pPtfContainer, DWORD dwFlags)
1822 ok(0, "unexpected call\n");
1823 return E_NOTIMPL;
1826 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1827 MSG *pMsg, DWORD grfModifiers)
1829 ok(0, "unexpected call\n");
1830 return E_NOTIMPL;
1833 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1835 if(fGotFocus)
1836 CHECK_EXPECT(OnFocus_TRUE);
1837 else
1838 CHECK_EXPECT2(OnFocus_FALSE);
1839 return S_OK;
1842 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1844 ok(0, "unexpected call\n");
1845 return E_NOTIMPL;
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)
1870 return 2;
1873 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1875 return 1;
1878 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1879 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1881 ok(0, "unexpected call\n");
1882 return E_NOTIMPL;
1885 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1887 CHECK_EXPECT(GetHostInfo);
1888 ok(pInfo != NULL, "pInfo=NULL\n");
1889 if(pInfo) {
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);
1899 return S_OK;
1902 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1903 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1904 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1906 CHECK_EXPECT(ShowUI);
1908 if (editmode)
1909 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1910 else
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);
1917 else
1918 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1920 return S_OK;
1923 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1925 CHECK_EXPECT(HideUI);
1926 return S_OK;
1929 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1931 CHECK_EXPECT(UpdateUI);
1932 return S_OK;
1935 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1937 if(fEnable)
1938 CHECK_EXPECT(EnableModeless_TRUE);
1939 else
1940 CHECK_EXPECT(EnableModeless_FALSE);
1941 return E_NOTIMPL;
1944 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1946 ok(0, "unexpected call\n");
1947 return E_NOTIMPL;
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);
1955 return S_OK;
1958 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1959 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1961 ok(0, "unexpected call\n");
1962 return E_NOTIMPL;
1965 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1966 const GUID *pguidCmdGroup, DWORD nCmdID)
1968 ok(0, "unexpected call\n");
1969 return E_NOTIMPL;
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);
1978 if(pchKey)
1979 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1980 return S_OK;
1983 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1984 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1986 CHECK_EXPECT(GetDropTarget);
1987 /* TODO */
1988 return E_NOTIMPL;
1991 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1993 CHECK_EXPECT(GetExternal);
1994 *ppDispatch = &External;
1995 return S_FALSE;
1998 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
1999 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2001 ok(0, "unexpected call\n");
2002 return E_NOTIMPL;
2005 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2006 IDataObject **ppPORet)
2008 ok(0, "unexpected call\n");
2009 return E_NOTIMPL;
2012 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2013 LPOLESTR *pchKey, DWORD dw)
2015 CHECK_EXPECT(GetOverrideKeyPath);
2016 ok(pchKey != NULL, "pchKey = NULL\n");
2017 if(pchKey)
2018 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2019 ok(!dw, "dw=%d, xepected 0\n", dw);
2020 return S_OK;
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)
2055 return 2;
2058 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2060 return 1;
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;
2074 return S_OK;
2075 case OLECMDID_OPEN:
2076 CHECK_EXPECT(QueryStatus_OPEN);
2077 prgCmds[0].cmdf = 0;
2078 return S_OK;
2079 case OLECMDID_NEW:
2080 CHECK_EXPECT(QueryStatus_NEW);
2081 prgCmds[0].cmdf = 0;
2082 return S_OK;
2083 default:
2084 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2087 return E_FAIL;
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) {
2097 switch(nCmdID) {
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");
2102 if(pvaIn) {
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);
2108 return S_OK;
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");
2113 if(pvaIn) {
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);
2119 return S_OK;
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;
2126 return S_OK;
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)) {
2134 case 0:
2135 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2136 load_state = LD_INTERACTIVE;
2137 break;
2138 case 1:
2139 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2140 break;
2141 default:
2142 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2145 return S_OK;
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);
2151 return S_OK;
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 */
2159 return S_OK;
2160 case OLECMDID_HTTPEQUIV:
2161 CHECK_EXPECT2(Exec_HTTPEQUIV);
2162 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2163 /* TODO */
2164 return S_OK;
2165 default:
2166 ok(0, "unexpected command %d\n", nCmdID);
2167 return E_FAIL;
2171 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2172 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2174 switch(nCmdID) {
2175 case 37:
2176 CHECK_EXPECT2(Exec_ShellDocView_37);
2178 if(load_from_stream)
2179 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2180 else if(!editmode)
2181 test_GetCurMoniker(doc_unk, &Moniker, NULL);
2183 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2184 ok(pvaIn != NULL, "pvaIn == NULL\n");
2185 if(pvaIn) {
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));
2189 return S_OK;
2190 case 84:
2191 CHECK_EXPECT2(Exec_ShellDocView_84);
2193 ok(pvaIn == NULL, "pvaIn != NULL\n");
2194 ok(pvaOut != NULL, "pvaOut == NULL\n");
2195 if(pvaIn)
2196 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2198 return E_NOTIMPL;
2200 case 103:
2201 CHECK_EXPECT2(Exec_ShellDocView_103);
2203 ok(pvaIn == NULL, "pvaIn != NULL\n");
2204 ok(pvaOut == NULL, "pvaOut != NULL\n");
2206 return E_NOTIMPL;
2208 default:
2209 ok(0, "unexpected command %d\n", nCmdID);
2210 return E_FAIL;
2214 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2215 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2217 switch(nCmdID) {
2218 case IDM_PARSECOMPLETE:
2219 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2220 ok(pvaIn == NULL, "pvaIn != NULL\n");
2221 ok(pvaOut == NULL, "pvaOut != NULL\n");
2222 return S_OK;
2223 default:
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);
2234 switch(nCmdID) {
2235 case 69:
2236 CHECK_EXPECT2(Exec_Explorer_69);
2237 ok(pvaIn == NULL, "pvaIn != NULL\n");
2238 ok(pvaOut != NULL, "pvaOut == NULL\n");
2239 return E_NOTIMPL;
2240 default:
2241 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2243 return E_NOTIMPL;
2246 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2247 switch (nCmdID) {
2248 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2249 SET_EXPECT(SetStatusText);
2250 ok(pvaIn == NULL, "pvaIn != NULL\n");
2251 ok(pvaOut == NULL, "pvaOut != NULL\n");
2252 return S_OK;
2253 default:
2254 ok(0, "unexpected command %d\n", nCmdID);
2255 return E_FAIL;
2259 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2260 return E_NOTIMPL;
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;
2295 return S_OK;
2296 case DISPID_AMBIENT_DLCONTROL:
2297 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2298 return E_FAIL;
2299 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2300 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2301 return E_FAIL;
2302 case DISPID_AMBIENT_SILENT:
2303 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2304 V_VT(pVarResult) = VT_BOOL;
2305 V_BOOL(pVarResult) = VARIANT_FALSE;
2306 return S_OK;
2307 case DISPID_AMBIENT_USERAGENT:
2308 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2309 return E_FAIL;
2310 case DISPID_AMBIENT_PALETTE:
2311 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2312 return E_FAIL;
2315 ok(0, "unexpected dispid %d\n", dispIdMember);
2316 return E_FAIL;
2319 static IDispatchVtbl DispatchVtbl = {
2320 Dispatch_QueryInterface,
2321 Dispatch_AddRef,
2322 Dispatch_Release,
2323 Dispatch_GetTypeInfoCount,
2324 Dispatch_GetTypeInfo,
2325 Dispatch_GetIDsOfNames,
2326 Dispatch_Invoke
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)
2339 return 2;
2342 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2344 return 1;
2347 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2348 REFIID riid, void **ppv)
2351 * Services used by HTMLDocument:
2353 * IOleUndoManager
2354 * IInternetSecurityManager
2355 * ITargetFrame
2356 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2357 * HTMLFrameBase
2358 * IShellObject
2359 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2360 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2361 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2362 * DefView (?)
2363 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2364 * IElementBehaviorFactory
2365 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2366 * STopLevelBrowser
2367 * IHTMLWindow2
2368 * IInternetProtocol
2369 * IWebBrowserApp
2370 * UrlHostory
2371 * IHTMLEditHost
2372 * IHlinkFrame
2375 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2376 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2377 *ppv = &HlinkFrame;
2378 return S_OK;
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)
2399 *ppv = NULL;
2401 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2402 *ppv = &ClientSite;
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))
2414 *ppv = &Dispatch;
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; /* ? */
2431 else
2432 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2434 if(*ppv)
2435 return S_OK;
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;
2448 BSTR state;
2449 VARIANT out;
2450 HRESULT hres;
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[] = {
2458 wszUninitialized,
2459 wszLoading,
2460 NULL,
2461 wszInteractive,
2462 wszComplete,
2463 wszUninitialized
2466 if(!unk)
2467 unk = doc_unk;
2469 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2470 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2471 if(FAILED(hres))
2472 return;
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);
2479 ok_(__FILE__, line)
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;
2489 VariantInit(&out);
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;
2505 IID iid;
2506 HRESULT hres;
2508 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2509 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2510 if(FAILED(hres))
2511 return;
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");
2523 if(SUCCEEDED(hres))
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)) {
2530 DWORD cookie;
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;
2542 HRESULT hres;
2544 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2545 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2546 if(FAILED(hres))
2547 return;
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;
2562 HRESULT hres;
2564 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2565 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2566 if(FAILED(hres))
2567 return;
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);
2578 if(exmon) {
2579 LPOLESTR url;
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");
2594 CoTaskMemFree(url);
2595 }else if(exurl) {
2596 LPOLESTR url;
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");
2606 CoTaskMemFree(url);
2607 }else {
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)
2622 IBindCtx *bind;
2623 HRESULT hres;
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)
2716 HWND hwnd;
2717 MSG msg;
2719 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2720 ok(hwnd != NULL, "Could not find hidden window\n");
2722 test_readyState(NULL);
2724 if(verb_done) {
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);
2732 if(css_try_dwl)
2733 SET_EXPECT(Exec_ShellDocView_84);
2734 if(css_dwl) {
2735 SET_EXPECT(CreateInstance);
2736 SET_EXPECT(Start);
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);
2762 if(verb_done) {
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);
2770 if(css_try_dwl)
2771 SET_CALLED(Exec_ShellDocView_84);
2772 if(css_dwl) {
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);
2780 }else {
2781 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2783 SET_CALLED(Exec_ShellDocView_84);
2784 SET_CALLED(CreateInstance);
2785 SET_CALLED(Start);
2786 SET_CALLED(LockRequest);
2787 SET_CALLED(Terminate);
2788 SET_CALLED(Protocol_Read);
2789 SET_CALLED(UnlockRequest);
2791 nogecko = TRUE;
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;
2817 GUID guid;
2818 HRESULT hres;
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 */
2877 0,0,0,0,0,0,
2878 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2879 0,0,
2880 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2881 0,0,
2882 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2883 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2884 0,0,0,0,0,
2885 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2886 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2887 0,0,
2888 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2889 0,0,0,
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};
2899 HRESULT hres;
2901 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2902 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2903 if(FAILED(hres))
2904 return;
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)
2917 if(!unk)
2918 unk = doc_unk;
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];
2942 int i;
2943 HRESULT hres;
2945 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2946 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2947 if(FAILED(hres))
2948 return;
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)
2965 continue;
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;
2979 int i;
2980 HRESULT hres;
2982 OLECMD cmd[2] = {
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);
2989 if(FAILED(hres))
2990 return;
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;
3031 VARIANT var;
3032 HRESULT hres;
3034 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3035 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3036 if(FAILED(hres))
3037 return;
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;
3056 HRESULT hres;
3058 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3059 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3060 if(FAILED(hres))
3061 return;
3063 editmode = TRUE;
3065 if(loaded)
3066 load_state = LD_DOLOAD;
3068 if(loaded)
3069 SET_EXPECT(GetClassID);
3070 SET_EXPECT(SetStatusText);
3071 SET_EXPECT(Exec_ShellDocView_37);
3072 SET_EXPECT(GetHostInfo);
3073 if(loaded)
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);
3080 if(loaded)
3081 SET_EXPECT(BindToStorage);
3082 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3083 SET_EXPECT(HideUI);
3084 SET_EXPECT(ShowUI);
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);
3094 if(loaded)
3095 CHECK_CALLED(GetClassID);
3096 CHECK_CALLED(SetStatusText);
3097 CHECK_CALLED(Exec_ShellDocView_37);
3098 CHECK_CALLED(GetHostInfo);
3099 if(loaded)
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);
3106 if(loaded)
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;
3126 HRESULT hres;
3128 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3129 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3130 if(FAILED(hres))
3131 return;
3133 if(name) {
3134 in = &_in;
3135 V_VT(in) = VT_BSTR;
3136 V_BSTR(in) = SysAllocString(name);
3139 if(exname) {
3140 out = &_out;
3141 V_VT(out) = VT_I4;
3142 V_I4(out) = 0xdeadbeef;
3145 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3146 if(!nogecko)
3147 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3149 if(in)
3150 VariantClear(in);
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) {
3155 if(exname)
3156 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3157 "unexpected fontname \"%s\"\n", debugstr_w(name));
3158 else
3159 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3161 VariantClear(out);
3164 IOleCommandTarget_Release(cmdtrg);
3167 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3169 IOleCommandTarget *cmdtrg;
3170 HRESULT hres;
3172 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3173 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3174 if(FAILED(hres))
3175 return;
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;
3189 HRESULT hres;
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),
3223 wnd_proc,
3224 0, 0, NULL, NULL, NULL, NULL, NULL,
3225 wszHTMLDocumentTest,
3226 NULL
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};
3238 HRESULT hres;
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;
3265 HRESULT hres;
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)
3278 return;
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;
3335 HRESULT hres;
3337 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3338 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3339 if(FAILED(hres))
3340 return;
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;
3384 HRESULT hres;
3386 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3387 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3388 if(FAILED(hres))
3389 return;
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;
3400 HRESULT hres;
3402 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3403 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3404 if(FAILED(hres))
3405 return;
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;
3416 if(set_client)
3417 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3419 IOleObject_Release(oleobj);
3422 static void test_OnFrameWindowActivate(IUnknown *unk)
3424 IOleInPlaceActiveObject *inplaceact;
3425 HRESULT hres;
3427 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3428 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3429 if(FAILED(hres))
3430 return;
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);
3455 }else {
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;
3469 HRESULT hres;
3471 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3472 (void**)&windowlessobj);
3473 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3474 if(FAILED(hres))
3475 return;
3477 if(expect_call) {
3478 SET_EXPECT(OnFocus_FALSE);
3479 if(ipsex)
3480 SET_EXPECT(OnInPlaceDeactivateEx);
3481 else
3482 SET_EXPECT(OnInPlaceDeactivate);
3484 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3485 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3486 if(expect_call) {
3487 CHECK_CALLED(OnFocus_FALSE);
3488 if(ipsex)
3489 CHECK_CALLED(OnInPlaceDeactivateEx);
3490 else
3491 CHECK_CALLED(OnInPlaceDeactivate);
3494 IOleInPlaceObjectWindowless_Release(windowlessobj);
3497 static void test_Activate(IUnknown *unk, DWORD flags)
3499 IOleObject *oleobj = NULL;
3500 IOleDocumentView *docview;
3501 GUID guid;
3502 HRESULT hres;
3504 last_hwnd = hwnd;
3506 if(view)
3507 IOleDocumentView_Release(view);
3508 view = NULL;
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);
3532 SET_EXPECT(ShowUI);
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;
3557 HWND tmp_hwnd;
3558 HRESULT hres;
3560 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3561 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3562 if(FAILED(hres))
3563 return;
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);
3570 }else {
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;
3581 HRESULT hres;
3583 if(!view)
3584 return;
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)
3602 HRESULT hres;
3604 if(call_UIActivate == CallUIActivate_AfterShow) {
3605 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3607 if(call_UIActivate != CallUIActivate_None) {
3608 SET_EXPECT(SetActiveObject_null);
3609 SET_EXPECT(HideUI);
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)
3628 HRESULT hres;
3630 if(!view)
3631 return;
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;
3640 HRESULT hres;
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);
3645 if(FAILED(hres))
3646 return hres;
3648 hres = IUnknown_QueryInterface(*unk, &IID_IHTMLDocument5, (void**)&doc5);
3649 if(SUCCEEDED(hres)) {
3650 IHTMLDocument5_Release(doc5);
3651 }else {
3652 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
3653 IUnknown_Release(*unk);
3656 return hres;
3659 static void test_Navigate(IUnknown *unk)
3661 IHlinkTarget *hlink;
3662 HRESULT hres;
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;
3680 HRESULT hres;
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);
3689 if(initialized)
3690 SET_EXPECT(GetExternal);
3691 external = (void*)0xdeadbeef;
3692 hres = IHTMLWindow2_get_external(htmlwin, &external);
3693 if(initialized) {
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");
3697 }else {
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;
3708 HRESULT hres;
3710 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3711 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3712 if(FAILED(hres))
3713 return;
3715 SET_EXPECT(Invoke_AMBIENT_SILENT);
3716 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3717 SET_EXPECT(Exec_ShellDocView_37);
3718 SET_EXPECT(OnChanged_READYSTATE);
3719 SET_EXPECT(Read);
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);
3729 CHECK_CALLED(Read);
3731 test_timer(EXPECT_SETTITLE);
3732 test_GetCurMoniker(unk, NULL, about_blank_url);
3734 IPersistStreamInit_Release(init);
3737 static void test_QueryInterface(IUnknown *unk)
3739 IUnknown *qi;
3740 HRESULT hres;
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) {
3777 doc_unk = NULL;
3778 hwnd = last_hwnd = NULL;
3779 set_clientsite = FALSE;
3780 load_from_stream = FALSE;
3781 call_UIActivate = CallUIActivate_None;
3782 load_state = ls;
3783 editmode = FALSE;
3784 stream_read = 0;
3785 protocol_read = 0;
3786 ipsex = FALSE;
3789 static void test_HTMLDocument(BOOL do_load)
3791 IUnknown *unk;
3792 HRESULT hres;
3793 ULONG ref;
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);
3800 if(FAILED(hres))
3801 return;
3802 doc_unk = 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);
3810 test_Persist(unk);
3811 if(!do_load)
3812 test_OnAmbientPropertyChange2(unk);
3814 test_Activate(unk, CLIENTSITE_EXPECTPATH);
3816 if(do_load) {
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);
3837 test_Hide();
3838 test_InPlaceDeactivate(unk, FALSE);
3839 test_CloseView();
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);
3857 test_CloseView();
3858 test_CloseView();
3859 test_Close(unk, TRUE);
3860 test_OnAmbientPropertyChange2(unk);
3861 test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3863 if(!do_load) {
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;
3875 if(view)
3876 IOleDocumentView_Release(view);
3877 view = NULL;
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)
3889 IUnknown *unk;
3890 HRESULT hres;
3891 ULONG ref;
3893 trace("Testing HTMLDocument (hlink)...\n");
3895 init_test(LD_DOLOAD);
3896 ipsex = TRUE;
3898 hres = create_document(&unk);
3899 if(FAILED(hres))
3900 return;
3901 doc_unk = unk;
3903 test_ConnectionPointContainer(unk);
3904 test_GetCurMoniker(unk, NULL, NULL);
3905 test_Persist(unk);
3906 test_Navigate(unk);
3907 if(show_failed) {
3908 IUnknown_Release(unk);
3909 return;
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);
3924 if(view)
3925 IOleDocumentView_Release(view);
3926 view = NULL;
3928 ref = IUnknown_Release(unk);
3929 ok(ref == 0, "ref=%d, expected 0\n", ref);
3932 static void test_HTMLDocument_StreamLoad(void)
3934 IOleObject *oleobj;
3935 IUnknown *unk;
3936 HRESULT hres;
3937 ULONG ref;
3939 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3941 init_test(LD_DOLOAD);
3942 load_from_stream = TRUE;
3944 hres = create_document(&unk);
3945 if(FAILED(hres))
3946 return;
3947 doc_unk = 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);
3971 if(view) {
3972 IOleDocumentView_Release(view);
3973 view = NULL;
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;
3984 HRESULT hres;
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);
3991 SET_EXPECT(ShowUI);
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)
4010 IUnknown *unk;
4011 IOleObject *oleobj;
4012 HRESULT hres;
4013 ULONG ref;
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);
4021 if(FAILED(hres))
4022 return;
4023 doc_unk = 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);
4035 if(do_load)
4036 test_Persist(unk);
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);
4052 if(!do_load) {
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);
4060 if(!nogecko)
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);
4068 if(!nogecko)
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);
4082 if(view) {
4083 IOleDocumentView_Release(view);
4084 view = NULL;
4087 ref = IUnknown_Release(unk);
4088 ok(ref == 0, "ref=%d, expected 0\n", ref);
4091 static void register_protocol(void)
4093 IInternetSession *session;
4094 HRESULT hres;
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)
4110 HKEY hkey;
4111 DWORD res;
4113 static BOOL has_url = FALSE;
4114 static char url[2048];
4116 if(!disable && !has_url)
4117 return;
4119 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4120 if(res != ERROR_SUCCESS)
4121 return;
4123 if(disable) {
4124 DWORD type, size = sizeof(url);
4126 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4127 if(res == ERROR_SUCCESS && type == REG_SZ)
4128 has_url = TRUE;
4130 RegDeleteValue(hkey, "GeckoUrl");
4131 }else {
4132 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4135 RegCloseKey(hkey);
4138 static void test_HTMLDoc_ISupportErrorInfo(void)
4140 HRESULT hres;
4141 IUnknown *unk;
4142 ISupportErrorInfo *sinfo;
4143 LONG ref;
4145 hres = create_document(&unk);
4146 if(FAILED(hres))
4147 return;
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);
4152 if(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);
4163 START_TEST(htmldoc)
4165 gecko_installer_workaround(TRUE);
4167 CoInitialize(NULL);
4168 container_hwnd = create_container_window();
4169 register_protocol();
4171 test_HTMLDocument_hlink();
4172 if(!show_failed) {
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);
4182 CoUninitialize();
4184 gecko_installer_workaround(FALSE);