166602091bf7357a71240e6e6c972f21999be022
[reactos.git] / rostests / winetests / mshtml / htmldoc.c
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #define COBJMACROS
20 #define CONST_VTABLE
21
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "mshtml.h"
31 #include "docobj.h"
32 #include "wininet.h"
33 #include "mshtmhst.h"
34 #include "mshtmdid.h"
35 #include "mshtmcid.h"
36 #include "hlink.h"
37 #include "dispex.h"
38 #include "idispids.h"
39 #include "shlguid.h"
40 #include "perhist.h"
41 #include "mshtml_test.h"
42
43 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
45 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
46
47 #define DEFINE_EXPECT(func) \
48 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
49
50 #define SET_EXPECT(func) \
51 expect_ ## func = TRUE
52
53 #define SET_CALLED(func) \
54 called_ ## func = TRUE
55
56 #define CHECK_EXPECT2(func) \
57 do { \
58 ok(expect_ ##func, "unexpected call " #func "\n"); \
59 called_ ## func = TRUE; \
60 }while(0)
61
62 #define CHECK_EXPECT(func) \
63 do { \
64 CHECK_EXPECT2(func); \
65 expect_ ## func = FALSE; \
66 }while(0)
67
68 #define CHECK_CALLED(func) \
69 do { \
70 ok(called_ ## func, "expected " #func "\n"); \
71 expect_ ## func = called_ ## func = FALSE; \
72 }while(0)
73
74 static IOleDocumentView *view = NULL;
75 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
76
77 DEFINE_EXPECT(LockContainer);
78 DEFINE_EXPECT(SetActiveObject);
79 DEFINE_EXPECT(SetActiveObject_null);
80 DEFINE_EXPECT(GetWindow);
81 DEFINE_EXPECT(CanInPlaceActivate);
82 DEFINE_EXPECT(OnInPlaceActivate);
83 DEFINE_EXPECT(OnInPlaceActivateEx);
84 DEFINE_EXPECT(OnUIActivate);
85 DEFINE_EXPECT(GetWindowContext);
86 DEFINE_EXPECT(OnUIDeactivate);
87 DEFINE_EXPECT(OnInPlaceDeactivate);
88 DEFINE_EXPECT(OnInPlaceDeactivateEx);
89 DEFINE_EXPECT(GetContainer);
90 DEFINE_EXPECT(ShowUI);
91 DEFINE_EXPECT(ActivateMe);
92 DEFINE_EXPECT(GetHostInfo);
93 DEFINE_EXPECT(HideUI);
94 DEFINE_EXPECT(GetOptionKeyPath);
95 DEFINE_EXPECT(GetOverrideKeyPath);
96 DEFINE_EXPECT(SetStatusText);
97 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
98 DEFINE_EXPECT(QueryStatus_OPEN);
99 DEFINE_EXPECT(QueryStatus_NEW);
100 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
101 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
102 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
103 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
104 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
105 DEFINE_EXPECT(Exec_ShellDocView_37);
106 DEFINE_EXPECT(Exec_ShellDocView_84);
107 DEFINE_EXPECT(Exec_ShellDocView_103);
108 DEFINE_EXPECT(Exec_ShellDocView_105);
109 DEFINE_EXPECT(Exec_ShellDocView_140);
110 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
111 DEFINE_EXPECT(Exec_SETTITLE);
112 DEFINE_EXPECT(Exec_HTTPEQUIV);
113 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
114 DEFINE_EXPECT(Exec_Explorer_69);
115 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
116 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
117 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
118 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
119 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
120 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
121 DEFINE_EXPECT(GetDropTarget);
122 DEFINE_EXPECT(UpdateUI);
123 DEFINE_EXPECT(Navigate);
124 DEFINE_EXPECT(OnFrameWindowActivate);
125 DEFINE_EXPECT(OnChanged_READYSTATE);
126 DEFINE_EXPECT(OnChanged_1005);
127 DEFINE_EXPECT(OnChanged_1012);
128 DEFINE_EXPECT(GetDisplayName);
129 DEFINE_EXPECT(BindToStorage);
130 DEFINE_EXPECT(IsSystemMoniker);
131 DEFINE_EXPECT(GetBindResult);
132 DEFINE_EXPECT(GetClassID);
133 DEFINE_EXPECT(Abort);
134 DEFINE_EXPECT(Read);
135 DEFINE_EXPECT(CreateInstance);
136 DEFINE_EXPECT(Start);
137 DEFINE_EXPECT(Terminate);
138 DEFINE_EXPECT(Protocol_Read);
139 DEFINE_EXPECT(LockRequest);
140 DEFINE_EXPECT(UnlockRequest);
141 DEFINE_EXPECT(OnFocus_TRUE);
142 DEFINE_EXPECT(OnFocus_FALSE);
143 DEFINE_EXPECT(RequestUIActivate);
144 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
145 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
146 DEFINE_EXPECT(GetExternal);
147 DEFINE_EXPECT(EnableModeless_TRUE);
148 DEFINE_EXPECT(EnableModeless_FALSE);
149 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
150 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
151 DEFINE_EXPECT(Frame_GetWindow);
152 DEFINE_EXPECT(TranslateUrl);
153 DEFINE_EXPECT(Advise_Close);
154
155 static IUnknown *doc_unk;
156 static IMoniker *doc_mon;
157 static BOOL expect_LockContainer_fLock;
158 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
159 static BOOL ipsex, ipsw;
160 static BOOL set_clientsite = FALSE, container_locked = FALSE;
161 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
162 static BOOL editmode = FALSE, show_failed;
163 static BOOL inplace_deactivated;
164 static int stream_read, protocol_read;
165 static enum load_state_t {
166 LD_DOLOAD,
167 LD_LOADING,
168 LD_LOADED,
169 LD_INTERACTIVE,
170 LD_COMPLETE,
171 LD_NO
172 } load_state;
173
174 static LPCOLESTR expect_status_text = NULL;
175
176 static const char html_page[] =
177 "<html>"
178 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
179 "<body>test</body>"
180 "</html>";
181
182 static const char css_data[] = "body {color: red}";
183
184 static const WCHAR http_urlW[] =
185 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
186
187 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
188 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
189
190 static HRESULT QueryInterface(REFIID riid, void **ppv);
191 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
192
193 #define test_readyState(u) _test_readyState(__LINE__,u)
194 static void _test_readyState(unsigned,IUnknown*);
195
196 static const WCHAR wszTimesNewRoman[] =
197 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
198 static const WCHAR wszArial[] =
199 {'A','r','i','a','l',0};
200
201 static const char *debugstr_guid(REFIID riid)
202 {
203 static char buf[50];
204
205 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
206 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
207 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
208 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
209
210 return buf;
211 }
212
213 static int strcmp_wa(LPCWSTR strw, const char *stra)
214 {
215 CHAR buf[512];
216 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
217 return lstrcmpA(stra, buf);
218 }
219
220 static const WCHAR *strstrW( const WCHAR *str, const WCHAR *sub )
221 {
222 while (*str)
223 {
224 const WCHAR *p1 = str, *p2 = sub;
225 while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
226 if (!*p2) return str;
227 str++;
228 }
229 return NULL;
230 }
231
232 static BSTR a2bstr(const char *str)
233 {
234 BSTR ret;
235 int len;
236
237 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
238 ret = SysAllocStringLen(NULL, len);
239 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
240
241 return ret;
242 }
243
244 static BOOL is_english(void)
245 {
246 return PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH
247 && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
248 }
249
250 #define EXPECT_UPDATEUI 1
251 #define EXPECT_SETTITLE 2
252
253 static void test_timer(DWORD flags)
254 {
255 BOOL *b = &called_Exec_SETTITLE;
256 MSG msg;
257
258 if(flags & EXPECT_UPDATEUI) {
259 SET_EXPECT(UpdateUI);
260 SET_EXPECT(Exec_UPDATECOMMANDS);
261 b = &called_UpdateUI;
262 }
263 if(flags & EXPECT_SETTITLE)
264 SET_EXPECT(Exec_SETTITLE);
265
266 while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
267 TranslateMessage(&msg);
268 DispatchMessage(&msg);
269 }
270
271 if(flags & EXPECT_UPDATEUI) {
272 CHECK_CALLED(UpdateUI);
273 CHECK_CALLED(Exec_UPDATECOMMANDS);
274 }
275 if(flags & EXPECT_SETTITLE)
276 CHECK_CALLED(Exec_SETTITLE);
277 }
278
279 static IMoniker Moniker;
280
281 #define test_GetCurMoniker(u,m,v) _test_GetCurMoniker(__LINE__,u,m,v)
282 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
283 {
284 IHTMLDocument2 *doc;
285 IPersistMoniker *permon;
286 IMoniker *mon = (void*)0xdeadbeef;
287 BSTR doc_url = (void*)0xdeadbeef;
288 HRESULT hres;
289
290 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
291 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
292 if(FAILED(hres))
293 return;
294
295 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
296 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
297
298 hres = IHTMLDocument2_get_URL(doc, &doc_url);
299 ok(hres == S_OK, "get_URL failed: %08x\n", hres);
300
301 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
302 IPersistMoniker_Release(permon);
303
304 if(exmon) {
305 LPOLESTR url;
306 BOOL exb = expect_GetDisplayName;
307 BOOL clb = called_GetDisplayName;
308
309 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
310 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
311
312 if(mon == &Moniker)
313 SET_EXPECT(GetDisplayName);
314 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
315 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
316 if(mon == &Moniker)
317 CHECK_CALLED(GetDisplayName);
318 expect_GetDisplayName = exb;
319 called_GetDisplayName = clb;
320
321 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
322 CoTaskMemFree(url);
323 }else if(exurl) {
324 LPOLESTR url;
325
326 ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
327
328 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
329 ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
330
331 ok(!lstrcmpW(url, exurl), "unexpected url\n");
332 ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
333
334 CoTaskMemFree(url);
335 }else {
336 ok(hres == E_UNEXPECTED,
337 "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
338 ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
339 ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
340 }
341
342 SysFreeString(doc_url);
343 IHTMLDocument_Release(doc);
344 if(mon && mon != (void*)0xdeadbeef)
345 IMoniker_Release(mon);
346 }
347
348 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
349
350 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
351 {
352 *ppv = NULL;
353
354 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
355 *ppv = iface;
356 return S_OK;
357 }
358
359 if(IsEqualGUID(&IID_IProxyManager, riid))
360 return E_NOINTERFACE; /* TODO */
361 if(IsEqualGUID(&IID_IDispatchEx, riid))
362 return E_NOINTERFACE; /* TODO */
363 if(IsEqualGUID(&IID_External_unk, riid))
364 return E_NOINTERFACE; /* TODO */
365
366 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
367 return E_NOINTERFACE;
368 }
369
370 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
371 {
372 return 2;
373 }
374
375 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
376 {
377 return 1;
378 }
379
380 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
381 {
382 ok(0, "unexpected call\n");
383 return E_NOTIMPL;
384 }
385
386 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
387 ITypeInfo **ppTInfo)
388 {
389 ok(0, "unexpected call\n");
390 return E_NOTIMPL;
391 }
392
393 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
394 UINT cNames, LCID lcid, DISPID *rgDispId)
395 {
396 ok(0, "unexpected call\n");
397 return E_NOTIMPL;
398 }
399
400 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
401 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
402 EXCEPINFO *pExcepInfo, UINT *puArgErr)
403 {
404 ok(0, "unexpected call\n");
405 return E_NOTIMPL;
406 }
407
408 static const IDispatchVtbl ExternalVtbl = {
409 External_QueryInterface,
410 Dispatch_AddRef,
411 Dispatch_Release,
412 Dispatch_GetTypeInfoCount,
413 Dispatch_GetTypeInfo,
414 Dispatch_GetIDsOfNames,
415 External_Invoke
416 };
417
418 static IDispatch External = { &ExternalVtbl };
419
420 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
421 {
422 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
423 *ppv = iface;
424 return S_OK;
425 }
426
427 *ppv = NULL;
428 return E_NOINTERFACE;
429 }
430
431 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
432 {
433 return 2;
434 }
435
436 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
437 {
438 return 1;
439 }
440
441 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
442 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
443 DWORD grfPI, HANDLE_PTR dwReserved)
444 {
445 BINDINFO bindinfo;
446 DWORD bindf = 0;
447 HRESULT hres;
448
449 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
450 static const WCHAR empty_str = {0};
451
452 CHECK_EXPECT(Start);
453
454 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
455 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
456 ok(!grfPI, "grfPI = %x\n", grfPI);
457 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
458
459 memset(&bindinfo, 0, sizeof(bindinfo));
460 bindinfo.cbSize = sizeof(bindinfo);
461 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
462 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
463 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
464 "bindf = %x\n", bindf);
465
466 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
467 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
468 /* TODO: test stgmedData */
469 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
470 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
471 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
472 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
473 ok(bindinfo.dwOptions == 0x80000 ||
474 bindinfo.dwOptions == 0x4080000, /* win2k3 */
475 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
476 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
477 /* TODO: test dwCodePage */
478 /* TODO: test securityAttributes */
479 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
480 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
481 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
482
483 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
484 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
485 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
486
487 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
488 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
489 ok(hres == S_OK,
490 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
491
492 hres = IInternetProtocolSink_ReportData(pOIProtSink,
493 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
494 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
495
496 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
497 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
498
499 return S_OK;
500 }
501
502 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
503 PROTOCOLDATA *pProtocolData)
504 {
505 ok(0, "unexpected call\n");
506 return E_NOTIMPL;
507 }
508
509 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
510 DWORD dwOptions)
511 {
512 ok(0, "unexpected call\n");
513 return E_NOTIMPL;
514 }
515
516 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
517 {
518 CHECK_EXPECT(Terminate);
519 return S_OK;
520 }
521
522 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
523 {
524 ok(0, "unexpected call\n");
525 return E_NOTIMPL;
526 }
527
528 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
529 {
530 ok(0, "unexpected call\n");
531 return E_NOTIMPL;
532 }
533
534 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
535 ULONG cb, ULONG *pcbRead)
536 {
537 CHECK_EXPECT2(Protocol_Read);
538
539 ok(pv != NULL, "pv == NULL\n");
540 ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
541 ok(pcbRead != NULL, "pcbRead == NULL\n");
542 ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
543
544 if(protocol_read)
545 return S_FALSE;
546
547 protocol_read += *pcbRead = sizeof(css_data)-1;
548 memcpy(pv, css_data, sizeof(css_data)-1);
549 return S_OK;
550 }
551
552 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
553 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
554 {
555 ok(0, "unexpected call\n");
556 return E_NOTIMPL;
557 }
558
559 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
560 {
561 CHECK_EXPECT(LockRequest);
562 return S_OK;
563 }
564
565 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
566 {
567 CHECK_EXPECT(UnlockRequest);
568 return S_OK;
569 }
570
571 static const IInternetProtocolVtbl ProtocolVtbl = {
572 Protocol_QueryInterface,
573 Protocol_AddRef,
574 Protocol_Release,
575 Protocol_Start,
576 Protocol_Continue,
577 Protocol_Abort,
578 Protocol_Terminate,
579 Protocol_Suspend,
580 Protocol_Resume,
581 Protocol_Read,
582 Protocol_Seek,
583 Protocol_LockRequest,
584 Protocol_UnlockRequest
585 };
586
587 static IInternetProtocol Protocol = { &ProtocolVtbl };
588
589 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
590 {
591 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
592 ok(0, "unexpected call\n");
593 return E_NOINTERFACE;
594 }
595
596 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
597 {
598 return 2;
599 }
600
601 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
602 {
603 return 1;
604 }
605
606 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
607 REFIID riid, void **ppv)
608 {
609 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
610 return E_NOINTERFACE;
611
612 CHECK_EXPECT(CreateInstance);
613 ok(ppv != NULL, "ppv == NULL\n");
614
615 *ppv = &Protocol;
616 return S_OK;
617 }
618
619 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
620 {
621 ok(0, "unexpected call\n");
622 return S_OK;
623 }
624
625 static const IClassFactoryVtbl ClassFactoryVtbl = {
626 ClassFactory_QueryInterface,
627 ClassFactory_AddRef,
628 ClassFactory_Release,
629 ClassFactory_CreateInstance,
630 ClassFactory_LockServer
631 };
632
633 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
634
635 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
636 {
637 ok(0, "unexpected call\n");
638 return E_NOTIMPL;
639 }
640
641 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
642 {
643 return 2;
644 }
645
646 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
647 {
648 return 1;
649 }
650
651 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
652 IHlinkBrowseContext *pihlbc)
653 {
654 ok(0, "unexpected call\n");
655 return E_NOTIMPL;
656 }
657
658 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
659 IHlinkBrowseContext **ppihlbc)
660 {
661 ok(0, "unexpected call\n");
662 return E_NOTIMPL;
663 }
664
665 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
666 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
667 {
668 HRESULT hres;
669
670 CHECK_EXPECT(Navigate);
671
672 ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
673 ok(pbc != NULL, "pbc == NULL\n");
674 ok(pibsc != NULL, "pubsc == NULL\n");
675 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
676
677 if(pihlNavigate) {
678 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
679 LPWSTR location = (LPWSTR)0xdeadbeef;
680 IHlinkSite *site;
681 IMoniker *mon = NULL;
682 DWORD site_data = 0xdeadbeef;
683
684 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
685 todo_wine
686 ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
687 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
688
689 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
690 ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
691 ok(location == NULL, "location = %p\n", location);
692 ok(mon != NULL, "mon == NULL\n");
693
694 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
695 ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
696 ok(site == NULL, "site = %p\n, expected NULL\n", site);
697 todo_wine
698 ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
699 }
700
701 return S_OK;
702 }
703
704 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
705 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
706 {
707 ok(0, "unexpected call\n");
708 return E_NOTIMPL;
709 }
710
711 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
712 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
713 {
714 ok(0, "unexpected call\n");
715 return E_NOTIMPL;
716 }
717
718 static const IHlinkFrameVtbl HlinkFrameVtbl = {
719 HlinkFrame_QueryInterface,
720 HlinkFrame_AddRef,
721 HlinkFrame_Release,
722 HlinkFrame_SetBrowseContext,
723 HlinkFrame_GetBrowseContext,
724 HlinkFrame_Navigate,
725 HlinkFrame_OnNavigate,
726 HlinkFrame_UpdateHlink
727 };
728
729 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
730
731 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
732 REFIID riid, void**ppv)
733 {
734 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
735 *ppv = iface;
736 return S_OK;
737 }
738
739 ok(0, "unexpected call\n");
740 return E_NOINTERFACE;
741 }
742
743 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
744 {
745 return 2;
746 }
747
748 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
749 {
750 return 1;
751 }
752
753 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
754 {
755 switch(dispID) {
756 case DISPID_READYSTATE:
757 CHECK_EXPECT2(OnChanged_READYSTATE);
758
759 if(readystate_set_interactive) {
760 readystate_set_interactive = FALSE;
761 load_state = LD_INTERACTIVE;
762 }
763 else
764 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
765 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
766 ? OLECMDF_ENABLED : 0));
767
768 if(readystate_set_loading) {
769 readystate_set_loading = FALSE;
770 load_state = LD_LOADING;
771 }
772 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
773 test_readyState(NULL);
774 return S_OK;
775 case 1005:
776 CHECK_EXPECT(OnChanged_1005);
777 if(!editmode)
778 test_readyState(NULL);
779 readystate_set_interactive = (load_state != LD_INTERACTIVE);
780 return S_OK;
781 case 1012:
782 CHECK_EXPECT(OnChanged_1012);
783 return S_OK;
784 case 1030:
785 case 3000029:
786 case 3000030:
787 /* TODO */
788 return S_OK;
789 }
790
791 ok(0, "unexpected id %d\n", dispID);
792 return E_NOTIMPL;
793 }
794
795 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
796 {
797 ok(0, "unexpected call\n");
798 return E_NOTIMPL;
799 }
800
801 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
802 PropertyNotifySink_QueryInterface,
803 PropertyNotifySink_AddRef,
804 PropertyNotifySink_Release,
805 PropertyNotifySink_OnChanged,
806 PropertyNotifySink_OnRequestEdit
807 };
808
809 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
810
811 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
812 {
813 ok(0, "unexpected call\n");
814 return E_NOINTERFACE;
815 }
816
817 static ULONG WINAPI Stream_AddRef(IStream *iface)
818 {
819 return 2;
820 }
821
822 static ULONG WINAPI Stream_Release(IStream *iface)
823 {
824 return 1;
825 }
826
827 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
828 ULONG cb, ULONG *pcbRead)
829 {
830 CHECK_EXPECT2(Read);
831 ok(pv != NULL, "pv == NULL\n");
832 ok(cb > sizeof(html_page), "cb = %d\n", cb);
833 ok(pcbRead != NULL, "pcbRead == NULL\n");
834 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
835
836 if(stream_read)
837 return S_FALSE;
838
839 memcpy(pv, html_page, sizeof(html_page)-1);
840 stream_read += *pcbRead = sizeof(html_page)-1;
841 return S_OK;
842 }
843
844 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
845 ULONG cb, ULONG *pcbWritten)
846 {
847 ok(0, "unexpected call\n");
848 return E_NOTIMPL;
849 }
850
851 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
852 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
853 {
854 ok(0, "unexpected call\n");
855 return E_NOTIMPL;
856 }
857
858 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
859 {
860 ok(0, "unexpected call\n");
861 return E_NOTIMPL;
862 }
863
864 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
865 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
866 {
867 ok(0, "unexpected call\n");
868 return E_NOTIMPL;
869 }
870
871 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
872 {
873 ok(0, "unexpected call\n");
874 return E_NOTIMPL;
875 }
876
877 static HRESULT WINAPI Stream_Revert(IStream *iface)
878 {
879 ok(0, "unexpected call\n");
880 return E_NOTIMPL;
881 }
882
883 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
884 ULARGE_INTEGER cb, DWORD dwLockType)
885 {
886 ok(0, "unexpected call\n");
887 return E_NOTIMPL;
888 }
889
890 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
891 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
892 {
893 ok(0, "unexpected call\n");
894 return E_NOTIMPL;
895 }
896
897 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
898 DWORD dwStatFlag)
899 {
900 ok(0, "unexpected call\n");
901 return E_NOTIMPL;
902 }
903
904 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
905 {
906 ok(0, "unexpected call\n");
907 return E_NOTIMPL;
908 }
909
910 static const IStreamVtbl StreamVtbl = {
911 Stream_QueryInterface,
912 Stream_AddRef,
913 Stream_Release,
914 Stream_Read,
915 Stream_Write,
916 Stream_Seek,
917 Stream_SetSize,
918 Stream_CopyTo,
919 Stream_Commit,
920 Stream_Revert,
921 Stream_LockRegion,
922 Stream_UnlockRegion,
923 Stream_Stat,
924 Stream_Clone
925 };
926
927 static IStream Stream = { &StreamVtbl };
928
929 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
930 {
931 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
932 return E_NOINTERFACE; /* TODO */
933
934 if(IsEqualGUID(&IID_IWinInetInfo, riid))
935 return E_NOINTERFACE; /* TODO */
936
937 ok(0, "unexpected call\n");
938 return E_NOINTERFACE;
939 }
940
941 static ULONG WINAPI Binding_AddRef(IBinding *iface)
942 {
943 return 2;
944 }
945
946 static ULONG WINAPI Binding_Release(IBinding *iface)
947 {
948 return 1;
949 }
950
951 static HRESULT WINAPI Binding_Abort(IBinding *iface)
952 {
953 CHECK_EXPECT(Abort);
954 return S_OK;
955 }
956
957 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
958 {
959 ok(0, "unexpected call\n");
960 return E_NOTIMPL;
961 }
962
963 static HRESULT WINAPI Binding_Resume(IBinding *iface)
964 {
965 ok(0, "unexpected call\n");
966 return E_NOTIMPL;
967 }
968
969 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
970 {
971 ok(0, "unexpected call\n");
972 return E_NOTIMPL;
973 }
974
975 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
976 {
977 ok(0, "unexpected call\n");
978 return E_NOTIMPL;
979 }
980
981 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
982 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
983 {
984 CHECK_EXPECT(GetBindResult);
985 return E_NOTIMPL;
986 }
987
988 static const IBindingVtbl BindingVtbl = {
989 Binding_QueryInterface,
990 Binding_AddRef,
991 Binding_Release,
992 Binding_Abort,
993 Binding_Suspend,
994 Binding_Resume,
995 Binding_SetPriority,
996 Binding_GetPriority,
997 Binding_GetBindResult
998 };
999
1000 static IBinding Binding = { &BindingVtbl };
1001
1002 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
1003 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
1004
1005 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
1006 {
1007 *ppv = NULL;
1008
1009 if(IsEqualGUID(&IID_IMoniker_unk, riid))
1010 return E_NOINTERFACE; /* TODO */
1011 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
1012 return E_NOINTERFACE; /* TODO */
1013
1014 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
1015 return E_NOINTERFACE;
1016 }
1017
1018 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
1019 {
1020 return 2;
1021 }
1022
1023 static ULONG WINAPI Moniker_Release(IMoniker *iface)
1024 {
1025 return 1;
1026 }
1027
1028 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
1029 {
1030 CHECK_EXPECT(GetClassID);
1031 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
1032 return E_FAIL;
1033 }
1034
1035 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
1036 {
1037 ok(0, "unexpected call\n");
1038 return E_NOTIMPL;
1039 }
1040
1041 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1042 {
1043 ok(0, "unexpected call\n");
1044 return E_NOTIMPL;
1045 }
1046
1047 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1048 {
1049 ok(0, "unexpected call\n");
1050 return E_NOTIMPL;
1051 }
1052
1053 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1054 {
1055 ok(0, "unexpected call\n");
1056 return E_NOTIMPL;
1057 }
1058
1059 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1060 REFIID riidResult, void **ppvResult)
1061 {
1062 ok(0, "unexpected call\n");
1063 return E_NOTIMPL;
1064 }
1065
1066 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1067 REFIID riid, void **ppv)
1068 {
1069 IBindStatusCallback *callback = NULL;
1070 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1071 STGMEDIUM stgmedium;
1072 BINDINFO bindinfo;
1073 DWORD bindf;
1074 HRESULT hres;
1075
1076 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1077 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1078
1079 CHECK_EXPECT(BindToStorage);
1080
1081 load_state = LD_LOADING;
1082
1083 ok(pbc != NULL, "pbc == NULL\n");
1084 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1085 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1086 ok(ppv != NULL, "ppv == NULL\n");
1087 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1088
1089 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1090 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1091 ok(callback != NULL, "callback == NULL\n");
1092
1093 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1094 bindinfo.cbSize = sizeof(bindinfo);
1095
1096 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1097 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1098 ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
1099 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
1100 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1101 /* TODO: test stgmedData */
1102 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
1103 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
1104 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1105 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
1106 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
1107 "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
1108 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
1109 /* TODO: test dwCodePage */
1110 /* TODO: test securityAttributes */
1111 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1112 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1113 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
1114
1115 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1116 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
1117
1118 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1119 wszTextHtml);
1120 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1121
1122 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1123 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1124 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1125
1126 SET_EXPECT(Read);
1127 stgmedium.tymed = TYMED_ISTREAM;
1128 U(stgmedium).pstm = &Stream;
1129 stgmedium.pUnkForRelease = (IUnknown*)iface;
1130 hres = IBindStatusCallback_OnDataAvailable(callback,
1131 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1132 sizeof(html_page)-1, &formatetc, &stgmedium);
1133 ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1134 CHECK_CALLED(Read);
1135
1136 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1137 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1138 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1139
1140 SET_EXPECT(GetBindResult);
1141 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1142 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1143 SET_CALLED(GetBindResult); /* IE7 */
1144
1145 IBindStatusCallback_Release(callback);
1146
1147 return S_OK;
1148 }
1149
1150 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1151 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1152 {
1153 ok(0, "unexpected call\n");
1154 return E_NOTIMPL;
1155 }
1156
1157 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1158 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1159 {
1160 ok(0, "unexpected call\n");
1161 return E_NOTIMPL;
1162 }
1163
1164 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1165 {
1166 ok(0, "unexpected call\n");
1167 return E_NOTIMPL;
1168 }
1169
1170 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1171 {
1172 ok(0, "unexpected call\n");
1173 return E_NOTIMPL;
1174 }
1175
1176 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1177 {
1178 ok(0, "unexpected call\n");
1179 return E_NOTIMPL;
1180 }
1181
1182 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1183 IMoniker *pmkNewlyRunning)
1184 {
1185 ok(0, "unexpected call\n");
1186 return E_NOTIMPL;
1187 }
1188
1189 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1190 IMoniker *pmkToLeft, FILETIME *pFileTime)
1191 {
1192 ok(0, "unexpected call\n");
1193 return E_NOTIMPL;
1194 }
1195
1196 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1197 {
1198 ok(0, "unexpected call\n");
1199 return E_NOTIMPL;
1200 }
1201
1202 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1203 IMoniker **ppmkPrefix)
1204 {
1205 ok(0, "unexpected call\n");
1206 return E_NOTIMPL;
1207 }
1208
1209 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1210 IMoniker **pmkRelPath)
1211 {
1212 ok(0, "unexpected call\n");
1213 return E_NOTIMPL;
1214 }
1215
1216 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1217 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1218 {
1219 CHECK_EXPECT2(GetDisplayName);
1220
1221 /* ok(pbc != NULL, "pbc == NULL\n"); */
1222 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1223 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1224
1225 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1226 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1227
1228 return S_OK;
1229 }
1230
1231 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1232 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1233 {
1234 ok(0, "unexpected call\n");
1235 return E_NOTIMPL;
1236 }
1237
1238 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1239 {
1240 CHECK_EXPECT(IsSystemMoniker);
1241 return E_NOTIMPL;
1242 }
1243
1244 static const IMonikerVtbl MonikerVtbl = {
1245 Moniker_QueryInterface,
1246 Moniker_AddRef,
1247 Moniker_Release,
1248 Moniker_GetClassID,
1249 Moniker_IsDirty,
1250 Moniker_Load,
1251 Moniker_Save,
1252 Moniker_GetSizeMax,
1253 Moniker_BindToObject,
1254 Moniker_BindToStorage,
1255 Moniker_Reduce,
1256 Moniker_ComposeWith,
1257 Moniker_Enum,
1258 Moniker_IsEqual,
1259 Moniker_Hash,
1260 Moniker_IsRunning,
1261 Moniker_GetTimeOfLastChange,
1262 Moniker_Inverse,
1263 Moniker_CommonPrefixWith,
1264 Moniker_RelativePathTo,
1265 Moniker_GetDisplayName,
1266 Moniker_ParseDisplayName,
1267 Moniker_IsSystemMoniker
1268 };
1269
1270 static IMoniker Moniker = { &MonikerVtbl };
1271
1272 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1273 {
1274 return QueryInterface(riid, ppv);
1275 }
1276
1277 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1278 {
1279 return 2;
1280 }
1281
1282 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1283 {
1284 return 1;
1285 }
1286
1287 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1288 LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1289 {
1290 ok(0, "unexpected call\n");
1291 return E_NOTIMPL;
1292 }
1293
1294 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1295 IEnumUnknown **ppenum)
1296 {
1297 ok(0, "unexpected call\n");
1298 return E_NOTIMPL;
1299 }
1300
1301 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1302 {
1303 CHECK_EXPECT(LockContainer);
1304 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1305 return S_OK;
1306 }
1307
1308 static const IOleContainerVtbl OleContainerVtbl = {
1309 OleContainer_QueryInterface,
1310 OleContainer_AddRef,
1311 OleContainer_Release,
1312 OleContainer_ParseDisplayName,
1313 OleContainer_EnumObjects,
1314 OleContainer_LockContainer
1315 };
1316
1317 static IOleContainer OleContainer = { &OleContainerVtbl };
1318
1319 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1320 {
1321 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1322
1323 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1324 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1325
1326 *ppv = NULL;
1327 return E_NOINTERFACE;
1328 }
1329
1330 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1331 {
1332 return 2;
1333 }
1334
1335 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1336 {
1337 return 1;
1338 }
1339
1340 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1341 {
1342 CHECK_EXPECT(Frame_GetWindow);
1343 return E_NOTIMPL;
1344 }
1345
1346 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1347 {
1348 ok(0, "unexpected call\n");
1349 return E_NOTIMPL;
1350 }
1351
1352 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1353 {
1354 ok(0, "unexpected call\n");
1355 return E_NOTIMPL;
1356 }
1357
1358 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1359 LPCBORDERWIDTHS pborderwidths)
1360 {
1361 ok(0, "unexpected call\n");
1362 return E_NOTIMPL;
1363 }
1364
1365 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1366 LPCBORDERWIDTHS pborderwidths)
1367 {
1368 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1369 return S_OK;
1370 }
1371
1372 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1373 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1374 {
1375 static const WCHAR wszHTML_Document[] =
1376 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1377
1378 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1379
1380 if(expect_InPlaceUIWindow_SetActiveObject_active) {
1381 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1382 if(pActiveObject && is_english())
1383 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1384 }
1385 else {
1386 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1387 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1388 }
1389 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1390 return S_OK;
1391 }
1392
1393 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1394 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1395 {
1396 static const WCHAR wszHTML_Document[] =
1397 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1398
1399 if(pActiveObject) {
1400 CHECK_EXPECT2(SetActiveObject);
1401
1402 if(pActiveObject && is_english())
1403 ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1404 }else {
1405 CHECK_EXPECT(SetActiveObject_null);
1406
1407 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1408 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1409 }
1410
1411 return S_OK;
1412 }
1413
1414 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1415 LPOLEMENUGROUPWIDTHS lpMenuWidths)
1416 {
1417 ok(0, "unexpected call\n");
1418 return E_NOTIMPL;
1419 }
1420
1421 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1422 HOLEMENU holemenu, HWND hwndActiveObject)
1423 {
1424 ok(0, "unexpected call\n");
1425 return E_NOTIMPL;
1426 }
1427
1428 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1429 {
1430 ok(0, "unexpected call\n");
1431 return E_NOTIMPL;
1432 }
1433
1434 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1435 {
1436 CHECK_EXPECT2(SetStatusText);
1437 if(!expect_status_text)
1438 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1439 return S_OK;
1440 }
1441
1442 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1443 {
1444 if(fEnable)
1445 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
1446 else
1447 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
1448 return E_NOTIMPL;
1449 }
1450
1451 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1452 {
1453 ok(0, "unexpected call\n");
1454 return E_NOTIMPL;
1455 }
1456
1457 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1458 InPlaceFrame_QueryInterface,
1459 InPlaceFrame_AddRef,
1460 InPlaceFrame_Release,
1461 InPlaceFrame_GetWindow,
1462 InPlaceFrame_ContextSensitiveHelp,
1463 InPlaceFrame_GetBorder,
1464 InPlaceFrame_RequestBorderSpace,
1465 InPlaceFrame_SetBorderSpace,
1466 InPlaceFrame_SetActiveObject,
1467 InPlaceFrame_InsertMenus,
1468 InPlaceFrame_SetMenu,
1469 InPlaceFrame_RemoveMenus,
1470 InPlaceFrame_SetStatusText,
1471 InPlaceFrame_EnableModeless,
1472 InPlaceFrame_TranslateAccelerator
1473 };
1474
1475 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1476
1477 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1478 InPlaceFrame_QueryInterface,
1479 InPlaceFrame_AddRef,
1480 InPlaceFrame_Release,
1481 InPlaceFrame_GetWindow,
1482 InPlaceFrame_ContextSensitiveHelp,
1483 InPlaceFrame_GetBorder,
1484 InPlaceFrame_RequestBorderSpace,
1485 InPlaceFrame_SetBorderSpace,
1486 InPlaceUIWindow_SetActiveObject,
1487 };
1488
1489 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1490
1491 static HRESULT WINAPI InPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
1492 {
1493 return QueryInterface(riid, ppv);
1494 }
1495
1496 static ULONG WINAPI InPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
1497 {
1498 return 2;
1499 }
1500
1501 static ULONG WINAPI InPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
1502 {
1503 return 1;
1504 }
1505
1506 static HRESULT WINAPI InPlaceSiteWindowless_GetWindow(
1507 IOleInPlaceSiteWindowless *iface, HWND *phwnd)
1508 {
1509 CHECK_EXPECT2(GetWindow);
1510 ok(phwnd != NULL, "phwnd = NULL\n");
1511 *phwnd = container_hwnd;
1512 return S_OK;
1513 }
1514
1515 static HRESULT WINAPI InPlaceSiteWindowless_ContextSensitiveHelp(
1516 IOleInPlaceSiteWindowless *iface, BOOL fEnterMode)
1517 {
1518 ok(0, "unexpected call\n");
1519 return E_NOTIMPL;
1520 }
1521
1522 static HRESULT WINAPI InPlaceSiteWindowless_CanInPlaceActivate(
1523 IOleInPlaceSiteWindowless *iface)
1524 {
1525 CHECK_EXPECT(CanInPlaceActivate);
1526 return S_OK;
1527 }
1528
1529 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivate(
1530 IOleInPlaceSiteWindowless *iface)
1531 {
1532 CHECK_EXPECT(OnInPlaceActivate);
1533 inplace_deactivated = FALSE;
1534 return S_OK;
1535 }
1536
1537 static HRESULT WINAPI InPlaceSiteWindowless_OnUIActivate(
1538 IOleInPlaceSiteWindowless *iface)
1539 {
1540 CHECK_EXPECT(OnUIActivate);
1541 return S_OK;
1542 }
1543
1544 static HRESULT WINAPI InPlaceSiteWindowless_GetWindowContext(
1545 IOleInPlaceSiteWindowless *iface, IOleInPlaceFrame **ppFrame,
1546 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1547 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1548 {
1549 static const RECT rect = {0,0,500,500};
1550
1551 CHECK_EXPECT(GetWindowContext);
1552
1553 ok(ppFrame != NULL, "ppFrame = NULL\n");
1554 if(ppFrame)
1555 *ppFrame = &InPlaceFrame;
1556 ok(ppDoc != NULL, "ppDoc = NULL\n");
1557 if(ppDoc)
1558 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1559 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1560 if(lprcPosRect)
1561 memcpy(lprcPosRect, &rect, sizeof(RECT));
1562 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1563 if(lprcClipRect)
1564 memcpy(lprcClipRect, &rect, sizeof(RECT));
1565 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1566 if(lpFrameInfo) {
1567 lpFrameInfo->cb = sizeof(*lpFrameInfo);
1568 lpFrameInfo->fMDIApp = FALSE;
1569 lpFrameInfo->hwndFrame = container_hwnd;
1570 lpFrameInfo->haccel = NULL;
1571 lpFrameInfo->cAccelEntries = 0;
1572 }
1573
1574 return S_OK;
1575 }
1576
1577 static HRESULT WINAPI InPlaceSiteWindowless_Scroll(
1578 IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
1579 {
1580 ok(0, "unexpected call\n");
1581 return E_NOTIMPL;
1582 }
1583
1584 static HRESULT WINAPI InPlaceSiteWindowless_OnUIDeactivate(
1585 IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
1586 {
1587 CHECK_EXPECT(OnUIDeactivate);
1588 ok(!fUndoable, "fUndoable = TRUE\n");
1589 return S_OK;
1590 }
1591
1592 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivate(
1593 IOleInPlaceSiteWindowless *iface)
1594 {
1595 CHECK_EXPECT(OnInPlaceDeactivate);
1596 inplace_deactivated = TRUE;
1597 return S_OK;
1598 }
1599
1600 static HRESULT WINAPI InPlaceSiteWindowless_DiscardUndoState(
1601 IOleInPlaceSiteWindowless *iface)
1602 {
1603 ok(0, "unexpected call\n");
1604 return E_NOTIMPL;
1605 }
1606
1607 static HRESULT WINAPI InPlaceSiteWindowless_DeactivateAndUndo(
1608 IOleInPlaceSiteWindowless *iface)
1609 {
1610 ok(0, "unexpected call\n");
1611 return E_NOTIMPL;
1612 }
1613
1614 static HRESULT WINAPI InPlaceSiteWindowless_OnPosRectChange(
1615 IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
1616 {
1617 ok(0, "unexpected call\n");
1618 return E_NOTIMPL;
1619 }
1620
1621 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivateEx(
1622 IOleInPlaceSiteWindowless *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1623 {
1624 CHECK_EXPECT(OnInPlaceActivateEx);
1625
1626 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1627 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1628 ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1629
1630 return S_OK;
1631 }
1632
1633 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivateEx(
1634 IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
1635 {
1636 CHECK_EXPECT(OnInPlaceDeactivateEx);
1637
1638 ok(fNoRedraw, "fNoRedraw == FALSE\n");
1639
1640 return S_OK;
1641 }
1642
1643 static HRESULT WINAPI InPlaceSiteWindowless_RequestUIActivate(
1644 IOleInPlaceSiteWindowless *iface)
1645 {
1646 CHECK_EXPECT2(RequestUIActivate);
1647 return S_OK;
1648 }
1649
1650 static HRESULT WINAPI InPlaceSiteWindowless_CanWindowlessActivate(
1651 IOleInPlaceSiteWindowless *iface)
1652 {
1653 ok(0, "unexpected call\n");
1654 return E_NOTIMPL;
1655 }
1656
1657 static HRESULT WINAPI InPlaceSiteWindowless_GetCapture(
1658 IOleInPlaceSiteWindowless *iface)
1659 {
1660 ok(0, "unexpected call\n");
1661 return E_NOTIMPL;
1662 }
1663
1664 static HRESULT WINAPI InPlaceSiteWindowless_SetCapture(
1665 IOleInPlaceSiteWindowless *iface, BOOL fCapture)
1666 {
1667 ok(0, "unexpected call\n");
1668 return E_NOTIMPL;
1669 }
1670
1671 static HRESULT WINAPI InPlaceSiteWindowless_GetFocus(
1672 IOleInPlaceSiteWindowless *iface)
1673 {
1674 ok(0, "unexpected call\n");
1675 return E_NOTIMPL;
1676 }
1677
1678 static HRESULT WINAPI InPlaceSiteWindowless_SetFocus(
1679 IOleInPlaceSiteWindowless *iface, BOOL fFocus)
1680 {
1681 ok(0, "unexpected call\n");
1682 return E_NOTIMPL;
1683 }
1684
1685 static HRESULT WINAPI InPlaceSiteWindowless_GetDC(
1686 IOleInPlaceSiteWindowless *iface, LPCRECT pRect,
1687 DWORD grfFlags, HDC *phDC)
1688 {
1689 ok(0, "unexpected call\n");
1690 return E_NOTIMPL;
1691 }
1692
1693 static HRESULT WINAPI InPlaceSiteWindowless_ReleaseDC(
1694 IOleInPlaceSiteWindowless *iface, HDC hDC)
1695 {
1696 ok(0, "unexpected call\n");
1697 return E_NOTIMPL;
1698 }
1699
1700 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRect(
1701 IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
1702 {
1703 ok(0, "unexpected call\n");
1704 return E_NOTIMPL;
1705 }
1706
1707 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRgn(
1708 IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
1709 {
1710 ok(0, "unexpected call\n");
1711 return E_NOTIMPL;
1712 }
1713
1714 static HRESULT WINAPI InPlaceSiteWindowless_ScrollRect(
1715 IOleInPlaceSiteWindowless *iface, INT dx, INT dy,
1716 LPCRECT pRectScroll, LPCRECT pRectClip)
1717 {
1718 ok(0, "unexpected call\n");
1719 return E_NOTIMPL;
1720 }
1721
1722 static HRESULT WINAPI InPlaceSiteWindowless_AdjustRect(
1723 IOleInPlaceSiteWindowless *iface, LPRECT prc)
1724 {
1725 ok(0, "unexpected call\n");
1726 return E_NOTIMPL;
1727 }
1728
1729 static HRESULT WINAPI InPlaceSiteWindowless_OnDefWindowMessage(
1730 IOleInPlaceSiteWindowless *iface, UINT msg,
1731 WPARAM wParam, LPARAM lParam, LRESULT *plResult)
1732 {
1733 ok(0, "unexpected call\n");
1734 return E_NOTIMPL;
1735 }
1736
1737 static const IOleInPlaceSiteWindowlessVtbl InPlaceSiteWindowlessVtbl = {
1738 InPlaceSiteWindowless_QueryInterface,
1739 InPlaceSiteWindowless_AddRef,
1740 InPlaceSiteWindowless_Release,
1741 InPlaceSiteWindowless_GetWindow,
1742 InPlaceSiteWindowless_ContextSensitiveHelp,
1743 InPlaceSiteWindowless_CanInPlaceActivate,
1744 InPlaceSiteWindowless_OnInPlaceActivate,
1745 InPlaceSiteWindowless_OnUIActivate,
1746 InPlaceSiteWindowless_GetWindowContext,
1747 InPlaceSiteWindowless_Scroll,
1748 InPlaceSiteWindowless_OnUIDeactivate,
1749 InPlaceSiteWindowless_OnInPlaceDeactivate,
1750 InPlaceSiteWindowless_DiscardUndoState,
1751 InPlaceSiteWindowless_DeactivateAndUndo,
1752 InPlaceSiteWindowless_OnPosRectChange,
1753 InPlaceSiteWindowless_OnInPlaceActivateEx,
1754 InPlaceSiteWindowless_OnInPlaceDeactivateEx,
1755 InPlaceSiteWindowless_RequestUIActivate,
1756 InPlaceSiteWindowless_CanWindowlessActivate,
1757 InPlaceSiteWindowless_GetCapture,
1758 InPlaceSiteWindowless_SetCapture,
1759 InPlaceSiteWindowless_GetFocus,
1760 InPlaceSiteWindowless_SetFocus,
1761 InPlaceSiteWindowless_GetDC,
1762 InPlaceSiteWindowless_ReleaseDC,
1763 InPlaceSiteWindowless_InvalidateRect,
1764 InPlaceSiteWindowless_InvalidateRgn,
1765 InPlaceSiteWindowless_ScrollRect,
1766 InPlaceSiteWindowless_AdjustRect,
1767 InPlaceSiteWindowless_OnDefWindowMessage
1768 };
1769
1770 static IOleInPlaceSiteWindowless InPlaceSiteWindowless = { &InPlaceSiteWindowlessVtbl };
1771
1772 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1773 {
1774 return QueryInterface(riid, ppv);
1775 }
1776
1777 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1778 {
1779 return 2;
1780 }
1781
1782 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1783 {
1784 return 1;
1785 }
1786
1787 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1788 {
1789 ok(0, "unexpected call\n");
1790 return E_NOTIMPL;
1791 }
1792
1793 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1794 IMoniker **ppmon)
1795 {
1796 ok(0, "unexpected call\n");
1797 return E_NOTIMPL;
1798 }
1799
1800 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1801 {
1802 CHECK_EXPECT(GetContainer);
1803 ok(ppContainer != NULL, "ppContainer = NULL\n");
1804 *ppContainer = &OleContainer;
1805 return S_OK;
1806 }
1807
1808 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1809 {
1810 ok(0, "unexpected call\n");
1811 return E_NOTIMPL;
1812 }
1813
1814 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1815 {
1816 ok(0, "unexpected call\n");
1817 return E_NOTIMPL;
1818 }
1819
1820 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1821 {
1822 ok(0, "unexpected call\n");
1823 return E_NOTIMPL;
1824 }
1825
1826 static const IOleClientSiteVtbl ClientSiteVtbl = {
1827 ClientSite_QueryInterface,
1828 ClientSite_AddRef,
1829 ClientSite_Release,
1830 ClientSite_SaveObject,
1831 ClientSite_GetMoniker,
1832 ClientSite_GetContainer,
1833 ClientSite_ShowObject,
1834 ClientSite_OnShowWindow,
1835 ClientSite_RequestNewObjectLayout
1836 };
1837
1838 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1839
1840 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1841 {
1842 return QueryInterface(riid, ppv);
1843 }
1844
1845 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1846 {
1847 return 2;
1848 }
1849
1850 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1851 {
1852 return 1;
1853 }
1854
1855 typedef enum
1856 {
1857 CallUIActivate_None,
1858 CallUIActivate_ActivateMe,
1859 CallUIActivate_AfterShow,
1860 } CallUIActivate;
1861
1862 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1863 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1864 {
1865 IOleDocument *document;
1866 HRESULT hres;
1867
1868 CHECK_EXPECT(ActivateMe);
1869 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1870
1871 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1872 ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1873
1874 if(SUCCEEDED(hres)) {
1875 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteWindowless, NULL, 0, &view);
1876 ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1877
1878 if(SUCCEEDED(hres)) {
1879 IOleInPlaceActiveObject *activeobj = NULL;
1880 IOleInPlaceSite *inplacesite = NULL;
1881 HWND tmp_hwnd = NULL;
1882 static RECT rect = {0,0,400,500};
1883
1884 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1885 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1886 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
1887 inplacesite, &InPlaceSiteWindowless);
1888
1889 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteWindowless);
1890 ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1891
1892 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1893 ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1894 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
1895 inplacesite, &InPlaceSiteWindowless);
1896
1897 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1898 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1899
1900 if(activeobj) {
1901 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1902 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1903 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1904 }
1905
1906 if(call_UIActivate == CallUIActivate_ActivateMe) {
1907 SET_EXPECT(CanInPlaceActivate);
1908 SET_EXPECT(GetWindowContext);
1909 SET_EXPECT(GetWindow);
1910 if(ipsex)
1911 SET_EXPECT(OnInPlaceActivateEx);
1912 else
1913 SET_EXPECT(OnInPlaceActivate);
1914 SET_EXPECT(SetStatusText);
1915 SET_EXPECT(Exec_SETPROGRESSMAX);
1916 SET_EXPECT(Exec_SETPROGRESSPOS);
1917 SET_EXPECT(OnUIActivate);
1918 SET_EXPECT(SetActiveObject);
1919 SET_EXPECT(ShowUI);
1920 expect_status_text = NULL;
1921
1922 hres = IOleDocumentView_UIActivate(view, TRUE);
1923 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1924
1925 CHECK_CALLED(CanInPlaceActivate);
1926 CHECK_CALLED(GetWindowContext);
1927 CHECK_CALLED(GetWindow);
1928 if(ipsex)
1929 CHECK_CALLED(OnInPlaceActivateEx);
1930 else
1931 CHECK_CALLED(OnInPlaceActivate);
1932 CHECK_CALLED(SetStatusText);
1933 CHECK_CALLED(Exec_SETPROGRESSMAX);
1934 CHECK_CALLED(Exec_SETPROGRESSPOS);
1935 CHECK_CALLED(OnUIActivate);
1936 CHECK_CALLED(SetActiveObject);
1937 CHECK_CALLED(ShowUI);
1938
1939 if(activeobj) {
1940 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1941 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1942 ok(hwnd != NULL, "hwnd == NULL\n");
1943 if(last_hwnd)
1944 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1945 }
1946
1947 hres = IOleDocumentView_UIActivate(view, TRUE);
1948 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1949
1950 if(activeobj) {
1951 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1952 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1953 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1954 }
1955 }
1956
1957 hres = IOleDocumentView_SetRect(view, &rect);
1958 ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1959
1960 if(call_UIActivate == CallUIActivate_ActivateMe) {
1961 hres = IOleDocumentView_Show(view, TRUE);
1962 ok(hres == S_OK, "Show failed: %08x\n", hres);
1963 }else {
1964 SET_EXPECT(CanInPlaceActivate);
1965 SET_EXPECT(GetWindowContext);
1966 SET_EXPECT(GetWindow);
1967 if(ipsex)
1968 SET_EXPECT(OnInPlaceActivateEx);
1969 else
1970 SET_EXPECT(OnInPlaceActivate);
1971 SET_EXPECT(SetStatusText);
1972 SET_EXPECT(Exec_SETPROGRESSMAX);
1973 SET_EXPECT(Exec_SETPROGRESSPOS);
1974 SET_EXPECT(OnUIActivate);
1975 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1976
1977 hres = IOleDocumentView_Show(view, TRUE);
1978 if(FAILED(hres)) {
1979 win_skip("Show failed\n");
1980 if(activeobj)
1981 IOleInPlaceActiveObject_Release(activeobj);
1982 IOleDocument_Release(document);
1983 show_failed = TRUE;
1984 return S_OK;
1985 }
1986 ok(hres == S_OK, "Show failed: %08x\n", hres);
1987
1988 CHECK_CALLED(CanInPlaceActivate);
1989 CHECK_CALLED(GetWindowContext);
1990 CHECK_CALLED(GetWindow);
1991 if(ipsex)
1992 CHECK_CALLED(OnInPlaceActivateEx);
1993 else
1994 CHECK_CALLED(OnInPlaceActivate);
1995 CHECK_CALLED(SetStatusText);
1996 CHECK_CALLED(Exec_SETPROGRESSMAX);
1997 CHECK_CALLED(Exec_SETPROGRESSPOS);
1998
1999 if(activeobj) {
2000 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2001 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
2002 ok(hwnd != NULL, "hwnd == NULL\n");
2003 if(last_hwnd)
2004 ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
2005 }
2006 }
2007
2008 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
2009
2010 if(activeobj)
2011 IOleInPlaceActiveObject_Release(activeobj);
2012 }
2013
2014 IOleDocument_Release(document);
2015 }
2016
2017 return S_OK;
2018 }
2019
2020 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
2021 DocumentSite_QueryInterface,
2022 DocumentSite_AddRef,
2023 DocumentSite_Release,
2024 DocumentSite_ActivateMe
2025 };
2026
2027 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
2028
2029 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
2030 {
2031 return QueryInterface(riid, ppv);
2032 }
2033
2034 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
2035 {
2036 return 2;
2037 }
2038
2039 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
2040 {
2041 return 1;
2042 }
2043
2044 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
2045 {
2046 ok(0, "unexpected call\n");
2047 return E_NOTIMPL;
2048 }
2049
2050 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
2051 {
2052 ok(0, "unexpected call\n");
2053 return E_NOTIMPL;
2054 }
2055
2056 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
2057 {
2058 ok(0, "unexpected call\n");
2059 return E_NOTIMPL;
2060 }
2061
2062 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
2063 POINTF *pPtfContainer, DWORD dwFlags)
2064 {
2065 ok(0, "unexpected call\n");
2066 return E_NOTIMPL;
2067 }
2068
2069 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
2070 MSG *pMsg, DWORD grfModifiers)
2071 {
2072 ok(0, "unexpected call\n");
2073 return E_NOTIMPL;
2074 }
2075
2076 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
2077 {
2078 if(fGotFocus)
2079 CHECK_EXPECT(OnFocus_TRUE);
2080 else
2081 CHECK_EXPECT2(OnFocus_FALSE);
2082 return S_OK;
2083 }
2084
2085 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
2086 {
2087 ok(0, "unexpected call\n");
2088 return E_NOTIMPL;
2089 }
2090
2091 static const IOleControlSiteVtbl OleControlSiteVtbl = {
2092 OleControlSite_QueryInterface,
2093 OleControlSite_AddRef,
2094 OleControlSite_Release,
2095 OleControlSite_OnControlInfoChanged,
2096 OleControlSite_LockInPlaceActive,
2097 OleControlSite_GetExtendedControl,
2098 OleControlSite_TransformCoords,
2099 OleControlSite_TranslateAccelerator,
2100 OleControlSite_OnFocus,
2101 OleControlSite_ShowPropertyFrame
2102 };
2103
2104 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
2105
2106 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2107 {
2108 return QueryInterface(riid, ppv);
2109 }
2110
2111 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
2112 {
2113 return 2;
2114 }
2115
2116 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
2117 {
2118 return 1;
2119 }
2120
2121 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
2122 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
2123 {
2124 ok(0, "unexpected call\n");
2125 return E_NOTIMPL;
2126 }
2127
2128 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
2129 {
2130 CHECK_EXPECT(GetHostInfo);
2131 ok(pInfo != NULL, "pInfo=NULL\n");
2132 if(pInfo) {
2133 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
2134 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
2135 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
2136 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
2137 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
2138 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
2139 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
2140 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
2141 }
2142 return S_OK;
2143 }
2144
2145 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
2146 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
2147 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
2148 {
2149 CHECK_EXPECT(ShowUI);
2150
2151 if (editmode)
2152 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
2153 else
2154 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
2155 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2156 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
2157 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2158 if (expect_InPlaceUIWindow_SetActiveObject_active)
2159 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2160 else
2161 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2162
2163 return S_OK;
2164 }
2165
2166 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2167 {
2168 CHECK_EXPECT(HideUI);
2169 return S_OK;
2170 }
2171
2172 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2173 {
2174 CHECK_EXPECT(UpdateUI);
2175 return S_OK;
2176 }
2177
2178 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2179 {
2180 if(fEnable)
2181 CHECK_EXPECT2(EnableModeless_TRUE);
2182 else
2183 CHECK_EXPECT2(EnableModeless_FALSE);
2184 return E_NOTIMPL;
2185 }
2186
2187 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2188 {
2189 ok(0, "unexpected call\n");
2190 return E_NOTIMPL;
2191 }
2192
2193 static BOOL expect_OnFrameWindowActivate_fActivate;
2194 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2195 {
2196 CHECK_EXPECT2(OnFrameWindowActivate);
2197 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2198 return S_OK;
2199 }
2200
2201 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2202 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2203 {
2204 ok(0, "unexpected call\n");
2205 return E_NOTIMPL;
2206 }
2207
2208 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2209 const GUID *pguidCmdGroup, DWORD nCmdID)
2210 {
2211 ok(0, "unexpected call\n");
2212 return E_NOTIMPL;
2213 }
2214
2215 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2216 LPOLESTR *pchKey, DWORD dw)
2217 {
2218 CHECK_EXPECT(GetOptionKeyPath);
2219 ok(pchKey != NULL, "pchKey = NULL\n");
2220 ok(!dw, "dw=%d, expected 0\n", dw);
2221 if(pchKey)
2222 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2223 return S_OK;
2224 }
2225
2226 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2227 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2228 {
2229 CHECK_EXPECT(GetDropTarget);
2230 /* TODO */
2231 return E_NOTIMPL;
2232 }
2233
2234 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2235 {
2236 CHECK_EXPECT(GetExternal);
2237 *ppDispatch = &External;
2238 return S_FALSE;
2239 }
2240
2241 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2242 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2243 {
2244 CHECK_EXPECT(TranslateUrl);
2245 ok(!dwTranslate, "dwTranslate = %x\n", dwTranslate);
2246 ok(!strcmp_wa(pchURLIn, "about:blank"), "pchURLIn = %s\n", wine_dbgstr_w(pchURLIn));
2247 ok(ppchURLOut != NULL, "ppchURLOut == NULL\n");
2248 ok(!*ppchURLOut, "*ppchURLOut = %p\n", *ppchURLOut);
2249
2250 return S_FALSE;
2251 }
2252
2253 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2254 IDataObject **ppPORet)
2255 {
2256 ok(0, "unexpected call\n");
2257 return E_NOTIMPL;
2258 }
2259
2260 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2261 LPOLESTR *pchKey, DWORD dw)
2262 {
2263 CHECK_EXPECT(GetOverrideKeyPath);
2264 ok(pchKey != NULL, "pchKey = NULL\n");
2265 if(pchKey)
2266 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2267 ok(!dw, "dw=%d, xepected 0\n", dw);
2268 return S_OK;
2269 }
2270
2271 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2272 DocHostUIHandler_QueryInterface,
2273 DocHostUIHandler_AddRef,
2274 DocHostUIHandler_Release,
2275 DocHostUIHandler_ShowContextMenu,
2276 DocHostUIHandler_GetHostInfo,
2277 DocHostUIHandler_ShowUI,
2278 DocHostUIHandler_HideUI,
2279 DocHostUIHandler_UpdateUI,
2280 DocHostUIHandler_EnableModeless,
2281 DocHostUIHandler_OnDocWindowActivate,
2282 DocHostUIHandler_OnFrameWindowActivate,
2283 DocHostUIHandler_ResizeBorder,
2284 DocHostUIHandler_TranslateAccelerator,
2285 DocHostUIHandler_GetOptionKeyPath,
2286 DocHostUIHandler_GetDropTarget,
2287 DocHostUIHandler_GetExternal,
2288 DocHostUIHandler_TranslateUrl,
2289 DocHostUIHandler_FilterDataObject,
2290 DocHostUIHandler_GetOverrideKeyPath
2291 };
2292
2293 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2294
2295 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2296 REFIID riid, void **ppv)
2297 {
2298 return QueryInterface(riid, ppv);
2299 }
2300
2301 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2302 {
2303 return 2;
2304 }
2305
2306 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2307 {
2308 return 1;
2309 }
2310
2311 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2312 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2313 {
2314 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2315 ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2316 ok(!pCmdText, "pCmdText != NULL\n");
2317
2318 switch(prgCmds[0].cmdID) {
2319 case OLECMDID_SETPROGRESSTEXT:
2320 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2321 prgCmds[0].cmdf = OLECMDF_ENABLED;
2322 return S_OK;
2323 case OLECMDID_OPEN:
2324 CHECK_EXPECT(QueryStatus_OPEN);
2325 prgCmds[0].cmdf = 0;
2326 return S_OK;
2327 case OLECMDID_NEW:
2328 CHECK_EXPECT(QueryStatus_NEW);
2329 prgCmds[0].cmdf = 0;
2330 return S_OK;
2331 default:
2332 ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2333 };
2334
2335 return E_FAIL;
2336 }
2337
2338 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2339 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2340 {
2341 if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2342 test_readyState(NULL);
2343
2344 if(!pguidCmdGroup) {
2345 switch(nCmdID) {
2346 case OLECMDID_SETPROGRESSMAX:
2347 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2348 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2349 ok(pvaIn != NULL, "pvaIn == NULL\n");
2350 if(pvaIn) {
2351 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2352 if(load_state == LD_NO)
2353 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2354 }
2355 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2356 return S_OK;
2357 case OLECMDID_SETPROGRESSPOS:
2358 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2359 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2360 ok(pvaIn != NULL, "pvaIn == NULL\n");
2361 if(pvaIn) {
2362 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2363 if(load_state == LD_NO)
2364 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2365 }
2366 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2367 return S_OK;
2368 case OLECMDID_HTTPEQUIV_DONE:
2369 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2370 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2371 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2372 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2373 readystate_set_loading = FALSE;
2374 readystate_set_interactive = FALSE;
2375 load_state = LD_COMPLETE;
2376 return S_OK;
2377 case OLECMDID_SETDOWNLOADSTATE:
2378 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2379 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2380 ok(pvaIn != NULL, "pvaIn == NULL\n");
2381 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2382
2383 switch(V_I4(pvaIn)) {
2384 case 0:
2385 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2386 load_state = LD_INTERACTIVE;
2387 break;
2388 case 1:
2389 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2390 readystate_set_interactive = (load_state != LD_INTERACTIVE);
2391 break;
2392 default:
2393 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2394 }
2395
2396 return S_OK;
2397 case OLECMDID_UPDATECOMMANDS:
2398 CHECK_EXPECT(Exec_UPDATECOMMANDS);
2399 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2400 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2401 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2402 return S_OK;
2403 case OLECMDID_SETTITLE:
2404 CHECK_EXPECT2(Exec_SETTITLE);
2405 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2406 ok(pvaIn != NULL, "pvaIn == NULL\n");
2407 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2408 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2409 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2410 return S_OK;
2411 case OLECMDID_HTTPEQUIV:
2412 CHECK_EXPECT2(Exec_HTTPEQUIV);
2413 ok(!nCmdexecopt, "nCmdexecopts=%08x\n", nCmdexecopt);
2414 ok(pvaIn != NULL, "pvaIn == NULL\n");
2415 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2416 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2417 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
2418 test_readyState(NULL);
2419 return S_OK;
2420 default:
2421 ok(0, "unexpected command %d\n", nCmdID);
2422 return E_FAIL;
2423 };
2424 }
2425
2426 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2427 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2428
2429 switch(nCmdID) {
2430 case 37:
2431 CHECK_EXPECT2(Exec_ShellDocView_37);
2432
2433 if(load_from_stream)
2434 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2435 else if(!editmode)
2436 test_GetCurMoniker(doc_unk, doc_mon, NULL);
2437
2438 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2439 ok(pvaIn != NULL, "pvaIn == NULL\n");
2440 if(pvaIn) {
2441 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2442 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2443 }
2444 return S_OK;
2445 case 84:
2446 CHECK_EXPECT2(Exec_ShellDocView_84);
2447
2448 ok(pvaIn == NULL, "pvaIn != NULL\n");
2449 ok(pvaOut != NULL, "pvaOut == NULL\n");
2450 if(pvaIn)
2451 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2452
2453 return E_NOTIMPL;
2454
2455 case 103:
2456 CHECK_EXPECT2(Exec_ShellDocView_103);
2457
2458 ok(pvaIn == NULL, "pvaIn != NULL\n");
2459 ok(pvaOut == NULL, "pvaOut != NULL\n");
2460
2461 return E_NOTIMPL;
2462
2463 case 105:
2464 CHECK_EXPECT2(Exec_ShellDocView_105);
2465
2466 ok(pvaIn != NULL, "pvaIn == NULL\n");
2467 ok(pvaOut == NULL, "pvaOut != NULL\n");
2468
2469 return E_NOTIMPL;
2470
2471 case 140:
2472 CHECK_EXPECT2(Exec_ShellDocView_140);
2473
2474 ok(pvaIn == NULL, "pvaIn != NULL\n");
2475 ok(pvaOut == NULL, "pvaOut != NULL\n");
2476
2477 return E_NOTIMPL;
2478
2479 default:
2480 ok(0, "unexpected command %d\n", nCmdID);
2481 return E_FAIL;
2482 };
2483 }
2484
2485 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2486 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2487
2488 switch(nCmdID) {
2489 case IDM_PARSECOMPLETE:
2490 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2491 ok(pvaIn == NULL, "pvaIn != NULL\n");
2492 ok(pvaOut == NULL, "pvaOut != NULL\n");
2493 return S_OK;
2494 default:
2495 ok(0, "unexpected command %d\n", nCmdID);
2496 };
2497 }
2498
2499 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2500 return E_FAIL; /* TODO */
2501
2502 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2503 ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2504
2505 switch(nCmdID) {
2506 case 69:
2507 CHECK_EXPECT2(Exec_Explorer_69);
2508 ok(pvaIn == NULL, "pvaIn != NULL\n");
2509 ok(pvaOut != NULL, "pvaOut == NULL\n");
2510 return E_NOTIMPL;
2511 default:
2512 ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2513 }
2514 return E_NOTIMPL;
2515 }
2516
2517 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2518 switch (nCmdID) {
2519 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2520 SET_EXPECT(SetStatusText);
2521 ok(pvaIn == NULL, "pvaIn != NULL\n");
2522 ok(pvaOut == NULL, "pvaOut != NULL\n");
2523 return S_OK;
2524 case OLECMDID_SHOWSCRIPTERROR:
2525 /* TODO */
2526 return S_OK;
2527 default:
2528 ok(0, "unexpected command %d\n", nCmdID);
2529 return E_FAIL;
2530 }
2531 }
2532
2533 ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2534 return E_NOTIMPL;
2535 }
2536
2537 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2538 OleCommandTarget_QueryInterface,
2539 OleCommandTarget_AddRef,
2540 OleCommandTarget_Release,
2541 OleCommandTarget_QueryStatus,
2542 OleCommandTarget_Exec
2543 };
2544
2545 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2546
2547 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2548 {
2549 return QueryInterface(riid, ppv);
2550 }
2551
2552 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2553 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2554 EXCEPINFO *pExcepInfo, UINT *puArgErr)
2555 {
2556 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2557 ok(pDispParams != NULL, "pDispParams == NULL\n");
2558 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2559 ok(puArgErr != NULL, "puArgErr == NULL\n");
2560 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2561 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2562 test_readyState(NULL);
2563
2564 switch(dispIdMember) {
2565 case DISPID_AMBIENT_USERMODE:
2566 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2567 V_VT(pVarResult) = VT_BOOL;
2568 V_BOOL(pVarResult) = VARIANT_TRUE;
2569 return S_OK;
2570 case DISPID_AMBIENT_DLCONTROL:
2571 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2572 return E_FAIL;
2573 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2574 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2575 return E_FAIL;
2576 case DISPID_AMBIENT_SILENT:
2577 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2578 V_VT(pVarResult) = VT_BOOL;
2579 V_BOOL(pVarResult) = VARIANT_FALSE;
2580 return S_OK;
2581 case DISPID_AMBIENT_USERAGENT:
2582 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2583 return E_FAIL;
2584 case DISPID_AMBIENT_PALETTE:
2585 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2586 return E_FAIL;
2587 };
2588
2589 ok(0, "unexpected dispid %d\n", dispIdMember);
2590 return E_FAIL;
2591 }
2592
2593 static IDispatchVtbl DispatchVtbl = {
2594 Dispatch_QueryInterface,
2595 Dispatch_AddRef,
2596 Dispatch_Release,
2597 Dispatch_GetTypeInfoCount,
2598 Dispatch_GetTypeInfo,
2599 Dispatch_GetIDsOfNames,
2600 Dispatch_Invoke
2601 };
2602
2603 static IDispatch Dispatch = { &DispatchVtbl };
2604
2605 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2606 REFIID riid, void **ppv)
2607 {
2608 return QueryInterface(riid, ppv);
2609 }
2610
2611 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2612 {
2613 return 2;
2614 }
2615
2616 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2617 {
2618 return 1;
2619 }
2620
2621 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2622 REFIID riid, void **ppv)
2623 {
2624 /*
2625 * Services used by HTMLDocument:
2626 *
2627 * IOleUndoManager
2628 * IInternetSecurityManager
2629 * ITargetFrame
2630 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2631 * HTMLFrameBase
2632 * IShellObject
2633 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2634 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2635 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2636 * DefView (?)
2637 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2638 * IElementBehaviorFactory
2639 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2640 * STopLevelBrowser
2641 * IHTMLWindow2
2642 * IInternetProtocol
2643 * IWebBrowserApp
2644 * UrlHostory
2645 * IHTMLEditHost
2646 * IHlinkFrame
2647 */
2648
2649 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2650 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2651 *ppv = &HlinkFrame;
2652 return S_OK;
2653 }
2654
2655 return E_NOINTERFACE;
2656 }
2657
2658 static const IServiceProviderVtbl ServiceProviderVtbl = {
2659 ServiceProvider_QueryInterface,
2660 ServiceProvider_AddRef,
2661 ServiceProvider_Release,
2662 ServiceProvider_QueryService
2663 };
2664
2665 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2666
2667 static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSink *iface,
2668 REFIID riid, void **ppv)
2669 {
2670 return QueryInterface(riid, ppv);
2671 }
2672
2673 static ULONG WINAPI AdviseSink_AddRef(IAdviseSink *iface)
2674 {
2675 return 2;
2676 }
2677
2678 static ULONG WINAPI AdviseSink_Release(IAdviseSink *iface)
2679 {
2680 return 1;
2681 }
2682
2683 static void WINAPI AdviseSink_OnDataChange(IAdviseSink *iface,
2684 FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
2685 {
2686 ok(0, "unexpected call\n");
2687 }
2688
2689 static void WINAPI AdviseSink_OnViewChange(IAdviseSink *iface,
2690 DWORD dwAspect, LONG lindex)
2691 {
2692 ok(0, "unexpected call\n");
2693 }
2694
2695 static void WINAPI AdviseSink_OnRename(IAdviseSink *iface, IMoniker *pmk)
2696 {
2697 ok(0, "unexpected call\n");
2698 }
2699
2700 static void WINAPI AdviseSink_OnSave(IAdviseSink *iface)
2701 {
2702 ok(0, "unexpected call\n");
2703 }
2704
2705 static void WINAPI AdviseSink_OnClose(IAdviseSink *iface)
2706 {
2707 CHECK_EXPECT(Advise_Close);
2708 }
2709
2710 static const IAdviseSinkVtbl AdviseSinkVtbl = {
2711 AdviseSink_QueryInterface,
2712 AdviseSink_AddRef,
2713 AdviseSink_Release,
2714 AdviseSink_OnDataChange,
2715 AdviseSink_OnViewChange,
2716 AdviseSink_OnRename,
2717 AdviseSink_OnSave,
2718 AdviseSink_OnClose
2719 };
2720
2721 static IAdviseSink AdviseSink = { &AdviseSinkVtbl };
2722
2723 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2724 DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2725 DEFINE_GUID(IID_IRenMailEditor, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2726 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
2727 DEFINE_GUID(IID_IDocHostUIHandlerPriv, 0xf0d241d1,0x5d0e,0x4e85,0xbc,0xb4,0xfa,0xd7,0xf7,0xc5,0x52,0x8c);
2728
2729 static HRESULT QueryInterface(REFIID riid, void **ppv)
2730 {
2731 *ppv = NULL;
2732
2733 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2734 *ppv = &ClientSite;
2735 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2736 *ppv = &DocumentSite;
2737 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2738 *ppv = &DocHostUIHandler;
2739 else if(IsEqualGUID(&IID_IOleContainer, riid))
2740 *ppv = &OleContainer;
2741 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2742 *ppv = &InPlaceSiteWindowless;
2743 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2744 *ppv = &OleCommandTarget;
2745 else if(IsEqualGUID(&IID_IDispatch, riid))
2746 *ppv = &Dispatch;
2747 else if(IsEqualGUID(&IID_IServiceProvider, riid))
2748 *ppv = &ServiceProvider;
2749 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2750 *ppv = ipsex ? &InPlaceSiteWindowless : NULL;
2751 else if(IsEqualGUID(&IID_IOleInPlaceSiteWindowless, riid))
2752 *ppv = ipsw ? &InPlaceSiteWindowless : NULL;
2753 else if(IsEqualGUID(&IID_IOleControlSite, riid))
2754 *ppv = &OleControlSite;
2755 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2756 return E_NOINTERFACE; /* TODO */
2757 else if(IsEqualGUID(&IID_IProxyManager, riid))
2758 return E_NOINTERFACE; /* ? */
2759 else if(IsEqualGUID(&IID_unk1, riid))
2760 return E_NOINTERFACE; /* HTMLWindow2 ? */
2761 else if(IsEqualGUID(&IID_IThumbnailView, riid))
2762 return E_NOINTERFACE; /* ? */
2763 else if(IsEqualGUID(&IID_IRenMailEditor, riid))
2764 return E_NOINTERFACE; /* ? */
2765 else if(IsEqualGUID(&IID_unk4, riid))
2766 return E_NOINTERFACE; /* ? */
2767 else if(IsEqualGUID(&IID_IDocHostUIHandlerPriv, riid))
2768 return E_NOINTERFACE; /* ? */
2769 else
2770 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2771
2772 if(*ppv)
2773 return S_OK;
2774 return E_NOINTERFACE;
2775 }
2776
2777 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2778 {
2779 return DefWindowProc(hwnd, msg, wParam, lParam);
2780 }
2781
2782 static void test_doscroll(IUnknown *unk)
2783 {
2784 IHTMLDocument3 *doc;
2785 IHTMLElement2 *elem2;
2786 IHTMLElement *elem;
2787 VARIANT v;
2788 HRESULT hres;
2789
2790 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument3, (void**)&doc);
2791 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
2792 if(FAILED(hres))
2793 return;
2794
2795 hres = IHTMLDocument3_get_documentElement(doc, &elem);
2796 IHTMLDocument3_Release(doc);
2797 ok(hres == S_OK, "get_documentElement failed: %08x\n", hres);
2798 switch(load_state) {
2799 case LD_DOLOAD:
2800 case LD_NO:
2801 ok(!elem, "elem != NULL\n");
2802 default:
2803 break;
2804 case LD_INTERACTIVE:
2805 case LD_COMPLETE:
2806 ok(elem != NULL, "elem == NULL\n");
2807 }
2808 if(!elem)
2809 return;
2810
2811 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
2812 IHTMLElement_Release(elem);
2813 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
2814
2815 V_VT(&v) = VT_BSTR;
2816 V_BSTR(&v) = a2bstr("left");
2817 hres = IHTMLElement2_doScroll(elem2, v);
2818 SysFreeString(V_BSTR(&v));
2819 IHTMLElement2_Release(elem2);
2820
2821 if(inplace_deactivated)
2822 ok(hres == E_PENDING, "doScroll failed: %08x\n", hres);
2823 else if(load_state == LD_COMPLETE)
2824 ok(hres == S_OK, "doScroll failed: %08x\n", hres);
2825 else
2826 ok(hres == E_PENDING || hres == S_OK, "doScroll failed: %08x\n", hres);
2827 }
2828
2829 static void _test_readyState(unsigned line, IUnknown *unk)
2830 {
2831 IHTMLDocument2 *htmldoc;
2832 DISPPARAMS dispparams;
2833 IHTMLElement *elem;
2834 BSTR state;
2835 VARIANT out;
2836 HRESULT hres;
2837
2838 static const LPCSTR expected_state[] = {
2839 "uninitialized",
2840 "loading",
2841 NULL,
2842 "interactive",
2843 "complete",
2844 "uninitialized"
2845 };
2846
2847 if(!unk)
2848 unk = doc_unk;
2849
2850 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2851 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2852 if(FAILED(hres))
2853 return;
2854
2855 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2856 ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2857
2858 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2859 ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2860
2861 if(!strcmp_wa(state, "interactive") && load_state == LD_LOADING)
2862 load_state = LD_INTERACTIVE;
2863
2864 ok_(__FILE__, line)
2865 (!strcmp_wa(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
2866 wine_dbgstr_w(state), load_state);
2867 SysFreeString(state);
2868
2869 hres = IHTMLDocument2_get_body(htmldoc, &elem);
2870 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08x\n", hres);
2871 if(elem) {
2872 IHTMLElement2 *elem2;
2873 VARIANT var;
2874
2875 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
2876 IHTMLElement_Release(elem);
2877 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08x\n", hres);
2878
2879 hres = IHTMLElement2_get_readyState(elem2, &var);
2880 IHTMLElement2_Release(elem2);
2881 ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
2882 ok(V_VT(&var) == VT_BSTR, "V_VT(state) = %d\n", V_VT(&var));
2883 ok(!strcmp_wa(V_BSTR(&var), "complete"), "unexpected body state %s\n", wine_dbgstr_w(V_BSTR(&var)));
2884 VariantClear(&var);
2885 }else {
2886 ok_(__FILE__,line)(load_state != LD_COMPLETE, "body is NULL in complete state\n");
2887 }
2888
2889 dispparams.cArgs = 0;
2890 dispparams.cNamedArgs = 0;
2891 dispparams.rgdispidNamedArgs = NULL;
2892 dispparams.rgvarg = NULL;
2893
2894 VariantInit(&out);
2895
2896 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2897 &dispparams, &out, NULL, NULL);
2898 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2899
2900 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2901 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2902
2903 test_doscroll((IUnknown*)htmldoc);
2904
2905 IHTMLDocument2_Release(htmldoc);
2906 }
2907
2908 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2909 {
2910 IConnectionPointContainer *tmp_container = NULL;
2911 IConnectionPoint *cp;
2912 IID iid;
2913 HRESULT hres;
2914
2915 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2916 ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2917 if(FAILED(hres))
2918 return;
2919
2920 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2921 ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2922 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2923
2924 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2925 ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2926
2927 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2928 ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2929 ok(tmp_container == container, "container != tmp_container\n");
2930 if(SUCCEEDED(hres))
2931 IConnectionPointContainer_Release(tmp_container);
2932
2933 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2934 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2935
2936 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2937 DWORD cookie;
2938
2939 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2940 ok(hres == S_OK, "Advise failed: %08x\n", hres);
2941 }
2942
2943 IConnectionPoint_Release(cp);
2944 }
2945
2946 static void test_ConnectionPointContainer(IUnknown *unk)
2947 {
2948 IConnectionPointContainer *container;
2949 HRESULT hres;
2950
2951 hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2952 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2953 if(FAILED(hres))
2954 return;
2955
2956 test_ConnectionPoint(container, &IID_IDispatch);
2957 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2958 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2959 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2960
2961 IConnectionPointContainer_Release(container);
2962 }
2963
2964 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
2965 {
2966 IBindCtx *bind;
2967 HRESULT hres;
2968 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2969
2970 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2971
2972 test_readyState((IUnknown*)persist);
2973
2974 doc_mon = mon;
2975
2976 CreateBindCtx(0, &bind);
2977 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2978 (IUnknown*)&ClientSite);
2979
2980 if(mon == &Moniker)
2981 SET_EXPECT(GetDisplayName);
2982 if(!set_clientsite) {
2983 SET_EXPECT(Invoke_AMBIENT_USERMODE);
2984 SET_EXPECT(GetHostInfo);
2985 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2986 SET_EXPECT(Invoke_AMBIENT_SILENT);
2987 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2988 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2989 SET_EXPECT(Invoke_AMBIENT_PALETTE);
2990 SET_EXPECT(GetOptionKeyPath);
2991 SET_EXPECT(GetOverrideKeyPath);
2992 SET_EXPECT(GetWindow);
2993 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2994 SET_EXPECT(Exec_SETPROGRESSMAX);
2995 SET_EXPECT(Exec_SETPROGRESSPOS);
2996 SET_EXPECT(Exec_ShellDocView_37);
2997 }
2998 if(!container_locked) {
2999 SET_EXPECT(GetContainer);
3000 SET_EXPECT(LockContainer);
3001 }
3002 SET_EXPECT(OnChanged_READYSTATE);
3003 SET_EXPECT(Exec_ShellDocView_84);
3004 SET_EXPECT(IsSystemMoniker);
3005 if(mon == &Moniker)
3006 SET_EXPECT(BindToStorage);
3007 SET_EXPECT(SetActiveObject);
3008 if(set_clientsite) {
3009 SET_EXPECT(Invoke_AMBIENT_SILENT);
3010 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3011 SET_EXPECT(Exec_ShellDocView_37);
3012 }
3013 load_state = LD_DOLOAD;
3014 expect_LockContainer_fLock = TRUE;
3015 readystate_set_loading = TRUE;
3016
3017 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
3018 ok(hres == S_OK, "Load failed: %08x\n", hres);
3019
3020 if(mon == &Moniker)
3021 CHECK_CALLED(GetDisplayName);
3022 if(!set_clientsite) {
3023 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3024 CHECK_CALLED(GetHostInfo);
3025 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3026 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3027 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3028 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3029 CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3030 CHECK_CALLED(GetOptionKeyPath);
3031 CHECK_CALLED(GetOverrideKeyPath);
3032 CHECK_CALLED(GetWindow);
3033 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3034 CHECK_CALLED(Exec_SETPROGRESSMAX);
3035 CHECK_CALLED(Exec_SETPROGRESSPOS);
3036 CHECK_CALLED(Exec_ShellDocView_37);
3037 }
3038 if(!container_locked) {
3039 CHECK_CALLED(GetContainer);
3040 CHECK_CALLED(LockContainer);
3041 container_locked = TRUE;
3042 }
3043 CHECK_CALLED(OnChanged_READYSTATE);
3044 SET_CALLED(IsSystemMoniker); /* IE7 */
3045 SET_CALLED(Exec_ShellDocView_84);
3046 if(mon == &Moniker)
3047 CHECK_CALLED(BindToStorage);
3048 SET_CALLED(SetActiveObject); /* FIXME */
3049 if(set_clientsite) {
3050 CHECK_CALLED(Invoke_AMBIENT_SILENT);
3051 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3052 CHECK_CALLED(Exec_ShellDocView_37);
3053 }
3054
3055 set_clientsite = container_locked = TRUE;
3056
3057 test_GetCurMoniker((IUnknown*)persist, mon, NULL);
3058
3059 IBindCtx_Release(bind);
3060
3061 test_readyState((IUnknown*)persist);
3062 }
3063
3064 #define DWL_VERBDONE 0x0001
3065 #define DWL_CSS 0x0002
3066 #define DWL_TRYCSS 0x0004
3067 #define DWL_HTTP 0x0008
3068 #define DWL_EMPTY 0x0010
3069
3070 static void test_download(DWORD flags)
3071 {
3072 HWND hwnd;
3073 MSG msg;
3074
3075 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
3076 ok(hwnd != NULL, "Could not find hidden window\n");
3077
3078 test_readyState(NULL);
3079
3080 if(flags & (DWL_VERBDONE|DWL_HTTP))
3081 SET_EXPECT(Exec_SETPROGRESSMAX);
3082 if((flags & DWL_VERBDONE) && !load_from_stream)
3083 SET_EXPECT(GetHostInfo);
3084 SET_EXPECT(SetStatusText);
3085 if(!(flags & DWL_EMPTY))
3086 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
3087 SET_EXPECT(GetDropTarget);
3088 if(flags & DWL_TRYCSS)
3089 SET_EXPECT(Exec_ShellDocView_84);
3090 if(flags & DWL_CSS) {
3091 SET_EXPECT(CreateInstance);
3092 SET_EXPECT(Start);
3093 SET_EXPECT(LockRequest);
3094 SET_EXPECT(Terminate);
3095 SET_EXPECT(Protocol_Read);
3096 SET_EXPECT(UnlockRequest);
3097 }
3098 SET_EXPECT(Exec_Explorer_69);
3099 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
3100 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
3101 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
3102 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
3103 if(doc_mon != &Moniker) {
3104 SET_EXPECT(OnChanged_1012);
3105 SET_EXPECT(Exec_HTTPEQUIV);
3106 SET_EXPECT(Exec_SETTITLE);
3107 }
3108 SET_EXPECT(OnChanged_1005);
3109 SET_EXPECT(OnChanged_READYSTATE);
3110 SET_EXPECT(Exec_SETPROGRESSPOS);
3111 if(!(flags & DWL_EMPTY))
3112 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
3113 SET_EXPECT(Exec_ShellDocView_103);
3114 SET_EXPECT(Exec_ShellDocView_105);
3115 SET_EXPECT(Exec_ShellDocView_140);
3116 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
3117 SET_EXPECT(Exec_HTTPEQUIV_DONE);
3118 SET_EXPECT(SetStatusText);
3119 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
3120
3121 while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
3122 TranslateMessage(&msg);
3123 DispatchMessage(&msg);
3124 }
3125
3126 if(flags & DWL_VERBDONE)
3127 CHECK_CALLED(Exec_SETPROGRESSMAX);
3128 if(flags & DWL_HTTP)
3129 SET_CALLED(Exec_SETPROGRESSMAX);
3130 if((flags & DWL_VERBDONE) && !load_from_stream)
3131 CHECK_CALLED(GetHostInfo);
3132 CHECK_CALLED(SetStatusText);
3133 if(!(flags & DWL_EMPTY))
3134 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
3135 CHECK_CALLED(GetDropTarget);
3136 if(flags & DWL_TRYCSS)
3137 SET_CALLED(Exec_ShellDocView_84);
3138 if(flags & DWL_CSS) {
3139 CHECK_CALLED(CreateInstance);
3140 CHECK_CALLED(Start);
3141 CHECK_CALLED(LockRequest);
3142 CHECK_CALLED(Terminate);
3143 CHECK_CALLED(Protocol_Read);
3144 CHECK_CALLED(UnlockRequest);
3145 }
3146 SET_CALLED(Exec_Explorer_69);
3147 SET_CALLED(EnableModeless_TRUE); /* IE7 */
3148 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
3149 SET_CALLED(EnableModeless_FALSE); /* IE7 */
3150 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
3151 if(doc_mon != &Moniker) todo_wine {
3152 CHECK_CALLED(OnChanged_1012);
3153 CHECK_CALLED(Exec_HTTPEQUIV);
3154 CHECK_CALLED(Exec_SETTITLE);
3155 }
3156 CHECK_CALLED(OnChanged_1005);
3157 CHECK_CALLED(OnChanged_READYSTATE);
3158 CHECK_CALLED(Exec_SETPROGRESSPOS);
3159 if(!(flags & DWL_EMPTY))
3160 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
3161 SET_CALLED(Exec_ShellDocView_103);
3162 SET_CALLED(Exec_ShellDocView_105);
3163 SET_CALLED(Exec_ShellDocView_140);
3164 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
3165 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
3166 SET_CALLED(SetStatusText);
3167
3168 load_state = LD_COMPLETE;
3169
3170 test_readyState(NULL);
3171 }
3172
3173 static void test_Persist(IUnknown *unk, IMoniker *mon)
3174 {
3175 IPersistMoniker *persist_mon;
3176 IPersistFile *persist_file;
3177 GUID guid;
3178 HRESULT hres;
3179
3180 hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
3181 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
3182 if(SUCCEEDED(hres)) {
3183 hres = IPersist_GetClassID(persist_file, NULL);
3184 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
3185
3186 hres = IPersist_GetClassID(persist_file, &guid);
3187 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
3188 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
3189
3190 IPersist_Release(persist_file);
3191 }
3192
3193 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
3194 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
3195 if(SUCCEEDED(hres)) {
3196 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
3197 ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
3198
3199 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
3200 ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
3201 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
3202
3203 if(load_state == LD_DOLOAD)
3204 test_Load(persist_mon, mon);
3205
3206 test_readyState(unk);
3207
3208 IPersistMoniker_Release(persist_mon);
3209 }
3210 }
3211
3212 static void test_put_href(IUnknown *unk)
3213 {
3214 IHTMLLocation *location;
3215 IHTMLDocument2 *doc;
3216 BSTR str;
3217 HRESULT hres;
3218
3219 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3220 ok(hres == S_OK, "Could not get IHTMLDocument2 iface: %08x\n", hres);
3221
3222 location = NULL;
3223 hres = IHTMLDocument2_get_location(doc, &location);
3224 IHTMLDocument2_Release(doc);
3225 ok(hres == S_OK, "get_location failed: %08x\n", hres);
3226 ok(location != NULL, "location == NULL\n");
3227
3228 SET_EXPECT(TranslateUrl);
3229 SET_EXPECT(Navigate);
3230 str = a2bstr("about:blank");
3231 hres = IHTMLLocation_put_href(location, str);
3232 SysFreeString(str);
3233 ok(hres == S_OK, "put_href failed: %08x\n", hres);
3234 CHECK_CALLED(TranslateUrl);
3235 CHECK_CALLED(Navigate);
3236
3237 IHTMLLocation_Release(location);
3238 }
3239
3240 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
3241 0,
3242 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
3243 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
3244 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
3245 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
3246 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
3247 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
3248 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
3249 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
3250 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
3251 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
3252 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
3253 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
3254 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
3255 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
3256 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
3257 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
3258 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
3259 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
3260 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
3261 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
3262 0,
3263 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
3264 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
3265 0,0,0,0,0,0,
3266 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
3267 0,0,
3268 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
3269 0,0,
3270 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
3271 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
3272 0,0,0,0,0,
3273 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
3274 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
3275 0,0,
3276 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
3277 0,0,0,
3278 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
3279 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
3280 };
3281
3282 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
3283 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
3284 {
3285 IOleCommandTarget *cmdtrg;
3286 OLECMD olecmd = {cmdid, 0};
3287 HRESULT hres;
3288
3289 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3290 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3291 if(FAILED(hres))
3292 return;
3293
3294 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
3295 ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
3296
3297 IOleCommandTarget_Release(cmdtrg);
3298
3299 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
3300 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
3301 }
3302
3303 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
3304 {
3305 if(!unk)
3306 unk = doc_unk;
3307
3308 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
3309 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
3310 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
3311 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
3312 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
3313 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
3314 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
3315 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
3316 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
3317 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
3318 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
3319 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
3320 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
3321 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
3322 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
3323 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
3324 }
3325
3326 static void test_OleCommandTarget(IUnknown *unk)
3327 {
3328 IOleCommandTarget *cmdtrg;
3329 OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
3330 int i;
3331 HRESULT hres;
3332
3333 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3334 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
3335 if(FAILED(hres))
3336 return;
3337
3338 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3339 cmds[i].cmdID = i+1;
3340 cmds[i].cmdf = 0xf0f0;
3341 }
3342
3343 SET_EXPECT(QueryStatus_OPEN);
3344 SET_EXPECT(QueryStatus_NEW);
3345 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
3346 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3347 CHECK_CALLED(QueryStatus_OPEN);
3348 CHECK_CALLED(QueryStatus_NEW);
3349
3350 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3351 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
3352 if(i+1 == OLECMDID_FIND)
3353 continue;
3354 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
3355 i+1, cmds[i].cmdf, expect_cmds[i+1]);
3356 }
3357
3358 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
3359 "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
3360
3361 IOleCommandTarget_Release(cmdtrg);
3362 }
3363
3364 static void test_OleCommandTarget_fail(IUnknown *unk)
3365 {
3366 IOleCommandTarget *cmdtrg;
3367 int i;
3368 HRESULT hres;
3369
3370 OLECMD cmd[2] = {
3371 {OLECMDID_OPEN, 0xf0f0},
3372 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
3373 };
3374
3375 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3376 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
3377 if(FAILED(hres))
3378 return;
3379
3380 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
3381 ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
3382
3383 SET_EXPECT(QueryStatus_OPEN);
3384 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
3385 CHECK_CALLED(QueryStatus_OPEN);
3386
3387 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3388 "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3389 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3390 "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3391 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3392 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3393 "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3394
3395 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3396 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3397 "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3398
3399 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3400 if(!expect_cmds[i]) {
3401 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3402 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3403 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3404 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3405 }
3406 }
3407
3408 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3409 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3410 ok(hres == OLECMDERR_E_NOTSUPPORTED,
3411 "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3412
3413 IOleCommandTarget_Release(cmdtrg);
3414 }
3415
3416 static void test_exec_onunload(IUnknown *unk)
3417 {
3418 IOleCommandTarget *cmdtrg;
3419 VARIANT var;
3420 HRESULT hres;
3421
3422 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3423 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3424 if(FAILED(hres))
3425 return;
3426
3427 memset(&var, 0x0a, sizeof(var));
3428 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3429 OLECMDEXECOPT_DODEFAULT, NULL, &var);
3430 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3431 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3432 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3433
3434 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3435 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3436 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3437
3438 IOleCommandTarget_Release(cmdtrg);
3439 }
3440
3441 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3442 {
3443 IOleCommandTarget *cmdtrg;
3444 HRESULT hres;
3445
3446 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3447 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3448 if(FAILED(hres))
3449 return;
3450
3451 editmode = TRUE;
3452
3453 if(loaded)
3454 load_state = LD_DOLOAD;
3455
3456 if(loaded)
3457 SET_EXPECT(GetClassID);
3458 SET_EXPECT(SetStatusText);
3459 SET_EXPECT(Exec_ShellDocView_37);
3460 SET_EXPECT(GetHostInfo);
3461 if(loaded)
3462 SET_EXPECT(GetDisplayName);
3463 SET_EXPECT(Invoke_AMBIENT_SILENT);
3464 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3465 SET_EXPECT(OnChanged_READYSTATE);
3466 SET_EXPECT(IsSystemMoniker);
3467 SET_EXPECT(Exec_ShellDocView_84);
3468 if(loaded)
3469 SET_EXPECT(BindToStorage