2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
32 #include "docobjectservice.h"
41 #include "shdeprecated.h"
44 #include "mshtml_test.h"
46 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
47 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
48 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
50 #define DEFINE_EXPECT(func) \
51 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
53 #define SET_EXPECT(func) \
54 expect_ ## func = TRUE
56 #define SET_CALLED(func) \
57 called_ ## func = TRUE
59 #define CHECK_EXPECT2(func) \
61 ok(expect_ ##func, "unexpected call " #func "\n"); \
62 called_ ## func = TRUE; \
65 #define CHECK_EXPECT(func) \
67 CHECK_EXPECT2(func); \
68 expect_ ## func = FALSE; \
71 #define CHECK_CALLED(func) \
73 ok(called_ ## func, "expected " #func "\n"); \
74 expect_ ## func = called_ ## func = FALSE; \
77 #define CHECK_NOT_CALLED(func) \
79 ok(!called_ ## func, "unexpected " #func "\n"); \
80 expect_ ## func = called_ ## func = FALSE; \
83 #define CHECK_CALLED_BROKEN(func) \
85 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
86 expect_ ## func = called_ ## func = FALSE; \
89 #define CLEAR_CALLED(func) \
90 expect_ ## func = called_ ## func = FALSE
92 static IOleDocumentView *view = NULL;
93 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
95 DEFINE_EXPECT(LockContainer);
96 DEFINE_EXPECT(SetActiveObject);
97 DEFINE_EXPECT(SetActiveObject_null);
98 DEFINE_EXPECT(GetWindow);
99 DEFINE_EXPECT(CanInPlaceActivate);
100 DEFINE_EXPECT(OnInPlaceActivate);
101 DEFINE_EXPECT(OnInPlaceActivateEx);
102 DEFINE_EXPECT(OnUIActivate);
103 DEFINE_EXPECT(GetWindowContext);
104 DEFINE_EXPECT(OnUIDeactivate);
105 DEFINE_EXPECT(OnInPlaceDeactivate);
106 DEFINE_EXPECT(OnInPlaceDeactivateEx);
107 DEFINE_EXPECT(GetContainer);
108 DEFINE_EXPECT(ShowUI);
109 DEFINE_EXPECT(ActivateMe);
110 DEFINE_EXPECT(GetHostInfo);
111 DEFINE_EXPECT(HideUI);
112 DEFINE_EXPECT(GetOptionKeyPath);
113 DEFINE_EXPECT(GetOverrideKeyPath);
114 DEFINE_EXPECT(SetStatusText);
115 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
116 DEFINE_EXPECT(QueryStatus_OPEN);
117 DEFINE_EXPECT(QueryStatus_NEW);
118 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
119 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
120 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
121 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
122 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
123 DEFINE_EXPECT(Exec_ShellDocView_37);
124 DEFINE_EXPECT(Exec_ShellDocView_63);
125 DEFINE_EXPECT(Exec_ShellDocView_67);
126 DEFINE_EXPECT(Exec_ShellDocView_84);
127 DEFINE_EXPECT(Exec_ShellDocView_103);
128 DEFINE_EXPECT(Exec_ShellDocView_105);
129 DEFINE_EXPECT(Exec_ShellDocView_140);
130 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
131 DEFINE_EXPECT(Exec_SETTITLE);
132 DEFINE_EXPECT(Exec_HTTPEQUIV);
133 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
134 DEFINE_EXPECT(Exec_Explorer_69);
135 DEFINE_EXPECT(Exec_DOCCANNAVIGATE);
136 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
137 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
138 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
139 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
140 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
141 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
142 DEFINE_EXPECT(Invoke_OnReadyStateChange_Interactive);
143 DEFINE_EXPECT(Invoke_OnReadyStateChange_Loading);
144 DEFINE_EXPECT(Invoke_OnReadyStateChange_Complete);
145 DEFINE_EXPECT(GetDropTarget);
146 DEFINE_EXPECT(UpdateUI);
147 DEFINE_EXPECT(Navigate);
148 DEFINE_EXPECT(OnFrameWindowActivate);
149 DEFINE_EXPECT(OnChanged_READYSTATE);
150 DEFINE_EXPECT(OnChanged_1005);
151 DEFINE_EXPECT(OnChanged_1012);
152 DEFINE_EXPECT(GetDisplayName);
153 DEFINE_EXPECT(BindToStorage);
154 DEFINE_EXPECT(IsSystemMoniker);
155 DEFINE_EXPECT(GetBindResult);
156 DEFINE_EXPECT(GetClassID);
157 DEFINE_EXPECT(Abort);
159 DEFINE_EXPECT(CreateInstance);
160 DEFINE_EXPECT(Start);
161 DEFINE_EXPECT(Terminate);
162 DEFINE_EXPECT(Protocol_Read);
163 DEFINE_EXPECT(LockRequest);
164 DEFINE_EXPECT(UnlockRequest);
165 DEFINE_EXPECT(OnFocus_TRUE);
166 DEFINE_EXPECT(OnFocus_FALSE);
167 DEFINE_EXPECT(RequestUIActivate);
168 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
169 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
170 DEFINE_EXPECT(GetExternal);
171 DEFINE_EXPECT(EnableModeless_TRUE);
172 DEFINE_EXPECT(EnableModeless_FALSE);
173 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
174 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
175 DEFINE_EXPECT(Frame_GetWindow);
176 DEFINE_EXPECT(TranslateUrl);
177 DEFINE_EXPECT(Advise_Close);
178 DEFINE_EXPECT(OnViewChange);
179 DEFINE_EXPECT(EvaluateNewWindow);
180 DEFINE_EXPECT(GetTravelLog);
181 DEFINE_EXPECT(UpdateBackForwardState);
182 DEFINE_EXPECT(FireNavigateComplete2);
183 DEFINE_EXPECT(FireDocumentComplete);
184 DEFINE_EXPECT(GetPendingUrl);
185 DEFINE_EXPECT(ActiveElementChanged);
186 DEFINE_EXPECT(IsErrorUrl);
188 static IUnknown *doc_unk;
189 static IMoniker *doc_mon;
190 static BOOL expect_LockContainer_fLock;
191 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
192 static BOOL ipsex, ipsw;
193 static BOOL set_clientsite, container_locked;
194 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
195 static BOOL editmode = FALSE;
196 static BOOL inplace_deactivated, open_call;
197 static BOOL complete = FALSE;
198 static DWORD status_code = HTTP_STATUS_OK;
199 static BOOL asynchronous_binding = FALSE;
200 static int stream_read, protocol_read;
201 static enum load_state_t {
210 static LPCOLESTR expect_status_text = NULL;
211 static const char *nav_url;
213 static const char html_page[] =
215 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
219 static const char css_data[] = "body {color: red}";
221 static const WCHAR http_urlW[] =
222 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
224 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
226 #define DOCHOST_DOCCANNAVIGATE 0
227 #define WM_CONTINUE_BINDING (WM_APP+1)
229 static HRESULT QueryInterface(REFIID riid, void **ppv);
230 static void test_MSHTML_QueryStatus(IHTMLDocument2*,DWORD);
232 #define test_readyState(u) _test_readyState(__LINE__,u)
233 static void _test_readyState(unsigned,IUnknown*);
235 static const WCHAR wszTimesNewRoman[] =
236 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
237 static const WCHAR wszArial[] =
238 {'A','r','i','a','l',0};
240 static const char *debugstr_guid(REFIID riid)
247 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
248 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
249 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
250 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
255 static int strcmp_wa(LPCWSTR strw, const char *stra)
258 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
259 return lstrcmpA(stra, buf);
262 static const WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
266 const WCHAR *p1 = str, *p2 = sub;
267 while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
268 if (!*p2) return str;
274 static BSTR a2bstr(const char *str)
279 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
280 ret = SysAllocStringLen(NULL, len);
281 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
286 static BOOL is_english(void)
288 return PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
289 && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
292 #define EXPECT_UPDATEUI 1
293 #define EXPECT_SETTITLE 2
295 static void test_timer(DWORD flags)
297 BOOL *b = &called_Exec_SETTITLE;
300 if(flags & EXPECT_UPDATEUI) {
301 SET_EXPECT(UpdateUI);
302 SET_EXPECT(Exec_UPDATECOMMANDS);
303 b = &called_UpdateUI;
305 if(flags & EXPECT_SETTITLE)
306 SET_EXPECT(Exec_SETTITLE);
308 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
309 TranslateMessage(&msg);
310 DispatchMessage(&msg);
313 if(flags & EXPECT_UPDATEUI) {
314 CHECK_CALLED(UpdateUI);
315 CHECK_CALLED(Exec_UPDATECOMMANDS);
317 if(flags & EXPECT_SETTITLE)
318 CHECK_CALLED(Exec_SETTITLE);
321 static IMoniker Moniker;
323 #define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
324 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, const char *exurl)
327 IPersistMoniker *permon;
328 IMoniker *mon = (void*)0xdeadbeef;
329 BSTR doc_url = (void*)0xdeadbeef;
335 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
336 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
340 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
341 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
343 hres = IHTMLDocument2_get_URL(doc, &doc_url);
344 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
346 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
347 IPersistMoniker_Release(permon);
351 BOOL exb = expect_GetDisplayName;
352 BOOL clb = called_GetDisplayName;
354 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
355 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
358 SET_EXPECT(GetDisplayName);
359 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
360 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
362 CHECK_CALLED(GetDisplayName);
363 expect_GetDisplayName = exb;
364 called_GetDisplayName = clb;
366 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
371 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
373 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
374 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
376 ok_(__FILE__,line)(!strcmp_wa(url, exurl), "unexpected url %s\n", wine_dbgstr_w(url));
377 ok_(__FILE__,line)(!lstrcmpW(url, doc_url), "url != doc_url\n");
381 ok_(__FILE__,line)(hres == E_UNEXPECTED,
382 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
383 ok_(__FILE__,line)(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
384 ok_(__FILE__,line)(!strcmp_wa(doc_url, "about:blank"), "doc_url is not about:blank\n");
387 SysFreeString(doc_url);
388 IHTMLDocument_Release(doc);
389 if(mon && mon != (void*)0xdeadbeef)
390 IMoniker_Release(mon);
393 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
395 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
399 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
404 if(IsEqualGUID(&IID_IProxyManager, riid))
405 return E_NOINTERFACE; /* TODO */
406 if(IsEqualGUID(&IID_IDispatchEx, riid))
407 return E_NOINTERFACE; /* TODO */
408 if(IsEqualGUID(&IID_External_unk, riid))
409 return E_NOINTERFACE; /* TODO */
411 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
412 return E_NOINTERFACE;
415 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
420 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
425 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
427 ok(0, "unexpected call\n");
431 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
434 ok(0, "unexpected call\n");
438 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
439 UINT cNames, LCID lcid, DISPID *rgDispId)
441 ok(0, "unexpected call\n");
445 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
446 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
447 EXCEPINFO *pExcepInfo, UINT *puArgErr)
449 ok(0, "unexpected call\n");
453 static const IDispatchVtbl ExternalVtbl = {
454 External_QueryInterface,
457 Dispatch_GetTypeInfoCount,
458 Dispatch_GetTypeInfo,
459 Dispatch_GetIDsOfNames,
463 static IDispatch External = { &ExternalVtbl };
465 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
467 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
473 return E_NOINTERFACE;
476 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
481 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
486 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
487 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
488 DWORD grfPI, HANDLE_PTR dwReserved)
494 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
495 static const WCHAR empty_str = {0};
499 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
500 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
501 ok(!grfPI, "grfPI = %x\n", grfPI);
502 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
504 memset(&bindinfo, 0, sizeof(bindinfo));
505 bindinfo.cbSize = sizeof(bindinfo);
506 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
507 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
508 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
509 "bindf = %x\n", bindf);
511 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
512 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
513 /* TODO: test stgmedData */
514 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
515 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
516 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
517 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
518 ok(bindinfo.dwOptions == 0x80000 ||
519 bindinfo.dwOptions == 0x4080000, /* win2k3 */
520 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
521 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
522 /* TODO: test dwCodePage */
523 /* TODO: test securityAttributes */
524 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
525 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
526 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
528 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
529 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
530 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
532 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
533 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
535 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
537 hres = IInternetProtocolSink_ReportData(pOIProtSink,
538 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
539 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
541 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
542 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
547 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
548 PROTOCOLDATA *pProtocolData)
550 ok(0, "unexpected call\n");
554 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
557 ok(0, "unexpected call\n");
561 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
563 CHECK_EXPECT(Terminate);
567 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
569 ok(0, "unexpected call\n");
573 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
575 ok(0, "unexpected call\n");
579 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
580 ULONG cb, ULONG *pcbRead)
582 CHECK_EXPECT2(Protocol_Read);
584 ok(pv != NULL, "pv == NULL\n");
585 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
586 ok(pcbRead != NULL, "pcbRead == NULL\n");
587 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
592 protocol_read += *pcbRead = sizeof(css_data)-1;
593 memcpy(pv, css_data, sizeof(css_data)-1);
597 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
598 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
600 ok(0, "unexpected call\n");
604 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
606 CHECK_EXPECT(LockRequest);
610 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
612 CHECK_EXPECT(UnlockRequest);
616 static const IInternetProtocolVtbl ProtocolVtbl = {
617 Protocol_QueryInterface,
628 Protocol_LockRequest,
629 Protocol_UnlockRequest
632 static IInternetProtocol Protocol = { &ProtocolVtbl };
634 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
636 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
637 ok(0, "unexpected call\n");
638 return E_NOINTERFACE;
641 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
646 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
651 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
652 REFIID riid, void **ppv)
654 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
655 return E_NOINTERFACE;
657 CHECK_EXPECT(CreateInstance);
658 ok(ppv != NULL, "ppv == NULL\n");
664 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
666 ok(0, "unexpected call\n");
670 static const IClassFactoryVtbl ClassFactoryVtbl = {
671 ClassFactory_QueryInterface,
673 ClassFactory_Release,
674 ClassFactory_CreateInstance,
675 ClassFactory_LockServer
678 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
680 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
682 ok(0, "unexpected call\n");
686 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
691 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
696 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
697 IHlinkBrowseContext *pihlbc)
699 ok(0, "unexpected call\n");
703 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
704 IHlinkBrowseContext **ppihlbc)
706 ok(0, "unexpected call\n");
710 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
711 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
715 CHECK_EXPECT(Navigate);
717 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
718 ok(pbc != NULL, "pbc == NULL\n");
719 ok(pibsc != NULL, "pubsc == NULL\n");
720 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
723 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
724 LPWSTR location = (LPWSTR)0xdeadbeef;
726 IMoniker *mon = NULL;
727 DWORD site_data = 0xdeadbeef;
729 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
731 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
732 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
734 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
735 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
736 ok(location == NULL, "location = %p\n", location);
737 ok(mon != NULL, "mon == NULL\n");
739 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
740 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
741 ok(site == NULL, "site = %p\n, expected NULL\n", site);
742 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
748 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
749 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
751 ok(0, "unexpected call\n");
755 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
756 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
758 ok(0, "unexpected call\n");
762 static const IHlinkFrameVtbl HlinkFrameVtbl = {
763 HlinkFrame_QueryInterface,
766 HlinkFrame_SetBrowseContext,
767 HlinkFrame_GetBrowseContext,
769 HlinkFrame_OnNavigate,
770 HlinkFrame_UpdateHlink
773 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
775 static HRESULT WINAPI NewWindowManager_QueryInterface(INewWindowManager *iface, REFIID riid, void **ppv)
777 ok(0, "unexpected call\n");
778 return E_NOINTERFACE;
781 static ULONG WINAPI NewWindowManager_AddRef(INewWindowManager *iface)
786 static ULONG WINAPI NewWindowManager_Release(INewWindowManager *iface)
791 static HRESULT WINAPI NewWindowManager_EvaluateNewWindow(INewWindowManager *iface, LPCWSTR pszUrl,
792 LPCWSTR pszName, LPCWSTR pszUrlContext, LPCWSTR pszFeatures, BOOL fReplace, DWORD dwFlags,
793 DWORD dwUserActionTime)
795 CHECK_EXPECT(EvaluateNewWindow);
797 ok(!strcmp_wa(pszUrl, "about:blank"), "pszUrl = %s\n", wine_dbgstr_w(pszUrl));
798 ok(!strcmp_wa(pszName, "test"), "pszName = %s\n", wine_dbgstr_w(pszName));
799 ok(!strcmp_wa(pszUrlContext, "about:replace"), "pszUrlContext = %s\n", wine_dbgstr_w(pszUrlContext));
800 ok(!pszFeatures, "pszFeatures = %s\n", wine_dbgstr_w(pszFeatures));
801 ok(!fReplace, "fReplace = %x\n", fReplace);
802 ok(dwFlags == NWMF_FIRST, "dwFlags = %x\n", dwFlags);
803 ok(!dwUserActionTime, "dwUserActionime = %d\n", dwUserActionTime);
808 static const INewWindowManagerVtbl NewWindowManagerVtbl = {
809 NewWindowManager_QueryInterface,
810 NewWindowManager_AddRef,
811 NewWindowManager_Release,
812 NewWindowManager_EvaluateNewWindow
815 static INewWindowManager NewWindowManager = { &NewWindowManagerVtbl };
817 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
818 REFIID riid, void**ppv)
820 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
825 ok(0, "unexpected call\n");
826 return E_NOINTERFACE;
829 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
834 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
839 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
842 case DISPID_READYSTATE:
843 CHECK_EXPECT2(OnChanged_READYSTATE);
845 if(!readystate_set_interactive)
846 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
847 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
848 ? OLECMDF_ENABLED : 0));
850 if(readystate_set_loading) {
851 readystate_set_loading = FALSE;
852 load_state = LD_LOADING;
854 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
855 test_readyState(NULL);
858 CHECK_EXPECT(OnChanged_1005);
860 test_readyState(NULL);
861 readystate_set_interactive = (load_state != LD_INTERACTIVE);
864 CHECK_EXPECT(OnChanged_1012);
879 ok(0, "unexpected id %d\n", dispID);
883 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
885 ok(0, "unexpected call\n");
889 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
890 PropertyNotifySink_QueryInterface,
891 PropertyNotifySink_AddRef,
892 PropertyNotifySink_Release,
893 PropertyNotifySink_OnChanged,
894 PropertyNotifySink_OnRequestEdit
897 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
899 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
901 ok(0, "unexpected call\n");
902 return E_NOINTERFACE;
905 static ULONG WINAPI Stream_AddRef(IStream *iface)
910 static ULONG WINAPI Stream_Release(IStream *iface)
915 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
916 ULONG cb, ULONG *pcbRead)
919 ok(pv != NULL, "pv == NULL\n");
920 ok(cb > sizeof(html_page), "cb = %d\n", cb);
921 ok(pcbRead != NULL, "pcbRead == NULL\n");
922 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
927 memcpy(pv, html_page, sizeof(html_page)-1);
928 stream_read += *pcbRead = sizeof(html_page)-1;
932 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
933 ULONG cb, ULONG *pcbWritten)
935 ok(0, "unexpected call\n");
939 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
940 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
942 ok(0, "unexpected call\n");
946 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
948 ok(0, "unexpected call\n");
952 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
953 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
955 ok(0, "unexpected call\n");
959 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
961 ok(0, "unexpected call\n");
965 static HRESULT WINAPI Stream_Revert(IStream *iface)
967 ok(0, "unexpected call\n");
971 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
972 ULARGE_INTEGER cb, DWORD dwLockType)
974 ok(0, "unexpected call\n");
978 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
979 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
981 ok(0, "unexpected call\n");
985 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
988 ok(0, "unexpected call\n");
992 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
994 ok(0, "unexpected call\n");
998 static const IStreamVtbl StreamVtbl = {
999 Stream_QueryInterface,
1010 Stream_UnlockRegion,
1015 static IStream Stream = { &StreamVtbl };
1017 static HRESULT WINAPI WinInetHttpInfo_QueryInterface(
1018 IWinInetHttpInfo* This,
1022 ok(0, "unexpected call\n");
1023 return E_NOINTERFACE;
1026 static ULONG WINAPI WinInetHttpInfo_AddRef(
1027 IWinInetHttpInfo* This)
1032 static ULONG WINAPI WinInetHttpInfo_Release(
1033 IWinInetHttpInfo* This)
1038 static HRESULT WINAPI WinInetHttpInfo_QueryOption(
1039 IWinInetHttpInfo* This,
1044 return E_NOTIMPL; /* TODO */
1047 static HRESULT WINAPI WinInetHttpInfo_QueryInfo(
1048 IWinInetHttpInfo* This,
1055 ok(pdwReserved == NULL, "pdwReserved != NULL\n");
1057 if(dwOption == (HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER)) {
1058 ok(pBuffer != NULL, "pBuffer == NULL\n");
1059 ok(*pcbBuf == sizeof(DWORD), "*pcbBuf = %d\n", *pcbBuf);
1060 ok(pdwFlags == NULL, "*pdwFlags != NULL\n");
1061 *((DWORD*)pBuffer) = status_code;
1065 return E_NOTIMPL; /* TODO */
1068 static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = {
1069 WinInetHttpInfo_QueryInterface,
1070 WinInetHttpInfo_AddRef,
1071 WinInetHttpInfo_Release,
1072 WinInetHttpInfo_QueryOption,
1073 WinInetHttpInfo_QueryInfo
1076 static IWinInetHttpInfo WinInetHttpInfo = { &WinInetHttpInfoVtbl };
1078 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
1080 if(IsEqualGUID(&IID_IUnknown, riid)) {
1085 if(IsEqualGUID(&IID_IWinInetInfo, riid) || IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
1086 *ppv = &WinInetHttpInfo;
1090 ok(0, "unexpected call\n");
1091 return E_NOINTERFACE;
1094 static ULONG WINAPI Binding_AddRef(IBinding *iface)
1099 static ULONG WINAPI Binding_Release(IBinding *iface)
1104 static HRESULT WINAPI Binding_Abort(IBinding *iface)
1106 CHECK_EXPECT(Abort);
1107 if(asynchronous_binding)
1108 PeekMessage(NULL, container_hwnd, WM_CONTINUE_BINDING, WM_CONTINUE_BINDING, PM_REMOVE);
1112 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
1114 ok(0, "unexpected call\n");
1118 static HRESULT WINAPI Binding_Resume(IBinding *iface)
1120 ok(0, "unexpected call\n");
1124 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
1126 ok(0, "unexpected call\n");
1130 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
1132 ok(0, "unexpected call\n");
1136 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
1137 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
1139 CHECK_EXPECT(GetBindResult);
1143 static const IBindingVtbl BindingVtbl = {
1144 Binding_QueryInterface,
1150 Binding_SetPriority,
1151 Binding_GetPriority,
1152 Binding_GetBindResult
1155 static IBinding Binding = { &BindingVtbl };
1157 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
1158 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
1160 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
1164 if(IsEqualGUID(&IID_IMoniker_unk, riid))
1165 return E_NOINTERFACE; /* TODO */
1166 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
1167 return E_NOINTERFACE; /* TODO */
1169 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
1170 return E_NOINTERFACE;
1173 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
1178 static ULONG WINAPI Moniker_Release(IMoniker *iface)
1183 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
1185 CHECK_EXPECT(GetClassID);
1186 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
1190 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
1192 ok(0, "unexpected call\n");
1196 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1198 ok(0, "unexpected call\n");
1202 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1204 ok(0, "unexpected call\n");
1208 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1210 ok(0, "unexpected call\n");
1214 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1215 REFIID riidResult, void **ppvResult)
1217 ok(0, "unexpected call\n");
1221 static void continue_binding(IBindStatusCallback *callback)
1223 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1224 STGMEDIUM stgmedium;
1227 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1229 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1231 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1233 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1234 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1235 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1236 if(status_code != HTTP_STATUS_OK) {
1237 CHECK_CALLED_BROKEN(IsErrorUrl);
1238 SET_EXPECT(IsErrorUrl);
1242 stgmedium.tymed = TYMED_ISTREAM;
1243 U(stgmedium).pstm = &Stream;
1244 stgmedium.pUnkForRelease = (IUnknown*)&Moniker;
1245 hres = IBindStatusCallback_OnDataAvailable(callback,
1246 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1247 sizeof(html_page)-1, &formatetc, &stgmedium);
1248 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1251 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1252 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1253 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1255 SET_EXPECT(GetBindResult);
1256 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1257 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1258 SET_CALLED(GetBindResult); /* IE7 */
1260 IBindStatusCallback_Release(callback);
1263 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1264 REFIID riid, void **ppv)
1266 IBindStatusCallback *callback = NULL;
1271 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1273 CHECK_EXPECT(BindToStorage);
1275 load_state = LD_LOADING;
1277 ok(pbc != NULL, "pbc == NULL\n");
1278 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1279 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1280 ok(ppv != NULL, "ppv == NULL\n");
1281 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1283 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1284 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1285 ok(callback != NULL, "callback == NULL\n");
1287 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1288 bindinfo.cbSize = sizeof(bindinfo);
1290 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1291 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1292 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
1293 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
1294 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1295 /* TODO: test stgmedData */
1296 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
1297 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
1298 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1299 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
1300 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
1301 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
1302 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
1303 /* TODO: test dwCodePage */
1304 /* TODO: test securityAttributes */
1305 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1306 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1307 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
1309 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1310 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1312 if(asynchronous_binding) {
1313 PostMessageW(container_hwnd, WM_CONTINUE_BINDING, (WPARAM)callback, 0);
1314 return MK_S_ASYNCHRONOUS;
1317 continue_binding(callback);
1321 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1322 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1324 ok(0, "unexpected call\n");
1328 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1329 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1331 ok(0, "unexpected call\n");
1335 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1337 ok(0, "unexpected call\n");
1341 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1343 ok(0, "unexpected call\n");
1347 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1349 ok(0, "unexpected call\n");
1353 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1354 IMoniker *pmkNewlyRunning)
1356 ok(0, "unexpected call\n");
1360 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1361 IMoniker *pmkToLeft, FILETIME *pFileTime)
1363 ok(0, "unexpected call\n");
1367 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1369 ok(0, "unexpected call\n");
1373 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1374 IMoniker **ppmkPrefix)
1376 ok(0, "unexpected call\n");
1380 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1381 IMoniker **pmkRelPath)
1383 ok(0, "unexpected call\n");
1387 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1388 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1390 CHECK_EXPECT2(GetDisplayName);
1392 /* ok(pbc != NULL, "pbc == NULL\n"); */
1393 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1394 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1396 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1397 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1402 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1403 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1405 ok(0, "unexpected call\n");
1409 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1411 CHECK_EXPECT(IsSystemMoniker);
1415 static const IMonikerVtbl MonikerVtbl = {
1416 Moniker_QueryInterface,
1424 Moniker_BindToObject,
1425 Moniker_BindToStorage,
1427 Moniker_ComposeWith,
1432 Moniker_GetTimeOfLastChange,
1434 Moniker_CommonPrefixWith,
1435 Moniker_RelativePathTo,
1436 Moniker_GetDisplayName,
1437 Moniker_ParseDisplayName,
1438 Moniker_IsSystemMoniker
1441 static IMoniker Moniker = { &MonikerVtbl };
1443 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1445 return QueryInterface(riid, ppv);
1448 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1453 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1458 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1459 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1461 ok(0, "unexpected call\n");
1465 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1466 IEnumUnknown **ppenum)
1468 ok(0, "unexpected call\n");
1472 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1474 CHECK_EXPECT(LockContainer);
1475 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1479 static const IOleContainerVtbl OleContainerVtbl = {
1480 OleContainer_QueryInterface,
1481 OleContainer_AddRef,
1482 OleContainer_Release,
1483 OleContainer_ParseDisplayName,
1484 OleContainer_EnumObjects,
1485 OleContainer_LockContainer
1488 static IOleContainer OleContainer = { &OleContainerVtbl };
1490 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1492 return QueryInterface(riid, ppv);
1495 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1500 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1505 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1507 ok(0, "unexpected call\n");
1511 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1514 ok(0, "unexpected call\n");
1518 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1520 CHECK_EXPECT(GetContainer);
1521 ok(ppContainer != NULL, "ppContainer = NULL\n");
1522 *ppContainer = &OleContainer;
1526 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1528 ok(0, "unexpected call\n");
1532 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1534 ok(0, "unexpected call\n");
1538 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1540 ok(0, "unexpected call\n");
1544 static const IOleClientSiteVtbl ClientSiteVtbl = {
1545 ClientSite_QueryInterface,
1548 ClientSite_SaveObject,
1549 ClientSite_GetMoniker,
1550 ClientSite_GetContainer,
1551 ClientSite_ShowObject,
1552 ClientSite_OnShowWindow,
1553 ClientSite_RequestNewObjectLayout
1556 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1558 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1560 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1562 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1563 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1566 return E_NOINTERFACE;
1569 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1574 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1579 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1581 CHECK_EXPECT(Frame_GetWindow);
1585 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1587 ok(0, "unexpected call\n");
1591 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1593 ok(0, "unexpected call\n");
1597 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1598 LPCBORDERWIDTHS pborderwidths)
1600 ok(0, "unexpected call\n");
1604 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1605 LPCBORDERWIDTHS pborderwidths)
1607 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1611 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1612 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1614 static const WCHAR wszHTML_Document[] =
1615 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1617 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1619 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1620 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1621 if(pActiveObject && is_english())
1622 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1625 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1626 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1628 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1632 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1633 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1635 static const WCHAR wszHTML_Document[] =
1636 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1639 CHECK_EXPECT2(SetActiveObject);
1641 if(pActiveObject && is_english())
1642 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1644 CHECK_EXPECT(SetActiveObject_null);
1646 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1647 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1653 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1654 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1656 ok(0, "unexpected call\n");
1660 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1661 HOLEMENU holemenu, HWND hwndActiveObject)
1663 ok(0, "unexpected call\n");
1667 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1669 ok(0, "unexpected call\n");
1673 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1675 CHECK_EXPECT2(SetStatusText);
1676 if(!expect_status_text)
1677 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1681 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1684 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
1686 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
1690 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1692 ok(0, "unexpected call\n");
1696 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1697 InPlaceFrame_QueryInterface,
1698 InPlaceFrame_AddRef,
1699 InPlaceFrame_Release,
1700 InPlaceFrame_GetWindow,
1701 InPlaceFrame_ContextSensitiveHelp,
1702 InPlaceFrame_GetBorder,
1703 InPlaceFrame_RequestBorderSpace,
1704 InPlaceFrame_SetBorderSpace,
1705 InPlaceFrame_SetActiveObject,
1706 InPlaceFrame_InsertMenus,
1707 InPlaceFrame_SetMenu,
1708 InPlaceFrame_RemoveMenus,
1709 InPlaceFrame_SetStatusText,
1710 InPlaceFrame_EnableModeless,
1711 InPlaceFrame_TranslateAccelerator
1714 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1716 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1717 InPlaceFrame_QueryInterface,
1718 InPlaceFrame_AddRef,
1719 InPlaceFrame_Release,
1720 InPlaceFrame_GetWindow,
1721 InPlaceFrame_ContextSensitiveHelp,
1722 InPlaceFrame_GetBorder,
1723 InPlaceFrame_RequestBorderSpace,
1724 InPlaceFrame_SetBorderSpace,
1725 InPlaceUIWindow_SetActiveObject,
1728 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1730 static HRESULT WINAPI InPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
1732 return QueryInterface(riid, ppv);
1735 static ULONG WINAPI InPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
1740 static ULONG WINAPI InPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
1745 static HRESULT WINAPI InPlaceSiteWindowless_GetWindow(
1746 IOleInPlaceSiteWindowless *iface, HWND *phwnd)
1748 IOleClientSite *client_site;
1749 IOleObject *ole_obj;
1752 CHECK_EXPECT2(GetWindow);
1753 ok(phwnd != NULL, "phwnd = NULL\n");
1754 *phwnd = container_hwnd;
1756 hres = IUnknown_QueryInterface(doc_unk, &IID_IOleObject, (void**)&ole_obj);
1757 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
1759 hres = IOleObject_GetClientSite(ole_obj, &client_site);
1760 IOleObject_Release(ole_obj);
1761 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
1762 ok(client_site == &ClientSite, "client_site != ClientSite\n");
1763 IOleClientSite_Release(client_site);
1768 static HRESULT WINAPI InPlaceSiteWindowless_ContextSensitiveHelp(
1769 IOleInPlaceSiteWindowless *iface, BOOL fEnterMode)
1771 ok(0, "unexpected call\n");
1775 static HRESULT WINAPI InPlaceSiteWindowless_CanInPlaceActivate(
1776 IOleInPlaceSiteWindowless *iface)
1778 CHECK_EXPECT(CanInPlaceActivate);
1782 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivate(
1783 IOleInPlaceSiteWindowless *iface)
1785 CHECK_EXPECT(OnInPlaceActivate);
1786 inplace_deactivated = FALSE;
1790 static HRESULT WINAPI InPlaceSiteWindowless_OnUIActivate(
1791 IOleInPlaceSiteWindowless *iface)
1793 CHECK_EXPECT(OnUIActivate);
1797 static HRESULT WINAPI InPlaceSiteWindowless_GetWindowContext(
1798 IOleInPlaceSiteWindowless *iface, IOleInPlaceFrame **ppFrame,
1799 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1800 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1802 static const RECT rect = {0,0,500,500};
1804 CHECK_EXPECT(GetWindowContext);
1806 ok(ppFrame != NULL, "ppFrame = NULL\n");
1808 *ppFrame = &InPlaceFrame;
1809 ok(ppDoc != NULL, "ppDoc = NULL\n");
1811 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1812 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1814 memcpy(lprcPosRect, &rect, sizeof(RECT));
1815 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1817 memcpy(lprcClipRect, &rect, sizeof(RECT));
1818 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1820 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
1821 lpFrameInfo->fMDIApp = FALSE;
1822 lpFrameInfo->hwndFrame = container_hwnd;
1823 lpFrameInfo->haccel = NULL;
1824 lpFrameInfo->cAccelEntries = 0;
1830 static HRESULT WINAPI InPlaceSiteWindowless_Scroll(
1831 IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
1833 ok(0, "unexpected call\n");
1837 static HRESULT WINAPI InPlaceSiteWindowless_OnUIDeactivate(
1838 IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
1840 CHECK_EXPECT(OnUIDeactivate);
1841 ok(!fUndoable, "fUndoable = TRUE\n");
1845 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivate(
1846 IOleInPlaceSiteWindowless *iface)
1848 CHECK_EXPECT(OnInPlaceDeactivate);
1849 inplace_deactivated = TRUE;
1853 static HRESULT WINAPI InPlaceSiteWindowless_DiscardUndoState(
1854 IOleInPlaceSiteWindowless *iface)
1856 ok(0, "unexpected call\n");
1860 static HRESULT WINAPI InPlaceSiteWindowless_DeactivateAndUndo(
1861 IOleInPlaceSiteWindowless *iface)
1863 ok(0, "unexpected call\n");
1867 static HRESULT WINAPI InPlaceSiteWindowless_OnPosRectChange(
1868 IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
1870 ok(0, "unexpected call\n");
1874 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivateEx(
1875 IOleInPlaceSiteWindowless *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1877 CHECK_EXPECT(OnInPlaceActivateEx);
1879 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1880 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1881 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1886 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivateEx(
1887 IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
1889 CHECK_EXPECT(OnInPlaceDeactivateEx);
1891 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1896 static HRESULT WINAPI InPlaceSiteWindowless_RequestUIActivate(
1897 IOleInPlaceSiteWindowless *iface)
1899 CHECK_EXPECT2(RequestUIActivate);
1903 static HRESULT WINAPI InPlaceSiteWindowless_CanWindowlessActivate(
1904 IOleInPlaceSiteWindowless *iface)
1906 ok(0, "unexpected call\n");
1910 static HRESULT WINAPI InPlaceSiteWindowless_GetCapture(
1911 IOleInPlaceSiteWindowless *iface)
1913 ok(0, "unexpected call\n");
1917 static HRESULT WINAPI InPlaceSiteWindowless_SetCapture(
1918 IOleInPlaceSiteWindowless *iface, BOOL fCapture)
1920 ok(0, "unexpected call\n");
1924 static HRESULT WINAPI InPlaceSiteWindowless_GetFocus(
1925 IOleInPlaceSiteWindowless *iface)
1927 ok(0, "unexpected call\n");
1931 static HRESULT WINAPI InPlaceSiteWindowless_SetFocus(
1932 IOleInPlaceSiteWindowless *iface, BOOL fFocus)
1934 ok(0, "unexpected call\n");
1938 static HRESULT WINAPI InPlaceSiteWindowless_GetDC(
1939 IOleInPlaceSiteWindowless *iface, LPCRECT pRect,
1940 DWORD grfFlags, HDC *phDC)
1942 ok(0, "unexpected call\n");
1946 static HRESULT WINAPI InPlaceSiteWindowless_ReleaseDC(
1947 IOleInPlaceSiteWindowless *iface, HDC hDC)
1949 ok(0, "unexpected call\n");
1953 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRect(
1954 IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
1956 ok(0, "unexpected call\n");
1960 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRgn(
1961 IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
1963 ok(0, "unexpected call\n");
1967 static HRESULT WINAPI InPlaceSiteWindowless_ScrollRect(
1968 IOleInPlaceSiteWindowless *iface, INT dx, INT dy,
1969 LPCRECT pRectScroll, LPCRECT pRectClip)
1971 ok(0, "unexpected call\n");
1975 static HRESULT WINAPI InPlaceSiteWindowless_AdjustRect(
1976 IOleInPlaceSiteWindowless *iface, LPRECT prc)
1978 ok(0, "unexpected call\n");
1982 static HRESULT WINAPI InPlaceSiteWindowless_OnDefWindowMessage(
1983 IOleInPlaceSiteWindowless *iface, UINT msg,
1984 WPARAM wParam, LPARAM lParam, LRESULT *plResult)
1986 ok(0, "unexpected call\n");
1990 static const IOleInPlaceSiteWindowlessVtbl InPlaceSiteWindowlessVtbl = {
1991 InPlaceSiteWindowless_QueryInterface,
1992 InPlaceSiteWindowless_AddRef,
1993 InPlaceSiteWindowless_Release,
1994 InPlaceSiteWindowless_GetWindow,
1995 InPlaceSiteWindowless_ContextSensitiveHelp,
1996 InPlaceSiteWindowless_CanInPlaceActivate,
1997 InPlaceSiteWindowless_OnInPlaceActivate,
1998 InPlaceSiteWindowless_OnUIActivate,
1999 InPlaceSiteWindowless_GetWindowContext,
2000 InPlaceSiteWindowless_Scroll,
2001 InPlaceSiteWindowless_OnUIDeactivate,
2002 InPlaceSiteWindowless_OnInPlaceDeactivate,
2003 InPlaceSiteWindowless_DiscardUndoState,
2004 InPlaceSiteWindowless_DeactivateAndUndo,
2005 InPlaceSiteWindowless_OnPosRectChange,
2006 InPlaceSiteWindowless_OnInPlaceActivateEx,
2007 InPlaceSiteWindowless_OnInPlaceDeactivateEx,
2008 InPlaceSiteWindowless_RequestUIActivate,
2009 InPlaceSiteWindowless_CanWindowlessActivate,
2010 InPlaceSiteWindowless_GetCapture,
2011 InPlaceSiteWindowless_SetCapture,
2012 InPlaceSiteWindowless_GetFocus,
2013 InPlaceSiteWindowless_SetFocus,
2014 InPlaceSiteWindowless_GetDC,
2015 InPlaceSiteWindowless_ReleaseDC,
2016 InPlaceSiteWindowless_InvalidateRect,
2017 InPlaceSiteWindowless_InvalidateRgn,
2018 InPlaceSiteWindowless_ScrollRect,
2019 InPlaceSiteWindowless_AdjustRect,
2020 InPlaceSiteWindowless_OnDefWindowMessage
2023 static IOleInPlaceSiteWindowless InPlaceSiteWindowless = { &InPlaceSiteWindowlessVtbl };
2025 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
2027 return QueryInterface(riid, ppv);
2030 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
2035 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
2042 CallUIActivate_None,
2043 CallUIActivate_ActivateMe,
2044 CallUIActivate_AfterShow,
2047 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
2048 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
2050 IOleDocument *document;
2053 CHECK_EXPECT(ActivateMe);
2054 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
2056 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
2057 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
2059 if(SUCCEEDED(hres)) {
2060 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteWindowless, NULL, 0, &view);
2061 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
2063 if(SUCCEEDED(hres)) {
2064 IOleInPlaceActiveObject *activeobj = NULL;
2065 IOleInPlaceSite *inplacesite = NULL;
2066 HWND tmp_hwnd = NULL;
2067 static RECT rect = {0,0,400,500};
2069 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
2070 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
2071 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
2072 inplacesite, &InPlaceSiteWindowless);
2074 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteWindowless);
2075 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
2077 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
2078 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
2079 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
2080 inplacesite, &InPlaceSiteWindowless);
2082 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
2083 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
2086 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2087 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2088 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
2091 if(call_UIActivate == CallUIActivate_ActivateMe) {
2092 SET_EXPECT(CanInPlaceActivate);
2093 SET_EXPECT(GetWindowContext);
2094 SET_EXPECT(GetWindow);
2096 SET_EXPECT(OnInPlaceActivateEx);
2098 SET_EXPECT(OnInPlaceActivate);
2099 SET_EXPECT(SetStatusText);
2100 SET_EXPECT(Exec_SETPROGRESSMAX);
2101 SET_EXPECT(Exec_SETPROGRESSPOS);
2102 SET_EXPECT(OnUIActivate);
2103 SET_EXPECT(SetActiveObject);
2105 expect_status_text = NULL;
2107 hres = IOleDocumentView_UIActivate(view, TRUE);
2108 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
2110 CHECK_CALLED(CanInPlaceActivate);
2111 CHECK_CALLED(GetWindowContext);
2112 CHECK_CALLED(GetWindow);
2114 CHECK_CALLED(OnInPlaceActivateEx);
2116 CHECK_CALLED(OnInPlaceActivate);
2117 CHECK_CALLED(SetStatusText);
2118 CHECK_CALLED(Exec_SETPROGRESSMAX);
2119 CHECK_CALLED(Exec_SETPROGRESSPOS);
2120 CHECK_CALLED(OnUIActivate);
2121 CHECK_CALLED(SetActiveObject);
2122 CHECK_CALLED(ShowUI);
2125 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2126 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2127 ok(hwnd != NULL, "hwnd == NULL\n");
2129 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
2132 hres = IOleDocumentView_UIActivate(view, TRUE);
2133 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
2136 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
2137 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2138 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
2142 hres = IOleDocumentView_SetRect(view, &rect);
2143 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
2145 if(call_UIActivate == CallUIActivate_ActivateMe) {
2146 hres = IOleDocumentView_Show(view, TRUE);
2147 ok(hres == S_OK, "Show failed: %08x\n", hres);
2149 SET_EXPECT(CanInPlaceActivate);
2150 SET_EXPECT(GetWindowContext);
2151 SET_EXPECT(GetWindow);
2153 SET_EXPECT(OnInPlaceActivateEx);
2155 SET_EXPECT(OnInPlaceActivate);
2156 SET_EXPECT(SetStatusText);
2157 SET_EXPECT(Exec_SETPROGRESSMAX);
2158 SET_EXPECT(Exec_SETPROGRESSPOS);
2159 SET_EXPECT(OnUIActivate);
2160 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
2162 hres = IOleDocumentView_Show(view, TRUE);
2163 ok(hres == S_OK, "Show failed: %08x\n", hres);
2165 CHECK_CALLED(CanInPlaceActivate);
2166 CHECK_CALLED(GetWindowContext);
2167 CHECK_CALLED(GetWindow);
2169 CHECK_CALLED(OnInPlaceActivateEx);
2171 CHECK_CALLED(OnInPlaceActivate);
2172 CHECK_CALLED(SetStatusText);
2173 CHECK_CALLED(Exec_SETPROGRESSMAX);
2174 CHECK_CALLED(Exec_SETPROGRESSPOS);
2177 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2178 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2179 ok(hwnd != NULL, "hwnd == NULL\n");
2181 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
2185 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
2188 IOleInPlaceActiveObject_Release(activeobj);
2191 IOleDocument_Release(document);
2197 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
2198 DocumentSite_QueryInterface,
2199 DocumentSite_AddRef,
2200 DocumentSite_Release,
2201 DocumentSite_ActivateMe
2204 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
2206 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
2208 return QueryInterface(riid, ppv);
2211 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
2216 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
2221 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
2223 ok(0, "unexpected call\n");
2227 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
2229 ok(0, "unexpected call\n");
2233 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
2235 ok(0, "unexpected call\n");
2239 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
2240 POINTF *pPtfContainer, DWORD dwFlags)
2242 ok(0, "unexpected call\n");
2246 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
2247 MSG *pMsg, DWORD grfModifiers)
2249 ok(0, "unexpected call\n");
2253 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
2256 CHECK_EXPECT(OnFocus_TRUE);
2258 CHECK_EXPECT2(OnFocus_FALSE);
2262 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
2264 ok(0, "unexpected call\n");
2268 static const IOleControlSiteVtbl OleControlSiteVtbl = {
2269 OleControlSite_QueryInterface,
2270 OleControlSite_AddRef,
2271 OleControlSite_Release,
2272 OleControlSite_OnControlInfoChanged,
2273 OleControlSite_LockInPlaceActive,
2274 OleControlSite_GetExtendedControl,
2275 OleControlSite_TransformCoords,
2276 OleControlSite_TranslateAccelerator,
2277 OleControlSite_OnFocus,
2278 OleControlSite_ShowPropertyFrame
2281 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
2283 static IDocHostUIHandler2 *expect_uihandler_iface;
2285 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2287 return QueryInterface(riid, ppv);
2290 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
2295 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
2300 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
2301 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
2303 ok(0, "unexpected call\n");
2304 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2308 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
2310 CHECK_EXPECT(GetHostInfo);
2311 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2312 ok(pInfo != NULL, "pInfo=NULL\n");
2314 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
2315 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
2316 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
2317 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
2318 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
2319 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
2320 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
2321 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
2326 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
2327 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
2328 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
2330 CHECK_EXPECT(ShowUI);
2331 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2334 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
2336 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
2337 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2338 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
2339 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2340 if (expect_InPlaceUIWindow_SetActiveObject_active)
2341 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2343 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2348 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2350 CHECK_EXPECT(HideUI);
2351 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2355 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2357 CHECK_EXPECT(UpdateUI);
2358 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2362 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2364 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2366 CHECK_EXPECT2(EnableModeless_TRUE);
2368 CHECK_EXPECT2(EnableModeless_FALSE);
2372 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2374 ok(0, "unexpected call\n");
2375 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2379 static BOOL expect_OnFrameWindowActivate_fActivate;
2380 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2382 CHECK_EXPECT2(OnFrameWindowActivate);
2383 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2384 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2388 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2389 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2391 ok(0, "unexpected call\n");
2395 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2396 const GUID *pguidCmdGroup, DWORD nCmdID)
2398 ok(0, "unexpected call\n");
2399 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2403 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2404 LPOLESTR *pchKey, DWORD dw)
2406 CHECK_EXPECT(GetOptionKeyPath);
2407 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2408 ok(pchKey != NULL, "pchKey = NULL\n");
2409 ok(!dw, "dw=%d, expected 0\n", dw);
2411 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2415 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2416 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2418 CHECK_EXPECT(GetDropTarget);
2419 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2424 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2426 CHECK_EXPECT(GetExternal);
2427 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2428 *ppDispatch = &External;
2432 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2433 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2435 CHECK_EXPECT(TranslateUrl);
2436 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2437 ok(!dwTranslate, "dwTranslate = %x\n", dwTranslate);
2438 ok(!strcmp_wa(pchURLIn, nav_url), "pchURLIn = %s, expected %s\n", wine_dbgstr_w(pchURLIn), nav_url);
2439 ok(ppchURLOut != NULL, "ppchURLOut == NULL\n");
2440 ok(!*ppchURLOut, "*ppchURLOut = %p\n", *ppchURLOut);
2445 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2446 IDataObject **ppPORet)
2448 ok(0, "unexpected call\n");
2449 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2453 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2454 LPOLESTR *pchKey, DWORD dw)
2456 CHECK_EXPECT(GetOverrideKeyPath);
2457 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2458 ok(pchKey != NULL, "pchKey = NULL\n");
2460 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2461 ok(!dw, "dw=%d, xepected 0\n", dw);
2465 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2466 DocHostUIHandler_QueryInterface,
2467 DocHostUIHandler_AddRef,
2468 DocHostUIHandler_Release,
2469 DocHostUIHandler_ShowContextMenu,
2470 DocHostUIHandler_GetHostInfo,
2471 DocHostUIHandler_ShowUI,
2472 DocHostUIHandler_HideUI,
2473 DocHostUIHandler_UpdateUI,
2474 DocHostUIHandler_EnableModeless,
2475 DocHostUIHandler_OnDocWindowActivate,
2476 DocHostUIHandler_OnFrameWindowActivate,
2477 DocHostUIHandler_ResizeBorder,
2478 DocHostUIHandler_TranslateAccelerator,
2479 DocHostUIHandler_GetOptionKeyPath,
2480 DocHostUIHandler_GetDropTarget,
2481 DocHostUIHandler_GetExternal,
2482 DocHostUIHandler_TranslateUrl,
2483 DocHostUIHandler_FilterDataObject,
2484 DocHostUIHandler_GetOverrideKeyPath
2487 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2489 static HRESULT WINAPI CustomDocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2491 if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
2496 if(IsEqualGUID(&IID_IOleCommandTarget, riid))
2497 return E_NOINTERFACE;
2499 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2500 return E_NOINTERFACE; /* TODO */
2502 ok(0, "unexpected call %s\n", debugstr_guid(riid));
2503 return E_NOINTERFACE;
2506 static const IDocHostUIHandler2Vtbl CustomDocHostUIHandlerVtbl = {
2507 CustomDocHostUIHandler_QueryInterface,
2508 DocHostUIHandler_AddRef,
2509 DocHostUIHandler_Release,
2510 DocHostUIHandler_ShowContextMenu,
2511 DocHostUIHandler_GetHostInfo,
2512 DocHostUIHandler_ShowUI,
2513 DocHostUIHandler_HideUI,
2514 DocHostUIHandler_UpdateUI,
2515 DocHostUIHandler_EnableModeless,
2516 DocHostUIHandler_OnDocWindowActivate,
2517 DocHostUIHandler_OnFrameWindowActivate,
2518 DocHostUIHandler_ResizeBorder,
2519 DocHostUIHandler_TranslateAccelerator,
2520 DocHostUIHandler_GetOptionKeyPath,
2521 DocHostUIHandler_GetDropTarget,
2522 DocHostUIHandler_GetExternal,
2523 DocHostUIHandler_TranslateUrl,
2524 DocHostUIHandler_FilterDataObject,
2525 DocHostUIHandler_GetOverrideKeyPath
2528 static IDocHostUIHandler2 CustomDocHostUIHandler = { &CustomDocHostUIHandlerVtbl };
2530 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2531 REFIID riid, void **ppv)
2533 return QueryInterface(riid, ppv);
2536 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2541 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2546 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2547 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2549 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2550 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2551 ok(!pCmdText, "pCmdText != NULL\n");
2553 switch(prgCmds[0].cmdID) {
2554 case OLECMDID_SETPROGRESSTEXT:
2555 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2556 prgCmds[0].cmdf = OLECMDF_ENABLED;
2559 CHECK_EXPECT(QueryStatus_OPEN);
2560 prgCmds[0].cmdf = 0;
2563 CHECK_EXPECT(QueryStatus_NEW);
2564 prgCmds[0].cmdf = 0;
2567 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2573 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2574 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2576 if((!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2577 && (!pguidCmdGroup || !IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup) || nCmdID != 63))
2578 test_readyState(NULL);
2580 if(!pguidCmdGroup) {
2582 case OLECMDID_SETPROGRESSMAX:
2583 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2584 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2585 ok(pvaIn != NULL, "pvaIn == NULL\n");
2587 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2588 if(load_state == LD_NO)
2589 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2591 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2593 case OLECMDID_SETPROGRESSPOS:
2594 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2595 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2596 ok(pvaIn != NULL, "pvaIn == NULL\n");
2598 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2599 if(load_state == LD_NO)
2600 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2602 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2604 case OLECMDID_HTTPEQUIV_DONE:
2605 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2606 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2607 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2608 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2609 readystate_set_loading = FALSE;
2610 readystate_set_interactive = FALSE;
2611 load_state = LD_COMPLETE;
2613 case OLECMDID_SETDOWNLOADSTATE:
2614 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2615 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2616 ok(pvaIn != NULL, "pvaIn == NULL\n");
2617 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2619 switch(V_I4(pvaIn)) {
2621 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2622 load_state = LD_INTERACTIVE;
2625 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2626 readystate_set_interactive = (load_state != LD_INTERACTIVE);
2629 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2633 case OLECMDID_UPDATECOMMANDS:
2634 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2635 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2636 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2637 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2639 case OLECMDID_SETTITLE:
2640 CHECK_EXPECT2(Exec_SETTITLE);
2641 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2642 ok(pvaIn != NULL, "pvaIn == NULL\n");
2643 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2644 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2645 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2647 case OLECMDID_HTTPEQUIV:
2648 CHECK_EXPECT2(Exec_HTTPEQUIV);
2649 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
2650 ok(pvaIn != NULL, "pvaIn == NULL\n");
2651 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2652 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2653 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
2654 test_readyState(NULL);
2656 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
2657 return E_FAIL; /* FIXME */
2659 ok(0, "unexpected command %d\n", nCmdID);
2664 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2665 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2669 CHECK_EXPECT2(Exec_ShellDocView_37);
2672 test_GetCurMoniker(doc_unk, NULL, nav_url);
2673 else if(load_from_stream)
2674 test_GetCurMoniker(doc_unk, NULL, "about:blank");
2676 test_GetCurMoniker(doc_unk, doc_mon, NULL);
2678 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2679 ok(pvaIn != NULL, "pvaIn == NULL\n");
2681 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2682 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2687 IHTMLPrivateWindow *priv_window;
2690 CHECK_EXPECT(Exec_ShellDocView_63);
2691 ok(pvaIn != NULL, "pvaIn == NULL\n");
2692 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2693 ok(V_UNKNOWN(pvaIn) != NULL, "VPUNKNOWN(pvaIn) = NULL\n");
2694 ok(pvaOut != NULL, "pvaOut == NULL\n");
2695 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2697 hres = IUnknown_QueryInterface(V_UNKNOWN(pvaIn), &IID_IHTMLPrivateWindow, (void**)&priv_window);
2698 ok(hres == S_OK, "Could not get IHTMLPrivateWindow: %08x\n", hres);
2700 IHTMLPrivateWindow_Release(priv_window);
2702 load_state = LD_LOADING;
2703 return S_OK; /* TODO */
2707 CHECK_EXPECT(Exec_ShellDocView_67);
2708 ok(pvaIn != NULL, "pvaIn == NULL\n");
2709 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2710 ok(!strcmp_wa(V_BSTR(pvaIn), nav_url), "V_BSTR(pvaIn) = %s, expected %s\n", wine_dbgstr_w(V_BSTR(pvaIn)), nav_url);
2711 ok(pvaOut != NULL, "pvaOut == NULL\n");
2712 ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2713 ok(V_BOOL(pvaOut) == VARIANT_TRUE, "V_BOOL(pvaOut) = %x\n", V_BOOL(pvaOut));
2714 load_state = LD_DOLOAD;
2718 CHECK_EXPECT2(Exec_ShellDocView_84);
2720 ok(pvaIn == NULL, "pvaIn != NULL\n");
2721 ok(pvaOut != NULL, "pvaOut == NULL\n");
2723 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2728 CHECK_EXPECT2(Exec_ShellDocView_103);
2730 ok(pvaIn == NULL, "pvaIn != NULL\n");
2731 ok(pvaOut == NULL, "pvaOut != NULL\n");
2736 CHECK_EXPECT2(Exec_ShellDocView_105);
2738 ok(pvaIn != NULL, "pvaIn == NULL\n");
2739 ok(pvaOut == NULL, "pvaOut != NULL\n");
2744 CHECK_EXPECT2(Exec_ShellDocView_140);
2746 ok(pvaIn == NULL, "pvaIn != NULL\n");
2747 ok(pvaOut == NULL, "pvaOut != NULL\n");
2752 ok(0, "unexpected command %d\n", nCmdID);
2757 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2758 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2761 case IDM_PARSECOMPLETE:
2762 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2763 ok(pvaIn == NULL, "pvaIn != NULL\n");
2764 ok(pvaOut == NULL, "pvaOut != NULL\n");
2767 ok(0, "unexpected command %d\n", nCmdID);
2771 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
2773 case DOCHOST_DOCCANNAVIGATE:
2774 CHECK_EXPECT(Exec_DOCCANNAVIGATE);
2775 ok(pvaIn != NULL, "pvaIn == NULL\n");
2776 ok(pvaOut == NULL, "pvaOut != NULL\n");
2777 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) != VT_UNKNOWN\n");
2778 /* FIXME: test V_UNKNOWN(pvaIn) == window */
2787 ok(pvaIn != NULL, "pvaIn == NULL\n");
2788 ok(pvaOut != NULL, "pvaOut != NULL\n");
2789 ok(V_VT(pvaIn) == VT_ARRAY, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
2790 ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
2791 sa = V_ARRAY(pvaIn);
2793 dim = SafeArrayGetDim(sa);
2794 ok(dim == 1, "dim = %d\n", dim);
2795 hres = SafeArrayGetLBound(sa, 1, &ind);
2796 ok(hres == S_OK, "SafeArrayGetLBound failed: %x\n", hres);
2797 ok(ind == 0, "Lower bound = %d\n", ind);
2798 hres = SafeArrayGetUBound(sa, 1, &ind);
2799 ok(hres == S_OK, "SafeArrayGetUBound failed: %x\n", hres);
2800 ok(ind == 7 || broken(ind == 5), "Upper bound = %d\n", ind);
2803 SafeArrayGetElement(sa, &ind, &var);
2804 ok(V_VT(&var) == VT_I4, "Incorrect data type: %d\n", V_VT(&var));
2805 ok(V_I4(&var) == status_code, "Incorrect error code: %d\n", V_I4(&var));
2808 SafeArrayGetElement(sa, &ind, &var);
2809 ok(V_VT(&var) == VT_BSTR, "Incorrect data type: %d\n", V_VT(&var));
2810 ok(!strcmp_wa(V_BSTR(&var), "winetest:doc"), "Page address: %s\n", wine_dbgstr_w(V_BSTR(&var)));
2813 SafeArrayGetElement(sa, &ind, &var);
2814 ok(V_VT(&var) == VT_UNKNOWN, "Incorrect data type: %d\n", V_VT(&var));
2817 SafeArrayGetElement(sa, &ind, &var);
2818 ok(V_VT(&var) == VT_UNKNOWN, "Incorrect data type: %d\n", V_VT(&var));
2821 SafeArrayGetElement(sa, &ind, &var);
2822 ok(V_VT(&var) == VT_BOOL, "Incorrect data type: %d\n", V_VT(&var));
2823 ok(!V_BOOL(&var), "Unknown value is incorrect\n");
2826 SafeArrayGetElement(sa, &ind, &var);
2827 ok(V_VT(&var) == VT_BOOL, "Incorrect data type: %d\n", V_VT(&var));
2828 ok(!V_BOOL(&var), "Unknown value is incorrect\n");
2832 return E_FAIL; /* TODO */
2836 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2837 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2841 CHECK_EXPECT2(Exec_Explorer_69);
2842 ok(pvaIn == NULL, "pvaIn != NULL\n");
2843 ok(pvaOut != NULL, "pvaOut == NULL\n");
2846 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2851 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2853 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2854 SET_EXPECT(SetStatusText);
2855 ok(pvaIn == NULL, "pvaIn != NULL\n");
2856 ok(pvaOut == NULL, "pvaOut != NULL\n");
2858 case OLECMDID_SHOWSCRIPTERROR:
2862 ok(0, "unexpected command %d\n", nCmdID);
2867 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2871 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2872 OleCommandTarget_QueryInterface,
2873 OleCommandTarget_AddRef,
2874 OleCommandTarget_Release,
2875 OleCommandTarget_QueryStatus,
2876 OleCommandTarget_Exec
2879 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2881 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2883 return QueryInterface(riid, ppv);
2886 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2887 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2888 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2890 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2891 ok(pDispParams != NULL, "pDispParams == NULL\n");
2892 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2893 ok(puArgErr != NULL, "puArgErr == NULL\n");
2894 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2895 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2896 test_readyState(NULL);
2898 switch(dispIdMember) {
2899 case DISPID_AMBIENT_USERMODE:
2900 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2901 V_VT(pVarResult) = VT_BOOL;
2902 V_BOOL(pVarResult) = VARIANT_TRUE;
2904 case DISPID_AMBIENT_DLCONTROL:
2905 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2907 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2908 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2910 case DISPID_AMBIENT_SILENT:
2911 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2912 V_VT(pVarResult) = VT_BOOL;
2913 V_BOOL(pVarResult) = VARIANT_FALSE;
2915 case DISPID_AMBIENT_USERAGENT:
2916 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2918 case DISPID_AMBIENT_PALETTE:
2919 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2923 ok(0, "unexpected dispid %d\n", dispIdMember);
2927 static const IDispatchVtbl DispatchVtbl = {
2928 Dispatch_QueryInterface,
2931 Dispatch_GetTypeInfoCount,
2932 Dispatch_GetTypeInfo,
2933 Dispatch_GetIDsOfNames,
2937 static IDispatch Dispatch = { &DispatchVtbl };
2939 static HRESULT WINAPI EventDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2941 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
2946 ok(0, "Unexpected call\n");
2947 return E_NOINTERFACE;
2950 static HRESULT WINAPI EventDispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2951 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2952 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2955 IHTMLDocument2 *doc;
2958 ok(IsEqualGUID(&IID_NULL, riid), "riid = %s\n", debugstr_guid(riid));
2959 ok(pDispParams != NULL, "pDispParams == NULL\n");
2960 ok(pExcepInfo != NULL, "pExcepInfo == NULL\n");
2961 ok(puArgErr != NULL, "puArgErr == NULL\n");
2962 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult) = %d\n", V_VT(pVarResult));
2963 ok(wFlags == DISPATCH_METHOD, "wFlags = %d, expected DISPATCH_METHOD\n", wFlags);
2965 hres = IUnknown_QueryInterface(doc_unk, &IID_IHTMLDocument2, (void**)&doc);
2966 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2968 switch(dispIdMember) {
2969 case DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE:
2970 hres = IHTMLDocument2_get_readyState(doc, &state);
2971 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
2973 if(!strcmp_wa(state, "interactive"))
2974 CHECK_EXPECT(Invoke_OnReadyStateChange_Interactive);
2975 else if(!strcmp_wa(state, "loading"))
2976 CHECK_EXPECT(Invoke_OnReadyStateChange_Loading);
2977 else if(!strcmp_wa(state, "complete")) {
2978 CHECK_EXPECT(Invoke_OnReadyStateChange_Complete);
2981 ok(0, "Unexpected readyState: %s\n", wine_dbgstr_w(state));
2983 SysFreeString(state);
2985 case DISPID_HTMLDOCUMENTEVENTS2_ONPROPERTYCHANGE:
2995 break; /* FIXME: Handle these events. */
2997 ok(0, "Unexpected DISPID: %d\n", dispIdMember);
3000 IHTMLDocument2_Release(doc);
3004 static const IDispatchVtbl EventDispatchVtbl = {
3005 EventDispatch_QueryInterface,
3008 Dispatch_GetTypeInfoCount,
3009 Dispatch_GetTypeInfo,
3010 Dispatch_GetIDsOfNames,
3011 EventDispatch_Invoke
3014 static IDispatch EventDispatch = { &EventDispatchVtbl };
3016 static HRESULT WINAPI DocObjectService_QueryInterface(
3017 IDocObjectService* This,
3021 /* F62D9369-75EF-4578-8856-232802C76468 (ITridentService2) */
3025 static ULONG WINAPI DocObjectService_AddRef(
3026 IDocObjectService* This)
3031 static ULONG WINAPI DocObjectService_Release(
3032 IDocObjectService* This)
3037 static HRESULT WINAPI DocObjectService_FireBeforeNavigate2(
3038 IDocObjectService* This,
3039 IDispatch *pDispatch,
3042 LPCWSTR lpszFrameName,
3045 LPCWSTR lpszHeaders,
3049 ok(0, "unexpected call\n");
3053 static HRESULT WINAPI DocObjectService_FireNavigateComplete2(
3054 IDocObjectService* This,
3055 IHTMLWindow2 *pHTMLWindow2,
3058 CHECK_EXPECT(FireNavigateComplete2);
3062 static HRESULT WINAPI DocObjectService_FireDownloadBegin(
3063 IDocObjectService* This)
3065 ok(0, "unexpected call\n");
3069 static HRESULT WINAPI DocObjectService_FireDownloadComplete(
3070 IDocObjectService* This)
3072 ok(0, "unexpected call\n");
3076 static HRESULT WINAPI DocObjectService_FireDocumentComplete(
3077 IDocObjectService* This,
3078 IHTMLWindow2 *pHTMLWindow,
3081 CHECK_EXPECT(FireDocumentComplete);
3085 static HRESULT WINAPI DocObjectService_UpdateDesktopComponent(
3086 IDocObjectService* This,
3087 IHTMLWindow2 *pHTMLWindow)
3089 ok(0, "unexpected call\n");
3093 static HRESULT WINAPI DocObjectService_GetPendingUrl(
3094 IDocObjectService* This,
3095 BSTR *pbstrPendingUrl)
3097 CHECK_EXPECT(GetPendingUrl);
3101 static HRESULT WINAPI DocObjectService_ActiveElementChanged(
3102 IDocObjectService* This,
3103 IHTMLElement *pHTMLElement)
3105 CHECK_EXPECT(ActiveElementChanged);
3109 static HRESULT WINAPI DocObjectService_GetUrlSearchComponent(
3110 IDocObjectService* This,
3113 ok(0, "unexpected call\n");
3117 static HRESULT WINAPI DocObjectService_IsErrorUrl(
3118 IDocObjectService* This,
3122 CHECK_EXPECT(IsErrorUrl);
3127 static IDocObjectServiceVtbl DocObjectServiceVtbl = {
3128 DocObjectService_QueryInterface,
3129 DocObjectService_AddRef,
3130 DocObjectService_Release,
3131 DocObjectService_FireBeforeNavigate2,
3132 DocObjectService_FireNavigateComplete2,
3133 DocObjectService_FireDownloadBegin,
3134 DocObjectService_FireDownloadComplete,
3135 DocObjectService_FireDocumentComplete,
3136 DocObjectService_UpdateDesktopComponent,
3137 DocObjectService_GetPendingUrl,
3138 DocObjectService_ActiveElementChanged,
3139 DocObjectService_GetUrlSearchComponent,
3140 DocObjectService_IsErrorUrl
3143 static IDocObjectService DocObjectService = { &DocObjectServiceVtbl };
3145 DEFINE_GUID(IID_ITabBrowserService, 0x5E8FA523,0x83D4,0x4DBE,0x81,0x99,0x4C,0x18,0xE4,0x85,0x87,0x25);
3147 static HRESULT WINAPI BrowserService_QueryInterface(
3148 IBrowserService* This,
3154 if(IsEqualGUID(&IID_IShellBrowser, riid))
3155 return E_NOINTERFACE; /* TODO */
3157 if(IsEqualGUID(&IID_IDocObjectService, riid)) {
3158 *ppvObject = &DocObjectService;
3162 if(IsEqualGUID(&IID_ITabBrowserService, riid))
3163 return E_NOINTERFACE; /* TODO */
3165 ok(0, "unexpected call\n");
3166 return E_NOINTERFACE;
3169 static ULONG WINAPI BrowserService_AddRef(
3170 IBrowserService* This)
3175 static ULONG WINAPI BrowserService_Release(
3176 IBrowserService* This)
3181 static HRESULT WINAPI BrowserService_GetParentSite(
3182 IBrowserService* This,
3183 IOleInPlaceSite **ppipsite)
3185 ok(0, "unexpected call\n");
3189 static HRESULT WINAPI BrowserService_SetTitle(
3190 IBrowserService* This,
3194 ok(0, "unexpected call\n");
3198 static HRESULT WINAPI BrowserService_GetTitle(
3199 IBrowserService* This,
3204 ok(0, "unexpected call\n");
3208 static HRESULT WINAPI BrowserService_GetOleObject(
3209 IBrowserService* This,
3210 IOleObject **ppobjv)
3212 ok(0, "unexpected call\n");
3216 static HRESULT WINAPI BrowserService_GetTravelLog(
3217 IBrowserService* This,
3220 CHECK_EXPECT(GetTravelLog);
3224 static HRESULT WINAPI BrowserService_ShowControlWindow(
3225 IBrowserService* This,
3229 ok(0, "unexpected call\n");
3233 static HRESULT WINAPI BrowserService_IsControlWindowShown(
3234 IBrowserService* This,
3238 ok(0, "unexpected call\n");
3242 static HRESULT WINAPI BrowserService_IEGetDisplayName(
3243 IBrowserService* This,
3244 PCIDLIST_ABSOLUTE pidl,
3248 ok(0, "unexpected call\n");
3252 static HRESULT WINAPI BrowserService_IEParseDisplayName(
3253 IBrowserService* This,
3256 PIDLIST_ABSOLUTE *ppidlOut)
3258 ok(0, "unexpected call\n");
3262 static HRESULT WINAPI BrowserService_DisplayParseError(
3263 IBrowserService* This,
3267 ok(0, "unexpected call\n");
3271 static HRESULT WINAPI BrowserService_NavigateToPidl(
3272 IBrowserService* This,
3273 PCIDLIST_ABSOLUTE pidl,
3276 ok(0, "unexpected call\n");
3280 static HRESULT WINAPI BrowserService_SetNavigateState(
3281 IBrowserService* This,
3284 ok(0, "unexpected call\n");
3288 static HRESULT WINAPI BrowserService_GetNavigateState(
3289 IBrowserService* This,
3292 ok(0, "unexpected call\n");
3296 static HRESULT WINAPI BrowserService_NotifyRedirect(
3297 IBrowserService* This,
3299 PCIDLIST_ABSOLUTE pidl,
3302 ok(0, "unexpected call\n");
3306 static HRESULT WINAPI BrowserService_UpdateWindowList(
3307 IBrowserService* This)
3309 ok(0, "unexpected call\n");
3313 static HRESULT WINAPI BrowserService_UpdateBackForwardState(
3314 IBrowserService* This)
3316 CHECK_EXPECT(UpdateBackForwardState);
3320 static HRESULT WINAPI BrowserService_SetFlags(
3321 IBrowserService* This,
3325 ok(0, "unexpected call\n");
3329 static HRESULT WINAPI BrowserService_GetFlags(
3330 IBrowserService* This,
3333 ok(0, "unexpected call\n");
3337 static HRESULT WINAPI BrowserService_CanNavigateNow(
3338 IBrowserService* This)
3340 ok(0, "unexpected call\n");
3344 static HRESULT WINAPI BrowserService_GetPidl(
3345 IBrowserService* This,
3346 PIDLIST_ABSOLUTE *ppidl)
3348 ok(0, "unexpected call\n");
3352 static HRESULT WINAPI BrowserService_SetReferrer(
3353 IBrowserService* This,
3354 PCIDLIST_ABSOLUTE pidl)
3356 ok(0, "unexpected call\n");
3360 static DWORD WINAPI BrowserService_GetBrowserIndex(
3361 IBrowserService* This)
3363 ok(0, "unexpected call\n");
3367 static HRESULT WINAPI BrowserService_GetBrowserByIndex(
3368 IBrowserService* This,
3372 ok(0, "unexpected call\n");
3376 static HRESULT WINAPI BrowserService_GetHistoryObject(
3377 IBrowserService* This,
3382 ok(0, "unexpected call\n");
3386 static HRESULT WINAPI BrowserService_SetHistoryObject(
3387 IBrowserService* This,
3389 BOOL fIsLocalAnchor)
3391 ok(0, "unexpected call\n");
3395 static HRESULT WINAPI BrowserService_CacheOLEServer(
3396 IBrowserService* This,
3399 ok(0, "unexpected call\n");
3403 static HRESULT WINAPI BrowserService_GetSetCodePage(
3404 IBrowserService* This,
3408 ok(0, "unexpected call\n");
3412 static HRESULT WINAPI BrowserService_OnHttpEquiv(
3413 IBrowserService* This,
3417 VARIANT *pvarargOut)
3419 ok(0, "unexpected call\n");
3423 static HRESULT WINAPI BrowserService_GetPalette(
3424 IBrowserService* This,
3427 ok(0, "unexpected call\n");
3431 static HRESULT WINAPI BrowserService_RegisterWindow(
3432 IBrowserService* This,
3433 BOOL fForceRegister,
3436 ok(0, "unexpected call\n");
3440 static IBrowserServiceVtbl BrowserServiceVtbl = {
3441 BrowserService_QueryInterface,
3442 BrowserService_AddRef,
3443 BrowserService_Release,
3444 BrowserService_GetParentSite,
3445 BrowserService_SetTitle,
3446 BrowserService_GetTitle,
3447 BrowserService_GetOleObject,
3448 BrowserService_GetTravelLog,
3449 BrowserService_ShowControlWindow,
3450 BrowserService_IsControlWindowShown,
3451 BrowserService_IEGetDisplayName,
3452 BrowserService_IEParseDisplayName,
3453 BrowserService_DisplayParseError,
3454 BrowserService_NavigateToPidl,
3455 BrowserService_SetNavigateState,
3456 BrowserService_GetNavigateState,
3457 BrowserService_NotifyRedirect,
3458 BrowserService_UpdateWindowList,
3459 BrowserService_UpdateBackForwardState,
3460 BrowserService_SetFlags,
3461 BrowserService_GetFlags,
3462 BrowserService_CanNavigateNow,
3463 BrowserService_GetPidl,
3464 BrowserService_SetReferrer,
3465 BrowserService_GetBrowserIndex,
3466 BrowserService_GetBrowserByIndex,
3467 BrowserService_GetHistoryObject,
3468 BrowserService_SetHistoryObject,
3469 BrowserService_CacheOLEServer,
3470 BrowserService_GetSetCodePage,
3471 BrowserService_OnHttpEquiv,
3472 BrowserService_GetPalette,
3473 BrowserService_RegisterWindow
3476 static IBrowserService BrowserService = { &BrowserServiceVtbl };
3478 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
3479 REFIID riid, void **ppv)
3481 return QueryInterface(riid, ppv);
3484 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
3489 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
3494 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
3495 REFIID riid, void **ppv)
3498 * Services used by HTMLDocument:
3501 * IInternetSecurityManager
3503 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
3506 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
3507 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
3508 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
3510 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
3511 * IElementBehaviorFactory
3512 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
3522 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
3523 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
3528 if(IsEqualGUID(&SID_SNewWindowManager, guidService)) {
3529 ok(IsEqualGUID(&IID_INewWindowManager, riid), "unexpected riid\n");
3530 *ppv = &NewWindowManager;
3534 if(IsEqualGUID(&IID_IShellBrowser, guidService)) {
3535 ok(IsEqualGUID(&IID_IBrowserService, riid), "unexpected riid\n");
3536 *ppv = &BrowserService;
3540 return E_NOINTERFACE;
3543 static const IServiceProviderVtbl ServiceProviderVtbl = {
3544 ServiceProvider_QueryInterface,
3545 ServiceProvider_AddRef,
3546 ServiceProvider_Release,
3547 ServiceProvider_QueryService
3550 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
3552 static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSinkEx *iface,
3553 REFIID riid, void **ppv)
3555 return QueryInterface(riid, ppv);
3558 static ULONG WINAPI AdviseSink_AddRef(IAdviseSinkEx *iface)
3563 static ULONG WINAPI AdviseSink_Release(IAdviseSinkEx *iface)
3568 static void WINAPI AdviseSink_OnDataChange(IAdviseSinkEx *iface,
3569 FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
3571 ok(0, "unexpected call\n");
3574 static void WINAPI AdviseSink_OnViewChange(IAdviseSinkEx *iface,
3575 DWORD dwAspect, LONG lindex)
3577 ok(0, "unexpected call\n");
3580 static void WINAPI AdviseSink_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
3582 ok(0, "unexpected call\n");
3585 static void WINAPI AdviseSink_OnSave(IAdviseSinkEx *iface)
3587 ok(0, "unexpected call\n");
3590 static void WINAPI AdviseSink_OnClose(IAdviseSinkEx *iface)
3592 ok(0, "unexpected call\n");
3595 static void WINAPI AdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
3597 ok(0, "unexpected call\n");
3600 static void WINAPI ObjectAdviseSink_OnClose(IAdviseSinkEx *iface)
3602 CHECK_EXPECT(Advise_Close);
3605 static const IAdviseSinkExVtbl AdviseSinkVtbl = {
3606 AdviseSink_QueryInterface,
3609 AdviseSink_OnDataChange,
3610 AdviseSink_OnViewChange,
3611 AdviseSink_OnRename,
3613 ObjectAdviseSink_OnClose,
3614 AdviseSinkEx_OnViewStatusChange
3617 static IAdviseSinkEx AdviseSink = { &AdviseSinkVtbl };
3619 static HRESULT WINAPI ViewAdviseSink_QueryInterface(IAdviseSinkEx *iface,
3620 REFIID riid, void **ppv)
3622 if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) {
3627 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
3629 return E_NOINTERFACE;
3632 static void WINAPI ViewAdviseSink_OnViewChange(IAdviseSinkEx *iface,
3633 DWORD dwAspect, LONG lindex)
3635 CHECK_EXPECT2(OnViewChange);
3637 ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %d\n", dwAspect);
3638 ok(lindex == -1, "lindex = %d\n", lindex);
3641 static const IAdviseSinkExVtbl ViewAdviseSinkVtbl = {
3642 ViewAdviseSink_QueryInterface,
3645 AdviseSink_OnDataChange,
3646 ViewAdviseSink_OnViewChange,
3647 AdviseSink_OnRename,
3650 AdviseSinkEx_OnViewStatusChange
3653 static IAdviseSinkEx ViewAdviseSink = { &ViewAdviseSinkVtbl };
3655 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
3656 DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
3657 DEFINE_GUID(IID_IRenMailEditor, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
3658 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
3659 DEFINE_GUID(IID_IDocHostUIHandlerPriv, 0xf0d241d1,0x5d0e,0x4e85,0xbc,0xb4,0xfa,0xd7,0xf7,0xc5,0x52,0x8c);
3661 static HRESULT QueryInterface(REFIID riid, void **ppv)
3665 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
3667 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
3668 *ppv = &DocumentSite;
3669 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
3670 *ppv = &DocHostUIHandler;
3671 else if(IsEqualGUID(&IID_IOleContainer, riid))
3672 *ppv = &OleContainer;
3673 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
3674 *ppv = &InPlaceSiteWindowless;
3675 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
3676 *ppv = &OleCommandTarget;
3677 else if(IsEqualGUID(&IID_IDispatch, riid))
3679 else if(IsEqualGUID(&IID_IServiceProvider, riid))
3680 *ppv = &ServiceProvider;
3681 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
3682 *ppv = ipsex ? &InPlaceSiteWindowless : NULL;
3683 else if(IsEqualGUID(&IID_IOleInPlaceSiteWindowless, riid))
3684 *ppv = ipsw ? &InPlaceSiteWindowless : NULL;
3685 else if(IsEqualGUID(&IID_IOleControlSite, riid))
3686 *ppv = &OleControlSite;
3687 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
3688 return E_NOINTERFACE; /* TODO */
3689 else if(IsEqualGUID(&IID_IProxyManager, riid))
3690 return E_NOINTERFACE; /* ? */
3691 else if(IsEqualGUID(&IID_unk1, riid))
3692 return E_NOINTERFACE; /* HTMLWindow2 ? */
3693 else if(IsEqualGUID(&IID_IThumbnailView, riid))
3694 return E_NOINTERFACE; /* ? */
3695 else if(IsEqualGUID(&IID_IRenMailEditor, riid))
3696 return E_NOINTERFACE; /* ? */
3697 else if(IsEqualGUID(&IID_unk4, riid))
3698 return E_NOINTERFACE; /* ? */
3699 else if(IsEqualGUID(&IID_IDocHostUIHandlerPriv, riid))
3700 return E_NOINTERFACE; /* ? */
3702 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
3706 return E_NOINTERFACE;
3709 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3711 if(msg == WM_CONTINUE_BINDING) {
3712 IBindStatusCallback *callback = (IBindStatusCallback*)wParam;
3713 continue_binding(callback);
3716 return DefWindowProc(hwnd, msg, wParam, lParam);
3719 static void test_doscroll(IUnknown *unk)
3721 IHTMLDocument3 *doc;
3722 IHTMLElement2 *elem2;
3727 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument3, (void**)&doc);
3728 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
3732 hres = IHTMLDocument3_get_documentElement(doc, &elem);
3733 IHTMLDocument3_Release(doc);
3734 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
3735 switch(load_state) {
3739 ok(!elem, "elem != NULL\n");
3742 case LD_INTERACTIVE:
3744 ok(elem != NULL, "elem == NULL\n");
3749 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
3750 IHTMLElement_Release(elem);
3751 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
3754 V_BSTR(&v) = a2bstr("left");
3755 hres = IHTMLElement2_doScroll(elem2, v);
3756 SysFreeString(V_BSTR(&v));
3757 IHTMLElement2_Release(elem2);
3759 if(inplace_deactivated)
3760 ok(hres == E_PENDING, "doScroll failed: %08x\n", hres);
3761 else if(load_state == LD_COMPLETE)
3762 ok(hres == S_OK, "doScroll failed: %08x\n", hres);
3764 ok(hres == E_PENDING || hres == S_OK, "doScroll failed: %08x\n", hres);
3767 static void _test_readyState(unsigned line, IUnknown *unk)
3769 IHTMLDocument2 *htmldoc;
3770 DISPPARAMS dispparams;
3776 static const LPCSTR expected_state[] = {
3791 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
3792 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
3796 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
3797 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
3799 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
3800 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
3802 if(!strcmp_wa(state, "interactive") && load_state == LD_LOADING)
3803 load_state = LD_INTERACTIVE;
3806 (!strcmp_wa(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
3807 wine_dbgstr_w(state), load_state);
3808 SysFreeString(state);
3810 hres = IHTMLDocument2_get_body(htmldoc, &elem);
3811 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
3813 IHTMLElement2 *elem2;
3816 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
3817 IHTMLElement_Release(elem);
3818 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
3820 hres = IHTMLElement2_get_readyState(elem2, &var);
3821 IHTMLElement2_Release(elem2);
3822 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
3823 ok(V_VT(&var) == VT_BSTR, "V_VT(state) = %d\n", V_VT(&var));
3824 ok(!strcmp_wa(V_BSTR(&var), "complete"), "unexpected body state %s\n", wine_dbgstr_w(V_BSTR(&var)));
3827 ok_(__FILE__,line)(load_state != LD_COMPLETE, "body is NULL in complete state\n");
3830 dispparams.cArgs = 0;
3831 dispparams.cNamedArgs = 0;
3832 dispparams.rgdispidNamedArgs = NULL;
3833 dispparams.rgvarg = NULL;
3837 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
3838 &dispparams, &out, NULL, NULL);
3839 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
3841 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
3842 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
3844 test_doscroll((IUnknown*)htmldoc);
3846 IHTMLDocument2_Release(htmldoc);
3849 static void test_ViewAdviseSink(IHTMLDocument2 *doc)
3854 hres = IHTMLDocument2_QueryInterface(doc, &IID_IViewObject, (void**)&view);
3855 ok(hres == S_OK, "QueryInterface(IID_IViewObject) failed: %08x\n", hres);
3857 hres = IViewObject_SetAdvise(view, DVASPECT_CONTENT, ADVF_PRIMEFIRST, (IAdviseSink*)&ViewAdviseSink);
3858 ok(hres == S_OK, "SetAdvise failed: %08x\n", hres);
3860 IViewObject_Release(view);
3863 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
3865 IConnectionPointContainer *tmp_container = NULL;
3866 IConnectionPoint *cp;
3871 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
3872 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
3876 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
3877 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
3878 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
3880 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
3881 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
3883 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
3884 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
3885 ok(tmp_container == container, "container != tmp_container\n");
3887 IConnectionPointContainer_Release(tmp_container);
3889 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
3890 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
3892 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
3893 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
3894 ok(hres == S_OK, "Advise failed: %08x\n", hres);
3895 } else if(IsEqualGUID(&IID_IDispatch, riid)) {
3896 hres = IConnectionPoint_Advise(cp, (IUnknown*)&EventDispatch, &cookie);
3897 ok(hres == S_OK, "Advise failed: %08x\n", hres);
3900 IConnectionPoint_Release(cp);
3903 static void test_ConnectionPointContainer(IHTMLDocument2 *doc)
3905 IConnectionPointContainer *container;
3908 hres = IUnknown_QueryInterface(doc, &IID_IConnectionPointContainer, (void**)&container);
3909 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
3913 test_ConnectionPoint(container, &IID_IDispatch);
3914 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
3915 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
3916 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
3918 IConnectionPointContainer_Release(container);
3921 static void set_custom_uihandler(IHTMLDocument2 *doc, IDocHostUIHandler2 *uihandler)
3923 ICustomDoc *custom_doc;
3926 hres = IHTMLDocument2_QueryInterface(doc, &IID_ICustomDoc, (void**)&custom_doc);
3927 ok(hres == S_OK, "Could not get ICustomDoc iface: %08x\n", hres);
3929 expect_uihandler_iface = uihandler;
3931 hres = ICustomDoc_SetUIHandler(custom_doc, (IDocHostUIHandler*)uihandler);
3932 ICustomDoc_Release(custom_doc);
3933 ok(hres == S_OK, "SetUIHandler failed: %08x\n", hres);
3936 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
3940 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
3942 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
3944 test_readyState((IUnknown*)persist);
3948 CreateBindCtx(0, &bind);
3949 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
3950 (IUnknown*)&ClientSite);
3953 SET_EXPECT(GetDisplayName);
3954 if(!set_clientsite) {
3955 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3956 SET_EXPECT(GetHostInfo);
3957 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3958 SET_EXPECT(Invoke_AMBIENT_SILENT);
3959 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3960 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3961 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3962 SET_EXPECT(GetOptionKeyPath);
3963 SET_EXPECT(GetOverrideKeyPath);
3964 SET_EXPECT(GetWindow);
3965 SET_EXPECT(Exec_DOCCANNAVIGATE);
3966 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3967 SET_EXPECT(Exec_SETPROGRESSMAX);
3968 SET_EXPECT(Exec_SETPROGRESSPOS);
3969 SET_EXPECT(Exec_ShellDocView_37);
3971 if(!container_locked) {
3972 SET_EXPECT(GetContainer);
3973 SET_EXPECT(LockContainer);
3975 SET_EXPECT(OnChanged_READYSTATE);
3976 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
3977 SET_EXPECT(Exec_ShellDocView_84);
3978 SET_EXPECT(IsSystemMoniker);
3980 SET_EXPECT(BindToStorage);
3981 SET_EXPECT(SetActiveObject);
3982 if(set_clientsite) {
3983 SET_EXPECT(Invoke_AMBIENT_SILENT);
3984 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3985 SET_EXPECT(Exec_ShellDocView_37);
3986 SET_EXPECT(IsErrorUrl);
3989 SET_EXPECT(GetTravelLog);
3990 SET_EXPECT(GetPendingUrl);
3991 load_state = LD_DOLOAD;
3992 expect_LockContainer_fLock = TRUE;
3993 readystate_set_loading = TRUE;
3995 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
3996 ok(hres == S_OK, "Load failed: %08x\n", hres);
3999 CHECK_CALLED(GetDisplayName);
4000 if(!set_clientsite) {
4001 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4002 CHECK_CALLED(GetHostInfo);
4003 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4004 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4005 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4006 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4007 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4008 CHECK_CALLED(GetOptionKeyPath);
4009 CHECK_CALLED(GetOverrideKeyPath);
4010 CHECK_CALLED(GetWindow);
4011 CHECK_CALLED(Exec_DOCCANNAVIGATE);
4012 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
4013 CHECK_CALLED(Exec_SETPROGRESSMAX);
4014 CHECK_CALLED(Exec_SETPROGRESSPOS);
4015 CHECK_CALLED(Exec_ShellDocView_37);
4017 if(!container_locked) {
4018 CHECK_CALLED(GetContainer);
4019 CHECK_CALLED(LockContainer);
4020 container_locked = TRUE;
4022 CHECK_CALLED(OnChanged_READYSTATE);
4023 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
4024 SET_CALLED(IsSystemMoniker); /* IE7 */
4025 SET_CALLED(Exec_ShellDocView_84);
4027 CHECK_CALLED(BindToStorage);
4028 SET_CALLED(SetActiveObject); /* FIXME */
4029 if(set_clientsite) {
4030 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4031 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4032 CHECK_CALLED(Exec_ShellDocView_37);
4033 todo_wine CHECK_CALLED_BROKEN(IsErrorUrl);
4036 todo_wine CHECK_CALLED(GetTravelLog);
4037 todo_wine CHECK_CALLED(GetPendingUrl);
4039 set_clientsite = container_locked = TRUE;
4041 test_GetCurMoniker((IUnknown*)persist, mon, NULL);
4043 IBindCtx_Release(bind);
4045 test_readyState((IUnknown*)persist);
4048 #define DWL_VERBDONE 0x0001
4049 #define DWL_CSS 0x0002
4050 #define DWL_TRYCSS 0x0004
4051 #define DWL_HTTP 0x0008
4052 #define DWL_EMPTY 0x0010
4054 static void test_download(DWORD flags)
4059 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
4060 ok(hwnd != NULL, "Could not find hidden window\n");
4062 test_readyState(NULL);
4064 if(flags & (DWL_VERBDONE|DWL_HTTP))
4065 SET_EXPECT(Exec_SETPROGRESSMAX);
4066 if((flags & DWL_VERBDONE) && !load_from_stream)
4067 SET_EXPECT(GetHostInfo);
4068 SET_EXPECT(SetStatusText);
4069 if(!(flags & DWL_EMPTY))
4070 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
4071 SET_EXPECT(OnViewChange);
4072 SET_EXPECT(GetDropTarget);
4073 if(flags & DWL_TRYCSS)
4074 SET_EXPECT(Exec_ShellDocView_84);
4075 if(flags & DWL_CSS) {
4076 SET_EXPECT(CreateInstance);
4078 SET_EXPECT(LockRequest);
4079 SET_EXPECT(Terminate);
4080 SET_EXPECT(Protocol_Read);
4081 SET_EXPECT(UnlockRequest);
4083 if(!(flags & DWL_EMPTY))
4084 SET_EXPECT(Invoke_OnReadyStateChange_Interactive);
4085 SET_EXPECT(Invoke_OnReadyStateChange_Complete);
4086 SET_EXPECT(Exec_Explorer_69);
4087 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
4088 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
4089 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
4090 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
4092 SET_EXPECT(Exec_ShellDocView_37);
4093 if(flags & DWL_HTTP) {
4094 SET_EXPECT(OnChanged_1012);
4095 SET_EXPECT(Exec_HTTPEQUIV);
4096 SET_EXPECT(Exec_SETTITLE);
4098 SET_EXPECT(OnChanged_1005);
4099 SET_EXPECT(OnChanged_READYSTATE);
4100 SET_EXPECT(Exec_SETPROGRESSPOS);
4101 if(!(flags & DWL_EMPTY))
4102 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
4103 SET_EXPECT(Exec_ShellDocView_103);
4104 SET_EXPECT(Exec_ShellDocView_105);
4105 SET_EXPECT(Exec_ShellDocView_140);
4106 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
4107 SET_EXPECT(Exec_HTTPEQUIV_DONE);
4108 SET_EXPECT(SetStatusText);
4110 SET_EXPECT(UpdateUI);
4111 SET_EXPECT(Exec_UPDATECOMMANDS);
4112 SET_EXPECT(Exec_SETTITLE);
4113 SET_EXPECT(UpdateBackForwardState);
4115 if(!editmode && !(flags & DWL_EMPTY))
4116 SET_EXPECT(FireNavigateComplete2);
4118 SET_EXPECT(FireDocumentComplete);
4119 SET_EXPECT(ActiveElementChanged);
4120 SET_EXPECT(IsErrorUrl);
4121 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
4123 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
4124 TranslateMessage(&msg);
4125 DispatchMessage(&msg);
4128 if(flags & DWL_VERBDONE)
4129 CHECK_CALLED(Exec_SETPROGRESSMAX);
4130 if(flags & DWL_HTTP)
4131 SET_CALLED(Exec_SETPROGRESSMAX);
4132 if((flags & DWL_VERBDONE) && !load_from_stream) {
4134 todo_wine CHECK_CALLED(GetHostInfo);
4136 CHECK_CALLED(GetHostInfo);
4138 CHECK_CALLED(SetStatusText);
4139 if(!(flags & DWL_EMPTY))
4140 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
4141 CHECK_CALLED(OnViewChange);
4142 SET_CALLED(GetDropTarget);
4143 if(flags & DWL_TRYCSS)
4144 SET_CALLED(Exec_ShellDocView_84);
4145 if(flags & DWL_CSS) {
4146 CHECK_CALLED(CreateInstance);
4147 CHECK_CALLED(Start);
4148 CHECK_CALLED(LockRequest);
4149 CHECK_CALLED(Terminate);
4150 CHECK_CALLED(Protocol_Read);
4151 CHECK_CALLED(UnlockRequest);
4153 if(!(flags & DWL_EMPTY))
4154 CHECK_CALLED(Invoke_OnReadyStateChange_Interactive);
4155 CHECK_CALLED(Invoke_OnReadyStateChange_Complete);
4156 SET_CALLED(Exec_Explorer_69);
4157 SET_CALLED(EnableModeless_TRUE); /* IE7 */
4158 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
4159 SET_CALLED(EnableModeless_FALSE); /* IE7 */
4160 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
4162 todo_wine CHECK_CALLED(Exec_ShellDocView_37);
4163 if(flags & DWL_HTTP) todo_wine {
4164 CHECK_CALLED(OnChanged_1012);
4165 CHECK_CALLED(Exec_HTTPEQUIV);
4166 CHECK_CALLED(Exec_SETTITLE);
4168 CHECK_CALLED(OnChanged_1005);
4169 CHECK_CALLED(OnChanged_READYSTATE);
4170 CHECK_CALLED(Exec_SETPROGRESSPOS);
4171 if(!(flags & DWL_EMPTY))
4172 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
4173 SET_CALLED(Exec_ShellDocView_103);
4174 SET_CALLED(Exec_ShellDocView_105);
4175 SET_CALLED(Exec_ShellDocView_140);
4176 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
4177 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
4178 SET_CALLED(SetStatusText);
4179 if(nav_url) { /* avoiding race, FIXME: find better way */
4180 SET_CALLED(UpdateUI);
4181 SET_CALLED(Exec_UPDATECOMMANDS);
4182 SET_CALLED(Exec_SETTITLE);
4183 todo_wine CHECK_CALLED_BROKEN(UpdateBackForwardState);
4185 if(!editmode && !(flags & DWL_EMPTY))
4186 todo_wine CHECK_CALLED(FireNavigateComplete2);
4188 CHECK_CALLED(FireDocumentComplete);
4189 todo_wine CHECK_CALLED(ActiveElementChanged);
4190 todo_wine CHECK_CALLED_BROKEN(IsErrorUrl);
4192 load_state = LD_COMPLETE;
4194 test_readyState(NULL);
4197 static void test_Persist(IHTMLDocument2 *doc, IMoniker *mon)
4199 IPersistMoniker *persist_mon;
4200 IPersistFile *persist_file;
4204 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&persist_file);
4205 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
4206 if(SUCCEEDED(hres)) {
4207 hres = IPersist_GetClassID(persist_file, NULL);
4208 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
4210 hres = IPersist_GetClassID(persist_file, &guid);
4211 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
4212 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
4214 IPersist_Release(persist_file);
4217 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist_mon);
4218 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
4219 if(SUCCEEDED(hres)) {
4220 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
4221 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
4223 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
4224 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
4225 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
4227 if(load_state == LD_DOLOAD)
4228 test_Load(persist_mon, mon);
4230 test_readyState((IUnknown*)doc);
4232 IPersistMoniker_Release(persist_mon);
4236 static void test_put_href(IHTMLDocument2 *doc, BOOL use_replace)
4238 IHTMLPrivateWindow *priv_window;
4239 IHTMLWindow2 *window;
4240 IHTMLLocation *location;
4246 hres = IHTMLDocument2_get_location(doc, &location);
4247 ok(hres == S_OK, "get_location failed: %08x\n", hres);
4248 ok(location != NULL, "location == NULL\n");
4250 nav_url = use_replace ? "about:replace" : "about:blank";
4252 str = a2bstr(nav_url);
4253 SET_EXPECT(TranslateUrl);
4254 SET_EXPECT(Navigate);
4256 hres = IHTMLLocation_replace(location, str);
4257 ok(hres == S_OK, "put_href failed: %08x\n", hres);
4259 hres = IHTMLLocation_put_href(location, str);
4260 ok(hres == S_OK, "put_href failed: %08x\n", hres);
4262 CHECK_CALLED(TranslateUrl);
4263 CHECK_CALLED(Navigate);
4265 IHTMLLocation_Release(location);
4267 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4268 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4270 hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window);
4271 IHTMLWindow2_Release(window);
4272 ok(hres == S_OK, "QueryInterface(IID_IHTMLPrivateWindow) failed: %08x\n", hres);
4274 readystate_set_loading = TRUE;
4275 SET_EXPECT(TranslateUrl);
4276 SET_EXPECT(Exec_ShellDocView_67);
4277 SET_EXPECT(Invoke_AMBIENT_SILENT);
4278 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4279 SET_EXPECT(OnChanged_READYSTATE);
4280 SET_EXPECT(Exec_ShellDocView_63);
4281 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
4284 V_VT(&vempty) = VT_EMPTY;
4285 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, str2, NULL, NULL, &vempty, &vempty, 0);
4286 SysFreeString(str2);
4287 ok(hres == S_OK, "SuperNavigate failed: %08x\n", hres);
4289 CHECK_CALLED(TranslateUrl);
4290 CHECK_CALLED(Exec_ShellDocView_67);
4291 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4292 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4293 SET_CALLED(OnChanged_READYSTATE); /* not always called */
4294 CHECK_CALLED(Exec_ShellDocView_63);
4295 CLEAR_CALLED(Invoke_OnReadyStateChange_Loading); /* not always called */
4298 test_GetCurMoniker(doc_unk, doc_mon, NULL);
4301 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str2);
4302 ok(hres == S_OK, "GetAddressBarUrl failed: %08x\n", hres);
4303 ok(!strcmp_wa(str2, use_replace?"about:blank":"http://www.winehq.org/"),
4304 "unexpected address bar url: %s\n", wine_dbgstr_w(str2));
4305 SysFreeString(str2);
4307 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
4308 test_download(DWL_VERBDONE);
4309 todo_wine CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
4311 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str2);
4312 ok(hres == S_OK, "GetAddressBarUrl failed: %08x\n", hres);
4313 ok(!lstrcmpW(str2, str), "unexpected address bar url: %s\n", wine_dbgstr_w(str2));
4314 SysFreeString(str2);
4316 IHTMLPrivateWindow_Release(priv_window);
4319 static void test_open_window(IHTMLDocument2 *doc)
4321 IHTMLWindow2 *window, *new_window;
4325 hres = IHTMLDocument2_get_parentWindow(doc, &window);
4326 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
4328 url = a2bstr(nav_url = "about:blank");
4329 name = a2bstr("test");
4330 new_window = (void*)0xdeadbeef;
4334 SET_EXPECT(TranslateUrl);
4335 SET_EXPECT(EvaluateNewWindow);
4337 hres = IHTMLWindow2_open(window, url, name, NULL, VARIANT_FALSE, &new_window);
4340 SysFreeString(name);
4343 CHECK_CALLED(TranslateUrl);
4345 if(!called_EvaluateNewWindow) {
4347 win_skip("INewWindowManager not supported\n");
4348 if(SUCCEEDED(hres) && new_window)
4349 IHTMLWindow2_Release(new_window);
4350 IHTMLWindow2_Release(window);
4355 CHECK_CALLED(EvaluateNewWindow);
4358 ok(hres == S_OK, "open failed: %08x\n", hres);
4360 ok(new_window == NULL, "new_window != NULL\n");
4362 IHTMLWindow2_Release(window);
4365 static void test_clear(IHTMLDocument2 *doc)
4369 hres = IHTMLDocument2_clear(doc);
4370 ok(hres == S_OK, "clear failed: %08x\n", hres);
4373 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
4375 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
4376 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
4377 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
4378 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
4379 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
4380 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
4381 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
4382 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
4383 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
4384 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
4385 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
4386 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
4387 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
4388 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
4389 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
4390 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
4391 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
4392 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
4393 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
4394 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
4396 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
4397 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
4399 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
4401 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
4403 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
4404 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
4406 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
4407 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
4409 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
4411 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
4412 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
4415 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
4416 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
4418 IOleCommandTarget *cmdtrg;
4419 OLECMD olecmd = {cmdid, 0};
4422 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
4423 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
4427 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
4428 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
4430 IOleCommandTarget_Release(cmdtrg);
4432 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
4433 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
4436 static void test_MSHTML_QueryStatus(IHTMLDocument2 *doc, DWORD cmdf)
4438 IUnknown *unk = doc ? (IUnknown*)doc : doc_unk;
4440 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
4441 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
4442 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
4443 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
4444 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
4445 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
4446 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
4447 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
4448 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
4449 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
4450 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
4451 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
4452 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
4453 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
4454 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
4455 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
4458 static void test_OleCommandTarget(IHTMLDocument2 *doc)
4460 IOleCommandTarget *cmdtrg;
4461 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
4465 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
4466 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
4470 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
4471 cmds[i].cmdID = i+1;
4472 cmds[i].cmdf = 0xf0f0;
4475 SET_EXPECT(QueryStatus_OPEN);
4476 SET_EXPECT(QueryStatus_NEW);
4477 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
4478 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
4479 CHECK_CALLED(QueryStatus_OPEN);
4480 CHECK_CALLED(QueryStatus_NEW);
4482 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
4483 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
4484 if(i+1 == OLECMDID_FIND)
4486 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
4487 i+1, cmds[i].cmdf, expect_cmds[i+1]);
4490 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
4491 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
4493 IOleCommandTarget_Release(cmdtrg);
4496 static void test_OleCommandTarget_fail(IHTMLDocument2 *doc)
4498 IOleCommandTarget *cmdtrg;
4503 {OLECMDID_OPEN, 0xf0f0},
4504 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
4507 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
4508 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
4512 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
4513 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
4515 SET_EXPECT(QueryStatus_OPEN);
4516 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
4517 CHECK_CALLED(QueryStatus_OPEN);
4519 ok(hres == OLECMDERR_E_NOTSUPPORTED,
4520 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
4521 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
4522 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
4523 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
4524 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
4525 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
4527 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
4528 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
4529 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
4531 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
4532 if(!expect_cmds[i]) {
4533 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
4534 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
4535 ok(hres == OLECMDERR_E_NOTSUPPORTED,
4536 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
4540 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
4541 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
4542 ok(hres == OLECMDERR_E_NOTSUPPORTED,
4543 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
4545 IOleCommandTarget_Release(cmdtrg);
4548 static void test_exec_onunload(IHTMLDocument2 *doc)
4550 IOleCommandTarget *cmdtrg;
4554 hres = IUnknown_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
4555 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
4559 memset(&var, 0x0a, sizeof(var));
4560 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
4561 OLECMDEXECOPT_DODEFAULT, NULL, &var);
4562 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
4563 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
4564 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
4566 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
4567 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
4568 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
4570 IOleCommandTarget_Release(cmdtrg);
4573 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
4575 IOleCommandTarget *cmdtrg;
4578 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
4579 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
4586 load_state = LD_DOLOAD;
4589 SET_EXPECT(GetClassID);
4590 SET_EXPECT(SetStatusText);
4591 SET_EXPECT(Exec_ShellDocView_37);
4592 SET_EXPECT(GetHostInfo);
4594 SET_EXPECT(GetDisplayName);
4595 SET_EXPECT(Invoke_AMBIENT_SILENT);
4596 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4597 SET_EXPECT(OnChanged_READYSTATE);
4598 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
4599 SET_EXPECT(IsSystemMoniker);
4600 SET_EXPECT(Exec_ShellDocView_84);
4602 SET_EXPECT(BindToStorage);
4603 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4606 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4608 expect_status_text = NULL;
4609 readystate_set_loading = TRUE;
4611 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
4612 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
4613 ok(hres == S_OK, "Exec failed: %08x\n", hres);
4616 CHECK_CALLED(GetClassID);
4617 CHECK_CALLED(SetStatusText);
4618 CHECK_CALLED(Exec_ShellDocView_37);
4619 CHECK_CALLED(GetHostInfo);
4621 CHECK_CALLED(GetDisplayName);
4622 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4623 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4624 CHECK_CALLED(OnChanged_READYSTATE);
4625 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
4626 SET_CALLED(IsSystemMoniker); /* IE7 */
4627 SET_CALLED(Exec_ShellDocView_84);
4629 CHECK_CALLED(BindToStorage);
4630 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4631 CHECK_CALLED(HideUI);
4632 CHECK_CALLED(ShowUI);
4633 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4635 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
4637 IOleCommandTarget_Release(cmdtrg);
4639 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
4640 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
4641 ok(hres == S_OK, "Exec failed: %08x\n", hres);
4644 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
4646 IOleCommandTarget *cmdtrg;
4647 VARIANT *in = NULL, _in, *out = NULL, _out;
4650 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
4651 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
4658 V_BSTR(in) = SysAllocString(name);
4664 V_I4(out) = 0xdeadbeef;
4667 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
4668 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
4674 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
4675 if(V_VT(out) == VT_BSTR) {
4677 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
4678 "unexpected fontname %s\n", wine_dbgstr_w(name));
4680 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
4685 IOleCommandTarget_Release(cmdtrg);
4688 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
4690 IOleCommandTarget *cmdtrg;
4693 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
4694 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
4698 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
4699 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
4700 ok(hres == S_OK, "Exec failed: %08x\n", hres);
4702 IOleCommandTarget_Release(cmdtrg);
4705 static void test_IsDirty(IHTMLDocument2 *doc, HRESULT exhres)
4707 IPersistStreamInit *perinit;
4708 IPersistMoniker *permon;
4709 IPersistFile *perfile;
4712 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&perinit);
4713 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
4714 if(SUCCEEDED(hres)) {
4715 hres = IPersistStreamInit_IsDirty(perinit);
4716 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
4717 IPersistStreamInit_Release(perinit);
4720 hres = IUnknown_QueryInterface(doc, &IID_IPersistMoniker, (void**)&permon);
4721 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
4722 if(SUCCEEDED(hres)) {
4723 hres = IPersistMoniker_IsDirty(permon);
4724 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
4725 IPersistMoniker_Release(permon);
4728 hres = IUnknown_QueryInterface(doc, &IID_IPersistFile, (void**)&perfile);
4729 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
4730 if(SUCCEEDED(hres)) {
4731 hres = IPersistFile_IsDirty(perfile);
4732 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
4733 IPersistFile_Release(perfile);
4737 static HWND create_container_window(void)
4739 static const WCHAR wszHTMLDocumentTest[] =
4740 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
4741 static WNDCLASSEXW wndclass = {
4742 sizeof(WNDCLASSEXW),
4745 0, 0, NULL, NULL, NULL, NULL, NULL,
4746 wszHTMLDocumentTest,
4750 RegisterClassExW(&wndclass);
4751 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
4752 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
4753 515, 530, NULL, NULL, NULL, NULL);
4756 static void test_DoVerb(IOleObject *oleobj)
4758 RECT rect = {0,0,500,500};
4761 if(!container_locked) {
4762 SET_EXPECT(GetContainer);
4763 SET_EXPECT(LockContainer);
4765 SET_EXPECT(ActivateMe);
4766 expect_LockContainer_fLock = TRUE;
4768 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
4769 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
4771 if(!container_locked) {
4772 CHECK_CALLED(GetContainer);
4773 CHECK_CALLED(LockContainer);
4774 container_locked = TRUE;
4776 CHECK_CALLED(ActivateMe);
4779 #define CLIENTSITE_EXPECTPATH 0x00000001
4780 #define CLIENTSITE_SETNULL 0x00000002
4781 #define CLIENTSITE_DONTSET 0x00000004
4783 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
4785 IOleClientSite *clientsite;
4788 if(flags & CLIENTSITE_SETNULL) {
4789 hres = IOleObject_GetClientSite(oleobj, &clientsite);
4790 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4792 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
4794 ok(!clientsite, "clientsite != NULL\n");
4796 hres = IOleObject_SetClientSite(oleobj, NULL);
4797 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4799 set_clientsite = FALSE;
4802 if(flags & CLIENTSITE_DONTSET)
4805 if(!expect_uihandler_iface)
4806 expect_uihandler_iface = &DocHostUIHandler;
4808 hres = IOleObject_GetClientSite(oleobj, &clientsite);
4809 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
4810 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
4811 clientsite, set_clientsite ? &ClientSite : NULL);
4813 if(!set_clientsite) {
4814 if(expect_uihandler_iface)
4815 SET_EXPECT(GetHostInfo);
4816 if(flags & CLIENTSITE_EXPECTPATH) {
4817 SET_EXPECT(GetOptionKeyPath);
4818 SET_EXPECT(GetOverrideKeyPath);
4820 SET_EXPECT(GetWindow);
4821 if(flags & CLIENTSITE_EXPECTPATH)
4822 SET_EXPECT(Exec_DOCCANNAVIGATE);
4823 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
4824 SET_EXPECT(Exec_SETPROGRESSMAX);
4825 SET_EXPECT(Exec_SETPROGRESSPOS);
4826 SET_EXPECT(Invoke_AMBIENT_USERMODE);
4827 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4828 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4829 SET_EXPECT(Invoke_AMBIENT_SILENT);
4830 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
4831 SET_EXPECT(Invoke_AMBIENT_PALETTE);
4832 SET_EXPECT(GetTravelLog);
4834 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
4835 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4837 if(expect_uihandler_iface)
4838 CHECK_CALLED(GetHostInfo);
4839 if(flags & CLIENTSITE_EXPECTPATH) {
4840 CHECK_CALLED(GetOptionKeyPath);
4841 CHECK_CALLED(GetOverrideKeyPath);
4843 CHECK_CALLED(GetWindow);
4844 if(flags & CLIENTSITE_EXPECTPATH)
4845 CHECK_CALLED(Exec_DOCCANNAVIGATE);
4846 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
4847 CHECK_CALLED(Exec_SETPROGRESSMAX);
4848 CHECK_CALLED(Exec_SETPROGRESSPOS);
4849 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4850 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4851 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4852 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4853 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4854 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4855 todo_wine CHECK_CALLED(GetTravelLog);
4857 set_clientsite = TRUE;
4860 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
4861 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
4863 hres = IOleObject_GetClientSite(oleobj, &clientsite);
4864 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
4865 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
4868 static void test_OnAmbientPropertyChange(IHTMLDocument2 *doc)
4870 IOleControl *control = NULL;
4873 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
4874 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
4878 SET_EXPECT(Invoke_AMBIENT_USERMODE);
4879 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
4880 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4881 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
4883 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4884 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
4885 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4886 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4888 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4889 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4890 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
4891 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4892 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4893 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
4895 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
4896 SET_EXPECT(Invoke_AMBIENT_SILENT);
4897 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
4898 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4899 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
4900 CHECK_CALLED(Invoke_AMBIENT_SILENT);
4902 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
4903 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
4904 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4905 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
4907 SET_EXPECT(Invoke_AMBIENT_PALETTE);
4908 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
4909 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
4910 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
4912 IOleControl_Release(control);
4917 static void test_OnAmbientPropertyChange2(IHTMLDocument2 *doc)
4919 IOleControl *control = NULL;
4922 hres = IUnknown_QueryInterface(doc, &IID_IOleControl, (void**)&control);
4923 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
4927 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
4928 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
4930 IOleControl_Release(control);
4933 static void test_Close(IHTMLDocument2 *doc, BOOL set_client)
4935 IOleObject *oleobj = NULL;
4938 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4939 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4943 SET_EXPECT(GetContainer);
4944 SET_EXPECT(LockContainer);
4945 expect_LockContainer_fLock = FALSE;
4946 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
4947 ok(hres == S_OK, "Close failed: %08x\n", hres);
4948 CHECK_CALLED(GetContainer);
4949 CHECK_CALLED(LockContainer);
4950 container_locked = FALSE;
4953 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
4955 IOleObject_Release(oleobj);
4958 static void test_Advise(IHTMLDocument2 *doc)
4960 IOleObject *oleobj = NULL;
4961 IEnumSTATDATA *enum_advise = (void*)0xdeadbeef;
4965 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
4966 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
4970 hres = IOleObject_Unadvise(oleobj, 0);
4971 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
4973 hres = IOleObject_EnumAdvise(oleobj, &enum_advise);
4974 ok(hres == S_OK, "EnumAdvise returned: %08x\n", hres);
4975 ok(enum_advise == NULL, "enum_advise != NULL\n");
4978 hres = IOleObject_Advise(oleobj, NULL, &conn);
4979 /* Old IE returns S_OK and sets conn to 1 */
4980 ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08x\n", hres);
4981 ok(conn == 0 || conn == 1, "conn = %d\n", conn);
4983 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL);
4984 ok(hres == E_INVALIDARG, "Advise returned: %08x\n", hres);
4986 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4987 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4988 ok(conn == 1, "conn = %d\n", conn);
4990 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
4991 ok(hres == S_OK, "Advise returned: %08x\n", hres);
4992 ok(conn == 2, "conn = %d\n", conn);
4994 hres = IOleObject_Unadvise(oleobj, 1);
4995 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
4997 hres = IOleObject_Unadvise(oleobj, 1);
4998 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08x\n", hres);
5000 hres = IOleObject_Unadvise(oleobj, 2);
5001 ok(hres == S_OK, "Unadvise returned: %08x\n", hres);
5003 IOleObject_Release(oleobj);
5006 static void test_OnFrameWindowActivate(IUnknown *unk)
5008 IOleInPlaceActiveObject *inplaceact;
5011 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
5012 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
5016 if(set_clientsite) {
5017 expect_OnFrameWindowActivate_fActivate = TRUE;
5018 SET_EXPECT(OnFrameWindowActivate);
5019 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
5020 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
5021 CHECK_CALLED(OnFrameWindowActivate);
5023 SET_EXPECT(OnFrameWindowActivate);
5024 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
5025 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
5026 CHECK_CALLED(OnFrameWindowActivate);
5028 expect_OnFrameWindowActivate_fActivate = FALSE;
5029 SET_EXPECT(OnFrameWindowActivate);
5030 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
5031 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
5032 CHECK_CALLED(OnFrameWindowActivate);
5034 expect_OnFrameWindowActivate_fActivate = TRUE;
5035 SET_EXPECT(OnFrameWindowActivate);
5036 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
5037 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
5038 CHECK_CALLED(OnFrameWindowActivate);
5040 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
5041 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
5043 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
5044 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
5047 IOleInPlaceActiveObject_Release(inplaceact);
5050 static void test_InPlaceDeactivate(IHTMLDocument2 *doc, BOOL expect_call)
5052 IOleInPlaceObjectWindowless *windowlessobj = NULL;
5055 hres = IUnknown_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless,
5056 (void**)&windowlessobj);
5057 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
5062 SET_EXPECT(OnFocus_FALSE);
5064 SET_EXPECT(OnInPlaceDeactivateEx);
5066 SET_EXPECT(OnInPlaceDeactivate);
5068 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
5069 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
5071 CHECK_CALLED(OnFocus_FALSE);
5073 CHECK_CALLED(OnInPlaceDeactivateEx);
5075 CHECK_CALLED(OnInPlaceDeactivate);
5078 IOleInPlaceObjectWindowless_Release(windowlessobj);
5081 static void test_Activate(IHTMLDocument2 *doc, DWORD flags)
5083 IOleObject *oleobj = NULL;
5084 IOleDocumentView *docview;
5091 IOleDocumentView_Release(view);
5094 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5095 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
5097 hres = IOleObject_GetUserClassID(oleobj, NULL);
5098 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
5100 hres = IOleObject_GetUserClassID(oleobj, &guid);
5101 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
5102 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
5104 test_OnFrameWindowActivate((IUnknown*)doc);
5106 test_ClientSite(oleobj, flags);
5107 test_InPlaceDeactivate(doc, FALSE);
5108 test_DoVerb(oleobj);
5110 if(call_UIActivate == CallUIActivate_AfterShow) {
5111 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
5112 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
5114 SET_EXPECT(OnFocus_TRUE);
5115 SET_EXPECT(SetActiveObject);
5117 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5118 SET_EXPECT(InPlaceFrame_SetBorderSpace);
5119 expect_status_text = NULL;
5121 hres = IOleDocumentView_UIActivate(docview, TRUE);
5122 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
5124 CHECK_CALLED(OnFocus_TRUE);
5125 CHECK_CALLED(SetActiveObject);
5126 CHECK_CALLED(ShowUI);
5127 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5128 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
5130 IOleDocumentView_Release(docview);
5133 IOleObject_Release(oleobj);
5135 test_OnFrameWindowActivate((IUnknown*)doc);
5138 static void test_Window(IHTMLDocument2 *doc, BOOL expect_success)
5140 IOleInPlaceActiveObject *activeobject = NULL;
5144 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
5145 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
5149 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
5151 if(expect_success) {
5152 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
5153 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
5155 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
5156 ok(IsWindow(hwnd), "hwnd is destroyed\n");
5159 IOleInPlaceActiveObject_Release(activeobject);
5162 static void test_CloseView(void)
5164 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
5170 hres = IOleDocumentView_Show(view, FALSE);
5171 ok(hres == S_OK, "Show failed: %08x\n", hres);
5173 hres = IOleDocumentView_CloseView(view, 0);
5174 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
5176 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
5177 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
5179 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
5180 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
5181 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
5184 static void test_UIDeactivate(void)
5188 if(call_UIActivate == CallUIActivate_AfterShow) {
5189 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5191 if(call_UIActivate != CallUIActivate_None) {
5192 SET_EXPECT(SetActiveObject_null);
5194 SET_EXPECT(OnUIDeactivate);
5197 hres = IOleDocumentView_UIActivate(view, FALSE);
5198 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
5200 if(call_UIActivate != CallUIActivate_None) {
5201 CHECK_CALLED(SetActiveObject_null);
5202 CHECK_CALLED(HideUI);
5203 CHECK_CALLED(OnUIDeactivate);
5205 if(call_UIActivate == CallUIActivate_AfterShow) {
5206 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5210 static void test_Hide(void)
5217 hres = IOleDocumentView_Show(view, FALSE);
5218 ok(hres == S_OK, "Show failed: %08x\n", hres);
5221 static IHTMLDocument2 *create_document(void)
5223 IHTMLDocument2 *doc;
5226 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
5227 &IID_IHTMLDocument2, (void**)&doc);
5228 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
5235 static void release_document(IHTMLDocument2 *doc)
5241 /* Some broken IEs don't like if the last released reference is IHTMLDocument2 iface.
5242 * To workaround it, we release it via IUnknown iface */
5243 hres = IHTMLDocument2_QueryInterface(doc, &IID_IUnknown, (void**)&unk);
5244 ok(hres == S_OK, "Could not get IUnknown iface: %08x\n", hres);
5246 IHTMLDocument2_Release(doc);
5247 ref = IUnknown_Release(unk);
5248 ok(!ref, "ref = %d\n", ref);
5251 static void test_Navigate(IHTMLDocument2 *doc)
5253 IHlinkTarget *hlink;
5256 hres = IUnknown_QueryInterface(doc, &IID_IHlinkTarget, (void**)&hlink);
5257 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
5259 SET_EXPECT(ActivateMe);
5260 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
5261 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
5262 CHECK_CALLED(ActivateMe);
5264 IHlinkTarget_Release(hlink);
5267 static void test_external(IHTMLDocument2 *doc, BOOL initialized)
5269 IDispatch *external;
5270 IHTMLWindow2 *htmlwin;
5273 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
5274 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5277 SET_EXPECT(GetExternal);
5278 external = (void*)0xdeadbeef;
5279 hres = IHTMLWindow2_get_external(htmlwin, &external);
5281 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
5282 CHECK_CALLED(GetExternal);
5283 ok(external != NULL, "external == NULL\n");
5285 ok(hres == S_OK, "get_external failed: %08x\n", hres);
5286 ok(external == NULL, "external != NULL\n");
5289 IHTMLWindow2_Release(htmlwin);
5292 static void test_StreamLoad(IHTMLDocument2 *doc)
5294 IPersistStreamInit *init;
5297 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5298 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
5302 SET_EXPECT(Invoke_AMBIENT_SILENT);
5303 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5304 SET_EXPECT(Exec_ShellDocView_37);
5305 SET_EXPECT(OnChanged_READYSTATE);
5306 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
5308 SET_EXPECT(GetPendingUrl);
5309 readystate_set_loading = TRUE;
5311 hres = IPersistStreamInit_Load(init, &Stream);
5312 ok(hres == S_OK, "Load failed: %08x\n", hres);
5314 CHECK_CALLED(Invoke_AMBIENT_SILENT);
5315 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5316 CHECK_CALLED(Exec_ShellDocView_37);
5317 CHECK_CALLED(OnChanged_READYSTATE);
5318 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
5320 todo_wine CHECK_CALLED(GetPendingUrl);
5322 test_timer(EXPECT_SETTITLE);
5323 test_GetCurMoniker((IUnknown*)doc, NULL, "about:blank");
5325 IPersistStreamInit_Release(init);
5328 static void test_StreamInitNew(IHTMLDocument2 *doc)
5330 IPersistStreamInit *init;
5333 hres = IUnknown_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
5334 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
5338 SET_EXPECT(Invoke_AMBIENT_SILENT);
5339 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5340 SET_EXPECT(Exec_ShellDocView_37);
5341 SET_EXPECT(OnChanged_READYSTATE);
5342 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
5343 SET_EXPECT(GetPendingUrl);
5344 readystate_set_loading = TRUE;
5346 hres = IPersistStreamInit_InitNew(init);
5347 ok(hres == S_OK, "Load failed: %08x\n", hres);
5349 CHECK_CALLED(Invoke_AMBIENT_SILENT);
5350 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5351 CHECK_CALLED(Exec_ShellDocView_37);
5352 CHECK_CALLED(OnChanged_READYSTATE);
5353 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
5354 todo_wine CHECK_CALLED(GetPendingUrl);
5356 test_timer(EXPECT_SETTITLE);
5357 test_GetCurMoniker((IUnknown*)doc, NULL, "about:blank");
5359 IPersistStreamInit_Release(init);
5362 static void test_QueryInterface(IHTMLDocument2 *doc)
5367 static const IID IID_UndocumentedScriptIface =
5368 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
5370 qi = (void*)0xdeadbeef;
5371 hres = IUnknown_QueryInterface(doc, &IID_IRunnableObject, (void**)&qi);
5372 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5373 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
5375 qi = (void*)0xdeadbeef;
5376 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode, (void**)&qi);
5377 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5378 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5380 qi = (void*)0xdeadbeef;
5381 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode2, (void**)&qi);
5382 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5383 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5385 qi = (void*)0xdeadbeef;
5386 hres = IUnknown_QueryInterface(doc, &IID_IPersistPropertyBag, (void**)&qi);
5387 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5388 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5390 qi = (void*)0xdeadbeef;
5391 hres = IUnknown_QueryInterface(doc, &IID_UndocumentedScriptIface, (void**)&qi);
5392 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5393 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5395 qi = (void*)0xdeadbeef;
5396 hres = IUnknown_QueryInterface(doc, &IID_IMarshal, (void**)&qi);
5397 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5398 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5400 qi = (void*)0xdeadbeef;
5401 hres = IUnknown_QueryInterface(doc, &IID_IExternalConnection, (void**)&qi);
5402 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5403 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5405 qi = (void*)0xdeadbeef;
5406 hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi);
5407 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
5408 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
5410 hres = IUnknown_QueryInterface(doc, &IID_IDispatch, (void**)&qi);
5411 ok(hres == S_OK, "Could not get IDispatch interface: %08x\n", hres);
5412 ok(qi != (IUnknown*)doc, "disp == doc\n");
5413 IUnknown_Release(qi);
5416 static void init_test(enum load_state_t ls) {
5418 hwnd = last_hwnd = NULL;
5419 set_clientsite = FALSE;
5420 load_from_stream = FALSE;
5421 call_UIActivate = CallUIActivate_None;
5428 inplace_deactivated = FALSE;
5430 expect_uihandler_iface = &DocHostUIHandler;
5433 static void test_HTMLDocument(BOOL do_load)
5435 IHTMLDocument2 *doc;
5437 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
5439 init_test(do_load ? LD_DOLOAD : LD_NO);
5441 doc = create_document();
5442 doc_unk = (IUnknown*)doc;
5444 test_QueryInterface(doc);
5446 test_IsDirty(doc, S_FALSE);
5447 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5448 test_external(doc, FALSE);
5449 test_ViewAdviseSink(doc);
5450 test_ConnectionPointContainer(doc);
5451 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
5452 test_Persist(doc, &Moniker);
5454 test_OnAmbientPropertyChange2(doc);
5456 test_Activate(doc, CLIENTSITE_EXPECTPATH);
5459 set_custom_uihandler(doc, &CustomDocHostUIHandler);
5460 test_download(DWL_CSS|DWL_TRYCSS);
5461 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
5464 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5465 test_OleCommandTarget_fail(doc);
5466 test_OleCommandTarget(doc);
5467 test_OnAmbientPropertyChange(doc);
5468 test_Window(doc, TRUE);
5469 test_external(doc, TRUE);
5471 test_UIDeactivate();
5472 test_OleCommandTarget(doc);
5473 test_Window(doc, TRUE);
5474 test_InPlaceDeactivate(doc, TRUE);
5476 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
5477 * MSHTML. It doesn't with Wine. */
5479 test_Window(doc, FALSE);
5481 test_InPlaceDeactivate(doc, FALSE);
5483 test_Close(doc, FALSE);
5485 /* Activate HTMLDocument again */
5486 test_Activate(doc, CLIENTSITE_SETNULL);
5487 test_Window(doc, TRUE);
5488 test_OleCommandTarget(doc);
5489 test_UIDeactivate();
5490 test_InPlaceDeactivate(doc, TRUE);
5491 test_Close(doc, FALSE);
5493 /* Activate HTMLDocument again, this time without UIActivate */
5494 call_UIActivate = CallUIActivate_None;
5495 test_Activate(doc, CLIENTSITE_SETNULL);
5496 test_Window(doc, TRUE);
5498 test_external(doc, TRUE);
5499 set_custom_uihandler(doc, NULL);
5500 test_external(doc, FALSE);
5502 test_UIDeactivate();
5503 test_InPlaceDeactivate(doc, TRUE);
5506 test_Close(doc, TRUE);
5507 test_OnAmbientPropertyChange2(doc);
5508 test_GetCurMoniker((IUnknown*)doc, do_load ? &Moniker : NULL, NULL);
5511 /* Activate HTMLDocument again, calling UIActivate after showing the window */
5512 call_UIActivate = CallUIActivate_AfterShow;
5513 test_Activate(doc, 0);
5514 test_Window(doc, TRUE);
5515 test_OleCommandTarget(doc);
5516 test_UIDeactivate();
5517 test_InPlaceDeactivate(doc, TRUE);
5518 test_Close(doc, FALSE);
5519 call_UIActivate = CallUIActivate_None;
5523 IOleDocumentView_Release(view);
5526 ok(IsWindow(hwnd), "hwnd is destroyed\n");
5527 release_document(doc);
5528 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
5531 static void test_HTMLDocument_hlink(DWORD status)
5533 IHTMLDocument2 *doc;
5535 trace("Testing HTMLDocument (hlink)...\n");
5537 init_test(LD_DOLOAD);
5540 doc = create_document();
5541 doc_unk = (IUnknown*)doc;
5543 set_custom_uihandler(doc, &CustomDocHostUIHandler);
5544 test_ViewAdviseSink(doc);
5545 test_ConnectionPointContainer(doc);
5546 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
5547 test_Persist(doc, &Moniker);
5550 status_code = status;
5551 test_download(DWL_CSS|DWL_TRYCSS);
5552 status_code = HTTP_STATUS_OK;
5554 test_IsDirty(doc, S_FALSE);
5555 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5557 test_exec_onunload(doc);
5558 test_Window(doc, TRUE);
5559 test_InPlaceDeactivate(doc, TRUE);
5560 test_Close(doc, FALSE);
5561 test_IsDirty(doc, S_FALSE);
5562 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
5564 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL);
5567 IOleDocumentView_Release(view);
5570 release_document(doc);
5573 static void test_cookies(IHTMLDocument2 *doc)
5581 hres = IHTMLDocument2_get_cookie(doc, &str);
5582 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
5584 size = sizeof(buf)/sizeof(WCHAR);
5585 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
5586 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
5587 ok(!lstrcmpW(buf, str), "cookie = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(buf));
5591 str = a2bstr("test=testval");
5592 hres = IHTMLDocument2_put_cookie(doc, str);
5593 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
5596 hres = IHTMLDocument2_get_cookie(doc, &str2);
5597 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
5598 ok(str2 != NULL, "cookie = NULL\n");
5599 size = sizeof(buf)/sizeof(WCHAR);
5600 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
5601 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
5602 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
5603 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
5605 SysFreeString(str2);
5607 str = a2bstr("test=testval2");
5608 hres = IHTMLDocument2_put_cookie(doc, str);
5609 ok(hres == S_OK, "put_cookie failed: %08x\n", hres);
5612 hres = IHTMLDocument2_get_cookie(doc, &str2);
5613 ok(hres == S_OK, "get_cookie failed: %08x\n", hres);
5614 ok(str2 != NULL, "cookie = NULL\n");
5615 size = sizeof(buf)/sizeof(WCHAR);
5616 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
5617 ok(b, "InternetGetCookieW failed: %08x\n", GetLastError());
5618 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
5619 ok(strstrW(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
5621 SysFreeString(str2);
5624 static void test_HTMLDocument_http(void)
5627 IHTMLDocument2 *doc;
5631 trace("Testing HTMLDocument (http)...\n");
5633 if(!winetest_interactive && is_ie_hardened()) {
5634 win_skip("IE running in Enhanced Security Configuration\n");
5638 init_test(LD_DOLOAD);
5641 doc = create_document();
5642 doc_unk = (IUnknown*)doc;
5644 hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
5645 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
5647 test_ViewAdviseSink(doc);
5648 test_ConnectionPointContainer(doc);
5649 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
5650 test_Persist(doc, http_mon);
5652 test_download(DWL_HTTP);
5654 test_IsDirty(doc, S_FALSE);
5655 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5656 test_GetCurMoniker((IUnknown*)doc, http_mon, NULL);
5658 test_put_href(doc, FALSE);
5659 test_put_href(doc, TRUE);
5660 test_open_window(doc);
5662 test_InPlaceDeactivate(doc, TRUE);
5663 test_Close(doc, FALSE);
5664 test_IsDirty(doc, S_FALSE);
5665 test_GetCurMoniker((IUnknown*)doc, NULL, "about:replace");
5668 IOleDocumentView_Release(view);
5671 release_document(doc);
5673 ref = IMoniker_Release(http_mon);
5674 ok(!ref, "ref=%d, expected 0\n", ref);
5677 static void test_QueryService(IHTMLDocument2 *doc, BOOL success)
5679 IHTMLWindow2 *window, *sp_window;
5680 IServiceProvider *sp;
5684 hres = IUnknown_QueryInterface(doc, &IID_IServiceProvider, (void**)&sp);
5685 ok(hres == S_OK, "QueryService returned %08x\n", hres);
5687 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
5689 ok(hres == E_NOINTERFACE, "QueryService returned %08x, expected E_NOINTERFACE\n", hres);
5690 IServiceProvider_Release(sp);
5694 ok(hres == S_OK, "QueryService(IID_IHlinkFrame) failed: %08x\n", hres);
5695 ok(hf == &HlinkFrame, "hf != HlinkFrame\n");
5696 IHlinkFrame_Release(hf);
5698 IServiceProvider_Release(sp);
5700 hres = IHTMLDocument2_get_parentWindow(doc, &window);
5701 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
5703 hres = IHTMLWindow2_QueryInterface(window, &IID_IServiceProvider, (void**)&sp);
5704 ok(hres == S_OK, "Could not get IServiceProvider iface: %08x\n", hres);
5706 hres = IServiceProvider_QueryService(sp, &IID_IHTMLWindow2, &IID_IHTMLWindow2, (void**)&sp_window);
5707 ok(hres == S_OK, "QueryService(IID_IHTMLWindow2) failed: %08x\n", hres);
5708 /* FIXME: test returned window */
5709 IHTMLWindow2_Release(sp_window);
5711 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
5712 ok(hres == S_OK, "QueryService(IID_IHlinkFrame) failed: %08x\n", hres);
5713 ok(hf == &HlinkFrame, "hf != HlinkFrame\n");
5714 IHlinkFrame_Release(hf);
5716 IServiceProvider_Release(sp);
5717 IHTMLWindow2_Release(window);
5720 static void test_HTMLDocument_StreamLoad(void)
5722 IHTMLDocument2 *doc;
5727 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
5729 init_test(LD_DOLOAD);
5730 load_from_stream = TRUE;
5732 doc = create_document();
5733 doc_unk = (IUnknown*)doc;
5735 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5736 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
5738 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
5739 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5741 test_readyState((IUnknown*)doc);
5742 test_IsDirty(doc, S_FALSE);
5743 test_ViewAdviseSink(doc);
5744 test_ConnectionPointContainer(doc);
5745 test_QueryService(doc, FALSE);
5746 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
5747 test_QueryService(doc, TRUE);
5748 test_DoVerb(oleobj);
5749 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5751 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
5752 test_StreamLoad(doc);
5753 test_download(DWL_VERBDONE|DWL_TRYCSS);
5754 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5756 test_UIDeactivate();
5757 test_InPlaceDeactivate(doc, TRUE);
5758 SET_EXPECT(Advise_Close);
5759 test_Close(doc, TRUE);
5760 CHECK_CALLED(Advise_Close);
5761 test_external(doc, FALSE);
5762 test_IsDirty(doc, S_FALSE);
5764 set_custom_uihandler(doc, &CustomDocHostUIHandler);
5765 test_ClientSite(oleobj, CLIENTSITE_SETNULL);
5766 test_external(doc, TRUE);
5767 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
5768 test_external(doc, TRUE);
5769 set_custom_uihandler(doc, NULL);
5770 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
5772 IOleObject_Release(oleobj);
5774 IOleDocumentView_Release(view);
5778 release_document(doc);
5781 static void test_HTMLDocument_StreamInitNew(void)
5783 IHTMLDocument2 *doc;
5788 trace("Testing HTMLDocument (IPersistStreamInit::InitNew)...\n");
5790 init_test(LD_DOLOAD);
5791 load_from_stream = TRUE;
5793 doc = create_document();
5794 doc_unk = (IUnknown*)doc;
5796 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5797 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
5799 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
5800 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5802 test_readyState((IUnknown*)doc);
5803 test_IsDirty(doc, S_FALSE);
5804 test_ViewAdviseSink(doc);
5805 test_ConnectionPointContainer(doc);
5806 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
5807 test_DoVerb(oleobj);
5808 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5810 IOleObject_Release(oleobj);
5812 test_GetCurMoniker((IUnknown*)doc, NULL, NULL);
5813 test_StreamInitNew(doc);
5815 SET_EXPECT(Invoke_OnReadyStateChange_Interactive);
5816 test_download(DWL_VERBDONE|DWL_TRYCSS|DWL_EMPTY);
5817 todo_wine CHECK_NOT_CALLED(Invoke_OnReadyStateChange_Interactive);
5819 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5821 test_UIDeactivate();
5822 test_InPlaceDeactivate(doc, TRUE);
5823 SET_EXPECT(Advise_Close);
5824 test_Close(doc, FALSE);
5825 CHECK_CALLED(Advise_Close);
5826 test_IsDirty(doc, S_FALSE);
5829 IOleDocumentView_Release(view);
5833 release_document(doc);
5836 static void test_edit_uiactivate(IOleObject *oleobj)
5838 IOleDocumentView *docview;
5841 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
5842 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
5844 SET_EXPECT(OnFocus_TRUE);
5845 SET_EXPECT(SetActiveObject);
5847 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
5848 SET_EXPECT(InPlaceFrame_SetBorderSpace);
5849 expect_status_text = NULL;
5851 hres = IOleDocumentView_UIActivate(docview, TRUE);
5852 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
5854 CHECK_CALLED(OnFocus_TRUE);
5855 CHECK_CALLED(SetActiveObject);
5856 CHECK_CALLED(ShowUI);
5857 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
5858 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
5860 IOleDocumentView_Release(docview);
5863 static void test_editing_mode(BOOL do_load)
5865 IHTMLDocument2 *doc;
5871 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
5873 init_test(do_load ? LD_DOLOAD : LD_NO);
5874 call_UIActivate = CallUIActivate_AfterShow;
5876 doc = create_document();
5877 unk = doc_unk = (IUnknown*)doc;
5879 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5880 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
5882 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
5883 ok(hres == S_OK, "Advise failed: %08x\n", hres);
5885 test_readyState((IUnknown*)doc);
5886 test_ViewAdviseSink(doc);
5887 test_ConnectionPointContainer(doc);
5888 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
5889 test_DoVerb(oleobj);
5890 test_edit_uiactivate(oleobj);
5892 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5894 test_Persist(doc, &Moniker);
5895 stream_read = protocol_read = 0;
5896 test_exec_editmode(unk, do_load);
5897 test_UIDeactivate();
5898 call_UIActivate = CallUIActivate_None;
5899 IOleObject_Release(oleobj);
5901 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
5902 test_download(DWL_VERBDONE | (do_load ? DWL_CSS|DWL_TRYCSS : 0));
5904 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
5905 test_timer(EXPECT_UPDATEUI);
5906 SET_CALLED(SetStatusText);
5908 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
5911 test_exec_fontname(unk, NULL, wszTimesNewRoman);
5912 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
5913 test_timer(EXPECT_UPDATEUI);
5914 test_exec_fontname(unk, NULL, wszArial);
5916 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
5917 test_timer(EXPECT_UPDATEUI);
5918 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
5919 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
5921 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
5922 test_timer(EXPECT_UPDATEUI);
5923 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
5924 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
5925 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
5926 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
5928 test_exec_noargs(unk, IDM_HORIZONTALLINE);
5929 test_timer(EXPECT_UPDATEUI);
5930 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
5931 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
5934 test_UIDeactivate();
5935 test_InPlaceDeactivate(doc, TRUE);
5936 SET_EXPECT(Advise_Close);
5937 test_Close(doc, FALSE);
5938 CHECK_CALLED(Advise_Close);
5941 IOleDocumentView_Release(view);
5945 release_document(doc);
5948 static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw)
5950 IHTMLDocument2 *doc;
5952 IOleInPlaceSite *inplacesite;
5955 trace("Running OleDocumentView_UIActivate tests (%d %d %d)\n", do_load, use_ipsex, use_ipsw);
5957 init_test(do_load ? LD_DOLOAD : LD_NO);
5959 doc = create_document();
5960 doc_unk = (IUnknown*)doc;
5965 hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
5966 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
5968 hres = IUnknown_QueryInterface(doc, &IID_IOleDocumentView, (void**)&view);
5969 ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08x\n", hres);
5971 SET_EXPECT(Invoke_AMBIENT_USERMODE);
5972 SET_EXPECT(GetHostInfo);
5973 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
5974 SET_EXPECT(Invoke_AMBIENT_SILENT);
5975 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5976 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
5977 SET_EXPECT(Invoke_AMBIENT_PALETTE);
5978 SET_EXPECT(GetOptionKeyPath);
5979 SET_EXPECT(GetOverrideKeyPath);
5980 SET_EXPECT(GetWindow);
5981 SET_EXPECT(Exec_DOCCANNAVIGATE);
5982 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
5983 SET_EXPECT(Exec_SETPROGRESSMAX);
5984 SET_EXPECT(Exec_SETPROGRESSPOS);
5985 SET_EXPECT(GetTravelLog);
5987 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
5988 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
5989 set_clientsite = TRUE;
5991 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
5992 CHECK_CALLED(GetHostInfo);
5993 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
5994 CHECK_CALLED(Invoke_AMBIENT_SILENT);
5995 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5996 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
5997 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
5998 CHECK_CALLED(GetOptionKeyPath);
5999 CHECK_CALLED(GetOverrideKeyPath);
6000 CHECK_CALLED(GetWindow);
6001 CHECK_CALLED(Exec_DOCCANNAVIGATE);
6002 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
6003 CHECK_CALLED(Exec_SETPROGRESSMAX);
6004 CHECK_CALLED(Exec_SETPROGRESSPOS);
6005 todo_wine CHECK_CALLED(GetTravelLog);
6007 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
6008 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
6009 ok(inplacesite == NULL, "inplacesite = %p, expected NULL\n", inplacesite);
6011 SET_EXPECT(GetContainer);
6012 SET_EXPECT(LockContainer);
6013 SET_EXPECT(CanInPlaceActivate);
6014 SET_EXPECT(GetWindowContext);
6015 SET_EXPECT(GetWindow);
6017 SET_EXPECT(OnInPlaceActivateEx);
6018 SET_EXPECT(RequestUIActivate);
6021 SET_EXPECT(OnInPlaceActivate);
6022 SET_EXPECT(OnUIActivate);
6023 SET_EXPECT(SetStatusText);
6024 SET_EXPECT(Exec_SETPROGRESSMAX);
6025 SET_EXPECT(Exec_SETPROGRESSPOS);
6027 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
6028 SET_EXPECT(InPlaceFrame_SetBorderSpace);
6029 SET_EXPECT(OnFocus_TRUE);
6030 SET_EXPECT(SetActiveObject);
6031 expect_LockContainer_fLock = TRUE;
6033 hres = IOleDocumentView_UIActivate(view, TRUE);
6034 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
6036 CHECK_CALLED(GetContainer);
6037 CHECK_CALLED(LockContainer);
6038 CHECK_CALLED(CanInPlaceActivate);
6039 CHECK_CALLED(GetWindowContext);
6040 CHECK_CALLED(GetWindow);
6042 CHECK_CALLED(OnInPlaceActivateEx);
6043 SET_EXPECT(RequestUIActivate);
6046 CHECK_CALLED(OnInPlaceActivate);
6047 CHECK_CALLED(OnUIActivate);
6048 CHECK_CALLED(SetStatusText);
6049 CHECK_CALLED(Exec_SETPROGRESSMAX);
6050 CHECK_CALLED(Exec_SETPROGRESSPOS);
6051 CHECK_CALLED(ShowUI);
6052 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
6053 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
6054 CHECK_CALLED(OnFocus_TRUE);
6055 CHECK_CALLED(SetActiveObject);
6056 container_locked = TRUE;
6058 SET_EXPECT(SetActiveObject_null);
6059 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
6061 SET_EXPECT(OnUIDeactivate);
6063 hres = IOleDocumentView_UIActivate(view, FALSE);
6064 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
6066 CHECK_CALLED(SetActiveObject_null);
6067 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
6068 CHECK_CALLED(HideUI);
6069 CHECK_CALLED(OnUIDeactivate);
6071 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
6072 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
6073 ok(inplacesite != NULL, "inplacesite = NULL\n");
6074 IOleInPlaceSite_Release(inplacesite);
6076 SET_EXPECT(OnFocus_FALSE);
6078 SET_EXPECT(OnInPlaceDeactivateEx);
6080 SET_EXPECT(OnInPlaceDeactivate);
6084 CHECK_CALLED(OnFocus_FALSE);
6086 CHECK_CALLED(OnInPlaceDeactivateEx);
6088 CHECK_CALLED(OnInPlaceDeactivate);
6090 test_Close(doc, TRUE);
6092 IOleObject_Release(oleobj);
6093 IOleDocumentView_Release(view);
6096 release_document(doc);
6099 static void register_protocol(void)
6101 IInternetSession *session;
6104 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
6106 hres = CoInternetGetSession(0, &session, 0);
6107 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
6109 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
6110 wsz_winetest, 0, NULL, 0);
6111 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
6113 IInternetSession_Release(session);
6116 static void test_HTMLDoc_ISupportErrorInfo(void)
6118 IHTMLDocument2 *doc;
6120 ISupportErrorInfo *sinfo;
6122 doc = create_document();
6124 hres = IUnknown_QueryInterface(doc, &IID_ISupportErrorInfo, (void**)&sinfo);
6125 ok(hres == S_OK, "got %x\n", hres);
6126 ok(sinfo != NULL, "got %p\n", sinfo);
6129 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
6130 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
6131 IUnknown_Release(sinfo);
6134 release_document(doc);
6137 static void test_IPersistHistory(void)
6139 IHTMLDocument2 *doc;
6141 IPersistHistory *phist;
6143 doc = create_document();
6145 hres = IUnknown_QueryInterface(doc, &IID_IPersistHistory, (void**)&phist);
6146 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
6148 IPersistHistory_Release(phist);
6150 release_document(doc);
6153 static BOOL check_ie(void)
6155 IHTMLDocument2 *doc;
6156 IHTMLDocument5 *doc5;
6159 doc = create_document();
6163 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
6165 IHTMLDocument5_Release(doc5);
6167 release_document(doc);
6168 return SUCCEEDED(hres);
6177 win_skip("Too old IE\n");
6181 container_hwnd = create_container_window();
6182 register_protocol();
6184 asynchronous_binding = TRUE;
6185 test_HTMLDocument_hlink(HTTP_STATUS_NOT_FOUND);
6187 asynchronous_binding = FALSE;
6188 test_HTMLDocument_hlink(HTTP_STATUS_OK);
6189 test_HTMLDocument(FALSE);
6190 test_HTMLDocument(TRUE);
6191 test_HTMLDocument_StreamLoad();
6192 test_HTMLDocument_StreamInitNew();
6193 test_editing_mode(FALSE);
6194 test_editing_mode(TRUE);
6195 test_HTMLDocument_http();
6196 test_UIActivate(FALSE, FALSE, FALSE);
6197 test_UIActivate(FALSE, TRUE, FALSE);
6198 test_UIActivate(FALSE, TRUE, TRUE);
6199 test_UIActivate(TRUE, FALSE, FALSE);
6200 test_UIActivate(TRUE, TRUE, FALSE);
6201 test_UIActivate(TRUE, TRUE, TRUE);
6202 test_HTMLDoc_ISupportErrorInfo();
6203 test_IPersistHistory();
6205 DestroyWindow(container_hwnd);