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>
41 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
42 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
43 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
45 #define DEFINE_EXPECT(func) \
46 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
48 #define SET_EXPECT(func) \
49 expect_ ## func = TRUE
51 #define SET_CALLED(func) \
52 called_ ## func = TRUE
54 #define CHECK_EXPECT2(func) \
56 ok(expect_ ##func, "unexpected call " #func "\n"); \
57 called_ ## func = TRUE; \
60 #define CHECK_EXPECT(func) \
62 CHECK_EXPECT2(func); \
63 expect_ ## func = FALSE; \
66 #define CHECK_CALLED(func) \
68 ok(called_ ## func, "expected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
72 static IOleDocumentView *view = NULL;
73 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
75 DEFINE_EXPECT(LockContainer);
76 DEFINE_EXPECT(SetActiveObject);
77 DEFINE_EXPECT(SetActiveObject_null);
78 DEFINE_EXPECT(GetWindow);
79 DEFINE_EXPECT(CanInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivate);
81 DEFINE_EXPECT(OnInPlaceActivateEx);
82 DEFINE_EXPECT(OnUIActivate);
83 DEFINE_EXPECT(GetWindowContext);
84 DEFINE_EXPECT(OnUIDeactivate);
85 DEFINE_EXPECT(OnInPlaceDeactivate);
86 DEFINE_EXPECT(OnInPlaceDeactivateEx);
87 DEFINE_EXPECT(GetContainer);
88 DEFINE_EXPECT(ShowUI);
89 DEFINE_EXPECT(ActivateMe);
90 DEFINE_EXPECT(GetHostInfo);
91 DEFINE_EXPECT(HideUI);
92 DEFINE_EXPECT(GetOptionKeyPath);
93 DEFINE_EXPECT(GetOverrideKeyPath);
94 DEFINE_EXPECT(SetStatusText);
95 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
96 DEFINE_EXPECT(QueryStatus_OPEN);
97 DEFINE_EXPECT(QueryStatus_NEW);
98 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
99 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
100 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
101 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
102 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
103 DEFINE_EXPECT(Exec_ShellDocView_37);
104 DEFINE_EXPECT(Exec_ShellDocView_84);
105 DEFINE_EXPECT(Exec_ShellDocView_103);
106 DEFINE_EXPECT(Exec_ShellDocView_105);
107 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
108 DEFINE_EXPECT(Exec_SETTITLE);
109 DEFINE_EXPECT(Exec_HTTPEQUIV);
110 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
111 DEFINE_EXPECT(Exec_Explorer_69);
112 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
113 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
114 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
115 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
116 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
117 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
118 DEFINE_EXPECT(GetDropTarget);
119 DEFINE_EXPECT(UpdateUI);
120 DEFINE_EXPECT(Navigate);
121 DEFINE_EXPECT(OnFrameWindowActivate);
122 DEFINE_EXPECT(OnChanged_READYSTATE);
123 DEFINE_EXPECT(OnChanged_1005);
124 DEFINE_EXPECT(OnChanged_1012);
125 DEFINE_EXPECT(GetDisplayName);
126 DEFINE_EXPECT(BindToStorage);
127 DEFINE_EXPECT(IsSystemMoniker);
128 DEFINE_EXPECT(GetBindResult);
129 DEFINE_EXPECT(GetClassID);
130 DEFINE_EXPECT(Abort);
132 DEFINE_EXPECT(CreateInstance);
133 DEFINE_EXPECT(Start);
134 DEFINE_EXPECT(Terminate);
135 DEFINE_EXPECT(Protocol_Read);
136 DEFINE_EXPECT(LockRequest);
137 DEFINE_EXPECT(UnlockRequest);
138 DEFINE_EXPECT(OnFocus_TRUE);
139 DEFINE_EXPECT(OnFocus_FALSE);
140 DEFINE_EXPECT(RequestUIActivate);
141 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
142 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
143 DEFINE_EXPECT(GetExternal);
144 DEFINE_EXPECT(EnableModeless_TRUE);
145 DEFINE_EXPECT(EnableModeless_FALSE);
146 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
147 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
148 DEFINE_EXPECT(Frame_GetWindow);
150 static IUnknown *doc_unk;
151 static IMoniker *doc_mon;
152 static BOOL expect_LockContainer_fLock;
153 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
155 static BOOL set_clientsite = FALSE, container_locked = FALSE;
156 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
157 static BOOL editmode = FALSE, show_failed;
158 static int stream_read, protocol_read;
159 static enum load_state_t {
168 static LPCOLESTR expect_status_text = NULL;
170 static const char html_page[] =
172 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
176 static const char css_data[] = "body {color: red}";
178 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
179 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
181 static HRESULT QueryInterface(REFIID riid, void **ppv);
182 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
183 static BOOL nogecko = FALSE;
185 #define test_readyState(u) _test_readyState(__LINE__,u)
186 static void _test_readyState(unsigned,IUnknown*);
188 static const WCHAR wszTimesNewRoman[] =
189 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
190 static const WCHAR wszArial[] =
191 {'A','r','i','a','l',0};
193 static const char *debugstr_guid(REFIID riid)
197 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
198 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
199 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
200 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
205 static BOOL is_english(void)
207 return PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
208 && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
211 #define EXPECT_UPDATEUI 1
212 #define EXPECT_SETTITLE 2
214 static void test_timer(DWORD flags)
216 BOOL *b = &called_Exec_SETTITLE;
219 if(flags & EXPECT_UPDATEUI) {
220 SET_EXPECT(UpdateUI);
221 SET_EXPECT(Exec_UPDATECOMMANDS);
222 b = &called_UpdateUI;
224 if(flags & EXPECT_SETTITLE)
225 SET_EXPECT(Exec_SETTITLE);
227 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
228 TranslateMessage(&msg);
229 DispatchMessage(&msg);
232 if(flags & EXPECT_UPDATEUI) {
233 CHECK_CALLED(UpdateUI);
234 CHECK_CALLED(Exec_UPDATECOMMANDS);
236 if(flags & EXPECT_SETTITLE)
237 CHECK_CALLED(Exec_SETTITLE);
240 static IMoniker Moniker;
242 #define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
243 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
246 IPersistMoniker *permon;
247 IMoniker *mon = (void*)0xdeadbeef;
248 BSTR doc_url = (void*)0xdeadbeef;
251 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
252 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
256 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
257 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
259 hres = IHTMLDocument2_get_URL(doc, &doc_url);
260 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
262 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
263 IPersistMoniker_Release(permon);
267 BOOL exb = expect_GetDisplayName;
268 BOOL clb = called_GetDisplayName;
270 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
271 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
274 SET_EXPECT(GetDisplayName);
275 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
276 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
278 CHECK_CALLED(GetDisplayName);
279 expect_GetDisplayName = exb;
280 called_GetDisplayName = clb;
282 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
287 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
289 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
290 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
292 ok(!lstrcmpW(url, exurl), "unexpected url\n");
293 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
297 ok(hres == E_UNEXPECTED,
298 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
299 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
300 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
303 SysFreeString(doc_url);
304 IHTMLDocument_Release(doc);
305 if(mon && mon != (void*)0xdeadbeef)
306 IMoniker_Release(mon);
309 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
311 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
315 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
320 if(IsEqualGUID(&IID_IProxyManager, riid))
321 return E_NOINTERFACE; /* TODO */
322 if(IsEqualGUID(&IID_IDispatchEx, riid))
323 return E_NOINTERFACE; /* TODO */
324 if(IsEqualGUID(&IID_External_unk, riid))
325 return E_NOINTERFACE; /* TODO */
327 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
328 return E_NOINTERFACE;
331 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
336 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
341 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
343 ok(0, "unexpected call\n");
347 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
350 ok(0, "unexpected call\n");
354 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
355 UINT cNames, LCID lcid, DISPID *rgDispId)
357 ok(0, "unexpected call\n");
361 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
362 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
363 EXCEPINFO *pExcepInfo, UINT *puArgErr)
365 ok(0, "unexpected call\n");
369 static const IDispatchVtbl ExternalVtbl = {
370 External_QueryInterface,
373 Dispatch_GetTypeInfoCount,
374 Dispatch_GetTypeInfo,
375 Dispatch_GetIDsOfNames,
379 static IDispatch External = { &ExternalVtbl };
381 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
383 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
389 return E_NOINTERFACE;
392 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
397 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
402 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
403 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
404 DWORD grfPI, HANDLE_PTR dwReserved)
410 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
411 static const WCHAR empty_str = {0};
415 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
416 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
417 ok(!grfPI, "grfPI = %x\n", grfPI);
418 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
420 memset(&bindinfo, 0, sizeof(bindinfo));
421 bindinfo.cbSize = sizeof(bindinfo);
422 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
423 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
424 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
425 "bindf = %x\n", bindf);
427 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
428 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
429 /* TODO: test stgmedData */
430 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
431 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
432 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
433 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
434 ok(bindinfo.dwOptions == 0x80000 ||
435 bindinfo.dwOptions == 0x4080000, /* win2k3 */
436 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
437 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
438 /* TODO: test dwCodePage */
439 /* TODO: test securityAttributes */
440 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
441 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
442 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
444 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
445 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
446 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
448 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
449 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
451 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
453 hres = IInternetProtocolSink_ReportData(pOIProtSink,
454 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
455 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
457 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
458 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
463 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
464 PROTOCOLDATA *pProtocolData)
466 ok(0, "unexpected call\n");
470 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
473 ok(0, "unexpected call\n");
477 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
479 CHECK_EXPECT(Terminate);
483 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
485 ok(0, "unexpected call\n");
489 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
491 ok(0, "unexpected call\n");
495 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
496 ULONG cb, ULONG *pcbRead)
498 CHECK_EXPECT2(Protocol_Read);
500 ok(pv != NULL, "pv == NULL\n");
501 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
502 ok(pcbRead != NULL, "pcbRead == NULL\n");
503 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
508 protocol_read += *pcbRead = sizeof(css_data)-1;
509 memcpy(pv, css_data, sizeof(css_data)-1);
513 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
514 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
516 ok(0, "unexpected call\n");
520 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
522 CHECK_EXPECT(LockRequest);
526 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
528 CHECK_EXPECT(UnlockRequest);
532 static const IInternetProtocolVtbl ProtocolVtbl = {
533 Protocol_QueryInterface,
544 Protocol_LockRequest,
545 Protocol_UnlockRequest
548 static IInternetProtocol Protocol = { &ProtocolVtbl };
550 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
552 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
553 ok(0, "unexpected call\n");
554 return E_NOINTERFACE;
557 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
562 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
567 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
568 REFIID riid, void **ppv)
570 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
571 return E_NOINTERFACE;
573 CHECK_EXPECT(CreateInstance);
574 ok(ppv != NULL, "ppv == NULL\n");
580 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
582 ok(0, "unexpected call\n");
586 static const IClassFactoryVtbl ClassFactoryVtbl = {
587 ClassFactory_QueryInterface,
589 ClassFactory_Release,
590 ClassFactory_CreateInstance,
591 ClassFactory_LockServer
594 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
596 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
598 ok(0, "unexpected call\n");
602 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
607 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
612 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
613 IHlinkBrowseContext *pihlbc)
615 ok(0, "unexpected call\n");
619 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
620 IHlinkBrowseContext **ppihlbc)
622 ok(0, "unexpected call\n");
626 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
627 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
631 CHECK_EXPECT(Navigate);
633 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
634 ok(pbc != NULL, "pbc == NULL\n");
635 ok(pibsc != NULL, "pubsc == NULL\n");
636 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
639 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
640 LPWSTR location = (LPWSTR)0xdeadbeef;
642 IMoniker *mon = NULL;
643 DWORD site_data = 0xdeadbeef;
645 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
646 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
647 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
649 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
650 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
651 ok(location == NULL, "location = %p\n", location);
652 ok(mon != NULL, "mon == NULL\n");
654 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
655 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
656 ok(site == NULL, "site = %p\n, expected NULL\n", site);
657 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
663 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
664 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
666 ok(0, "unexpected call\n");
670 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
671 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
673 ok(0, "unexpected call\n");
677 static const IHlinkFrameVtbl HlinkFrameVtbl = {
678 HlinkFrame_QueryInterface,
681 HlinkFrame_SetBrowseContext,
682 HlinkFrame_GetBrowseContext,
684 HlinkFrame_OnNavigate,
685 HlinkFrame_UpdateHlink
688 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
690 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
691 REFIID riid, void**ppv)
693 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
698 ok(0, "unexpected call\n");
699 return E_NOINTERFACE;
702 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
707 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
712 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
715 case DISPID_READYSTATE:
716 CHECK_EXPECT2(OnChanged_READYSTATE);
718 if(readystate_set_interactive) {
719 readystate_set_interactive = FALSE;
720 load_state = LD_INTERACTIVE;
723 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
724 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
725 ? OLECMDF_ENABLED : 0));
727 if(readystate_set_loading) {
728 readystate_set_loading = FALSE;
729 load_state = LD_LOADING;
731 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
732 test_readyState(NULL);
735 CHECK_EXPECT(OnChanged_1005);
737 test_readyState(NULL);
738 readystate_set_interactive = (load_state != LD_INTERACTIVE);
741 CHECK_EXPECT(OnChanged_1012);
749 ok(0, "unexpected id %d\n", dispID);
753 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
755 ok(0, "unexpected call\n");
759 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
760 PropertyNotifySink_QueryInterface,
761 PropertyNotifySink_AddRef,
762 PropertyNotifySink_Release,
763 PropertyNotifySink_OnChanged,
764 PropertyNotifySink_OnRequestEdit
767 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
769 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
771 ok(0, "unexpected call\n");
772 return E_NOINTERFACE;
775 static ULONG WINAPI Stream_AddRef(IStream *iface)
780 static ULONG WINAPI Stream_Release(IStream *iface)
785 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
786 ULONG cb, ULONG *pcbRead)
789 ok(pv != NULL, "pv == NULL\n");
790 ok(cb > sizeof(html_page), "cb = %d\n", cb);
791 ok(pcbRead != NULL, "pcbRead == NULL\n");
792 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
797 memcpy(pv, html_page, sizeof(html_page)-1);
798 stream_read += *pcbRead = sizeof(html_page)-1;
802 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
803 ULONG cb, ULONG *pcbWritten)
805 ok(0, "unexpected call\n");
809 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
810 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
812 ok(0, "unexpected call\n");
816 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
818 ok(0, "unexpected call\n");
822 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
823 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
825 ok(0, "unexpected call\n");
829 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
831 ok(0, "unexpected call\n");
835 static HRESULT WINAPI Stream_Revert(IStream *iface)
837 ok(0, "unexpected call\n");
841 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
842 ULARGE_INTEGER cb, DWORD dwLockType)
844 ok(0, "unexpected call\n");
848 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
849 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
851 ok(0, "unexpected call\n");
855 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
858 ok(0, "unexpected call\n");
862 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
864 ok(0, "unexpected call\n");
868 static const IStreamVtbl StreamVtbl = {
869 Stream_QueryInterface,
885 static IStream Stream = { &StreamVtbl };
887 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
889 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
890 return E_NOINTERFACE; /* TODO */
892 if(IsEqualGUID(&IID_IWinInetInfo, riid))
893 return E_NOINTERFACE; /* TODO */
895 ok(0, "unexpected call\n");
896 return E_NOINTERFACE;
899 static ULONG WINAPI Binding_AddRef(IBinding *iface)
904 static ULONG WINAPI Binding_Release(IBinding *iface)
909 static HRESULT WINAPI Binding_Abort(IBinding *iface)
915 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
917 ok(0, "unexpected call\n");
921 static HRESULT WINAPI Binding_Resume(IBinding *iface)
923 ok(0, "unexpected call\n");
927 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
929 ok(0, "unexpected call\n");
933 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
935 ok(0, "unexpected call\n");
939 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
940 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
942 CHECK_EXPECT(GetBindResult);
946 static const IBindingVtbl BindingVtbl = {
947 Binding_QueryInterface,
955 Binding_GetBindResult
958 static IBinding Binding = { &BindingVtbl };
960 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
961 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
963 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
967 if(IsEqualGUID(&IID_IMoniker_unk, riid))
968 return E_NOINTERFACE; /* TODO */
969 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
970 return E_NOINTERFACE; /* TODO */
972 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
973 return E_NOINTERFACE;
976 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
981 static ULONG WINAPI Moniker_Release(IMoniker *iface)
986 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
988 CHECK_EXPECT(GetClassID);
989 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
993 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
995 ok(0, "unexpected call\n");
999 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1001 ok(0, "unexpected call\n");
1005 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1007 ok(0, "unexpected call\n");
1011 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1013 ok(0, "unexpected call\n");
1017 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1018 REFIID riidResult, void **ppvResult)
1020 ok(0, "unexpected call\n");
1024 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1025 REFIID riid, void **ppv)
1027 IBindStatusCallback *callback = NULL;
1028 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1029 STGMEDIUM stgmedium;
1034 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1035 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1037 CHECK_EXPECT(BindToStorage);
1039 load_state = LD_LOADING;
1041 ok(pbc != NULL, "pbc == NULL\n");
1042 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1043 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1044 ok(ppv != NULL, "ppv == NULL\n");
1045 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1047 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1048 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1049 ok(callback != NULL, "callback == NULL\n");
1051 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1052 bindinfo.cbSize = sizeof(bindinfo);
1054 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1055 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1056 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
1057 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
1058 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1059 /* TODO: test stgmedData */
1060 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
1061 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
1062 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1063 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
1064 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
1065 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
1066 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
1067 /* TODO: test dwCodePage */
1068 /* TODO: test securityAttributes */
1069 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1070 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1071 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
1073 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1074 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1076 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1078 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1080 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1081 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1082 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1085 stgmedium.tymed = TYMED_ISTREAM;
1086 U(stgmedium).pstm = &Stream;
1087 stgmedium.pUnkForRelease = (IUnknown*)iface;
1088 hres = IBindStatusCallback_OnDataAvailable(callback,
1089 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1090 sizeof(html_page)-1, &formatetc, &stgmedium);
1091 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1094 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1095 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1096 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1098 SET_EXPECT(GetBindResult);
1099 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1100 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1101 SET_CALLED(GetBindResult); /* IE7 */
1103 IBindStatusCallback_Release(callback);
1108 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1109 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1111 ok(0, "unexpected call\n");
1115 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1116 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1118 ok(0, "unexpected call\n");
1122 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1124 ok(0, "unexpected call\n");
1128 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1130 ok(0, "unexpected call\n");
1134 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1136 ok(0, "unexpected call\n");
1140 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1141 IMoniker *pmkNewlyRunning)
1143 ok(0, "unexpected call\n");
1147 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1148 IMoniker *pmkToLeft, FILETIME *pFileTime)
1150 ok(0, "unexpected call\n");
1154 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1156 ok(0, "unexpected call\n");
1160 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1161 IMoniker **ppmkPrefix)
1163 ok(0, "unexpected call\n");
1167 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1168 IMoniker **pmkRelPath)
1170 ok(0, "unexpected call\n");
1174 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1175 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1177 CHECK_EXPECT2(GetDisplayName);
1179 /* ok(pbc != NULL, "pbc == NULL\n"); */
1180 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1181 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1183 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1184 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1189 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1190 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1192 ok(0, "unexpected call\n");
1196 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1198 CHECK_EXPECT(IsSystemMoniker);
1202 static const IMonikerVtbl MonikerVtbl = {
1203 Moniker_QueryInterface,
1211 Moniker_BindToObject,
1212 Moniker_BindToStorage,
1214 Moniker_ComposeWith,
1219 Moniker_GetTimeOfLastChange,
1221 Moniker_CommonPrefixWith,
1222 Moniker_RelativePathTo,
1223 Moniker_GetDisplayName,
1224 Moniker_ParseDisplayName,
1225 Moniker_IsSystemMoniker
1228 static IMoniker Moniker = { &MonikerVtbl };
1230 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1232 return QueryInterface(riid, ppv);
1235 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1240 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1245 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1246 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1248 ok(0, "unexpected call\n");
1252 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1253 IEnumUnknown **ppenum)
1255 ok(0, "unexpected call\n");
1259 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1261 CHECK_EXPECT(LockContainer);
1262 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1266 static const IOleContainerVtbl OleContainerVtbl = {
1267 OleContainer_QueryInterface,
1268 OleContainer_AddRef,
1269 OleContainer_Release,
1270 OleContainer_ParseDisplayName,
1271 OleContainer_EnumObjects,
1272 OleContainer_LockContainer
1275 static IOleContainer OleContainer = { &OleContainerVtbl };
1277 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1279 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1281 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1282 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1285 return E_NOINTERFACE;
1288 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1293 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1298 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1300 CHECK_EXPECT(Frame_GetWindow);
1304 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1306 ok(0, "unexpected call\n");
1310 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1312 ok(0, "unexpected call\n");
1316 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1317 LPCBORDERWIDTHS pborderwidths)
1319 ok(0, "unexpected call\n");
1323 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1324 LPCBORDERWIDTHS pborderwidths)
1326 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1330 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1331 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1333 static const WCHAR wszHTML_Document[] =
1334 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1336 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1338 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1339 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1340 if(pActiveObject && is_english())
1341 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1344 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1345 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1347 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1351 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1352 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1354 static const WCHAR wszHTML_Document[] =
1355 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1358 CHECK_EXPECT2(SetActiveObject);
1360 if(pActiveObject && is_english())
1361 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1363 CHECK_EXPECT(SetActiveObject_null);
1365 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1366 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1372 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1373 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1375 ok(0, "unexpected call\n");
1379 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1380 HOLEMENU holemenu, HWND hwndActiveObject)
1382 ok(0, "unexpected call\n");
1386 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1388 ok(0, "unexpected call\n");
1392 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1394 CHECK_EXPECT2(SetStatusText);
1395 if(!expect_status_text)
1396 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1400 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1403 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
1405 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
1409 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1411 ok(0, "unexpected call\n");
1415 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1416 InPlaceFrame_QueryInterface,
1417 InPlaceFrame_AddRef,
1418 InPlaceFrame_Release,
1419 InPlaceFrame_GetWindow,
1420 InPlaceFrame_ContextSensitiveHelp,
1421 InPlaceFrame_GetBorder,
1422 InPlaceFrame_RequestBorderSpace,
1423 InPlaceFrame_SetBorderSpace,
1424 InPlaceFrame_SetActiveObject,
1425 InPlaceFrame_InsertMenus,
1426 InPlaceFrame_SetMenu,
1427 InPlaceFrame_RemoveMenus,
1428 InPlaceFrame_SetStatusText,
1429 InPlaceFrame_EnableModeless,
1430 InPlaceFrame_TranslateAccelerator
1433 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1435 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1436 InPlaceFrame_QueryInterface,
1437 InPlaceFrame_AddRef,
1438 InPlaceFrame_Release,
1439 InPlaceFrame_GetWindow,
1440 InPlaceFrame_ContextSensitiveHelp,
1441 InPlaceFrame_GetBorder,
1442 InPlaceFrame_RequestBorderSpace,
1443 InPlaceFrame_SetBorderSpace,
1444 InPlaceUIWindow_SetActiveObject,
1447 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1449 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1451 return QueryInterface(riid, ppv);
1454 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1459 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1464 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1466 CHECK_EXPECT2(GetWindow);
1467 ok(phwnd != NULL, "phwnd = NULL\n");
1468 *phwnd = container_hwnd;
1472 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1474 ok(0, "unexpected call\n");
1478 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1480 CHECK_EXPECT(CanInPlaceActivate);
1484 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1486 CHECK_EXPECT(OnInPlaceActivate);
1490 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1492 CHECK_EXPECT(OnUIActivate);
1496 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1497 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1498 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1500 static const RECT rect = {0,0,500,500};
1502 CHECK_EXPECT(GetWindowContext);
1504 ok(ppFrame != NULL, "ppFrame = NULL\n");
1506 *ppFrame = &InPlaceFrame;
1507 ok(ppDoc != NULL, "ppDoc = NULL\n");
1509 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1510 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1512 memcpy(lprcPosRect, &rect, sizeof(RECT));
1513 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1515 memcpy(lprcClipRect, &rect, sizeof(RECT));
1516 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1518 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1519 lpFrameInfo->fMDIApp = FALSE;
1520 lpFrameInfo->hwndFrame = container_hwnd;
1521 lpFrameInfo->haccel = NULL;
1522 lpFrameInfo->cAccelEntries = 0;
1528 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1530 ok(0, "unexpected call\n");
1534 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1536 CHECK_EXPECT(OnUIDeactivate);
1537 ok(!fUndoable, "fUndoable = TRUE\n");
1541 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1543 CHECK_EXPECT(OnInPlaceDeactivate);
1547 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1549 ok(0, "unexpected call\n");
1553 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1555 ok(0, "unexpected call\n");
1559 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1561 ok(0, "unexpected call\n");
1565 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1567 CHECK_EXPECT(OnInPlaceActivateEx);
1569 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1570 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1571 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1576 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1578 CHECK_EXPECT(OnInPlaceDeactivateEx);
1580 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1585 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1587 CHECK_EXPECT(RequestUIActivate);
1591 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1592 InPlaceSite_QueryInterface,
1594 InPlaceSite_Release,
1595 InPlaceSite_GetWindow,
1596 InPlaceSite_ContextSensitiveHelp,
1597 InPlaceSite_CanInPlaceActivate,
1598 InPlaceSite_OnInPlaceActivate,
1599 InPlaceSite_OnUIActivate,
1600 InPlaceSite_GetWindowContext,
1602 InPlaceSite_OnUIDeactivate,
1603 InPlaceSite_OnInPlaceDeactivate,
1604 InPlaceSite_DiscardUndoState,
1605 InPlaceSite_DeactivateAndUndo,
1606 InPlaceSite_OnPosRectChange,
1607 InPlaceSiteEx_OnInPlaceActivateEx,
1608 InPlaceSiteEx_OnInPlaceDeactivateEx,
1609 InPlaceSiteEx_RequestUIActivate
1612 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1614 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1616 return QueryInterface(riid, ppv);
1619 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1624 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1629 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1631 ok(0, "unexpected call\n");
1635 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1638 ok(0, "unexpected call\n");
1642 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1644 CHECK_EXPECT(GetContainer);
1645 ok(ppContainer != NULL, "ppContainer = NULL\n");
1646 *ppContainer = &OleContainer;
1650 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1652 ok(0, "unexpected call\n");
1656 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1658 ok(0, "unexpected call\n");
1662 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1664 ok(0, "unexpected call\n");
1668 static const IOleClientSiteVtbl ClientSiteVtbl = {
1669 ClientSite_QueryInterface,
1672 ClientSite_SaveObject,
1673 ClientSite_GetMoniker,
1674 ClientSite_GetContainer,
1675 ClientSite_ShowObject,
1676 ClientSite_OnShowWindow,
1677 ClientSite_RequestNewObjectLayout
1680 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1682 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1684 return QueryInterface(riid, ppv);
1687 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1692 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1699 CallUIActivate_None,
1700 CallUIActivate_ActivateMe,
1701 CallUIActivate_AfterShow,
1704 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1705 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1707 IOleDocument *document;
1710 CHECK_EXPECT(ActivateMe);
1711 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1713 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1714 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1716 if(SUCCEEDED(hres)) {
1717 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1718 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1720 if(SUCCEEDED(hres)) {
1721 IOleInPlaceActiveObject *activeobj = NULL;
1722 IOleInPlaceSite *inplacesite = NULL;
1723 HWND tmp_hwnd = NULL;
1724 static RECT rect = {0,0,400,500};
1726 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1727 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1728 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1729 inplacesite, &InPlaceSiteEx);
1731 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1732 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1734 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1735 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1736 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1737 inplacesite, &InPlaceSiteEx);
1739 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1740 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1743 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1744 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1745 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1748 if(call_UIActivate == CallUIActivate_ActivateMe) {
1749 SET_EXPECT(CanInPlaceActivate);
1750 SET_EXPECT(GetWindowContext);
1751 SET_EXPECT(GetWindow);
1753 SET_EXPECT(OnInPlaceActivateEx);
1755 SET_EXPECT(OnInPlaceActivate);
1756 SET_EXPECT(SetStatusText);
1757 SET_EXPECT(Exec_SETPROGRESSMAX);
1758 SET_EXPECT(Exec_SETPROGRESSPOS);
1759 SET_EXPECT(OnUIActivate);
1760 SET_EXPECT(SetActiveObject);
1762 expect_status_text = NULL;
1764 hres = IOleDocumentView_UIActivate(view, TRUE);
1765 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1767 CHECK_CALLED(CanInPlaceActivate);
1768 CHECK_CALLED(GetWindowContext);
1769 CHECK_CALLED(GetWindow);
1771 CHECK_CALLED(OnInPlaceActivateEx);
1773 CHECK_CALLED(OnInPlaceActivate);
1774 CHECK_CALLED(SetStatusText);
1775 CHECK_CALLED(Exec_SETPROGRESSMAX);
1776 CHECK_CALLED(Exec_SETPROGRESSPOS);
1777 CHECK_CALLED(OnUIActivate);
1778 CHECK_CALLED(SetActiveObject);
1779 CHECK_CALLED(ShowUI);
1782 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1783 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1784 ok(hwnd != NULL, "hwnd == NULL\n");
1786 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1789 hres = IOleDocumentView_UIActivate(view, TRUE);
1790 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1793 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1794 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1795 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1799 hres = IOleDocumentView_SetRect(view, &rect);
1800 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1802 if(call_UIActivate == CallUIActivate_ActivateMe) {
1803 hres = IOleDocumentView_Show(view, TRUE);
1804 ok(hres == S_OK, "Show failed: %08x\n", hres);
1806 SET_EXPECT(CanInPlaceActivate);
1807 SET_EXPECT(GetWindowContext);
1808 SET_EXPECT(GetWindow);
1810 SET_EXPECT(OnInPlaceActivateEx);
1812 SET_EXPECT(OnInPlaceActivate);
1813 SET_EXPECT(SetStatusText);
1814 SET_EXPECT(Exec_SETPROGRESSMAX);
1815 SET_EXPECT(Exec_SETPROGRESSPOS);
1816 SET_EXPECT(OnUIActivate);
1817 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1819 hres = IOleDocumentView_Show(view, TRUE);
1821 win_skip("Show failed\n");
1823 IOleInPlaceActiveObject_Release(activeobj);
1824 IOleDocument_Release(document);
1828 ok(hres == S_OK, "Show failed: %08x\n", hres);
1830 CHECK_CALLED(CanInPlaceActivate);
1831 CHECK_CALLED(GetWindowContext);
1832 CHECK_CALLED(GetWindow);
1834 CHECK_CALLED(OnInPlaceActivateEx);
1836 CHECK_CALLED(OnInPlaceActivate);
1837 CHECK_CALLED(SetStatusText);
1838 CHECK_CALLED(Exec_SETPROGRESSMAX);
1839 CHECK_CALLED(Exec_SETPROGRESSPOS);
1842 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1843 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1844 ok(hwnd != NULL, "hwnd == NULL\n");
1846 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1850 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1853 IOleInPlaceActiveObject_Release(activeobj);
1856 IOleDocument_Release(document);
1862 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1863 DocumentSite_QueryInterface,
1864 DocumentSite_AddRef,
1865 DocumentSite_Release,
1866 DocumentSite_ActivateMe
1869 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1871 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1873 return QueryInterface(riid, ppv);
1876 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1881 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1886 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1888 ok(0, "unexpected call\n");
1892 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1894 ok(0, "unexpected call\n");
1898 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1900 ok(0, "unexpected call\n");
1904 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1905 POINTF *pPtfContainer, DWORD dwFlags)
1907 ok(0, "unexpected call\n");
1911 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1912 MSG *pMsg, DWORD grfModifiers)
1914 ok(0, "unexpected call\n");
1918 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1921 CHECK_EXPECT(OnFocus_TRUE);
1923 CHECK_EXPECT2(OnFocus_FALSE);
1927 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1929 ok(0, "unexpected call\n");
1933 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1934 OleControlSite_QueryInterface,
1935 OleControlSite_AddRef,
1936 OleControlSite_Release,
1937 OleControlSite_OnControlInfoChanged,
1938 OleControlSite_LockInPlaceActive,
1939 OleControlSite_GetExtendedControl,
1940 OleControlSite_TransformCoords,
1941 OleControlSite_TranslateAccelerator,
1942 OleControlSite_OnFocus,
1943 OleControlSite_ShowPropertyFrame
1946 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1948 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1950 return QueryInterface(riid, ppv);
1953 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1958 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1963 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1964 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1966 ok(0, "unexpected call\n");
1970 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1972 CHECK_EXPECT(GetHostInfo);
1973 ok(pInfo != NULL, "pInfo=NULL\n");
1975 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1976 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1977 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1978 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1979 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1980 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1981 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1982 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1987 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1988 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1989 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1991 CHECK_EXPECT(ShowUI);
1994 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1996 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1997 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1998 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1999 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2000 if (expect_InPlaceUIWindow_SetActiveObject_active)
2001 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2003 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2008 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2010 CHECK_EXPECT(HideUI);
2014 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2016 CHECK_EXPECT(UpdateUI);
2020 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2023 CHECK_EXPECT2(EnableModeless_TRUE);
2025 CHECK_EXPECT2(EnableModeless_FALSE);
2029 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2031 ok(0, "unexpected call\n");
2035 static BOOL expect_OnFrameWindowActivate_fActivate;
2036 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2038 CHECK_EXPECT2(OnFrameWindowActivate);
2039 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2043 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2044 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2046 ok(0, "unexpected call\n");
2050 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2051 const GUID *pguidCmdGroup, DWORD nCmdID)
2053 ok(0, "unexpected call\n");
2057 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2058 LPOLESTR *pchKey, DWORD dw)
2060 CHECK_EXPECT(GetOptionKeyPath);
2061 ok(pchKey != NULL, "pchKey = NULL\n");
2062 ok(!dw, "dw=%d, expected 0\n", dw);
2064 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2068 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2069 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2071 CHECK_EXPECT(GetDropTarget);
2076 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2078 CHECK_EXPECT(GetExternal);
2079 *ppDispatch = &External;
2083 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2084 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2086 ok(0, "unexpected call\n");
2090 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2091 IDataObject **ppPORet)
2093 ok(0, "unexpected call\n");
2097 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2098 LPOLESTR *pchKey, DWORD dw)
2100 CHECK_EXPECT(GetOverrideKeyPath);
2101 ok(pchKey != NULL, "pchKey = NULL\n");
2103 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2104 ok(!dw, "dw=%d, xepected 0\n", dw);
2108 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2109 DocHostUIHandler_QueryInterface,
2110 DocHostUIHandler_AddRef,
2111 DocHostUIHandler_Release,
2112 DocHostUIHandler_ShowContextMenu,
2113 DocHostUIHandler_GetHostInfo,
2114 DocHostUIHandler_ShowUI,
2115 DocHostUIHandler_HideUI,
2116 DocHostUIHandler_UpdateUI,
2117 DocHostUIHandler_EnableModeless,
2118 DocHostUIHandler_OnDocWindowActivate,
2119 DocHostUIHandler_OnFrameWindowActivate,
2120 DocHostUIHandler_ResizeBorder,
2121 DocHostUIHandler_TranslateAccelerator,
2122 DocHostUIHandler_GetOptionKeyPath,
2123 DocHostUIHandler_GetDropTarget,
2124 DocHostUIHandler_GetExternal,
2125 DocHostUIHandler_TranslateUrl,
2126 DocHostUIHandler_FilterDataObject,
2127 DocHostUIHandler_GetOverrideKeyPath
2130 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2132 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2133 REFIID riid, void **ppv)
2135 return QueryInterface(riid, ppv);
2138 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2143 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2148 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2149 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2151 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2152 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2153 ok(!pCmdText, "pCmdText != NULL\n");
2155 switch(prgCmds[0].cmdID) {
2156 case OLECMDID_SETPROGRESSTEXT:
2157 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2158 prgCmds[0].cmdf = OLECMDF_ENABLED;
2161 CHECK_EXPECT(QueryStatus_OPEN);
2162 prgCmds[0].cmdf = 0;
2165 CHECK_EXPECT(QueryStatus_NEW);
2166 prgCmds[0].cmdf = 0;
2169 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2175 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2176 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2178 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2179 test_readyState(NULL);
2181 if(!pguidCmdGroup) {
2183 case OLECMDID_SETPROGRESSMAX:
2184 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2185 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2186 ok(pvaIn != NULL, "pvaIn == NULL\n");
2188 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2189 if(load_state == LD_NO)
2190 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2192 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2194 case OLECMDID_SETPROGRESSPOS:
2195 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2196 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2197 ok(pvaIn != NULL, "pvaIn == NULL\n");
2199 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2200 if(load_state == LD_NO)
2201 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2203 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2205 case OLECMDID_HTTPEQUIV_DONE:
2206 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2207 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2208 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2209 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2210 load_state = LD_COMPLETE;
2212 case OLECMDID_SETDOWNLOADSTATE:
2213 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2214 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2215 ok(pvaIn != NULL, "pvaIn == NULL\n");
2216 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2218 switch(V_I4(pvaIn)) {
2220 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2221 load_state = LD_INTERACTIVE;
2224 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2225 readystate_set_interactive = (load_state != LD_INTERACTIVE);
2228 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2232 case OLECMDID_UPDATECOMMANDS:
2233 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2234 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2235 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2236 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2238 case OLECMDID_SETTITLE:
2239 CHECK_EXPECT2(Exec_SETTITLE);
2240 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2241 ok(pvaIn != NULL, "pvaIn == NULL\n");
2242 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2243 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2244 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2246 case OLECMDID_HTTPEQUIV:
2247 CHECK_EXPECT2(Exec_HTTPEQUIV);
2248 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
2249 ok(pvaIn != NULL, "pvaIn == NULL\n");
2250 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2251 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2252 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
2253 test_readyState(NULL);
2256 ok(0, "unexpected command %d\n", nCmdID);
2261 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2262 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2266 CHECK_EXPECT2(Exec_ShellDocView_37);
2268 if(load_from_stream)
2269 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2271 test_GetCurMoniker(doc_unk, doc_mon, NULL);
2273 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2274 ok(pvaIn != NULL, "pvaIn == NULL\n");
2276 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2277 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2281 CHECK_EXPECT2(Exec_ShellDocView_84);
2283 ok(pvaIn == NULL, "pvaIn != NULL\n");
2284 ok(pvaOut != NULL, "pvaOut == NULL\n");
2286 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2291 CHECK_EXPECT2(Exec_ShellDocView_103);
2293 ok(pvaIn == NULL, "pvaIn != NULL\n");
2294 ok(pvaOut == NULL, "pvaOut != NULL\n");
2299 CHECK_EXPECT2(Exec_ShellDocView_105);
2301 ok(pvaIn != NULL, "pvaIn == NULL\n");
2302 ok(pvaOut == NULL, "pvaOut != NULL\n");
2307 ok(0, "unexpected command %d\n", nCmdID);
2312 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2313 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2316 case IDM_PARSECOMPLETE:
2317 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2318 ok(pvaIn == NULL, "pvaIn != NULL\n");
2319 ok(pvaOut == NULL, "pvaOut != NULL\n");
2322 ok(0, "unexpected command %d\n", nCmdID);
2326 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2327 return E_FAIL; /* TODO */
2329 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2330 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2334 CHECK_EXPECT2(Exec_Explorer_69);
2335 ok(pvaIn == NULL, "pvaIn != NULL\n");
2336 ok(pvaOut != NULL, "pvaOut == NULL\n");
2339 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2344 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2346 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2347 SET_EXPECT(SetStatusText);
2348 ok(pvaIn == NULL, "pvaIn != NULL\n");
2349 ok(pvaOut == NULL, "pvaOut != NULL\n");
2351 case OLECMDID_SHOWSCRIPTERROR:
2355 ok(0, "unexpected command %d\n", nCmdID);
2360 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2364 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2365 OleCommandTarget_QueryInterface,
2366 OleCommandTarget_AddRef,
2367 OleCommandTarget_Release,
2368 OleCommandTarget_QueryStatus,
2369 OleCommandTarget_Exec
2372 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2374 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2376 return QueryInterface(riid, ppv);
2379 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2380 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2381 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2383 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2384 ok(pDispParams != NULL, "pDispParams == NULL\n");
2385 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2386 ok(puArgErr != NULL, "puArgErr == NULL\n");
2387 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2388 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2389 test_readyState(NULL);
2391 switch(dispIdMember) {
2392 case DISPID_AMBIENT_USERMODE:
2393 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2394 V_VT(pVarResult) = VT_BOOL;
2395 V_BOOL(pVarResult) = VARIANT_TRUE;
2397 case DISPID_AMBIENT_DLCONTROL:
2398 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2400 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2401 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2403 case DISPID_AMBIENT_SILENT:
2404 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2405 V_VT(pVarResult) = VT_BOOL;
2406 V_BOOL(pVarResult) = VARIANT_FALSE;
2408 case DISPID_AMBIENT_USERAGENT:
2409 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2411 case DISPID_AMBIENT_PALETTE:
2412 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2416 ok(0, "unexpected dispid %d\n", dispIdMember);
2420 static IDispatchVtbl DispatchVtbl = {
2421 Dispatch_QueryInterface,
2424 Dispatch_GetTypeInfoCount,
2425 Dispatch_GetTypeInfo,
2426 Dispatch_GetIDsOfNames,
2430 static IDispatch Dispatch = { &DispatchVtbl };
2432 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2433 REFIID riid, void **ppv)
2435 return QueryInterface(riid, ppv);
2438 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2443 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2448 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2449 REFIID riid, void **ppv)
2452 * Services used by HTMLDocument:
2455 * IInternetSecurityManager
2457 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2460 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2461 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2462 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2464 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2465 * IElementBehaviorFactory
2466 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2476 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2477 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2482 return E_NOINTERFACE;
2485 static const IServiceProviderVtbl ServiceProviderVtbl = {
2486 ServiceProvider_QueryInterface,
2487 ServiceProvider_AddRef,
2488 ServiceProvider_Release,
2489 ServiceProvider_QueryService
2492 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2494 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2495 DEFINE_GUID(IID_unk2, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2496 DEFINE_GUID(IID_unk3, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2497 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
2499 static HRESULT QueryInterface(REFIID riid, void **ppv)
2503 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2505 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2506 *ppv = &DocumentSite;
2507 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2508 *ppv = &DocHostUIHandler;
2509 else if(IsEqualGUID(&IID_IOleContainer, riid))
2510 *ppv = &OleContainer;
2511 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2512 *ppv = &InPlaceSiteEx;
2513 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2514 *ppv = &OleCommandTarget;
2515 else if(IsEqualGUID(&IID_IDispatch, riid))
2517 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2518 *ppv = &ServiceProvider;
2519 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2520 *ppv = ipsex ? &InPlaceSiteEx : NULL;
2521 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2522 *ppv = &OleControlSite;
2523 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2524 return E_NOINTERFACE; /* TODO */
2525 else if(IsEqualGUID(&IID_IProxyManager, riid))
2526 return E_NOINTERFACE; /* ? */
2527 else if(IsEqualGUID(&IID_unk1, riid))
2528 return E_NOINTERFACE; /* HTMLWindow2 ? */
2529 else if(IsEqualGUID(&IID_unk2, riid))
2530 return E_NOINTERFACE; /* ? */
2531 else if(IsEqualGUID(&IID_unk3, riid))
2532 return E_NOINTERFACE; /* ? */
2533 else if(IsEqualGUID(&IID_unk4, riid))
2534 return E_NOINTERFACE; /* ? */
2536 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2540 return E_NOINTERFACE;
2543 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2545 return DefWindowProc(hwnd, msg, wParam, lParam);
2548 static void _test_readyState(unsigned line, IUnknown *unk)
2550 IHTMLDocument2 *htmldoc;
2551 DISPPARAMS dispparams;
2556 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2557 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2558 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2559 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2561 static const LPCWSTR expected_state[] = {
2573 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2574 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2578 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2579 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2581 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2582 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2584 if(!lstrcmpW(state, wszInteractive) && load_state == LD_LOADING)
2585 load_state = LD_INTERACTIVE;
2588 (!lstrcmpW(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
2589 wine_dbgstr_w(state), load_state);
2590 SysFreeString(state);
2592 dispparams.cArgs = 0;
2593 dispparams.cNamedArgs = 0;
2594 dispparams.rgdispidNamedArgs = NULL;
2595 dispparams.rgvarg = NULL;
2599 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2600 &dispparams, &out, NULL, NULL);
2601 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2603 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2604 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2606 IHTMLDocument2_Release(htmldoc);
2609 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2611 IConnectionPointContainer *tmp_container = NULL;
2612 IConnectionPoint *cp;
2616 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2617 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2621 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2622 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2623 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2625 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2626 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2628 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2629 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2630 ok(tmp_container == container, "container != tmp_container\n");
2632 IConnectionPointContainer_Release(tmp_container);
2634 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2635 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2637 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2640 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2641 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2644 IConnectionPoint_Release(cp);
2647 static void test_ConnectionPointContainer(IUnknown *unk)
2649 IConnectionPointContainer *container;
2652 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2653 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2657 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2658 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2659 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2661 IConnectionPointContainer_Release(container);
2664 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
2668 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2670 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2672 test_readyState((IUnknown*)persist);
2676 CreateBindCtx(0, &bind);
2677 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2678 (IUnknown*)&ClientSite);
2681 SET_EXPECT(GetDisplayName);
2682 if(!set_clientsite) {
2683 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2684 SET_EXPECT(GetHostInfo);
2685 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2686 SET_EXPECT(Invoke_AMBIENT_SILENT);
2687 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2688 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2689 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2690 SET_EXPECT(GetOptionKeyPath);
2691 SET_EXPECT(GetOverrideKeyPath);
2692 SET_EXPECT(GetWindow);
2693 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2694 SET_EXPECT(Exec_SETPROGRESSMAX);
2695 SET_EXPECT(Exec_SETPROGRESSPOS);
2696 SET_EXPECT(Exec_ShellDocView_37);
2698 if(!container_locked) {
2699 SET_EXPECT(GetContainer);
2700 SET_EXPECT(LockContainer);
2702 SET_EXPECT(OnChanged_READYSTATE);
2703 SET_EXPECT(Exec_ShellDocView_84);
2704 SET_EXPECT(IsSystemMoniker);
2706 SET_EXPECT(BindToStorage);
2707 SET_EXPECT(SetActiveObject);
2708 if(set_clientsite) {
2709 SET_EXPECT(Invoke_AMBIENT_SILENT);
2710 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2711 SET_EXPECT(Exec_ShellDocView_37);
2713 load_state = LD_DOLOAD;
2714 expect_LockContainer_fLock = TRUE;
2715 readystate_set_loading = TRUE;
2717 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
2718 ok(hres == S_OK, "Load failed: %08x\n", hres);
2721 CHECK_CALLED(GetDisplayName);
2722 if(!set_clientsite) {
2723 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2724 CHECK_CALLED(GetHostInfo);
2725 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2726 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2727 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2728 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2729 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2730 CHECK_CALLED(GetOptionKeyPath);
2731 CHECK_CALLED(GetOverrideKeyPath);
2732 CHECK_CALLED(GetWindow);
2733 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2734 CHECK_CALLED(Exec_SETPROGRESSMAX);
2735 CHECK_CALLED(Exec_SETPROGRESSPOS);
2736 CHECK_CALLED(Exec_ShellDocView_37);
2738 if(!container_locked) {
2739 CHECK_CALLED(GetContainer);
2740 CHECK_CALLED(LockContainer);
2741 container_locked = TRUE;
2743 CHECK_CALLED(OnChanged_READYSTATE);
2744 SET_CALLED(IsSystemMoniker); /* IE7 */
2745 SET_CALLED(Exec_ShellDocView_84);
2747 CHECK_CALLED(BindToStorage);
2748 SET_CALLED(SetActiveObject); /* FIXME */
2749 if(set_clientsite) {
2750 CHECK_CALLED(Invoke_AMBIENT_SILENT);
2751 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2752 CHECK_CALLED(Exec_ShellDocView_37);
2755 set_clientsite = container_locked = TRUE;
2757 test_GetCurMoniker((IUnknown*)persist, mon, NULL);
2759 IBindCtx_Release(bind);
2761 test_readyState((IUnknown*)persist);
2764 static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
2769 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2770 ok(hwnd != NULL, "Could not find hidden window\n");
2772 test_readyState(NULL);
2775 SET_EXPECT(Exec_SETPROGRESSMAX);
2776 if(!load_from_stream)
2777 SET_EXPECT(GetHostInfo);
2779 SET_EXPECT(SetStatusText);
2780 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2781 SET_EXPECT(GetDropTarget);
2783 SET_EXPECT(Exec_ShellDocView_84);
2785 SET_EXPECT(CreateInstance);
2787 SET_EXPECT(LockRequest);
2788 SET_EXPECT(Terminate);
2789 SET_EXPECT(Protocol_Read);
2790 SET_EXPECT(UnlockRequest);
2792 SET_EXPECT(Exec_Explorer_69);
2793 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
2794 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
2795 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
2796 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
2797 if(doc_mon != &Moniker) {
2798 SET_EXPECT(OnChanged_1012);
2799 SET_EXPECT(Exec_HTTPEQUIV);
2800 SET_EXPECT(Exec_SETTITLE);
2802 SET_EXPECT(OnChanged_1005);
2803 SET_EXPECT(OnChanged_READYSTATE);
2804 SET_EXPECT(Exec_SETPROGRESSPOS);
2805 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2806 SET_EXPECT(Exec_ShellDocView_103);
2807 SET_EXPECT(Exec_ShellDocView_105);
2808 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2809 SET_EXPECT(Exec_HTTPEQUIV_DONE);
2810 SET_EXPECT(SetStatusText);
2811 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2813 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2814 TranslateMessage(&msg);
2815 DispatchMessage(&msg);
2819 CHECK_CALLED(Exec_SETPROGRESSMAX);
2820 if(!load_from_stream)
2821 CHECK_CALLED(GetHostInfo);
2823 CHECK_CALLED(SetStatusText);
2824 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2825 CHECK_CALLED(GetDropTarget);
2827 SET_CALLED(Exec_ShellDocView_84);
2829 if(called_CreateInstance) {
2830 CHECK_CALLED(CreateInstance);
2831 CHECK_CALLED(Start);
2832 CHECK_CALLED(LockRequest);
2833 CHECK_CALLED(Terminate);
2834 CHECK_CALLED(Protocol_Read);
2835 CHECK_CALLED(UnlockRequest);
2837 skip("CreateInstance not called. Assuming no Gecko installed.\n");
2839 SET_CALLED(Exec_ShellDocView_84);
2840 SET_CALLED(CreateInstance);
2842 SET_CALLED(LockRequest);
2843 SET_CALLED(Terminate);
2844 SET_CALLED(Protocol_Read);
2845 SET_CALLED(UnlockRequest);
2850 SET_CALLED(Exec_Explorer_69);
2851 SET_CALLED(EnableModeless_TRUE); /* IE7 */
2852 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
2853 SET_CALLED(EnableModeless_FALSE); /* IE7 */
2854 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
2855 if(doc_mon != &Moniker) todo_wine {
2856 CHECK_CALLED(OnChanged_1012);
2857 CHECK_CALLED(Exec_HTTPEQUIV);
2858 CHECK_CALLED(Exec_SETTITLE);
2860 CHECK_CALLED(OnChanged_1005);
2861 CHECK_CALLED(OnChanged_READYSTATE);
2862 CHECK_CALLED(Exec_SETPROGRESSPOS);
2863 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2864 SET_CALLED(Exec_ShellDocView_103);
2865 SET_CALLED(Exec_ShellDocView_105);
2866 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2867 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2868 SET_CALLED(SetStatusText);
2870 load_state = LD_COMPLETE;
2872 test_readyState(NULL);
2875 static void test_Persist(IUnknown *unk, IMoniker *mon)
2877 IPersistMoniker *persist_mon;
2878 IPersistFile *persist_file;
2882 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2883 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2884 if(SUCCEEDED(hres)) {
2885 hres = IPersist_GetClassID(persist_file, NULL);
2886 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2888 hres = IPersist_GetClassID(persist_file, &guid);
2889 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2890 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2892 IPersist_Release(persist_file);
2895 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2896 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2897 if(SUCCEEDED(hres)) {
2898 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2899 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2901 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2902 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2903 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2905 if(load_state == LD_DOLOAD)
2906 test_Load(persist_mon, mon);
2908 test_readyState(unk);
2910 IPersistMoniker_Release(persist_mon);
2914 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2916 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
2917 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
2918 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
2919 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
2920 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
2921 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
2922 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
2923 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
2924 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
2925 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
2926 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
2927 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
2928 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
2929 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
2930 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
2931 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
2932 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
2933 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
2934 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
2935 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
2937 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
2938 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
2940 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
2942 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
2944 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
2945 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
2947 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
2948 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
2950 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
2952 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
2953 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
2956 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2957 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2959 IOleCommandTarget *cmdtrg;
2960 OLECMD olecmd = {cmdid, 0};
2963 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2964 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2968 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2969 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2971 IOleCommandTarget_Release(cmdtrg);
2973 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2974 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2977 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2982 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2983 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2984 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
2985 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2986 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2987 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2988 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2989 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2990 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2991 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2992 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2993 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2994 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2995 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2996 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2997 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
3000 static void test_OleCommandTarget(IUnknown *unk)
3002 IOleCommandTarget *cmdtrg;
3003 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
3007 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3008 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3012 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3013 cmds[i].cmdID = i+1;
3014 cmds[i].cmdf = 0xf0f0;
3017 SET_EXPECT(QueryStatus_OPEN);
3018 SET_EXPECT(QueryStatus_NEW);
3019 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
3020 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3021 CHECK_CALLED(QueryStatus_OPEN);
3022 CHECK_CALLED(QueryStatus_NEW);
3024 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3025 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
3026 if(i+1 == OLECMDID_FIND)
3028 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
3029 i+1, cmds[i].cmdf, expect_cmds[i+1]);
3032 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
3033 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
3035 IOleCommandTarget_Release(cmdtrg);
3038 static void test_OleCommandTarget_fail(IUnknown *unk)
3040 IOleCommandTarget *cmdtrg;
3045 {OLECMDID_OPEN, 0xf0f0},
3046 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
3049 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3050 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
3054 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
3055 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3057 SET_EXPECT(QueryStatus_OPEN);
3058 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
3059 CHECK_CALLED(QueryStatus_OPEN);
3061 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3062 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3063 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3064 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3065 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3066 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3067 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3069 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3070 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3071 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3073 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3074 if(!expect_cmds[i]) {
3075 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3076 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3077 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3078 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3082 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3083 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3084 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3085 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3087 IOleCommandTarget_Release(cmdtrg);
3090 static void test_exec_onunload(IUnknown *unk)
3092 IOleCommandTarget *cmdtrg;
3096 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3097 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3101 memset(&var, 0x0a, sizeof(var));
3102 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3103 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3104 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3105 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3106 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3108 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3109 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3110 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3112 IOleCommandTarget_Release(cmdtrg);
3115 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3117 IOleCommandTarget *cmdtrg;
3120 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3121 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3128 load_state = LD_DOLOAD;
3131 SET_EXPECT(GetClassID);
3132 SET_EXPECT(SetStatusText);
3133 SET_EXPECT(Exec_ShellDocView_37);
3134 SET_EXPECT(GetHostInfo);
3136 SET_EXPECT(GetDisplayName);
3137 SET_EXPECT(Invoke_AMBIENT_SILENT);
3138 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3139 SET_EXPECT(OnChanged_READYSTATE);
3140 SET_EXPECT(IsSystemMoniker);
3141 SET_EXPECT(Exec_ShellDocView_84);
3143 SET_EXPECT(BindToStorage);
3144 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3147 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3149 expect_status_text = NULL;
3150 readystate_set_loading = TRUE;
3152 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3153 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3154 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3157 CHECK_CALLED(GetClassID);
3158 CHECK_CALLED(SetStatusText);
3159 CHECK_CALLED(Exec_ShellDocView_37);
3160 CHECK_CALLED(GetHostInfo);
3162 CHECK_CALLED(GetDisplayName);
3163 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3164 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3165 CHECK_CALLED(OnChanged_READYSTATE);
3166 SET_CALLED(IsSystemMoniker); /* IE7 */
3167 SET_CALLED(Exec_ShellDocView_84);
3169 CHECK_CALLED(BindToStorage);
3170 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3171 CHECK_CALLED(HideUI);
3172 CHECK_CALLED(ShowUI);
3173 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3175 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3177 IOleCommandTarget_Release(cmdtrg);
3179 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3180 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3181 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3184 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3186 IOleCommandTarget *cmdtrg;
3187 VARIANT *in = NULL, _in, *out = NULL, _out;
3190 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3191 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3198 V_BSTR(in) = SysAllocString(name);
3204 V_I4(out) = 0xdeadbeef;
3207 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3209 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3214 if(out && !nogecko) {
3215 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3216 if(V_VT(out) == VT_BSTR) {
3218 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3219 "unexpected fontname %s\n", wine_dbgstr_w(name));
3221 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3226 IOleCommandTarget_Release(cmdtrg);
3229 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3231 IOleCommandTarget *cmdtrg;
3234 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3235 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3239 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3240 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3241 ok(hres == S_OK, "Exec failed: %08x\n", hres);
3243 IOleCommandTarget_Release(cmdtrg);
3246 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3248 IPersistStreamInit *perinit;
3249 IPersistMoniker *permon;
3250 IPersistFile *perfile;
3253 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3254 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3255 if(SUCCEEDED(hres)) {
3256 hres = IPersistStreamInit_IsDirty(perinit);
3257 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3258 IPersistStreamInit_Release(perinit);
3261 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3262 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3263 if(SUCCEEDED(hres)) {
3264 hres = IPersistMoniker_IsDirty(permon);
3265 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3266 IPersistMoniker_Release(permon);
3269 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3270 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3271 if(SUCCEEDED(hres)) {
3272 hres = IPersistFile_IsDirty(perfile);
3273 ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3274 IPersistFile_Release(perfile);
3278 static HWND create_container_window(void)
3280 static const WCHAR wszHTMLDocumentTest[] =
3281 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3282 static WNDCLASSEXW wndclass = {
3283 sizeof(WNDCLASSEXW),
3286 0, 0, NULL, NULL, NULL, NULL, NULL,
3287 wszHTMLDocumentTest,
3291 RegisterClassExW(&wndclass);
3292 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3293 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3294 515, 530, NULL, NULL, NULL, NULL);
3297 static void test_DoVerb(IOleObject *oleobj)
3299 RECT rect = {0,0,500,500};
3302 if(!container_locked) {
3303 SET_EXPECT(GetContainer);
3304 SET_EXPECT(LockContainer);
3306 SET_EXPECT(ActivateMe);
3307 expect_LockContainer_fLock = TRUE;
3309 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3310 ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3312 if(!container_locked) {
3313 CHECK_CALLED(GetContainer);
3314 CHECK_CALLED(LockContainer);
3315 container_locked = TRUE;
3317 CHECK_CALLED(ActivateMe);
3320 #define CLIENTSITE_EXPECTPATH 0x00000001
3321 #define CLIENTSITE_SETNULL 0x00000002
3322 #define CLIENTSITE_DONTSET 0x00000004
3324 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3326 IOleClientSite *clientsite;
3329 if(flags & CLIENTSITE_SETNULL) {
3330 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3331 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3333 hres = IOleObject_SetClientSite(oleobj, NULL);
3334 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3336 set_clientsite = FALSE;
3339 if(flags & CLIENTSITE_DONTSET)
3342 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3343 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3344 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3345 clientsite, set_clientsite ? &ClientSite : NULL);
3347 if(!set_clientsite) {
3348 SET_EXPECT(GetHostInfo);
3349 if(flags & CLIENTSITE_EXPECTPATH) {
3350 SET_EXPECT(GetOptionKeyPath);
3351 SET_EXPECT(GetOverrideKeyPath);
3353 SET_EXPECT(GetWindow);
3354 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3355 SET_EXPECT(Exec_SETPROGRESSMAX);
3356 SET_EXPECT(Exec_SETPROGRESSPOS);
3357 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3358 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3359 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3360 SET_EXPECT(Invoke_AMBIENT_SILENT);
3361 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3362 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3364 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3365 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3367 CHECK_CALLED(GetHostInfo);
3368 if(flags & CLIENTSITE_EXPECTPATH) {
3369 CHECK_CALLED(GetOptionKeyPath);
3370 CHECK_CALLED(GetOverrideKeyPath);
3372 CHECK_CALLED(GetWindow);
3373 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3374 CHECK_CALLED(Exec_SETPROGRESSMAX);
3375 CHECK_CALLED(Exec_SETPROGRESSPOS);
3376 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3377 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3378 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3379 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3380 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3381 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3383 set_clientsite = TRUE;
3386 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3387 ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3389 hres = IOleObject_GetClientSite(oleobj, &clientsite);
3390 ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3391 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3394 static void test_OnAmbientPropertyChange(IUnknown *unk)
3396 IOleControl *control = NULL;
3399 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3400 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3404 SET_EXPECT(Invoke_AMBIENT_USERMODE);
3405 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3406 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3407 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3409 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3410 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3411 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3412 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3414 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3415 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3416 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3417 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3418 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3419 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3421 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3422 SET_EXPECT(Invoke_AMBIENT_SILENT);
3423 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3424 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3425 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3426 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3428 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3429 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3430 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3431 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3433 SET_EXPECT(Invoke_AMBIENT_PALETTE);
3434 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3435 ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3436 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3438 IOleControl_Release(control);
3443 static void test_OnAmbientPropertyChange2(IUnknown *unk)
3445 IOleControl *control = NULL;
3448 hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3449 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3453 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3454 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3456 IOleControl_Release(control);
3459 static void test_Close(IUnknown *unk, BOOL set_client)
3461 IOleObject *oleobj = NULL;
3464 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3465 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3469 SET_EXPECT(GetContainer);
3470 SET_EXPECT(LockContainer);
3471 expect_LockContainer_fLock = FALSE;
3472 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3473 ok(hres == S_OK, "Close failed: %08x\n", hres);
3474 CHECK_CALLED(GetContainer);
3475 CHECK_CALLED(LockContainer);
3476 container_locked = FALSE;
3479 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3481 IOleObject_Release(oleobj);
3484 static void test_OnFrameWindowActivate(IUnknown *unk)
3486 IOleInPlaceActiveObject *inplaceact;
3489 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3490 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3494 if(set_clientsite) {
3495 expect_OnFrameWindowActivate_fActivate = TRUE;
3496 SET_EXPECT(OnFrameWindowActivate);
3497 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3498 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3499 CHECK_CALLED(OnFrameWindowActivate);
3501 SET_EXPECT(OnFrameWindowActivate);
3502 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3503 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3504 CHECK_CALLED(OnFrameWindowActivate);
3506 expect_OnFrameWindowActivate_fActivate = FALSE;
3507 SET_EXPECT(OnFrameWindowActivate);
3508 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3509 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3510 CHECK_CALLED(OnFrameWindowActivate);
3512 expect_OnFrameWindowActivate_fActivate = TRUE;
3513 SET_EXPECT(OnFrameWindowActivate);
3514 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3515 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3516 CHECK_CALLED(OnFrameWindowActivate);
3518 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3519 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3521 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3522 ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3525 IOleInPlaceActiveObject_Release(inplaceact);
3528 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3530 IOleInPlaceObjectWindowless *windowlessobj = NULL;
3533 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3534 (void**)&windowlessobj);
3535 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3540 SET_EXPECT(OnFocus_FALSE);
3542 SET_EXPECT(OnInPlaceDeactivateEx);
3544 SET_EXPECT(OnInPlaceDeactivate);
3546 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3547 ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3549 CHECK_CALLED(OnFocus_FALSE);
3551 CHECK_CALLED(OnInPlaceDeactivateEx);
3553 CHECK_CALLED(OnInPlaceDeactivate);
3556 IOleInPlaceObjectWindowless_Release(windowlessobj);
3559 static void test_Activate(IUnknown *unk, DWORD flags)
3561 IOleObject *oleobj = NULL;
3562 IOleDocumentView *docview;
3569 IOleDocumentView_Release(view);
3572 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3573 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3575 hres = IOleObject_GetUserClassID(oleobj, NULL);
3576 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3578 hres = IOleObject_GetUserClassID(oleobj, &guid);
3579 ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3580 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3582 test_OnFrameWindowActivate(unk);
3584 test_ClientSite(oleobj, flags);
3585 test_InPlaceDeactivate(unk, FALSE);
3586 test_DoVerb(oleobj);
3588 if(call_UIActivate == CallUIActivate_AfterShow) {
3589 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3590 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3592 SET_EXPECT(OnFocus_TRUE);
3593 SET_EXPECT(SetActiveObject);
3595 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3596 SET_EXPECT(InPlaceFrame_SetBorderSpace);
3597 expect_status_text = NULL;
3599 hres = IOleDocumentView_UIActivate(docview, TRUE);
3600 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3602 CHECK_CALLED(OnFocus_TRUE);
3603 CHECK_CALLED(SetActiveObject);
3604 CHECK_CALLED(ShowUI);
3605 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3606 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3608 IOleDocumentView_Release(docview);
3611 IOleObject_Release(oleobj);
3613 test_OnFrameWindowActivate(unk);
3616 static void test_Window(IUnknown *unk, BOOL expect_success)
3618 IOleInPlaceActiveObject *activeobject = NULL;
3622 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3623 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3627 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3629 if(expect_success) {
3630 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3631 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3633 ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3634 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3637 IOleInPlaceActiveObject_Release(activeobject);
3640 static void test_CloseView(void)
3642 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3648 hres = IOleDocumentView_Show(view, FALSE);
3649 ok(hres == S_OK, "Show failed: %08x\n", hres);
3651 hres = IOleDocumentView_CloseView(view, 0);
3652 ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3654 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3655 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3657 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3658 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3659 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3662 static void test_UIDeactivate(void)
3666 if(call_UIActivate == CallUIActivate_AfterShow) {
3667 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3669 if(call_UIActivate != CallUIActivate_None) {
3670 SET_EXPECT(SetActiveObject_null);
3672 SET_EXPECT(OnUIDeactivate);
3675 hres = IOleDocumentView_UIActivate(view, FALSE);
3676 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3678 if(call_UIActivate != CallUIActivate_None) {
3679 CHECK_CALLED(SetActiveObject_null);
3680 CHECK_CALLED(HideUI);
3681 CHECK_CALLED(OnUIDeactivate);
3683 if(call_UIActivate == CallUIActivate_AfterShow) {
3684 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3688 static void test_Hide(void)
3695 hres = IOleDocumentView_Show(view, FALSE);
3696 ok(hres == S_OK, "Show failed: %08x\n", hres);
3699 static HRESULT create_document(IUnknown **unk)
3701 IHTMLDocument5 *doc5;
3704 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3705 &IID_IUnknown, (void**)unk);
3706 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3710 hres = IUnknown_QueryInterface(*unk, &IID_IHTMLDocument5, (void**)&doc5);
3711 if(SUCCEEDED(hres)) {
3712 IHTMLDocument5_Release(doc5);
3714 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
3715 IUnknown_Release(*unk);
3721 static void test_Navigate(IUnknown *unk)
3723 IHlinkTarget *hlink;
3726 hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3727 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3729 SET_EXPECT(ActivateMe);
3730 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3731 ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3732 CHECK_CALLED(ActivateMe);
3734 IHlinkTarget_Release(hlink);
3737 static void test_external(IUnknown *unk, BOOL initialized)
3739 IDispatch *external;
3740 IHTMLDocument2 *doc;
3741 IHTMLWindow2 *htmlwin;
3744 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3745 ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres);
3747 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
3748 IHTMLDocument2_Release(doc);
3749 ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3752 SET_EXPECT(GetExternal);
3753 external = (void*)0xdeadbeef;
3754 hres = IHTMLWindow2_get_external(htmlwin, &external);
3756 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
3757 CHECK_CALLED(GetExternal);
3758 ok(external != NULL, "external == NULL\n");
3760 ok(hres == S_OK, "get_external failed: %08x\n", hres);
3761 ok(external == NULL, "external != NULL\n");
3764 IHTMLWindow2_Release(htmlwin);
3767 static void test_StreamLoad(IUnknown *unk)
3769 IPersistStreamInit *init;
3772 hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3773 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3777 SET_EXPECT(Invoke_AMBIENT_SILENT);
3778 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3779 SET_EXPECT(Exec_ShellDocView_37);
3780 SET_EXPECT(OnChanged_READYSTATE);
3782 readystate_set_loading = TRUE;
3784 hres = IPersistStreamInit_Load(init, &Stream);
3785 ok(hres == S_OK, "Load failed: %08x\n", hres);
3787 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3788 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3789 CHECK_CALLED(Exec_ShellDocView_37);
3790 CHECK_CALLED(OnChanged_READYSTATE);
3793 test_timer(EXPECT_SETTITLE);
3794 test_GetCurMoniker(unk, NULL, about_blank_url);
3796 IPersistStreamInit_Release(init);
3799 static void test_QueryInterface(IUnknown *unk)
3804 static const IID IID_UndocumentedScriptIface =
3805 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
3807 qi = (void*)0xdeadbeef;
3808 hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi);
3809 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3810 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
3812 qi = (void*)0xdeadbeef;
3813 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi);
3814 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3815 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3817 qi = (void*)0xdeadbeef;
3818 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi);
3819 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3820 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3822 qi = (void*)0xdeadbeef;
3823 hres = IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void**)&qi);
3824 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3825 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3827 qi = (void*)0xdeadbeef;
3828 hres = IUnknown_QueryInterface(unk, &IID_UndocumentedScriptIface, (void**)&qi);
3829 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3830 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3832 qi = (void*)0xdeadbeef;
3833 hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&qi);
3834 ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3835 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3838 static void init_test(enum load_state_t ls) {
3840 hwnd = last_hwnd = NULL;
3841 set_clientsite = FALSE;
3842 load_from_stream = FALSE;
3843 call_UIActivate = CallUIActivate_None;
3851 static void test_HTMLDocument(BOOL do_load)
3857 trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
3859 init_test(do_load ? LD_DOLOAD : LD_NO);
3861 hres = create_document(&unk);
3866 test_QueryInterface(unk);
3867 test_IsDirty(unk, S_FALSE);
3868 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3869 test_external(unk, FALSE);
3870 test_ConnectionPointContainer(unk);
3871 test_GetCurMoniker(unk, NULL, NULL);
3872 test_Persist(unk, &Moniker);
3874 test_OnAmbientPropertyChange2(unk);
3876 test_Activate(unk, CLIENTSITE_EXPECTPATH);
3879 test_download(FALSE, TRUE, TRUE);
3880 test_GetCurMoniker(unk, &Moniker, NULL);
3883 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3884 test_OleCommandTarget_fail(unk);
3885 test_OleCommandTarget(unk);
3886 test_OnAmbientPropertyChange(unk);
3887 test_Window(unk, TRUE);
3888 test_external(unk, TRUE);
3890 test_UIDeactivate();
3891 test_OleCommandTarget(unk);
3892 test_Window(unk, TRUE);
3893 test_InPlaceDeactivate(unk, TRUE);
3895 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
3896 * MSHTML. It doesn't with Wine. */
3898 test_Window(unk, FALSE);
3900 test_InPlaceDeactivate(unk, FALSE);
3902 test_Close(unk, FALSE);
3904 /* Activate HTMLDocument again */
3905 test_Activate(unk, CLIENTSITE_SETNULL);
3906 test_Window(unk, TRUE);
3907 test_OleCommandTarget(unk);
3908 test_UIDeactivate();
3909 test_InPlaceDeactivate(unk, TRUE);
3910 test_Close(unk, FALSE);
3912 /* Activate HTMLDocument again, this time without UIActivate */
3913 call_UIActivate = CallUIActivate_None;
3914 test_Activate(unk, CLIENTSITE_SETNULL);
3915 test_Window(unk, TRUE);
3917 test_UIDeactivate();
3918 test_InPlaceDeactivate(unk, TRUE);
3921 test_Close(unk, TRUE);
3922 test_OnAmbientPropertyChange2(unk);
3923 test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3926 /* Activate HTMLDocument again, calling UIActivate after showing the window */
3927 call_UIActivate = CallUIActivate_AfterShow;
3928 test_Activate(unk, 0);
3929 test_Window(unk, TRUE);
3930 test_OleCommandTarget(unk);
3931 test_UIDeactivate();
3932 test_InPlaceDeactivate(unk, TRUE);
3933 test_Close(unk, FALSE);
3934 call_UIActivate = CallUIActivate_None;
3938 IOleDocumentView_Release(view);
3941 ok(IsWindow(hwnd), "hwnd is destroyed\n");
3943 ref = IUnknown_Release(unk);
3944 ok(ref == 0, "ref=%d, expected 0\n", ref);
3946 ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3949 static void test_HTMLDocument_hlink(void)
3955 trace("Testing HTMLDocument (hlink)...\n");
3957 init_test(LD_DOLOAD);
3960 hres = create_document(&unk);
3965 test_ConnectionPointContainer(unk);
3966 test_GetCurMoniker(unk, NULL, NULL);
3967 test_Persist(unk, &Moniker);
3970 IUnknown_Release(unk);
3974 test_download(FALSE, TRUE, TRUE);
3976 test_IsDirty(unk, S_FALSE);
3977 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3979 test_exec_onunload(unk);
3980 test_Window(unk, TRUE);
3981 test_InPlaceDeactivate(unk, TRUE);
3982 test_Close(unk, FALSE);
3983 test_IsDirty(unk, S_FALSE);
3984 test_GetCurMoniker(unk, &Moniker, NULL);
3987 IOleDocumentView_Release(view);
3990 ref = IUnknown_Release(unk);
3991 ok(ref == 0, "ref=%d, expected 0\n", ref);
3994 static void test_HTMLDocument_http(void)
4001 static const WCHAR http_urlW[] =
4002 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
4004 trace("Testing HTMLDocument (http)...\n");
4006 hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
4007 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
4009 init_test(LD_DOLOAD);
4012 hres = create_document(&unk);
4017 test_ConnectionPointContainer(unk);
4018 test_GetCurMoniker(unk, NULL, NULL);
4019 test_Persist(unk, http_mon);
4022 IUnknown_Release(unk);
4026 test_download(FALSE, FALSE, FALSE);
4028 test_IsDirty(unk, S_FALSE);
4029 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4031 test_InPlaceDeactivate(unk, TRUE);
4032 test_Close(unk, FALSE);
4033 test_IsDirty(unk, S_FALSE);
4034 test_GetCurMoniker(unk, http_mon, NULL);
4037 IOleDocumentView_Release(view);
4040 ref = IUnknown_Release(unk);
4041 ok(!ref, "ref=%d, expected 0\n", ref);
4043 ref = IMoniker_Release(http_mon);
4044 ok(!ref, "ref=%d, expected 0\n", ref);
4047 static void test_HTMLDocument_StreamLoad(void)
4054 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
4056 init_test(LD_DOLOAD);
4057 load_from_stream = TRUE;
4059 hres = create_document(&unk);
4064 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
4065 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4067 test_readyState(unk);
4068 test_IsDirty(unk, S_FALSE);
4069 test_ConnectionPointContainer(unk);
4070 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4071 test_DoVerb(oleobj);
4072 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4074 IOleObject_Release(oleobj);
4076 test_GetCurMoniker(unk, NULL, NULL);
4077 test_StreamLoad(unk);
4078 test_download(TRUE, FALSE, TRUE);
4079 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4081 test_UIDeactivate();
4082 test_InPlaceDeactivate(unk, TRUE);
4083 test_Close(unk, FALSE);
4084 test_IsDirty(unk, S_FALSE);
4087 IOleDocumentView_Release(view);
4092 ref = IUnknown_Release(unk);
4093 ok(ref == 0, "ref=%d, expected 0\n", ref);
4096 static void test_edit_uiactivate(IOleObject *oleobj)
4098 IOleDocumentView *docview;
4101 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
4102 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
4104 SET_EXPECT(OnFocus_TRUE);
4105 SET_EXPECT(SetActiveObject);
4107 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
4108 SET_EXPECT(InPlaceFrame_SetBorderSpace);
4109 expect_status_text = NULL;
4111 hres = IOleDocumentView_UIActivate(docview, TRUE);
4112 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
4114 CHECK_CALLED(OnFocus_TRUE);
4115 CHECK_CALLED(SetActiveObject);
4116 CHECK_CALLED(ShowUI);
4117 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4118 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4120 IOleDocumentView_Release(docview);
4123 static void test_editing_mode(BOOL do_load)
4130 trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
4132 init_test(do_load ? LD_DOLOAD : LD_NO);
4133 call_UIActivate = CallUIActivate_AfterShow;
4135 hres = create_document(&unk);
4140 hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
4141 ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4143 test_readyState(unk);
4144 test_ConnectionPointContainer(unk);
4145 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4146 test_DoVerb(oleobj);
4147 test_edit_uiactivate(oleobj);
4149 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4151 test_Persist(unk, &Moniker);
4152 stream_read = protocol_read = 0;
4153 test_exec_editmode(unk, do_load);
4154 test_UIDeactivate();
4155 call_UIActivate = CallUIActivate_None;
4156 IOleObject_Release(oleobj);
4158 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4159 test_download(TRUE, do_load, do_load);
4161 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
4162 test_timer(EXPECT_UPDATEUI);
4163 SET_CALLED(SetStatusText);
4165 test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4168 test_exec_fontname(unk, NULL, wszTimesNewRoman);
4169 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4170 test_timer(EXPECT_UPDATEUI);
4171 test_exec_fontname(unk, NULL, wszArial);
4173 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4174 test_timer(EXPECT_UPDATEUI);
4176 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4177 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4179 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4180 test_timer(EXPECT_UPDATEUI);
4181 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4182 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4184 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4185 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4187 test_exec_noargs(unk, IDM_HORIZONTALLINE);
4188 test_timer(EXPECT_UPDATEUI);
4189 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4190 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4193 test_UIDeactivate();
4194 test_InPlaceDeactivate(unk, TRUE);
4195 test_Close(unk, FALSE);
4198 IOleDocumentView_Release(view);
4202 ref = IUnknown_Release(unk);
4203 ok(ref == 0, "ref=%d, expected 0\n", ref);
4206 static void register_protocol(void)
4208 IInternetSession *session;
4211 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
4213 hres = CoInternetGetSession(0, &session, 0);
4214 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
4216 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
4217 wsz_winetest, 0, NULL, 0);
4218 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
4220 IInternetSession_Release(session);
4223 static void gecko_installer_workaround(BOOL disable)
4228 static BOOL has_url = FALSE;
4229 static char url[2048];
4231 if(!disable && !has_url)
4234 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4235 if(res != ERROR_SUCCESS)
4239 DWORD type, size = sizeof(url);
4241 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4242 if(res == ERROR_SUCCESS && type == REG_SZ)
4245 RegDeleteValue(hkey, "GeckoUrl");
4247 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4253 static void test_HTMLDoc_ISupportErrorInfo(void)
4257 ISupportErrorInfo *sinfo;
4260 hres = create_document(&unk);
4264 hres = IUnknown_QueryInterface(unk, &IID_ISupportErrorInfo, (void**)&sinfo);
4265 ok(hres == S_OK, "got %x\n", hres);
4266 ok(sinfo != NULL, "got %p\n", sinfo);
4269 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
4270 ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
4271 IUnknown_Release(sinfo);
4274 ref = IUnknown_Release(unk);
4275 ok(ref == 0, "ref=%d, expected 0\n", ref);
4278 static void test_IPersistHistory(void)
4283 IPersistHistory *phist;
4285 hres = create_document(&unk);
4289 hres = IUnknown_QueryInterface(unk, &IID_IPersistHistory, (void**)&phist);
4290 ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
4292 IPersistHistory_Release(phist);
4294 ref = IUnknown_Release(unk);
4295 ok(ref == 0, "ref=%d, expected 0\n", ref);
4300 gecko_installer_workaround(TRUE);
4303 container_hwnd = create_container_window();
4304 register_protocol();
4306 test_HTMLDocument_hlink();
4308 test_HTMLDocument(FALSE);
4309 test_HTMLDocument(TRUE);
4310 test_HTMLDocument_StreamLoad();
4311 test_editing_mode(FALSE);
4312 test_editing_mode(TRUE);
4313 test_HTMLDocument_http();
4315 test_HTMLDoc_ISupportErrorInfo();
4316 test_IPersistHistory();
4318 DestroyWindow(container_hwnd);
4321 gecko_installer_workaround(FALSE);