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