mshtml: Implement IHTMLStyle get/put textDecorationNone.
[wine] / dlls / mshtml / tests / htmldoc.c
1 /*
2  * Copyright 2005-2007 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 "mshtmhst.h"
33 #include "mshtmdid.h"
34 #include "mshtmcid.h"
35 #include "hlink.h"
36 #include "dispex.h"
37 #include "idispids.h"
38 #include "shlguid.h"
39 #include "perhist.h"
40
41 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
42 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
43 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
44
45 #define DEFINE_EXPECT(func) \
46     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
47
48 #define SET_EXPECT(func) \
49     expect_ ## func = TRUE
50
51 #define SET_CALLED(func) \
52     called_ ## func = TRUE
53
54 #define CHECK_EXPECT2(func) \
55     do { \
56         ok(expect_ ##func, "unexpected call " #func "\n"); \
57         called_ ## func = TRUE; \
58     }while(0)
59
60 #define CHECK_EXPECT(func) \
61     do { \
62         CHECK_EXPECT2(func); \
63         expect_ ## func = FALSE; \
64     }while(0)
65
66 #define CHECK_CALLED(func) \
67     do { \
68         ok(called_ ## func, "expected " #func "\n"); \
69         expect_ ## func = called_ ## func = FALSE; \
70     }while(0)
71
72 static IOleDocumentView *view = NULL;
73 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
74
75 DEFINE_EXPECT(LockContainer);
76 DEFINE_EXPECT(SetActiveObject);
77 DEFINE_EXPECT(SetActiveObject_null);
78 DEFINE_EXPECT(GetWindow);
79 DEFINE_EXPECT(CanInPlaceActivate);
80 DEFINE_EXPECT(OnInPlaceActivate);
81 DEFINE_EXPECT(OnInPlaceActivateEx);
82 DEFINE_EXPECT(OnUIActivate);
83 DEFINE_EXPECT(GetWindowContext);
84 DEFINE_EXPECT(OnUIDeactivate);
85 DEFINE_EXPECT(OnInPlaceDeactivate);
86 DEFINE_EXPECT(OnInPlaceDeactivateEx);
87 DEFINE_EXPECT(GetContainer);
88 DEFINE_EXPECT(ShowUI);
89 DEFINE_EXPECT(ActivateMe);
90 DEFINE_EXPECT(GetHostInfo);
91 DEFINE_EXPECT(HideUI);
92 DEFINE_EXPECT(GetOptionKeyPath);
93 DEFINE_EXPECT(GetOverrideKeyPath);
94 DEFINE_EXPECT(SetStatusText);
95 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
96 DEFINE_EXPECT(QueryStatus_OPEN);
97 DEFINE_EXPECT(QueryStatus_NEW);
98 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
99 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
100 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE); 
101 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
102 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
103 DEFINE_EXPECT(Exec_ShellDocView_37);
104 DEFINE_EXPECT(Exec_ShellDocView_84);
105 DEFINE_EXPECT(Exec_ShellDocView_103);
106 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
107 DEFINE_EXPECT(Exec_SETTITLE);
108 DEFINE_EXPECT(Exec_HTTPEQUIV);
109 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
110 DEFINE_EXPECT(Exec_Explorer_69);
111 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
112 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
113 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
114 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
115 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
116 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
117 DEFINE_EXPECT(GetDropTarget);
118 DEFINE_EXPECT(UpdateUI);
119 DEFINE_EXPECT(Navigate);
120 DEFINE_EXPECT(OnFrameWindowActivate);
121 DEFINE_EXPECT(OnChanged_READYSTATE);
122 DEFINE_EXPECT(OnChanged_1005);
123 DEFINE_EXPECT(GetDisplayName);
124 DEFINE_EXPECT(BindToStorage);
125 DEFINE_EXPECT(IsSystemMoniker);
126 DEFINE_EXPECT(GetBindResult);
127 DEFINE_EXPECT(GetClassID);
128 DEFINE_EXPECT(Abort);
129 DEFINE_EXPECT(Read);
130 DEFINE_EXPECT(CreateInstance);
131 DEFINE_EXPECT(Start);
132 DEFINE_EXPECT(Terminate);
133 DEFINE_EXPECT(Protocol_Read);
134 DEFINE_EXPECT(LockRequest);
135 DEFINE_EXPECT(UnlockRequest);
136 DEFINE_EXPECT(OnFocus_TRUE);
137 DEFINE_EXPECT(OnFocus_FALSE);
138 DEFINE_EXPECT(RequestUIActivate);
139 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
140 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
141 DEFINE_EXPECT(GetExternal);
142 DEFINE_EXPECT(EnableModeless_TRUE);
143 DEFINE_EXPECT(EnableModeless_FALSE);
144 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
145 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
146
147 static IUnknown *doc_unk;
148 static BOOL expect_LockContainer_fLock;
149 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
150 static BOOL ipsex;
151 static BOOL set_clientsite = FALSE, container_locked = FALSE;
152 static BOOL readystate_set_loading = FALSE, load_from_stream;
153 static BOOL editmode = FALSE, show_failed;
154 static int stream_read, protocol_read;
155 static enum load_state_t {
156     LD_DOLOAD,
157     LD_LOADING,
158     LD_LOADED,
159     LD_INTERACTIVE,
160     LD_COMPLETE,
161     LD_NO
162 } load_state;
163
164 static LPCOLESTR expect_status_text = NULL;
165
166 static const char html_page[] =
167 "<html>"
168 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
169 "<body>test</body>"
170 "</html>";
171
172 static const char css_data[] = "body {color: red}";
173
174 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
175 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
176
177 static HRESULT QueryInterface(REFIID riid, void **ppv);
178 static void test_MSHTML_QueryStatus(IUnknown*,DWORD);
179 static BOOL nogecko = FALSE;
180
181 #define test_readyState(u) _test_readyState(__LINE__,u)
182 static void _test_readyState(unsigned,IUnknown*);
183
184 static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR);
185
186 static const WCHAR wszTimesNewRoman[] =
187     {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
188 static const WCHAR wszArial[] =
189     {'A','r','i','a','l',0};
190
191 static const char *debugstr_guid(REFIID riid)
192 {
193     static char buf[50];
194
195     sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
196             riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
197             riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
198             riid->Data4[5], riid->Data4[6], riid->Data4[7]);
199
200     return buf;
201 }
202
203 static const char *debugstr_w(LPCWSTR str)
204 {
205     static char buf[1024];
206
207     if(!str)
208         return "(null)";
209
210     WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL);
211     return buf;
212 }
213
214 #define EXPECT_UPDATEUI  1
215 #define EXPECT_SETTITLE  2
216
217 static void test_timer(DWORD flags)
218 {
219     BOOL *b = &called_Exec_SETTITLE;
220     MSG msg;
221
222     if(flags & EXPECT_UPDATEUI) {
223         SET_EXPECT(UpdateUI);
224         SET_EXPECT(Exec_UPDATECOMMANDS);
225         b = &called_UpdateUI;
226     }
227     if(flags & EXPECT_SETTITLE)
228         SET_EXPECT(Exec_SETTITLE);
229
230     while(!*b && GetMessage(&msg, hwnd, 0, 0)) {
231         TranslateMessage(&msg);
232         DispatchMessage(&msg);
233     }
234
235     if(flags & EXPECT_UPDATEUI) {
236         CHECK_CALLED(UpdateUI);
237         CHECK_CALLED(Exec_UPDATECOMMANDS);
238     }
239     if(flags & EXPECT_SETTITLE)
240         CHECK_CALLED(Exec_SETTITLE);
241 }
242
243 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
244
245 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
246 {
247     *ppv = NULL;
248
249     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
250         *ppv = iface;
251         return S_OK;
252     }
253
254     if(IsEqualGUID(&IID_IProxyManager, riid))
255         return E_NOINTERFACE; /* TODO */
256     if(IsEqualGUID(&IID_IDispatchEx, riid))
257         return E_NOINTERFACE; /* TODO */
258     if(IsEqualGUID(&IID_External_unk, riid))
259         return E_NOINTERFACE; /* TODO */
260
261     ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
262     return E_NOINTERFACE;
263 }
264
265 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
266 {
267     return 2;
268 }
269
270 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
271 {
272     return 1;
273 }
274
275 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
276 {
277     ok(0, "unexpected call\n");
278     return E_NOTIMPL;
279 }
280
281 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
282         ITypeInfo **ppTInfo)
283 {
284     ok(0, "unexpected call\n");
285     return E_NOTIMPL;
286 }
287
288 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
289         UINT cNames, LCID lcid, DISPID *rgDispId)
290 {
291     ok(0, "unexpected call\n");
292     return E_NOTIMPL;
293 }
294
295 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
296         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
297         EXCEPINFO *pExcepInfo, UINT *puArgErr)
298 {
299     ok(0, "unexpected call\n");
300     return E_NOTIMPL;
301 }
302
303 static const IDispatchVtbl ExternalVtbl = {
304     External_QueryInterface,
305     Dispatch_AddRef,
306     Dispatch_Release,
307     Dispatch_GetTypeInfoCount,
308     Dispatch_GetTypeInfo,
309     Dispatch_GetIDsOfNames,
310     External_Invoke
311 };
312
313 static IDispatch External = { &ExternalVtbl };
314
315 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
316 {
317     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
318         *ppv = iface;
319         return S_OK;
320     }
321
322     *ppv = NULL;
323     return E_NOINTERFACE;
324 }
325
326 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
327 {
328     return 2;
329 }
330
331 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
332 {
333     return 1;
334 }
335
336 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
337         IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
338         DWORD grfPI, DWORD dwReserved)
339 {
340     BINDINFO bindinfo;
341     DWORD bindf = 0;
342     HRESULT hres;
343
344     static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
345     static const WCHAR empty_str = {0};
346
347     CHECK_EXPECT(Start);
348
349     ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
350     ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
351     ok(!grfPI, "grfPI = %x\n", grfPI);
352     ok(!dwReserved, "dwReserved = %d\n", dwReserved);
353
354     memset(&bindinfo, 0, sizeof(bindinfo));
355     bindinfo.cbSize = sizeof(bindinfo);
356     hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
357     ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
358     ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
359        "bindf = %x\n", bindf);
360
361     ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
362     ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
363     /* TODO: test stgmedData */
364     ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
365     ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
366     ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
367     ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
368     ok(bindinfo.dwOptions == 0x80000 ||
369        bindinfo.dwOptions == 0x4080000, /* win2k3 */
370        "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
371     ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
372     /* TODO: test dwCodePage */
373     /* TODO: test securityAttributes */
374     ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
375     ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
376     ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
377
378     hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
379             BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
380     ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
381
382     hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
383             BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
384     ok(hres == S_OK,
385        "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
386
387     hres = IInternetProtocolSink_ReportData(pOIProtSink,
388             BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
389     ok(hres == S_OK, "ReportData failed: %08x\n", hres);
390
391     hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
392     ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
393
394     return S_OK;
395 }
396
397 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
398         PROTOCOLDATA *pProtocolData)
399 {
400     ok(0, "unexpected call\n");
401     return E_NOTIMPL;
402 }
403
404 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
405         DWORD dwOptions)
406 {
407     ok(0, "unexpected call\n");
408     return E_NOTIMPL;
409 }
410
411 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
412 {
413     CHECK_EXPECT(Terminate);
414     return S_OK;
415 }
416
417 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
418 {
419     ok(0, "unexpected call\n");
420     return E_NOTIMPL;
421 }
422
423 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
424 {
425     ok(0, "unexpected call\n");
426     return E_NOTIMPL;
427 }
428
429 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
430         ULONG cb, ULONG *pcbRead)
431 {
432     CHECK_EXPECT2(Protocol_Read);
433
434     ok(pv != NULL, "pv == NULL\n");
435     ok(cb > sizeof(css_data), "cb < sizeof(css_data)\n");
436     ok(pcbRead != NULL, "pcbRead == NULL\n");
437     ok(!*pcbRead, "*pcbRead=%d\n", *pcbRead);
438
439     if(protocol_read)
440         return S_FALSE;
441
442     protocol_read += *pcbRead = sizeof(css_data)-1;
443     memcpy(pv, css_data, sizeof(css_data)-1);
444     return S_OK;
445 }
446
447 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
448         LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
449 {
450     ok(0, "unexpected call\n");
451     return E_NOTIMPL;
452 }
453
454 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
455 {
456     CHECK_EXPECT(LockRequest);
457     return S_OK;
458 }
459
460 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
461 {
462     CHECK_EXPECT(UnlockRequest);
463     return S_OK;
464 }
465
466 static const IInternetProtocolVtbl ProtocolVtbl = {
467     Protocol_QueryInterface,
468     Protocol_AddRef,
469     Protocol_Release,
470     Protocol_Start,
471     Protocol_Continue,
472     Protocol_Abort,
473     Protocol_Terminate,
474     Protocol_Suspend,
475     Protocol_Resume,
476     Protocol_Read,
477     Protocol_Seek,
478     Protocol_LockRequest,
479     Protocol_UnlockRequest
480 };
481
482 static IInternetProtocol Protocol = { &ProtocolVtbl };
483
484 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
485 {
486     if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
487         ok(0, "unexpected call\n");
488     return E_NOINTERFACE;
489 }
490
491 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
492 {
493     return 2;
494 }
495
496 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
497 {
498     return 1;
499 }
500
501 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
502                                         REFIID riid, void **ppv)
503 {
504     if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
505         return E_NOINTERFACE;
506
507     CHECK_EXPECT(CreateInstance);
508     ok(ppv != NULL, "ppv == NULL\n");
509
510     *ppv = &Protocol;
511     return S_OK;
512 }
513
514 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
515 {
516     ok(0, "unexpected call\n");
517     return S_OK;
518 }
519
520 static const IClassFactoryVtbl ClassFactoryVtbl = {
521     ClassFactory_QueryInterface,
522     ClassFactory_AddRef,
523     ClassFactory_Release,
524     ClassFactory_CreateInstance,
525     ClassFactory_LockServer
526 };
527
528 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
529
530 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
531 {
532     ok(0, "unexpected call\n");
533     return E_NOTIMPL;
534 }
535
536 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
537 {
538     return 2;
539 }
540
541 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
542 {
543     return 1;
544 }
545
546 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
547                                                   IHlinkBrowseContext *pihlbc)
548 {
549     ok(0, "unexpected call\n");
550     return E_NOTIMPL;
551 }
552
553 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
554                                                   IHlinkBrowseContext **ppihlbc)
555 {
556     ok(0, "unexpected call\n");
557     return E_NOTIMPL;
558 }
559
560 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
561                                           IBindStatusCallback *pibsc, IHlink *pihlNavigate)
562 {
563     HRESULT hres;
564
565     CHECK_EXPECT(Navigate);
566
567     ok(grfHLNF == 0, "grfHLNF=%d, expected 0\n", grfHLNF);
568     ok(pbc != NULL, "pbc == NULL\n");
569     ok(pibsc != NULL, "pubsc == NULL\n");
570     ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
571
572     if(pihlNavigate) {
573         LPWSTR frame_name = (LPWSTR)0xdeadbeef;
574         LPWSTR location = (LPWSTR)0xdeadbeef;
575         IHlinkSite *site;
576         IMoniker *mon = NULL;
577         DWORD site_data = 0xdeadbeef;
578
579         hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
580         ok(hres == S_FALSE, "GetTargetFrameName failed: %08x\n", hres);
581         ok(frame_name == NULL, "frame_name = %p\n", frame_name);
582
583         hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
584         ok(hres == S_OK, "GetMonikerReference failed: %08x\n", hres);
585         ok(location == NULL, "location = %p\n", location);
586         ok(mon != NULL, "mon == NULL\n");
587
588         hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
589         ok(hres == S_OK, "GetHlinkSite failed: %08x\n", hres);
590         ok(site == NULL, "site = %p\n, expected NULL\n", site);
591         ok(site_data == 0xdeadbeef, "site_data = %x\n", site_data);
592     }
593
594     return S_OK;
595 }
596
597 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
598         IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
599 {
600     ok(0, "unexpected call\n");
601     return E_NOTIMPL;
602 }
603
604 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
605         IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
606 {
607     ok(0, "unexpected call\n");
608     return E_NOTIMPL;
609 }
610
611 static const IHlinkFrameVtbl HlinkFrameVtbl = {
612     HlinkFrame_QueryInterface,
613     HlinkFrame_AddRef,
614     HlinkFrame_Release,
615     HlinkFrame_SetBrowseContext,
616     HlinkFrame_GetBrowseContext,
617     HlinkFrame_Navigate,
618     HlinkFrame_OnNavigate,
619     HlinkFrame_UpdateHlink
620 };
621
622 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
623
624 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
625         REFIID riid, void**ppv)
626 {
627     if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
628         *ppv = iface;
629         return S_OK;
630     }
631
632     ok(0, "unexpected call\n");
633     return E_NOINTERFACE;
634 }
635
636 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
637 {
638     return 2;
639 }
640
641 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
642 {
643     return 1;
644 }
645
646 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
647 {
648     switch(dispID) {
649     case DISPID_READYSTATE:
650         CHECK_EXPECT2(OnChanged_READYSTATE);
651         test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
652             | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
653                ? OLECMDF_ENABLED : 0));
654
655         if(readystate_set_loading) {
656             readystate_set_loading = FALSE;
657             load_state = LD_LOADING;
658         }
659         if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
660             test_readyState(NULL);
661         return S_OK;
662     case 1005:
663         CHECK_EXPECT(OnChanged_1005);
664         if(!editmode)
665             test_readyState(NULL);
666         load_state = LD_INTERACTIVE;
667         return S_OK;
668     }
669
670     ok(0, "unexpected id %d\n", dispID);
671     return E_NOTIMPL;
672 }
673
674 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
675 {
676     ok(0, "unexpected call\n");
677     return E_NOTIMPL;
678 }
679
680 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
681     PropertyNotifySink_QueryInterface,
682     PropertyNotifySink_AddRef,
683     PropertyNotifySink_Release,
684     PropertyNotifySink_OnChanged,
685     PropertyNotifySink_OnRequestEdit
686 };
687
688 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
689
690 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
691 {
692     ok(0, "unexpected call\n");
693     return E_NOINTERFACE;
694 }
695
696 static ULONG WINAPI Stream_AddRef(IStream *iface)
697 {
698     return 2;
699 }
700
701 static ULONG WINAPI Stream_Release(IStream *iface)
702 {
703     return 1;
704 }
705
706 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
707                                   ULONG cb, ULONG *pcbRead)
708 {
709     CHECK_EXPECT2(Read);
710     ok(pv != NULL, "pv == NULL\n");
711     ok(cb > sizeof(html_page), "cb = %d\n", cb);
712     ok(pcbRead != NULL, "pcbRead == NULL\n");
713     ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
714
715     if(stream_read)
716         return S_FALSE;
717
718     memcpy(pv, html_page, sizeof(html_page)-1);
719     stream_read += *pcbRead = sizeof(html_page)-1;
720     return S_OK;
721 }
722
723 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
724                                           ULONG cb, ULONG *pcbWritten)
725 {
726     ok(0, "unexpected call\n");
727     return E_NOTIMPL;
728 }
729
730 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
731                                          DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
732 {
733     ok(0, "unexpected call\n");
734     return E_NOTIMPL;
735 }
736
737 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
738 {
739     ok(0, "unexpected call\n");
740     return E_NOTIMPL;
741 }
742
743 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
744         ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
745 {
746     ok(0, "unexpected call\n");
747     return E_NOTIMPL;
748 }
749
750 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
751 {
752     ok(0, "unexpected call\n");
753     return E_NOTIMPL;
754 }
755
756 static HRESULT WINAPI Stream_Revert(IStream *iface)
757 {
758     ok(0, "unexpected call\n");
759     return E_NOTIMPL;
760 }
761
762 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
763                                                ULARGE_INTEGER cb, DWORD dwLockType)
764 {
765     ok(0, "unexpected call\n");
766     return E_NOTIMPL;
767 }
768
769 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
770         ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
771 {
772     ok(0, "unexpected call\n");
773     return E_NOTIMPL;
774 }
775
776 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
777                                          DWORD dwStatFlag)
778 {
779     ok(0, "unexpected call\n");
780     return E_NOTIMPL;
781 }
782
783 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
784 {
785     ok(0, "unexpected call\n");
786     return E_NOTIMPL;
787 }
788
789 static const IStreamVtbl StreamVtbl = {
790     Stream_QueryInterface,
791     Stream_AddRef,
792     Stream_Release,
793     Stream_Read,
794     Stream_Write,
795     Stream_Seek,
796     Stream_SetSize,
797     Stream_CopyTo,
798     Stream_Commit,
799     Stream_Revert,
800     Stream_LockRegion,
801     Stream_UnlockRegion,
802     Stream_Stat,
803     Stream_Clone
804 };
805
806 static IStream Stream = { &StreamVtbl };
807
808 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
809 {
810     if(IsEqualGUID(&IID_IWinInetHttpInfo, riid))
811         return E_NOINTERFACE; /* TODO */
812
813     if(IsEqualGUID(&IID_IWinInetInfo, riid))
814         return E_NOINTERFACE; /* TODO */
815
816     ok(0, "unexpected call\n");
817     return E_NOINTERFACE;
818 }
819
820 static ULONG WINAPI Binding_AddRef(IBinding *iface)
821 {
822     return 2;
823 }
824
825 static ULONG WINAPI Binding_Release(IBinding *iface)
826 {
827     return 1;
828 }
829
830 static HRESULT WINAPI Binding_Abort(IBinding *iface)
831 {
832     CHECK_EXPECT(Abort);
833     return S_OK;
834 }
835
836 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
837 {
838     ok(0, "unexpected call\n");
839     return E_NOTIMPL;
840 }
841
842 static HRESULT WINAPI Binding_Resume(IBinding *iface)
843 {
844     ok(0, "unexpected call\n");
845     return E_NOTIMPL;
846 }
847
848 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
849 {
850     ok(0, "unexpected call\n");
851     return E_NOTIMPL;
852 }
853
854 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
855 {
856     ok(0, "unexpected call\n");
857     return E_NOTIMPL;
858 }
859
860 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
861         DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
862 {
863     CHECK_EXPECT(GetBindResult);
864     return E_NOTIMPL;
865 }
866
867 static const IBindingVtbl BindingVtbl = {
868     Binding_QueryInterface,
869     Binding_AddRef,
870     Binding_Release,
871     Binding_Abort,
872     Binding_Suspend,
873     Binding_Resume,
874     Binding_SetPriority,
875     Binding_GetPriority,
876     Binding_GetBindResult
877 };
878
879 static IBinding Binding = { &BindingVtbl };
880
881 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
882 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
883
884 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
885 {
886     *ppv = NULL;
887
888     if(IsEqualGUID(&IID_IMoniker_unk, riid))
889         return E_NOINTERFACE; /* TODO */
890     if(IsEqualGUID(&IID_IMoniker_unk2, riid))
891         return E_NOINTERFACE; /* TODO */
892
893     ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
894     return E_NOINTERFACE;
895 }
896
897 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
898 {
899     return 2;
900 }
901
902 static ULONG WINAPI Moniker_Release(IMoniker *iface)
903 {
904     return 1;
905 }
906
907 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
908 {
909     CHECK_EXPECT(GetClassID);
910     ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID));
911     return E_FAIL;
912 }
913
914 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
915 {
916     ok(0, "unexpected call\n");
917     return E_NOTIMPL;
918 }
919
920 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
921 {
922     ok(0, "unexpected call\n");
923     return E_NOTIMPL;
924 }
925
926 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
927 {
928     ok(0, "unexpected call\n");
929     return E_NOTIMPL;
930 }
931
932 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
933 {
934     ok(0, "unexpected call\n");
935     return E_NOTIMPL;
936 }
937
938 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
939         REFIID riidResult, void **ppvResult)
940 {
941     ok(0, "unexpected call\n");
942     return E_NOTIMPL;
943 }
944
945 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
946         REFIID riid, void **ppv)
947 {
948     IBindStatusCallback *callback = NULL;
949     FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
950     STGMEDIUM stgmedium;
951     BINDINFO bindinfo;
952     DWORD bindf;
953     HRESULT hres;
954
955     static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
956     static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
957
958     CHECK_EXPECT(BindToStorage);
959
960     load_state = LD_LOADING;
961
962     ok(pbc != NULL, "pbc == NULL\n");
963     ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
964     ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
965     ok(ppv != NULL, "ppv == NULL\n");
966     ok(*ppv == NULL, "*ppv=%p\n", *ppv);
967
968     hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
969     ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
970     ok(callback != NULL, "callback == NULL\n");
971
972     memset(&bindinfo, 0xf0, sizeof(bindinfo));
973     bindinfo.cbSize = sizeof(bindinfo);
974
975     hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
976     ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
977     ok(bindf == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08x\n", bindf);
978     ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%d\n", bindinfo.cbSize);
979     ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
980     /* TODO: test stgmedData */
981     ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08x\n", bindinfo.grfBindInfoF);
982     ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%d\n", bindinfo.dwBindVerb);
983     ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
984     ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%d\n", bindinfo.cbstgmedData);
985     ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000,
986        "bindinfo.dwOptions=%x\n", bindinfo.dwOptions);
987     ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%d\n", bindinfo.dwOptionsFlags);
988     /* TODO: test dwCodePage */
989     /* TODO: test securityAttributes */
990     ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
991     ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
992     ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%d\n", bindinfo.dwReserved);
993
994     hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
995     ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
996
997     hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
998                                           wszTextHtml);
999     ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1000
1001     hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1002                                           BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1003     ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1004
1005     SET_EXPECT(Read);
1006     stgmedium.tymed = TYMED_ISTREAM;
1007     U(stgmedium).pstm = &Stream;
1008     stgmedium.pUnkForRelease = (IUnknown*)iface;
1009     hres = IBindStatusCallback_OnDataAvailable(callback,
1010             BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1011             sizeof(html_page)-1, &formatetc, &stgmedium);
1012     ok(hres == S_OK, "OnDataAvailable failed: %08x\n", hres);
1013     CHECK_CALLED(Read);
1014
1015     hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1016             BINDSTATUS_ENDDOWNLOADDATA, NULL);
1017     ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08x\n", hres);
1018
1019     SET_EXPECT(GetBindResult);
1020     hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1021     ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
1022     SET_CALLED(GetBindResult); /* IE7 */
1023
1024     IBindStatusCallback_Release(callback);
1025
1026     return S_OK;
1027 }
1028
1029 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1030         IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1031 {
1032     ok(0, "unexpected call\n");
1033     return E_NOTIMPL;
1034 }
1035
1036 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1037         BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1038 {
1039     ok(0, "unexpected call\n");
1040     return E_NOTIMPL;
1041 }
1042
1043 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1044 {
1045     ok(0, "unexpected call\n");
1046     return E_NOTIMPL;
1047 }
1048
1049 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1050 {
1051     ok(0, "unexpected call\n");
1052     return E_NOTIMPL;
1053 }
1054
1055 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1056 {
1057     ok(0, "unexpected call\n");
1058     return E_NOTIMPL;
1059 }
1060
1061 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1062         IMoniker *pmkNewlyRunning)
1063 {
1064     ok(0, "unexpected call\n");
1065     return E_NOTIMPL;
1066 }
1067
1068 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1069         IMoniker *pmkToLeft, FILETIME *pFileTime)
1070 {
1071     ok(0, "unexpected call\n");
1072     return E_NOTIMPL;
1073 }
1074
1075 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1076 {
1077     ok(0, "unexpected call\n");
1078     return E_NOTIMPL;
1079 }
1080
1081 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1082         IMoniker **ppmkPrefix)
1083 {
1084     ok(0, "unexpected call\n");
1085     return E_NOTIMPL;
1086 }
1087
1088 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1089         IMoniker **pmkRelPath)
1090 {
1091     ok(0, "unexpected call\n");
1092     return E_NOTIMPL;
1093 }
1094
1095 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1096         IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1097 {
1098     CHECK_EXPECT2(GetDisplayName);
1099
1100     /* ok(pbc != NULL, "pbc == NULL\n"); */
1101     ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1102     ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1103
1104     *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1105     memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1106
1107     return S_OK;
1108 }
1109
1110 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1111         IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1112 {
1113     ok(0, "unexpected call\n");
1114     return E_NOTIMPL;
1115 }
1116
1117 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1118 {
1119     CHECK_EXPECT(IsSystemMoniker);
1120     return E_NOTIMPL;
1121 }
1122
1123 static const IMonikerVtbl MonikerVtbl = {
1124     Moniker_QueryInterface,
1125     Moniker_AddRef,
1126     Moniker_Release,
1127     Moniker_GetClassID,
1128     Moniker_IsDirty,
1129     Moniker_Load,
1130     Moniker_Save,
1131     Moniker_GetSizeMax,
1132     Moniker_BindToObject,
1133     Moniker_BindToStorage,
1134     Moniker_Reduce,
1135     Moniker_ComposeWith,
1136     Moniker_Enum,
1137     Moniker_IsEqual,
1138     Moniker_Hash,
1139     Moniker_IsRunning,
1140     Moniker_GetTimeOfLastChange,
1141     Moniker_Inverse,
1142     Moniker_CommonPrefixWith,
1143     Moniker_RelativePathTo,
1144     Moniker_GetDisplayName,
1145     Moniker_ParseDisplayName,
1146     Moniker_IsSystemMoniker
1147 };
1148
1149 static IMoniker Moniker = { &MonikerVtbl };
1150
1151 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1152 {
1153     return QueryInterface(riid, ppv);
1154 }
1155
1156 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1157 {
1158     return 2;
1159 }
1160
1161 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1162 {
1163     return 1;
1164 }
1165
1166 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1167         LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1168 {
1169     ok(0, "unexpected call\n");
1170     return E_NOTIMPL;
1171 }
1172
1173 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1174         IEnumUnknown **ppenum)
1175 {
1176     ok(0, "unexpected call\n");
1177     return E_NOTIMPL;
1178 }
1179
1180 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1181 {
1182     CHECK_EXPECT(LockContainer);
1183     ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1184     return S_OK;
1185 }
1186
1187 static const IOleContainerVtbl OleContainerVtbl = {
1188     OleContainer_QueryInterface,
1189     OleContainer_AddRef,
1190     OleContainer_Release,
1191     OleContainer_ParseDisplayName,
1192     OleContainer_EnumObjects,
1193     OleContainer_LockContainer
1194 };
1195
1196 static IOleContainer OleContainer = { &OleContainerVtbl };
1197
1198 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1199 {
1200     ok(0, "unexpected call\n");
1201     return E_NOINTERFACE;
1202 }
1203
1204 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1205 {
1206     return 2;
1207 }
1208
1209 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1210 {
1211     return 1;
1212 }
1213
1214 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1215 {
1216     ok(0, "unexpected call\n");
1217     return E_NOTIMPL;
1218 }
1219
1220 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1221 {
1222     ok(0, "unexpected call\n");
1223     return E_NOTIMPL;
1224 }
1225
1226 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1227 {
1228     ok(0, "unexpected call\n");
1229     return E_NOTIMPL;
1230 }
1231
1232 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
1233         LPCBORDERWIDTHS pborderwidths)
1234 {
1235     ok(0, "unexpected call\n");
1236     return E_NOTIMPL;
1237 }
1238
1239 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
1240         LPCBORDERWIDTHS pborderwidths)
1241 {
1242     CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
1243     return S_OK;
1244 }
1245
1246 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
1247         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1248 {
1249     static const WCHAR wszHTML_Document[] =
1250         {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1251
1252     CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
1253
1254     if(expect_InPlaceUIWindow_SetActiveObject_active) {
1255         ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1256         if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1257             ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1258     }
1259     else {
1260         ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1261         ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1262     }
1263     expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
1264     return S_OK;
1265 }
1266
1267 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
1268         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
1269 {
1270     static const WCHAR wszHTML_Document[] =
1271         {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
1272
1273     if(pActiveObject) {
1274         CHECK_EXPECT2(SetActiveObject);
1275
1276         if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH)
1277             ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
1278     }else {
1279         CHECK_EXPECT(SetActiveObject_null);
1280
1281         ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
1282         ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
1283     }
1284
1285     return S_OK;
1286 }
1287
1288 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
1289         LPOLEMENUGROUPWIDTHS lpMenuWidths)
1290 {
1291     ok(0, "unexpected call\n");
1292     return E_NOTIMPL;
1293 }
1294
1295 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
1296         HOLEMENU holemenu, HWND hwndActiveObject)
1297 {
1298     ok(0, "unexpected call\n");
1299     return E_NOTIMPL;
1300 }
1301
1302 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
1303 {
1304     ok(0, "unexpected call\n");
1305     return E_NOTIMPL;
1306 }
1307
1308 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
1309 {
1310     CHECK_EXPECT2(SetStatusText);
1311     if(!expect_status_text)
1312         ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
1313     return S_OK;
1314 }
1315
1316 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
1317 {
1318     if(fEnable)
1319         CHECK_EXPECT(Frame_EnableModeless_TRUE);
1320     else
1321         CHECK_EXPECT(Frame_EnableModeless_FALSE);
1322     return E_NOTIMPL;
1323 }
1324
1325 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
1326 {
1327     ok(0, "unexpected call\n");
1328     return E_NOTIMPL;
1329 }
1330
1331 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
1332     InPlaceFrame_QueryInterface,
1333     InPlaceFrame_AddRef,
1334     InPlaceFrame_Release,
1335     InPlaceFrame_GetWindow,
1336     InPlaceFrame_ContextSensitiveHelp,
1337     InPlaceFrame_GetBorder,
1338     InPlaceFrame_RequestBorderSpace,
1339     InPlaceFrame_SetBorderSpace,
1340     InPlaceFrame_SetActiveObject,
1341     InPlaceFrame_InsertMenus,
1342     InPlaceFrame_SetMenu,
1343     InPlaceFrame_RemoveMenus,
1344     InPlaceFrame_SetStatusText,
1345     InPlaceFrame_EnableModeless,
1346     InPlaceFrame_TranslateAccelerator
1347 };
1348
1349 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
1350
1351 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
1352     InPlaceFrame_QueryInterface,
1353     InPlaceFrame_AddRef,
1354     InPlaceFrame_Release,
1355     InPlaceFrame_GetWindow,
1356     InPlaceFrame_ContextSensitiveHelp,
1357     InPlaceFrame_GetBorder,
1358     InPlaceFrame_RequestBorderSpace,
1359     InPlaceFrame_SetBorderSpace,
1360     InPlaceUIWindow_SetActiveObject,
1361 };
1362
1363 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
1364
1365 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSiteEx *iface, REFIID riid, void **ppv)
1366 {
1367     return QueryInterface(riid, ppv);
1368 }
1369
1370 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSiteEx *iface)
1371 {
1372     return 2;
1373 }
1374
1375 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSiteEx *iface)
1376 {
1377     return 1;
1378 }
1379
1380 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSiteEx *iface, HWND *phwnd)
1381 {
1382     CHECK_EXPECT(GetWindow);
1383     ok(phwnd != NULL, "phwnd = NULL\n");
1384     *phwnd = container_hwnd;
1385     return S_OK;
1386 }
1387
1388 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSiteEx *iface, BOOL fEnterMode)
1389 {
1390     ok(0, "unexpected call\n");
1391     return E_NOTIMPL;
1392 }
1393
1394 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSiteEx *iface)
1395 {
1396     CHECK_EXPECT(CanInPlaceActivate);
1397     return S_OK;
1398 }
1399
1400 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSiteEx *iface)
1401 {
1402     CHECK_EXPECT(OnInPlaceActivate);
1403     return S_OK;
1404 }
1405
1406 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSiteEx *iface)
1407 {
1408     CHECK_EXPECT(OnUIActivate);
1409     return S_OK;
1410 }
1411
1412 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSiteEx *iface,
1413         IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
1414         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
1415 {
1416     static const RECT rect = {0,0,500,500};
1417
1418     CHECK_EXPECT(GetWindowContext);
1419
1420     ok(ppFrame != NULL, "ppFrame = NULL\n");
1421     if(ppFrame)
1422         *ppFrame = &InPlaceFrame;
1423     ok(ppDoc != NULL, "ppDoc = NULL\n");
1424     if(ppDoc)
1425         *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
1426     ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
1427     if(lprcPosRect)
1428         memcpy(lprcPosRect, &rect, sizeof(RECT));
1429     ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
1430     if(lprcClipRect)
1431         memcpy(lprcClipRect, &rect, sizeof(RECT));
1432     ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
1433     if(lpFrameInfo) {
1434         lpFrameInfo->cb = sizeof(*lpFrameInfo);
1435         lpFrameInfo->fMDIApp = FALSE;
1436         lpFrameInfo->hwndFrame = container_hwnd;
1437         lpFrameInfo->haccel = NULL;
1438         lpFrameInfo->cAccelEntries = 0;
1439     }
1440
1441     return S_OK;
1442 }
1443
1444 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSiteEx *iface, SIZE scrollExtant)
1445 {
1446     ok(0, "unexpected call\n");
1447     return E_NOTIMPL;
1448 }
1449
1450 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSiteEx *iface, BOOL fUndoable)
1451 {
1452     CHECK_EXPECT(OnUIDeactivate);
1453     ok(!fUndoable, "fUndoable = TRUE\n");
1454     return S_OK;
1455 }
1456
1457 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSiteEx *iface)
1458 {
1459     CHECK_EXPECT(OnInPlaceDeactivate);
1460     return S_OK;
1461 }
1462
1463 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSiteEx *iface)
1464 {
1465     ok(0, "unexpected call\n");
1466     return E_NOTIMPL;
1467 }
1468
1469 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSiteEx *iface)
1470 {
1471     ok(0, "unexpected call\n");
1472     return E_NOTIMPL;
1473 }
1474
1475 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSiteEx *iface, LPCRECT lprcPosRect)
1476 {
1477     ok(0, "unexpected call\n");
1478     return E_NOTIMPL;
1479 }
1480
1481 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceActivateEx(IOleInPlaceSiteEx *iface, BOOL *pfNoRedraw, DWORD dwFlags)
1482 {
1483     CHECK_EXPECT(OnInPlaceActivateEx);
1484
1485     ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
1486     ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
1487     ok(dwFlags == 0, "dwFlags = %08x\n", dwFlags);
1488
1489     return S_OK;
1490 }
1491
1492 static HRESULT WINAPI InPlaceSiteEx_OnInPlaceDeactivateEx(IOleInPlaceSiteEx *iface, BOOL fNoRedraw)
1493 {
1494     CHECK_EXPECT(OnInPlaceDeactivateEx);
1495
1496     ok(fNoRedraw, "fNoRedraw == FALSE\n");
1497
1498     return S_OK;
1499 }
1500
1501 static HRESULT WINAPI InPlaceSiteEx_RequestUIActivate(IOleInPlaceSiteEx *iface)
1502 {
1503     CHECK_EXPECT(RequestUIActivate);
1504     return S_OK;
1505 }
1506
1507 static const IOleInPlaceSiteExVtbl InPlaceSiteVtbl = {
1508     InPlaceSite_QueryInterface,
1509     InPlaceSite_AddRef,
1510     InPlaceSite_Release,
1511     InPlaceSite_GetWindow,
1512     InPlaceSite_ContextSensitiveHelp,
1513     InPlaceSite_CanInPlaceActivate,
1514     InPlaceSite_OnInPlaceActivate,
1515     InPlaceSite_OnUIActivate,
1516     InPlaceSite_GetWindowContext,
1517     InPlaceSite_Scroll,
1518     InPlaceSite_OnUIDeactivate,
1519     InPlaceSite_OnInPlaceDeactivate,
1520     InPlaceSite_DiscardUndoState,
1521     InPlaceSite_DeactivateAndUndo,
1522     InPlaceSite_OnPosRectChange,
1523     InPlaceSiteEx_OnInPlaceActivateEx,
1524     InPlaceSiteEx_OnInPlaceDeactivateEx,
1525     InPlaceSiteEx_RequestUIActivate
1526 };
1527
1528 static IOleInPlaceSiteEx InPlaceSiteEx = { &InPlaceSiteVtbl };
1529
1530 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1531 {
1532     return QueryInterface(riid, ppv);
1533 }
1534
1535 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1536 {
1537     return 2;
1538 }
1539
1540 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1541 {
1542     return 1;
1543 }
1544
1545 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1546 {
1547     ok(0, "unexpected call\n");
1548     return E_NOTIMPL;
1549 }
1550
1551 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1552         IMoniker **ppmon)
1553 {
1554     ok(0, "unexpected call\n");
1555     return E_NOTIMPL;
1556 }
1557
1558 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1559 {
1560     CHECK_EXPECT(GetContainer);
1561     ok(ppContainer != NULL, "ppContainer = NULL\n");
1562     *ppContainer = &OleContainer;
1563     return S_OK;
1564 }
1565
1566 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1567 {
1568     ok(0, "unexpected call\n");
1569     return E_NOTIMPL;
1570 }
1571
1572 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1573 {
1574     ok(0, "unexpected call\n");
1575     return E_NOTIMPL;
1576 }
1577
1578 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1579 {
1580     ok(0, "unexpected call\n");
1581     return E_NOTIMPL;
1582 }
1583
1584 static const IOleClientSiteVtbl ClientSiteVtbl = {
1585     ClientSite_QueryInterface,
1586     ClientSite_AddRef,
1587     ClientSite_Release,
1588     ClientSite_SaveObject,
1589     ClientSite_GetMoniker,
1590     ClientSite_GetContainer,
1591     ClientSite_ShowObject,
1592     ClientSite_OnShowWindow,
1593     ClientSite_RequestNewObjectLayout
1594 };
1595
1596 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1597
1598 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
1599 {
1600     return QueryInterface(riid, ppv);
1601 }
1602
1603 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
1604 {
1605     return 2;
1606 }
1607
1608 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
1609 {
1610     return 1;
1611 }
1612
1613 typedef enum
1614 {
1615     CallUIActivate_None,
1616     CallUIActivate_ActivateMe,
1617     CallUIActivate_AfterShow,
1618 } CallUIActivate;
1619
1620 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
1621 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
1622 {
1623     IOleDocument *document;
1624     HRESULT hres;
1625
1626     CHECK_EXPECT(ActivateMe);
1627     ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
1628
1629     hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
1630     ok(hres == S_OK, "could not get IOleDocument: %08x\n", hres);
1631
1632     if(SUCCEEDED(hres)) {
1633         hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteEx, NULL, 0, &view);
1634         ok(hres == S_OK, "CreateView failed: %08x\n", hres);
1635
1636         if(SUCCEEDED(hres)) {
1637             IOleInPlaceActiveObject *activeobj = NULL;
1638             IOleInPlaceSite *inplacesite = NULL;
1639             HWND tmp_hwnd = NULL;
1640             static RECT rect = {0,0,400,500};
1641
1642             hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1643             ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1644             ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1645                     inplacesite, &InPlaceSiteEx);
1646
1647             hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteEx);
1648             ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
1649
1650             hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1651             ok(hres == S_OK, "GetInPlaceSite failed: %08x\n", hres);
1652             ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteEx, "inplacesite=%p, expected %p\n",
1653                     inplacesite, &InPlaceSiteEx);
1654
1655             hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
1656             ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08x\n", hres);
1657
1658             if(activeobj) {
1659                 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1660                 ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1661                 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
1662             }
1663             
1664             if(call_UIActivate == CallUIActivate_ActivateMe) {
1665                 SET_EXPECT(CanInPlaceActivate);
1666                 SET_EXPECT(GetWindowContext);
1667                 SET_EXPECT(GetWindow);
1668                 if(ipsex)
1669                     SET_EXPECT(OnInPlaceActivateEx);
1670                 else
1671                     SET_EXPECT(OnInPlaceActivate);
1672                 SET_EXPECT(SetStatusText);
1673                 SET_EXPECT(Exec_SETPROGRESSMAX);
1674                 SET_EXPECT(Exec_SETPROGRESSPOS);
1675                 SET_EXPECT(OnUIActivate);
1676                 SET_EXPECT(SetActiveObject);
1677                 SET_EXPECT(ShowUI);
1678                 expect_status_text = NULL;
1679
1680                 hres = IOleDocumentView_UIActivate(view, TRUE);
1681                 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1682
1683                 CHECK_CALLED(CanInPlaceActivate);
1684                 CHECK_CALLED(GetWindowContext);
1685                 CHECK_CALLED(GetWindow);
1686                 if(ipsex)
1687                     CHECK_CALLED(OnInPlaceActivateEx);
1688                 else
1689                     CHECK_CALLED(OnInPlaceActivate);
1690                 CHECK_CALLED(SetStatusText);
1691                 CHECK_CALLED(Exec_SETPROGRESSMAX);
1692                 CHECK_CALLED(Exec_SETPROGRESSPOS);
1693                 CHECK_CALLED(OnUIActivate);
1694                 CHECK_CALLED(SetActiveObject);
1695                 CHECK_CALLED(ShowUI);
1696
1697                 if(activeobj) {
1698                     hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1699                     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1700                     ok(hwnd != NULL, "hwnd == NULL\n");
1701                     if(last_hwnd)
1702                         ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1703                 }
1704
1705                 hres = IOleDocumentView_UIActivate(view, TRUE);
1706                 ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
1707
1708                 if(activeobj) {
1709                     hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
1710                     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1711                     ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1712                 }
1713             }
1714
1715             hres = IOleDocumentView_SetRect(view, &rect);
1716             ok(hres == S_OK, "SetRect failed: %08x\n", hres);
1717
1718             if(call_UIActivate == CallUIActivate_ActivateMe) {
1719                 hres = IOleDocumentView_Show(view, TRUE);
1720                 ok(hres == S_OK, "Show failed: %08x\n", hres);
1721             }else {
1722                 SET_EXPECT(CanInPlaceActivate);
1723                 SET_EXPECT(GetWindowContext);
1724                 SET_EXPECT(GetWindow);
1725                 if(ipsex)
1726                     SET_EXPECT(OnInPlaceActivateEx);
1727                 else
1728                     SET_EXPECT(OnInPlaceActivate);
1729                 SET_EXPECT(SetStatusText);
1730                 SET_EXPECT(Exec_SETPROGRESSMAX);
1731                 SET_EXPECT(Exec_SETPROGRESSPOS);
1732                 SET_EXPECT(OnUIActivate);
1733                 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
1734
1735                 hres = IOleDocumentView_Show(view, TRUE);
1736                 if(FAILED(hres)) {
1737                     win_skip("Show failed\n");
1738                     if(activeobj)
1739                         IOleInPlaceActiveObject_Release(activeobj);
1740                     IOleDocument_Release(document);
1741                     show_failed = TRUE;
1742                     return S_OK;
1743                 }
1744                 ok(hres == S_OK, "Show failed: %08x\n", hres);
1745
1746                 CHECK_CALLED(CanInPlaceActivate);
1747                 CHECK_CALLED(GetWindowContext);
1748                 CHECK_CALLED(GetWindow);
1749                 if(ipsex)
1750                     CHECK_CALLED(OnInPlaceActivateEx);
1751                 else
1752                     CHECK_CALLED(OnInPlaceActivate);
1753                 CHECK_CALLED(SetStatusText);
1754                 CHECK_CALLED(Exec_SETPROGRESSMAX);
1755                 CHECK_CALLED(Exec_SETPROGRESSPOS);
1756
1757                 if(activeobj) {
1758                     hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
1759                     ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
1760                     ok(hwnd != NULL, "hwnd == NULL\n");
1761                     if(last_hwnd)
1762                         ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
1763                 }
1764             }
1765
1766             test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
1767
1768             if(activeobj)
1769                 IOleInPlaceActiveObject_Release(activeobj);
1770         }
1771
1772         IOleDocument_Release(document);
1773     }
1774
1775     return S_OK;
1776 }
1777
1778 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
1779     DocumentSite_QueryInterface,
1780     DocumentSite_AddRef,
1781     DocumentSite_Release,
1782     DocumentSite_ActivateMe
1783 };
1784
1785 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
1786
1787 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
1788 {
1789     return QueryInterface(riid, ppv);
1790 }
1791
1792 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
1793 {
1794     return 2;
1795 }
1796
1797 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
1798 {
1799     return 1;
1800 }
1801
1802 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
1803 {
1804     ok(0, "unexpected call\n");
1805     return E_NOTIMPL;
1806 }
1807
1808 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
1809 {
1810     ok(0, "unexpected call\n");
1811     return E_NOTIMPL;
1812 }
1813
1814 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
1815 {
1816     ok(0, "unexpected call\n");
1817     return E_NOTIMPL;
1818 }
1819
1820 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
1821         POINTF *pPtfContainer, DWORD dwFlags)
1822 {
1823     ok(0, "unexpected call\n");
1824     return E_NOTIMPL;
1825 }
1826
1827 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
1828         MSG *pMsg, DWORD grfModifiers)
1829 {
1830     ok(0, "unexpected call\n");
1831     return E_NOTIMPL;
1832 }
1833
1834 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
1835 {
1836     if(fGotFocus)
1837         CHECK_EXPECT(OnFocus_TRUE);
1838     else
1839         CHECK_EXPECT2(OnFocus_FALSE);
1840     return S_OK;
1841 }
1842
1843 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
1844 {
1845     ok(0, "unexpected call\n");
1846     return E_NOTIMPL;
1847 }
1848
1849 static const IOleControlSiteVtbl OleControlSiteVtbl = {
1850     OleControlSite_QueryInterface,
1851     OleControlSite_AddRef,
1852     OleControlSite_Release,
1853     OleControlSite_OnControlInfoChanged,
1854     OleControlSite_LockInPlaceActive,
1855     OleControlSite_GetExtendedControl,
1856     OleControlSite_TransformCoords,
1857     OleControlSite_TranslateAccelerator,
1858     OleControlSite_OnFocus,
1859     OleControlSite_ShowPropertyFrame
1860 };
1861
1862 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
1863
1864 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
1865 {
1866     return QueryInterface(riid, ppv);
1867 }
1868
1869 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
1870 {
1871     return 2;
1872 }
1873
1874 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
1875 {
1876     return 1;
1877 }
1878
1879 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
1880         IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
1881 {
1882     ok(0, "unexpected call\n");
1883     return E_NOTIMPL;
1884 }
1885
1886 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
1887 {
1888     CHECK_EXPECT(GetHostInfo);
1889     ok(pInfo != NULL, "pInfo=NULL\n");
1890     if(pInfo) {
1891         ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%u\n", pInfo->cbSize);
1892         ok(!pInfo->dwFlags, "pInfo->dwFlags=%08x, expected 0\n", pInfo->dwFlags);
1893         pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
1894             | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
1895             | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
1896         ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08x, expected 0\n", pInfo->dwDoubleClick);
1897         ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
1898         ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
1899     }
1900     return S_OK;
1901 }
1902
1903 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
1904         IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
1905         IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
1906 {
1907     CHECK_EXPECT(ShowUI);
1908
1909     if (editmode)
1910         ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%d, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
1911     else
1912         ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%d, expected DOCHOSTUITYPE_BROWSE\n", dwID);
1913     ok(pActiveObject != NULL, "pActiveObject = NULL\n");
1914     ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
1915     ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
1916     if (expect_InPlaceUIWindow_SetActiveObject_active)
1917         ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
1918     else
1919         ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
1920
1921     return S_OK;
1922 }
1923
1924 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
1925 {
1926     CHECK_EXPECT(HideUI);
1927     return S_OK;
1928 }
1929
1930 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
1931 {
1932     CHECK_EXPECT(UpdateUI);
1933     return S_OK;
1934 }
1935
1936 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
1937 {
1938     if(fEnable)
1939         CHECK_EXPECT(EnableModeless_TRUE);
1940     else
1941         CHECK_EXPECT(EnableModeless_FALSE);
1942     return E_NOTIMPL;
1943 }
1944
1945 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1946 {
1947     ok(0, "unexpected call\n");
1948     return E_NOTIMPL;
1949 }
1950
1951 static BOOL expect_OnFrameWindowActivate_fActivate;
1952 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
1953 {
1954     CHECK_EXPECT2(OnFrameWindowActivate);
1955     ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
1956     return S_OK;
1957 }
1958
1959 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
1960         IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
1961 {
1962     ok(0, "unexpected call\n");
1963     return E_NOTIMPL;
1964 }
1965
1966 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
1967         const GUID *pguidCmdGroup, DWORD nCmdID)
1968 {
1969     ok(0, "unexpected call\n");
1970     return E_NOTIMPL;
1971 }
1972
1973 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
1974         LPOLESTR *pchKey, DWORD dw)
1975 {
1976     CHECK_EXPECT(GetOptionKeyPath);
1977     ok(pchKey != NULL, "pchKey = NULL\n");
1978     ok(!dw, "dw=%d, expected 0\n", dw);
1979     if(pchKey)
1980         ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
1981     return S_OK;
1982 }
1983
1984 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
1985         IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
1986 {
1987     CHECK_EXPECT(GetDropTarget);
1988     /* TODO */
1989     return E_NOTIMPL;
1990 }
1991
1992 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
1993 {
1994     CHECK_EXPECT(GetExternal);
1995     *ppDispatch = &External;
1996     return S_FALSE;
1997 }
1998
1999 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2000         OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2001 {
2002     ok(0, "unexpected call\n");
2003     return E_NOTIMPL;
2004 }
2005
2006 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2007         IDataObject **ppPORet)
2008 {
2009     ok(0, "unexpected call\n");
2010     return E_NOTIMPL;
2011 }
2012
2013 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2014         LPOLESTR *pchKey, DWORD dw)
2015 {
2016     CHECK_EXPECT(GetOverrideKeyPath);
2017     ok(pchKey != NULL, "pchKey = NULL\n");
2018     if(pchKey)
2019         ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2020     ok(!dw, "dw=%d, xepected 0\n", dw);
2021     return S_OK;
2022 }
2023
2024 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2025     DocHostUIHandler_QueryInterface,
2026     DocHostUIHandler_AddRef,
2027     DocHostUIHandler_Release,
2028     DocHostUIHandler_ShowContextMenu,
2029     DocHostUIHandler_GetHostInfo,
2030     DocHostUIHandler_ShowUI,
2031     DocHostUIHandler_HideUI,
2032     DocHostUIHandler_UpdateUI,
2033     DocHostUIHandler_EnableModeless,
2034     DocHostUIHandler_OnDocWindowActivate,
2035     DocHostUIHandler_OnFrameWindowActivate,
2036     DocHostUIHandler_ResizeBorder,
2037     DocHostUIHandler_TranslateAccelerator,
2038     DocHostUIHandler_GetOptionKeyPath,
2039     DocHostUIHandler_GetDropTarget,
2040     DocHostUIHandler_GetExternal,
2041     DocHostUIHandler_TranslateUrl,
2042     DocHostUIHandler_FilterDataObject,
2043     DocHostUIHandler_GetOverrideKeyPath
2044 };
2045
2046 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2047
2048 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2049         REFIID riid, void **ppv)
2050 {
2051     return QueryInterface(riid, ppv);
2052 }
2053
2054 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2055 {
2056     return 2;
2057 }
2058
2059 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2060 {
2061     return 1;
2062 }
2063
2064 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2065         ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2066 {
2067     ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2068     ok(cCmds == 1, "cCmds=%d, expected 1\n", cCmds);
2069     ok(!pCmdText, "pCmdText != NULL\n");
2070
2071     switch(prgCmds[0].cmdID) {
2072     case OLECMDID_SETPROGRESSTEXT:
2073         CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2074         prgCmds[0].cmdf = OLECMDF_ENABLED;
2075         return S_OK;
2076     case OLECMDID_OPEN:
2077         CHECK_EXPECT(QueryStatus_OPEN);
2078         prgCmds[0].cmdf = 0;
2079         return S_OK;
2080     case OLECMDID_NEW:
2081         CHECK_EXPECT(QueryStatus_NEW);
2082         prgCmds[0].cmdf = 0;
2083         return S_OK;
2084     default:
2085         ok(0, "unexpected command %d\n", prgCmds[0].cmdID);
2086     };
2087
2088     return E_FAIL;
2089 }
2090
2091 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2092         DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
2093 {
2094     if(!pguidCmdGroup || !IsEqualGUID(pguidCmdGroup, &CGID_Explorer))
2095         test_readyState(NULL);
2096
2097     if(!pguidCmdGroup) {
2098         switch(nCmdID) {
2099         case OLECMDID_SETPROGRESSMAX:
2100             CHECK_EXPECT2(Exec_SETPROGRESSMAX);
2101             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2102             ok(pvaIn != NULL, "pvaIn == NULL\n");
2103             if(pvaIn) {
2104                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2105                 if(load_state == LD_NO)
2106                     ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2107             }
2108             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2109             return S_OK;
2110         case OLECMDID_SETPROGRESSPOS:
2111             CHECK_EXPECT2(Exec_SETPROGRESSPOS);
2112             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2113             ok(pvaIn != NULL, "pvaIn == NULL\n");
2114             if(pvaIn) {
2115                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2116                 if(load_state == LD_NO)
2117                     ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2118             }
2119             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2120             return S_OK;
2121         case OLECMDID_HTTPEQUIV_DONE:
2122             CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
2123             ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2124             ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2125             ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2126             load_state = LD_COMPLETE;
2127             return S_OK;
2128         case OLECMDID_SETDOWNLOADSTATE:
2129             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2130             ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2131             ok(pvaIn != NULL, "pvaIn == NULL\n");
2132             ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2133
2134             switch(V_I4(pvaIn)) {
2135             case 0:
2136                 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
2137                 load_state = LD_INTERACTIVE;
2138                 break;
2139             case 1:
2140                 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
2141                 break;
2142             default:
2143                 ok(0, "unexpevted V_I4(pvaIn)=%d\n", V_I4(pvaIn));
2144             }
2145
2146             return S_OK;
2147         case OLECMDID_UPDATECOMMANDS:
2148             CHECK_EXPECT(Exec_UPDATECOMMANDS);
2149             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2150             ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
2151             ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2152             return S_OK;
2153         case OLECMDID_SETTITLE:
2154             CHECK_EXPECT2(Exec_SETTITLE);
2155             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2156             ok(pvaIn != NULL, "pvaIn == NULL\n");
2157             ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
2158             ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
2159             ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
2160             return S_OK;
2161         case OLECMDID_HTTPEQUIV:
2162             CHECK_EXPECT2(Exec_HTTPEQUIV);
2163             ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08x\n", nCmdexecopt);
2164             /* TODO */
2165             return S_OK;
2166         default:
2167             ok(0, "unexpected command %d\n", nCmdID);
2168             return E_FAIL;
2169         };
2170     }
2171
2172     if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
2173         ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2174
2175         switch(nCmdID) {
2176         case 37:
2177             CHECK_EXPECT2(Exec_ShellDocView_37);
2178
2179             if(load_from_stream)
2180                 test_GetCurMoniker(doc_unk, NULL, about_blank_url);
2181             else if(!editmode)
2182                 test_GetCurMoniker(doc_unk, &Moniker, NULL);
2183
2184             ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
2185             ok(pvaIn != NULL, "pvaIn == NULL\n");
2186             if(pvaIn) {
2187                 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
2188                 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%d, expected 0\n", V_I4(pvaIn));
2189             }
2190             return S_OK;
2191         case 84:
2192             CHECK_EXPECT2(Exec_ShellDocView_84);
2193
2194             ok(pvaIn == NULL, "pvaIn != NULL\n");
2195             ok(pvaOut != NULL, "pvaOut == NULL\n");
2196             if(pvaIn)
2197                 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
2198
2199             return E_NOTIMPL;
2200
2201         case 103:
2202             CHECK_EXPECT2(Exec_ShellDocView_103);
2203
2204             ok(pvaIn == NULL, "pvaIn != NULL\n");
2205             ok(pvaOut == NULL, "pvaOut != NULL\n");
2206
2207             return E_NOTIMPL;
2208
2209         default:
2210             ok(0, "unexpected command %d\n", nCmdID);
2211             return E_FAIL;
2212         };
2213     }
2214
2215     if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
2216         ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2217
2218         switch(nCmdID) {
2219         case IDM_PARSECOMPLETE:
2220             CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2221             ok(pvaIn == NULL, "pvaIn != NULL\n");
2222             ok(pvaOut == NULL, "pvaOut != NULL\n");
2223             return S_OK;
2224         default:
2225             ok(0, "unexpected command %d\n", nCmdID);
2226         };
2227     }
2228
2229     if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup))
2230         return E_FAIL; /* TODO */
2231
2232     if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
2233         ok(nCmdexecopt == 0, "nCmdexecopts=%08x\n", nCmdexecopt);
2234
2235         switch(nCmdID) {
2236         case 69:
2237             CHECK_EXPECT2(Exec_Explorer_69);
2238             ok(pvaIn == NULL, "pvaIn != NULL\n");
2239             ok(pvaOut != NULL, "pvaOut == NULL\n");
2240             return E_NOTIMPL;
2241         default:
2242             ok(0, "unexpected cmd %d of CGID_Explorer\n", nCmdID);
2243         }
2244         return E_NOTIMPL;
2245     }
2246
2247     if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
2248         switch (nCmdID) {
2249         case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
2250             SET_EXPECT(SetStatusText);
2251             ok(pvaIn == NULL, "pvaIn != NULL\n");
2252             ok(pvaOut == NULL, "pvaOut != NULL\n");
2253             return S_OK;
2254         default:
2255             ok(0, "unexpected command %d\n", nCmdID);
2256             return E_FAIL;
2257         }
2258     }
2259
2260     ok(0, "unexpected pguidCmdGroup: %s\n", debugstr_guid(pguidCmdGroup));
2261     return E_NOTIMPL;
2262 }
2263
2264 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
2265     OleCommandTarget_QueryInterface,
2266     OleCommandTarget_AddRef,
2267     OleCommandTarget_Release,
2268     OleCommandTarget_QueryStatus,
2269     OleCommandTarget_Exec
2270 };
2271
2272 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
2273
2274 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
2275 {
2276     return QueryInterface(riid, ppv);
2277 }
2278
2279 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
2280         LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
2281         EXCEPINFO *pExcepInfo, UINT *puArgErr)
2282 {
2283     ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
2284     ok(pDispParams != NULL, "pDispParams == NULL\n");
2285     ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
2286     ok(puArgErr != NULL, "puArgErr == NULL\n");
2287     ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
2288     ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
2289     test_readyState(NULL);
2290
2291     switch(dispIdMember) {
2292     case DISPID_AMBIENT_USERMODE:
2293         CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
2294         V_VT(pVarResult) = VT_BOOL;
2295         V_BOOL(pVarResult) = VARIANT_TRUE;
2296         return S_OK;
2297     case DISPID_AMBIENT_DLCONTROL:
2298         CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
2299         return E_FAIL;
2300     case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
2301         CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2302         return E_FAIL;
2303     case DISPID_AMBIENT_SILENT:
2304         CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
2305         V_VT(pVarResult) = VT_BOOL;
2306         V_BOOL(pVarResult) = VARIANT_FALSE;
2307         return S_OK;
2308     case DISPID_AMBIENT_USERAGENT:
2309         CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
2310         return E_FAIL;
2311     case DISPID_AMBIENT_PALETTE:
2312         CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
2313         return E_FAIL;
2314     };
2315
2316     ok(0, "unexpected dispid %d\n", dispIdMember);
2317     return E_FAIL;
2318 }
2319
2320 static IDispatchVtbl DispatchVtbl = {
2321     Dispatch_QueryInterface,
2322     Dispatch_AddRef,
2323     Dispatch_Release,
2324     Dispatch_GetTypeInfoCount,
2325     Dispatch_GetTypeInfo,
2326     Dispatch_GetIDsOfNames,
2327     Dispatch_Invoke
2328 };
2329
2330 static IDispatch Dispatch = { &DispatchVtbl };
2331
2332 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
2333                                                      REFIID riid, void **ppv)
2334 {
2335     return QueryInterface(riid, ppv);
2336 }
2337
2338 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
2339 {
2340     return 2;
2341 }
2342
2343 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
2344 {
2345     return 1;
2346 }
2347
2348 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
2349                                     REFIID riid, void **ppv)
2350 {
2351     /*
2352      * Services used by HTMLDocument:
2353      *
2354      * IOleUndoManager
2355      * IInternetSecurityManager
2356      * ITargetFrame
2357      * {D5F78C80-5252-11CF-90FA-00AA0042106E}
2358      * HTMLFrameBase
2359      * IShellObject
2360      * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
2361      * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
2362      * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
2363      * DefView (?)
2364      * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
2365      * IElementBehaviorFactory
2366      * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
2367      * STopLevelBrowser
2368      * IHTMLWindow2
2369      * IInternetProtocol
2370      * IWebBrowserApp
2371      * UrlHostory
2372      * IHTMLEditHost
2373      * IHlinkFrame
2374      */
2375
2376     if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
2377         ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
2378         *ppv = &HlinkFrame;
2379         return S_OK;
2380     }
2381
2382     return E_NOINTERFACE;
2383 }
2384
2385 static const IServiceProviderVtbl ServiceProviderVtbl = {
2386     ServiceProvider_QueryInterface,
2387     ServiceProvider_AddRef,
2388     ServiceProvider_Release,
2389     ServiceProvider_QueryService
2390 };
2391
2392 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
2393
2394 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
2395 DEFINE_GUID(IID_unk2, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
2396 DEFINE_GUID(IID_unk3, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
2397
2398 static HRESULT QueryInterface(REFIID riid, void **ppv)
2399 {
2400     *ppv = NULL;
2401
2402     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
2403         *ppv = &ClientSite;
2404     else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
2405         *ppv = &DocumentSite;
2406     else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
2407         *ppv = &DocHostUIHandler;
2408     else if(IsEqualGUID(&IID_IOleContainer, riid))
2409         *ppv = &OleContainer;
2410     else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
2411         *ppv = &InPlaceSiteEx;
2412     else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
2413         *ppv = &OleCommandTarget;
2414     else if(IsEqualGUID(&IID_IDispatch, riid))
2415         *ppv = &Dispatch;
2416     else if(IsEqualGUID(&IID_IServiceProvider, riid))
2417         *ppv = &ServiceProvider;
2418     else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
2419         *ppv = ipsex ? &InPlaceSiteEx : NULL;
2420     else if(IsEqualGUID(&IID_IOleControlSite, riid))
2421         *ppv = &OleControlSite;
2422     else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2423         return E_NOINTERFACE; /* TODO */
2424     else if(IsEqualGUID(&IID_IProxyManager, riid))
2425         return E_NOINTERFACE; /* ? */
2426     else if(IsEqualGUID(&IID_unk1, riid))
2427         return E_NOINTERFACE; /* HTMLWindow2 ? */
2428     else if(IsEqualGUID(&IID_unk2, riid))
2429         return E_NOINTERFACE; /* ? */
2430     else if(IsEqualGUID(&IID_unk3, riid))
2431         return E_NOINTERFACE; /* ? */
2432     else
2433         ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2434
2435     if(*ppv)
2436         return S_OK;
2437     return E_NOINTERFACE;
2438 }
2439
2440 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
2441 {
2442     return DefWindowProc(hwnd, msg, wParam, lParam);
2443 }
2444
2445 static void _test_readyState(unsigned line, IUnknown *unk)
2446 {
2447     IHTMLDocument2 *htmldoc;
2448     DISPPARAMS dispparams;
2449     BSTR state;
2450     VARIANT out;
2451     HRESULT hres;
2452
2453     static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
2454     static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
2455     static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
2456     static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
2457
2458     static const LPCWSTR expected_state[] = {
2459         wszUninitialized,
2460         wszLoading,
2461         NULL,
2462         wszInteractive,
2463         wszComplete,
2464         wszUninitialized
2465     };
2466
2467     if(!unk)
2468         unk = doc_unk;
2469
2470     hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
2471     ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2472     if(FAILED(hres))
2473         return;
2474
2475     hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
2476     ok(hres == E_POINTER, "get_readyState failed: %08x, expected\n", hres);
2477
2478     hres = IHTMLDocument2_get_readyState(htmldoc, &state);
2479     ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres);
2480     ok_(__FILE__, line)
2481         (!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n",
2482          debugstr_w(state), load_state);
2483     SysFreeString(state);
2484
2485     dispparams.cArgs = 0;
2486     dispparams.cNamedArgs = 0;
2487     dispparams.rgdispidNamedArgs = NULL;
2488     dispparams.rgvarg = NULL;
2489
2490     VariantInit(&out);
2491
2492     hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
2493                                  &dispparams, &out, NULL, NULL);
2494     ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08x\n", hres);
2495
2496     ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
2497     ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%d, expected %d\n", V_I4(&out), load_state%5);
2498
2499     IHTMLDocument2_Release(htmldoc);
2500 }
2501
2502 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
2503 {
2504     IConnectionPointContainer *tmp_container = NULL;
2505     IConnectionPoint *cp;
2506     IID iid;
2507     HRESULT hres;
2508
2509     hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
2510     ok(hres == S_OK, "FindConnectionPoint failed: %08x\n", hres);
2511     if(FAILED(hres))
2512         return;
2513
2514     hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
2515     ok(hres == S_OK, "GetConnectionInterface failed: %08x\n", hres);
2516     ok(IsEqualGUID(riid, &iid), "wrong iid\n");
2517
2518     hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
2519     ok(hres == E_POINTER, "GetConnectionInterface failed: %08x, expected E_POINTER\n", hres);
2520
2521     hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
2522     ok(hres == S_OK, "GetConnectionPointContainer failed: %08x\n", hres);
2523     ok(tmp_container == container, "container != tmp_container\n");
2524     if(SUCCEEDED(hres))
2525         IConnectionPointContainer_Release(tmp_container);
2526
2527     hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
2528     ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08x, expected E_POINTER\n", hres);
2529
2530     if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
2531         DWORD cookie;
2532
2533         hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
2534         ok(hres == S_OK, "Advise failed: %08x\n", hres);
2535     }
2536
2537     IConnectionPoint_Release(cp);
2538 }
2539
2540 static void test_ConnectionPointContainer(IUnknown *unk)
2541 {
2542     IConnectionPointContainer *container;
2543     HRESULT hres;
2544
2545     hres = IUnknown_QueryInterface(unk, &IID_IConnectionPointContainer, (void**)&container);
2546     ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres);
2547     if(FAILED(hres))
2548         return;
2549
2550     test_ConnectionPoint(container, &IID_IPropertyNotifySink);
2551     test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
2552     test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
2553
2554     IConnectionPointContainer_Release(container);
2555 }
2556
2557 static void test_GetCurMoniker(IUnknown *unk, IMoniker *exmon, LPCWSTR exurl)
2558 {
2559     IHTMLDocument2 *doc;
2560     IPersistMoniker *permon;
2561     IMoniker *mon = (void*)0xdeadbeef;
2562     BSTR doc_url = (void*)0xdeadbeef;
2563     HRESULT hres;
2564
2565     hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
2566     ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2567     if(FAILED(hres))
2568         return;
2569
2570     hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
2571     ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08x\n", hres);
2572
2573     hres = IHTMLDocument2_get_URL(doc, &doc_url);
2574     ok(hres == S_OK, "get_URL failed: %08x\n", hres);
2575
2576     hres = IPersistMoniker_GetCurMoniker(permon, &mon);
2577     IPersistMoniker_Release(permon);
2578
2579     if(exmon) {
2580         LPOLESTR url;
2581         BOOL exb = expect_GetDisplayName;
2582         BOOL clb = called_GetDisplayName;
2583
2584         ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2585         ok(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
2586
2587         SET_EXPECT(GetDisplayName);
2588         hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2589         ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2590         CHECK_CALLED(GetDisplayName);
2591         expect_GetDisplayName = exb;
2592         called_GetDisplayName = clb;
2593
2594         ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2595         CoTaskMemFree(url);
2596     }else if(exurl) {
2597         LPOLESTR url;
2598
2599         ok(hres == S_OK, "GetCurrentMoniker failed: %08x\n", hres);
2600
2601         hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
2602         ok(hres == S_OK, "GetDisplayName failed: %08x\n", hres);
2603
2604         ok(!lstrcmpW(url, exurl), "unexpected url\n");
2605         ok(!lstrcmpW(url, doc_url), "url != doc_url\n");
2606
2607         CoTaskMemFree(url);
2608     }else {
2609         ok(hres == E_UNEXPECTED,
2610            "GetCurrentMoniker failed: %08x, expected E_UNEXPECTED\n", hres);
2611         ok(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
2612         ok(!lstrcmpW(doc_url, about_blank_url), "doc_url is not about:blank\n");
2613     }
2614
2615     SysFreeString(doc_url);
2616     IHTMLDocument_Release(doc);
2617     if(mon && mon != (void*)0xdeadbeef)
2618         IMoniker_Release(mon);
2619 }
2620
2621 static void test_Load(IPersistMoniker *persist)
2622 {
2623     IBindCtx *bind;
2624     HRESULT hres;
2625     WCHAR sz_html_clientsite_objectparam[MAX_PATH];
2626
2627     lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
2628
2629     test_readyState((IUnknown*)persist);
2630
2631     CreateBindCtx(0, &bind);
2632     IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
2633                                  (IUnknown*)&ClientSite);
2634
2635     SET_EXPECT(GetDisplayName);
2636     if(!set_clientsite) {
2637         SET_EXPECT(Invoke_AMBIENT_USERMODE);
2638         SET_EXPECT(GetHostInfo);
2639         SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
2640         SET_EXPECT(Invoke_AMBIENT_SILENT);
2641         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2642         SET_EXPECT(Invoke_AMBIENT_USERAGENT);
2643         SET_EXPECT(Invoke_AMBIENT_PALETTE);
2644         SET_EXPECT(GetOptionKeyPath);
2645         SET_EXPECT(GetOverrideKeyPath);
2646         SET_EXPECT(GetWindow);
2647         SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
2648         SET_EXPECT(Exec_SETPROGRESSMAX);
2649         SET_EXPECT(Exec_SETPROGRESSPOS);
2650         SET_EXPECT(Exec_ShellDocView_37);
2651     }
2652     if(!container_locked) {
2653         SET_EXPECT(GetContainer);
2654         SET_EXPECT(LockContainer);
2655     }
2656     SET_EXPECT(OnChanged_READYSTATE);
2657     SET_EXPECT(Exec_ShellDocView_84);
2658     SET_EXPECT(IsSystemMoniker);
2659     SET_EXPECT(BindToStorage);
2660     SET_EXPECT(SetActiveObject);
2661     if(set_clientsite) {
2662         SET_EXPECT(Invoke_AMBIENT_SILENT);
2663         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2664         SET_EXPECT(Exec_ShellDocView_37);
2665     }
2666     load_state = LD_DOLOAD;
2667     expect_LockContainer_fLock = TRUE;
2668     readystate_set_loading = TRUE;
2669
2670     hres = IPersistMoniker_Load(persist, FALSE, &Moniker, bind, 0x12);
2671     ok(hres == S_OK, "Load failed: %08x\n", hres);
2672
2673     CHECK_CALLED(GetDisplayName);
2674     if(!set_clientsite) {
2675         CHECK_CALLED(Invoke_AMBIENT_USERMODE);
2676         CHECK_CALLED(GetHostInfo);
2677         CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
2678         CHECK_CALLED(Invoke_AMBIENT_SILENT);
2679         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2680         CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
2681         CHECK_CALLED(Invoke_AMBIENT_PALETTE);
2682         CHECK_CALLED(GetOptionKeyPath);
2683         CHECK_CALLED(GetOverrideKeyPath);
2684         CHECK_CALLED(GetWindow);
2685         CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
2686         CHECK_CALLED(Exec_SETPROGRESSMAX);
2687         CHECK_CALLED(Exec_SETPROGRESSPOS);
2688         CHECK_CALLED(Exec_ShellDocView_37);
2689     }
2690     if(!container_locked) {
2691         CHECK_CALLED(GetContainer);
2692         CHECK_CALLED(LockContainer);
2693         container_locked = TRUE;
2694     }
2695     CHECK_CALLED(OnChanged_READYSTATE);
2696     SET_CALLED(IsSystemMoniker); /* IE7 */
2697     SET_CALLED(Exec_ShellDocView_84);
2698     CHECK_CALLED(BindToStorage);
2699     SET_CALLED(SetActiveObject); /* FIXME */
2700     if(set_clientsite) {
2701         CHECK_CALLED(Invoke_AMBIENT_SILENT);
2702         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
2703         CHECK_CALLED(Exec_ShellDocView_37);
2704     }
2705
2706     set_clientsite = container_locked = TRUE;
2707
2708     test_GetCurMoniker((IUnknown*)persist, &Moniker, NULL);
2709
2710     IBindCtx_Release(bind);
2711
2712     test_readyState((IUnknown*)persist);
2713 }
2714
2715 static void test_download(BOOL verb_done, BOOL css_dwl, BOOL css_try_dwl)
2716 {
2717     HWND hwnd;
2718     MSG msg;
2719
2720     hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
2721     ok(hwnd != NULL, "Could not find hidden window\n");
2722
2723     test_readyState(NULL);
2724
2725     if(verb_done) {
2726         SET_EXPECT(Exec_SETPROGRESSMAX);
2727         if(!load_from_stream)
2728             SET_EXPECT(GetHostInfo);
2729     }
2730     SET_EXPECT(SetStatusText);
2731     SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
2732     SET_EXPECT(GetDropTarget);
2733     if(css_try_dwl)
2734         SET_EXPECT(Exec_ShellDocView_84);
2735     if(css_dwl) {
2736         SET_EXPECT(CreateInstance);
2737         SET_EXPECT(Start);
2738         SET_EXPECT(LockRequest);
2739         SET_EXPECT(Terminate);
2740         SET_EXPECT(Protocol_Read);
2741         SET_EXPECT(UnlockRequest);
2742     }
2743     SET_EXPECT(Exec_Explorer_69);
2744     SET_EXPECT(EnableModeless_TRUE); /* IE7 */
2745     SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
2746     SET_EXPECT(EnableModeless_FALSE); /* IE7 */
2747     SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
2748     SET_EXPECT(OnChanged_1005);
2749     SET_EXPECT(OnChanged_READYSTATE);
2750     SET_EXPECT(Exec_SETPROGRESSPOS);
2751     SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
2752     SET_EXPECT(Exec_ShellDocView_103);
2753     SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
2754     SET_EXPECT(Exec_HTTPEQUIV_DONE);
2755     SET_EXPECT(SetStatusText);
2756     expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
2757
2758     while(!called_Exec_HTTPEQUIV_DONE && GetMessage(&msg, NULL, 0, 0)) {
2759         TranslateMessage(&msg);
2760         DispatchMessage(&msg);
2761     }
2762
2763     if(verb_done) {
2764         CHECK_CALLED(Exec_SETPROGRESSMAX);
2765         if(!load_from_stream)
2766             CHECK_CALLED(GetHostInfo);
2767     }
2768     CHECK_CALLED(SetStatusText);
2769     CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
2770     CHECK_CALLED(GetDropTarget);
2771     if(css_try_dwl)
2772         SET_CALLED(Exec_ShellDocView_84);
2773     if(css_dwl) {
2774         if(called_CreateInstance) {
2775             CHECK_CALLED(CreateInstance);
2776             CHECK_CALLED(Start);
2777             CHECK_CALLED(LockRequest);
2778             CHECK_CALLED(Terminate);
2779             CHECK_CALLED(Protocol_Read);
2780             CHECK_CALLED(UnlockRequest);
2781         }else {
2782             skip("CreateInstance not called. Assuming no Gecko installed.\n");
2783
2784             SET_CALLED(Exec_ShellDocView_84);
2785             SET_CALLED(CreateInstance);
2786             SET_CALLED(Start);
2787             SET_CALLED(LockRequest);
2788             SET_CALLED(Terminate);
2789             SET_CALLED(Protocol_Read);
2790             SET_CALLED(UnlockRequest);
2791
2792             nogecko = TRUE;
2793         }
2794     }
2795     SET_CALLED(Exec_Explorer_69);
2796     SET_CALLED(EnableModeless_TRUE); /* IE7 */
2797     SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
2798     SET_CALLED(EnableModeless_FALSE); /* IE7 */
2799     SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
2800     CHECK_CALLED(OnChanged_1005);
2801     CHECK_CALLED(OnChanged_READYSTATE);
2802     CHECK_CALLED(Exec_SETPROGRESSPOS);
2803     CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
2804     SET_CALLED(Exec_ShellDocView_103);
2805     CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
2806     CHECK_CALLED(Exec_HTTPEQUIV_DONE);
2807     SET_CALLED(SetStatusText);
2808
2809     load_state = LD_COMPLETE;
2810
2811     test_readyState(NULL);
2812 }
2813
2814 static void test_Persist(IUnknown *unk)
2815 {
2816     IPersistMoniker *persist_mon;
2817     IPersistFile *persist_file;
2818     GUID guid;
2819     HRESULT hres;
2820
2821     hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&persist_file);
2822     ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08x\n", hres);
2823     if(SUCCEEDED(hres)) {
2824         hres = IPersist_GetClassID(persist_file, NULL);
2825         ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2826
2827         hres = IPersist_GetClassID(persist_file, &guid);
2828         ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2829         ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2830
2831         IPersist_Release(persist_file);
2832     }
2833
2834     hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&persist_mon);
2835     ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08x\n", hres);
2836     if(SUCCEEDED(hres)) {
2837         hres = IPersistMoniker_GetClassID(persist_mon, NULL);
2838         ok(hres == E_INVALIDARG, "GetClassID returned: %08x, expected E_INVALIDARG\n", hres);
2839
2840         hres = IPersistMoniker_GetClassID(persist_mon, &guid);
2841         ok(hres == S_OK, "GetClassID failed: %08x\n", hres);
2842         ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
2843
2844         if(load_state == LD_DOLOAD)
2845             test_Load(persist_mon);
2846
2847         test_readyState(unk);
2848
2849         IPersistMoniker_Release(persist_mon);
2850     }
2851 }
2852
2853 static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = {
2854     0,
2855     OLECMDF_SUPPORTED,                  /* OLECMDID_OPEN */
2856     OLECMDF_SUPPORTED,                  /* OLECMDID_NEW */
2857     OLECMDF_SUPPORTED,                  /* OLECMDID_SAVE */
2858     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_SAVEAS */
2859     OLECMDF_SUPPORTED,                  /* OLECMDID_SAVECOPYAS */
2860     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_PRINT */
2861     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_PRINTPREVIEW */
2862     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_PAGESETUP */
2863     OLECMDF_SUPPORTED,                  /* OLECMDID_SPELL */
2864     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_PROPERTIES */
2865     OLECMDF_SUPPORTED,                  /* OLECMDID_CUT */
2866     OLECMDF_SUPPORTED,                  /* OLECMDID_COPY */
2867     OLECMDF_SUPPORTED,                  /* OLECMDID_PASTE */
2868     OLECMDF_SUPPORTED,                  /* OLECMDID_PASTESPECIAL */
2869     OLECMDF_SUPPORTED,                  /* OLECMDID_UNDO */
2870     OLECMDF_SUPPORTED,                  /* OLECMDID_REDO */
2871     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_SELECTALL */
2872     OLECMDF_SUPPORTED,                  /* OLECMDID_CLEARSELECTION */
2873     OLECMDF_SUPPORTED,                  /* OLECMDID_ZOOM */
2874     OLECMDF_SUPPORTED,                  /* OLECMDID_GETZOOMRANGE */
2875     0,
2876     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_REFRESH */
2877     OLECMDF_SUPPORTED|OLECMDF_ENABLED,  /* OLECMDID_STOP */
2878     0,0,0,0,0,0,
2879     OLECMDF_SUPPORTED,                  /* OLECMDID_STOPDOWNLOAD */
2880     0,0,
2881     OLECMDF_SUPPORTED,                  /* OLECMDID_DELETE */
2882     0,0,
2883     OLECMDF_SUPPORTED,                  /* OLECMDID_ENABLE_INTERACTION */
2884     OLECMDF_SUPPORTED,                  /* OLECMDID_ONUNLOAD */
2885     0,0,0,0,0,
2886     OLECMDF_SUPPORTED,                  /* OLECMDID_SHOWPAGESETUP */
2887     OLECMDF_SUPPORTED,                  /* OLECMDID_SHOWPRINT */
2888     0,0,
2889     OLECMDF_SUPPORTED,                  /* OLECMDID_CLOSE */
2890     0,0,0,
2891     OLECMDF_SUPPORTED,                  /* OLECMDID_SETPRINTTEMPLATE */
2892     OLECMDF_SUPPORTED                   /* OLECMDID_GETPRINTTEMPLATE */
2893 };
2894
2895 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
2896 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
2897 {
2898     IOleCommandTarget *cmdtrg;
2899     OLECMD olecmd = {cmdid, 0};
2900     HRESULT hres;
2901
2902     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2903     ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2904     if(FAILED(hres))
2905         return;
2906
2907     hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
2908     ok(hres == S_OK, "QueryStatus(%u) failed: %08x\n", cmdid, hres);
2909
2910     IOleCommandTarget_Release(cmdtrg);
2911
2912     ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
2913     ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf);
2914 }
2915
2916 static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf)
2917 {
2918     if(!unk)
2919         unk = doc_unk;
2920
2921     test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
2922     test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
2923     test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
2924     test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
2925     test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
2926     test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
2927     test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
2928     test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
2929     test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
2930     test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
2931     test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
2932     test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
2933     test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
2934     test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
2935     test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
2936     test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
2937 }
2938
2939 static void test_OleCommandTarget(IUnknown *unk)
2940 {
2941     IOleCommandTarget *cmdtrg;
2942     OLECMD cmds[OLECMDID_GETPRINTTEMPLATE];
2943     int i;
2944     HRESULT hres;
2945
2946     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2947     ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres);
2948     if(FAILED(hres))
2949         return;
2950
2951     for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2952         cmds[i].cmdID = i+1;
2953         cmds[i].cmdf = 0xf0f0;
2954     }
2955
2956     SET_EXPECT(QueryStatus_OPEN);
2957     SET_EXPECT(QueryStatus_NEW);
2958     hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, sizeof(cmds)/sizeof(cmds[0]), cmds, NULL);
2959     ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2960     CHECK_CALLED(QueryStatus_OPEN);
2961     CHECK_CALLED(QueryStatus_NEW);
2962
2963     for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
2964         ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %x\n", i, cmds[i].cmdID);
2965         if(i+1 == OLECMDID_FIND)
2966             continue;
2967         ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%x, expected %x\n",
2968                 i+1, cmds[i].cmdf, expect_cmds[i+1]);
2969     }
2970
2971     ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
2972        "cmds[OLECMDID_FIND].cmdf=%x\n", cmds[OLECMDID_FIND-1].cmdf);
2973
2974     IOleCommandTarget_Release(cmdtrg);
2975 }
2976
2977 static void test_OleCommandTarget_fail(IUnknown *unk)
2978 {
2979     IOleCommandTarget *cmdtrg;
2980     int i;
2981     HRESULT hres;
2982
2983     OLECMD cmd[2] = {
2984         {OLECMDID_OPEN, 0xf0f0},
2985         {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
2986     };
2987
2988     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
2989     ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08x\n", hres);
2990     if(FAILED(hres))
2991         return;
2992
2993     hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
2994     ok(hres == S_OK, "QueryStatus failed: %08x\n", hres);
2995
2996     SET_EXPECT(QueryStatus_OPEN);
2997     hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
2998     CHECK_CALLED(QueryStatus_OPEN);
2999
3000     ok(hres == OLECMDERR_E_NOTSUPPORTED,
3001             "QueryStatus failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3002     ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
3003             "cmd[0].cmdID=%d, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
3004     ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%x, expected 0\n", cmd[0].cmdf);
3005     ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
3006             "cmd[1].cmdf=%x, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
3007
3008     hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
3009     ok(hres == OLECMDERR_E_UNKNOWNGROUP,
3010             "QueryStatus failed: %08x, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
3011
3012     for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
3013         if(!expect_cmds[i]) {
3014             hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
3015                     OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3016             ok(hres == OLECMDERR_E_NOTSUPPORTED,
3017                     "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3018         }
3019     }
3020
3021     hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
3022             OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3023     ok(hres == OLECMDERR_E_NOTSUPPORTED,
3024             "Exec failed: %08x, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
3025
3026     IOleCommandTarget_Release(cmdtrg);
3027 }
3028
3029 static void test_exec_onunload(IUnknown *unk)
3030 {
3031     IOleCommandTarget *cmdtrg;
3032     VARIANT var;
3033     HRESULT hres;
3034
3035     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3036     ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3037     if(FAILED(hres))
3038         return;
3039
3040     memset(&var, 0x0a, sizeof(var));
3041     hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3042             OLECMDEXECOPT_DODEFAULT, NULL, &var);
3043     ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3044     ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
3045     ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
3046
3047     hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
3048             OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3049     ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08x\n", hres);
3050
3051     IOleCommandTarget_Release(cmdtrg);
3052 }
3053
3054 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
3055 {
3056     IOleCommandTarget *cmdtrg;
3057     HRESULT hres;
3058
3059     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3060     ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3061     if(FAILED(hres))
3062         return;
3063
3064     editmode = TRUE;
3065
3066     if(loaded)
3067         load_state = LD_DOLOAD;
3068
3069     if(loaded)
3070         SET_EXPECT(GetClassID);
3071     SET_EXPECT(SetStatusText);
3072     SET_EXPECT(Exec_ShellDocView_37);
3073     SET_EXPECT(GetHostInfo);
3074     if(loaded)
3075         SET_EXPECT(GetDisplayName);
3076     SET_EXPECT(Invoke_AMBIENT_SILENT);
3077     SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3078     SET_EXPECT(OnChanged_READYSTATE);
3079     SET_EXPECT(IsSystemMoniker);
3080     SET_EXPECT(Exec_ShellDocView_84);
3081     if(loaded)
3082         SET_EXPECT(BindToStorage);
3083     SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3084     SET_EXPECT(HideUI);
3085     SET_EXPECT(ShowUI);
3086     SET_EXPECT(InPlaceFrame_SetBorderSpace);
3087
3088     expect_status_text = NULL;
3089     readystate_set_loading = TRUE;
3090
3091     hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3092             OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3093     ok(hres == S_OK, "Exec failed: %08x\n", hres);
3094
3095     if(loaded)
3096         CHECK_CALLED(GetClassID);
3097     CHECK_CALLED(SetStatusText);
3098     CHECK_CALLED(Exec_ShellDocView_37);
3099     CHECK_CALLED(GetHostInfo);
3100     if(loaded)
3101         CHECK_CALLED(GetDisplayName);
3102     CHECK_CALLED(Invoke_AMBIENT_SILENT);
3103     CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3104     CHECK_CALLED(OnChanged_READYSTATE);
3105     SET_CALLED(IsSystemMoniker); /* IE7 */
3106     SET_CALLED(Exec_ShellDocView_84);
3107     if(loaded)
3108         CHECK_CALLED(BindToStorage);
3109     CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3110     CHECK_CALLED(HideUI);
3111     CHECK_CALLED(ShowUI);
3112     CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3113
3114     test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
3115
3116     IOleCommandTarget_Release(cmdtrg);
3117
3118     hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
3119             OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3120     ok(hres == S_OK, "Exec failed: %08x\n", hres);
3121 }
3122
3123 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
3124 {
3125    IOleCommandTarget *cmdtrg;
3126    VARIANT *in = NULL, _in, *out = NULL, _out;
3127    HRESULT hres;
3128
3129    hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3130    ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08x\n", hres);
3131    if(FAILED(hres))
3132        return;
3133
3134    if(name) {
3135        in = &_in;
3136        V_VT(in) = VT_BSTR;
3137        V_BSTR(in) = SysAllocString(name);
3138    }
3139
3140    if(exname) {
3141        out = &_out;
3142        V_VT(out) = VT_I4;
3143        V_I4(out) = 0xdeadbeef;
3144    }
3145
3146    hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
3147    if(!nogecko)
3148        ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08x\n", hres);
3149
3150    if(in)
3151        VariantClear(in);
3152
3153    if(out && !nogecko) {
3154        ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
3155        if(V_VT(out) == VT_BSTR) {
3156            if(exname)
3157                ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
3158                   "unexpected fontname \"%s\"\n", debugstr_w(name));
3159            else
3160                ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
3161        }
3162        VariantClear(out);
3163    }
3164
3165    IOleCommandTarget_Release(cmdtrg);
3166 }
3167
3168 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
3169 {
3170     IOleCommandTarget *cmdtrg;
3171     HRESULT hres;
3172
3173     hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
3174     ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08x\n", hres);
3175     if(FAILED(hres))
3176         return;
3177
3178     hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
3179             OLECMDEXECOPT_DODEFAULT, NULL, NULL);
3180     ok(hres == S_OK, "Exec failed: %08x\n", hres);
3181
3182     IOleCommandTarget_Release(cmdtrg);
3183 }
3184
3185 static void test_IsDirty(IUnknown *unk, HRESULT exhres)
3186 {
3187     IPersistStreamInit *perinit;
3188     IPersistMoniker *permon;
3189     IPersistFile *perfile;
3190     HRESULT hres;
3191
3192     hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&perinit);
3193     ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08x\n", hres);
3194     if(SUCCEEDED(hres)) {
3195         hres = IPersistStreamInit_IsDirty(perinit);
3196         ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3197         IPersistStreamInit_Release(perinit);
3198     }
3199
3200     hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
3201     ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08x\n", hres);
3202     if(SUCCEEDED(hres)) {
3203         hres = IPersistMoniker_IsDirty(permon);
3204         ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3205         IPersistMoniker_Release(permon);
3206     }
3207
3208     hres = IUnknown_QueryInterface(unk, &IID_IPersistFile, (void**)&perfile);
3209     ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08x\n", hres);
3210     if(SUCCEEDED(hres)) {
3211         hres = IPersistFile_IsDirty(perfile);
3212         ok(hres == exhres, "IsDirty() = %08x, expected %08x\n", hres, exhres);
3213         IPersistFile_Release(perfile);
3214     }
3215 }
3216
3217 static HWND create_container_window(void)
3218 {
3219     static const WCHAR wszHTMLDocumentTest[] =
3220         {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
3221     static WNDCLASSEXW wndclass = {
3222         sizeof(WNDCLASSEXW),
3223         0,
3224         wnd_proc,
3225         0, 0, NULL, NULL, NULL, NULL, NULL,
3226         wszHTMLDocumentTest,
3227         NULL
3228     };
3229
3230     RegisterClassExW(&wndclass);
3231     return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
3232             WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
3233             515, 530, NULL, NULL, NULL, NULL);
3234 }
3235
3236 static void test_DoVerb(IOleObject *oleobj)
3237 {
3238     RECT rect = {0,0,500,500};
3239     HRESULT hres;
3240
3241     if(!container_locked) {
3242         SET_EXPECT(GetContainer);
3243         SET_EXPECT(LockContainer);
3244     }
3245     SET_EXPECT(ActivateMe);
3246     expect_LockContainer_fLock = TRUE;
3247
3248     hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
3249     ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
3250
3251     if(!container_locked) {
3252         CHECK_CALLED(GetContainer);
3253         CHECK_CALLED(LockContainer);
3254         container_locked = TRUE;
3255     }
3256     CHECK_CALLED(ActivateMe);
3257 }
3258
3259 #define CLIENTSITE_EXPECTPATH 0x00000001
3260 #define CLIENTSITE_SETNULL    0x00000002
3261 #define CLIENTSITE_DONTSET    0x00000004
3262
3263 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
3264 {
3265     IOleClientSite *clientsite;
3266     HRESULT hres;
3267
3268     if(flags & CLIENTSITE_SETNULL) {
3269         hres = IOleObject_GetClientSite(oleobj, &clientsite);
3270         ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
3271
3272         hres = IOleObject_SetClientSite(oleobj, NULL);
3273         ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3274
3275         set_clientsite = FALSE;
3276     }
3277
3278     if(flags & CLIENTSITE_DONTSET)
3279         return;
3280
3281     hres = IOleObject_GetClientSite(oleobj, &clientsite);
3282     ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3283     ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
3284             clientsite, set_clientsite ? &ClientSite : NULL);
3285
3286     if(!set_clientsite) {
3287         SET_EXPECT(GetHostInfo);
3288         if(flags & CLIENTSITE_EXPECTPATH) {
3289             SET_EXPECT(GetOptionKeyPath);
3290             SET_EXPECT(GetOverrideKeyPath);
3291         }
3292         SET_EXPECT(GetWindow);
3293         SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
3294         SET_EXPECT(Exec_SETPROGRESSMAX);
3295         SET_EXPECT(Exec_SETPROGRESSPOS);
3296         SET_EXPECT(Invoke_AMBIENT_USERMODE);
3297         SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3298         SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3299         SET_EXPECT(Invoke_AMBIENT_SILENT);
3300         SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3301         SET_EXPECT(Invoke_AMBIENT_PALETTE);
3302
3303         hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3304         ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3305
3306         CHECK_CALLED(GetHostInfo);
3307         if(flags & CLIENTSITE_EXPECTPATH) {
3308             CHECK_CALLED(GetOptionKeyPath);
3309             CHECK_CALLED(GetOverrideKeyPath);
3310         }
3311         CHECK_CALLED(GetWindow);
3312         CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
3313         CHECK_CALLED(Exec_SETPROGRESSMAX);
3314         CHECK_CALLED(Exec_SETPROGRESSPOS);
3315         CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3316         CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3317         CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); 
3318         CHECK_CALLED(Invoke_AMBIENT_SILENT);
3319         CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3320         CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3321
3322         set_clientsite = TRUE;
3323     }
3324
3325     hres = IOleObject_SetClientSite(oleobj, &ClientSite);
3326     ok(hres == S_OK, "SetClientSite failed: %08x\n", hres);
3327
3328     hres = IOleObject_GetClientSite(oleobj, &clientsite);
3329     ok(hres == S_OK, "GetClientSite failed: %08x\n", hres);
3330     ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
3331 }
3332
3333 static void test_OnAmbientPropertyChange(IUnknown *unk)
3334 {
3335     IOleControl *control = NULL;
3336     HRESULT hres;
3337
3338     hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3339     ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3340     if(FAILED(hres))
3341         return;
3342
3343     SET_EXPECT(Invoke_AMBIENT_USERMODE);
3344     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
3345     ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3346     CHECK_CALLED(Invoke_AMBIENT_USERMODE);
3347
3348     SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3349     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
3350     ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3351     CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3352
3353     SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3354     SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3355     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
3356     ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3357     CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3358     CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3359
3360     SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
3361     SET_EXPECT(Invoke_AMBIENT_SILENT);
3362     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
3363     ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3364     CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
3365     CHECK_CALLED(Invoke_AMBIENT_SILENT);
3366
3367     SET_EXPECT(Invoke_AMBIENT_USERAGENT);
3368     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
3369     ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3370     CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
3371
3372     SET_EXPECT(Invoke_AMBIENT_PALETTE);
3373     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3374     ok(hres == S_OK, "OnAmbientChange failed: %08x\n", hres);
3375     CHECK_CALLED(Invoke_AMBIENT_PALETTE);
3376
3377     IOleControl_Release(control);
3378 }
3379
3380
3381
3382 static void test_OnAmbientPropertyChange2(IUnknown *unk)
3383 {
3384     IOleControl *control = NULL;
3385     HRESULT hres;
3386
3387     hres = IUnknown_QueryInterface(unk, &IID_IOleControl, (void**)&control);
3388     ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08x\n", hres);
3389     if(FAILED(hres))
3390         return;
3391
3392     hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
3393     ok(hres == S_OK, "OnAmbientPropertyChange failed: %08x\n", hres);
3394
3395     IOleControl_Release(control);
3396 }
3397
3398 static void test_Close(IUnknown *unk, BOOL set_client)
3399 {
3400     IOleObject *oleobj = NULL;
3401     HRESULT hres;
3402
3403     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3404     ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3405     if(FAILED(hres))
3406         return;
3407
3408     SET_EXPECT(GetContainer);
3409     SET_EXPECT(LockContainer);
3410     expect_LockContainer_fLock = FALSE;
3411     hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
3412     ok(hres == S_OK, "Close failed: %08x\n", hres);
3413     CHECK_CALLED(GetContainer);
3414     CHECK_CALLED(LockContainer);
3415     container_locked = FALSE;
3416
3417     if(set_client)
3418         test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
3419
3420     IOleObject_Release(oleobj);
3421 }
3422
3423 static void test_OnFrameWindowActivate(IUnknown *unk)
3424 {
3425     IOleInPlaceActiveObject *inplaceact;
3426     HRESULT hres;
3427
3428     hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
3429     ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08x\n", hres);
3430     if(FAILED(hres))
3431         return;
3432
3433     if(set_clientsite) {
3434         expect_OnFrameWindowActivate_fActivate = TRUE;
3435         SET_EXPECT(OnFrameWindowActivate);
3436         hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3437         ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3438         CHECK_CALLED(OnFrameWindowActivate);
3439
3440         SET_EXPECT(OnFrameWindowActivate);
3441         hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3442         ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3443         CHECK_CALLED(OnFrameWindowActivate);
3444
3445         expect_OnFrameWindowActivate_fActivate = FALSE;
3446         SET_EXPECT(OnFrameWindowActivate);
3447         hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3448         ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3449         CHECK_CALLED(OnFrameWindowActivate);
3450
3451         expect_OnFrameWindowActivate_fActivate = TRUE;
3452         SET_EXPECT(OnFrameWindowActivate);
3453         hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3454         ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3455         CHECK_CALLED(OnFrameWindowActivate);
3456     }else {
3457         hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
3458         ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3459
3460         hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
3461         ok(hres == S_OK, "OnFrameWindowActivate failed: %08x\n", hres);
3462     }
3463
3464     IOleInPlaceActiveObject_Release(inplaceact);
3465 }
3466
3467 static void test_InPlaceDeactivate(IUnknown *unk, BOOL expect_call)
3468 {
3469     IOleInPlaceObjectWindowless *windowlessobj = NULL;
3470     HRESULT hres;
3471
3472     hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceObjectWindowless,
3473             (void**)&windowlessobj);
3474     ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08x\n", hres);
3475     if(FAILED(hres))
3476         return;
3477
3478     if(expect_call) {
3479         SET_EXPECT(OnFocus_FALSE);
3480         if(ipsex)
3481             SET_EXPECT(OnInPlaceDeactivateEx);
3482         else
3483             SET_EXPECT(OnInPlaceDeactivate);
3484     }
3485     hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
3486     ok(hres == S_OK, "InPlaceDeactivate failed: %08x\n", hres);
3487     if(expect_call) {
3488         CHECK_CALLED(OnFocus_FALSE);
3489         if(ipsex)
3490             CHECK_CALLED(OnInPlaceDeactivateEx);
3491         else
3492             CHECK_CALLED(OnInPlaceDeactivate);
3493     }
3494
3495     IOleInPlaceObjectWindowless_Release(windowlessobj);
3496 }
3497
3498 static void test_Activate(IUnknown *unk, DWORD flags)
3499 {
3500     IOleObject *oleobj = NULL;
3501     IOleDocumentView *docview;
3502     GUID guid;
3503     HRESULT hres;
3504
3505     last_hwnd = hwnd;
3506
3507     if(view)
3508         IOleDocumentView_Release(view);
3509     view = NULL;
3510
3511     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3512     ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08x\n", hres);
3513
3514     hres = IOleObject_GetUserClassID(oleobj, NULL);
3515     ok(hres == E_INVALIDARG, "GetUserClassID returned: %08x, expected E_INVALIDARG\n", hres);
3516
3517     hres = IOleObject_GetUserClassID(oleobj, &guid);
3518     ok(hres == S_OK, "GetUserClassID failed: %08x\n", hres);
3519     ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
3520
3521     test_OnFrameWindowActivate(unk);
3522
3523     test_ClientSite(oleobj, flags);
3524     test_InPlaceDeactivate(unk, FALSE);
3525     test_DoVerb(oleobj);
3526
3527     if(call_UIActivate == CallUIActivate_AfterShow) {
3528         hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3529         ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3530
3531         SET_EXPECT(OnFocus_TRUE);
3532         SET_EXPECT(SetActiveObject);
3533         SET_EXPECT(ShowUI);
3534         SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3535         SET_EXPECT(InPlaceFrame_SetBorderSpace);
3536         expect_status_text = NULL;
3537
3538         hres = IOleDocumentView_UIActivate(docview, TRUE);
3539         ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3540
3541         CHECK_CALLED(OnFocus_TRUE);
3542         CHECK_CALLED(SetActiveObject);
3543         CHECK_CALLED(ShowUI);
3544         CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3545         CHECK_CALLED(InPlaceFrame_SetBorderSpace);
3546
3547         IOleDocumentView_Release(docview);
3548     }
3549
3550     IOleObject_Release(oleobj);
3551
3552     test_OnFrameWindowActivate(unk);
3553 }
3554
3555 static void test_Window(IUnknown *unk, BOOL expect_success)
3556 {
3557     IOleInPlaceActiveObject *activeobject = NULL;
3558     HWND tmp_hwnd;
3559     HRESULT hres;
3560
3561     hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
3562     ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08x\n", hres);
3563     if(FAILED(hres))
3564         return;
3565
3566     hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
3567
3568     if(expect_success) {
3569         ok(hres == S_OK, "GetWindow failed: %08x\n", hres);
3570         ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
3571     }else {
3572         ok(hres == E_FAIL, "GetWindow returned %08x, expected E_FAIL\n", hres);
3573         ok(IsWindow(hwnd), "hwnd is destroyed\n");
3574     }
3575
3576     IOleInPlaceActiveObject_Release(activeobject);
3577 }
3578
3579 static void test_CloseView(void)
3580 {
3581     IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
3582     HRESULT hres;
3583
3584     if(!view)
3585         return;
3586
3587     hres = IOleDocumentView_Show(view, FALSE);
3588     ok(hres == S_OK, "Show failed: %08x\n", hres);
3589
3590     hres = IOleDocumentView_CloseView(view, 0);
3591     ok(hres == S_OK, "CloseView failed: %08x\n", hres);
3592
3593     hres = IOleDocumentView_SetInPlaceSite(view, NULL);
3594     ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3595
3596     hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
3597     ok(hres == S_OK, "SetInPlaceSite failed: %08x\n", hres);
3598     ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
3599 }
3600
3601 static void test_UIDeactivate(void)
3602 {
3603     HRESULT hres;
3604
3605     if(call_UIActivate == CallUIActivate_AfterShow) {
3606         SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3607     }
3608     if(call_UIActivate != CallUIActivate_None) {
3609         SET_EXPECT(SetActiveObject_null);
3610         SET_EXPECT(HideUI);
3611         SET_EXPECT(OnUIDeactivate);
3612     }
3613
3614     hres = IOleDocumentView_UIActivate(view, FALSE);
3615     ok(hres == S_OK, "UIActivate failed: %08x\n", hres);
3616
3617     if(call_UIActivate != CallUIActivate_None) {
3618         CHECK_CALLED(SetActiveObject_null);
3619         CHECK_CALLED(HideUI);
3620         CHECK_CALLED(OnUIDeactivate);
3621     }
3622     if(call_UIActivate == CallUIActivate_AfterShow) {
3623         CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
3624     }
3625 }
3626
3627 static void test_Hide(void)
3628 {
3629     HRESULT hres;
3630
3631     if(!view)
3632         return;
3633
3634     hres = IOleDocumentView_Show(view, FALSE);
3635     ok(hres == S_OK, "Show failed: %08x\n", hres);
3636 }
3637
3638 static HRESULT create_document(IUnknown **unk)
3639 {
3640     IHTMLDocument5 *doc5;
3641     HRESULT hres;
3642
3643     hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3644             &IID_IUnknown, (void**)unk);
3645     ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
3646     if(FAILED(hres))
3647         return hres;
3648
3649     hres = IUnknown_QueryInterface(*unk, &IID_IHTMLDocument5, (void**)&doc5);
3650     if(SUCCEEDED(hres)) {
3651         IHTMLDocument5_Release(doc5);
3652     }else {
3653         win_skip("Could not get IHTMLDocument5, probably too old IE\n");
3654         IUnknown_Release(*unk);
3655     }
3656
3657     return hres;
3658 }
3659
3660 static void test_Navigate(IUnknown *unk)
3661 {
3662     IHlinkTarget *hlink;
3663     HRESULT hres;
3664
3665     hres = IUnknown_QueryInterface(unk, &IID_IHlinkTarget, (void**)&hlink);
3666     ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08x\n", hres);
3667
3668     SET_EXPECT(ActivateMe);
3669     hres = IHlinkTarget_Navigate(hlink, 0, NULL);
3670     ok(hres == S_OK, "Navigate failed: %08x\n", hres);
3671     CHECK_CALLED(ActivateMe);
3672
3673     IHlinkTarget_Release(hlink);
3674 }
3675
3676 static void test_external(IUnknown *unk, BOOL initialized)
3677 {
3678     IDispatch *external;
3679     IHTMLDocument2 *doc;
3680     IHTMLWindow2 *htmlwin;
3681     HRESULT hres;
3682
3683     hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
3684     ok(hres == S_OK, "QueryInterface(IID_IHTMLWindow2) failed: %08x\n", hres);
3685
3686     hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
3687     IHTMLDocument2_Release(doc);
3688     ok(hres == S_OK, "get_parentWindow failed: %08x\n", hres);
3689
3690     if(initialized)
3691         SET_EXPECT(GetExternal);
3692     external = (void*)0xdeadbeef;
3693     hres = IHTMLWindow2_get_external(htmlwin, &external);
3694     if(initialized) {
3695         ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08x\n", hres);
3696         CHECK_CALLED(GetExternal);
3697         ok(external != NULL, "external == NULL\n");
3698     }else {
3699         ok(hres == S_OK, "get_external failed: %08x\n", hres);
3700         ok(external == NULL, "external != NULL\n");
3701     }
3702
3703     IHTMLWindow2_Release(htmlwin);
3704 }
3705
3706 static void test_StreamLoad(IUnknown *unk)
3707 {
3708     IPersistStreamInit *init;
3709     HRESULT hres;
3710
3711     hres = IUnknown_QueryInterface(unk, &IID_IPersistStreamInit, (void**)&init);
3712     ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08x\n", hres);
3713     if(FAILED(hres))
3714         return;
3715
3716     SET_EXPECT(Invoke_AMBIENT_SILENT);
3717     SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3718     SET_EXPECT(Exec_ShellDocView_37);
3719     SET_EXPECT(OnChanged_READYSTATE);
3720     SET_EXPECT(Read);
3721     readystate_set_loading = TRUE;
3722
3723     hres = IPersistStreamInit_Load(init, &Stream);
3724     ok(hres == S_OK, "Load failed: %08x\n", hres);
3725
3726     CHECK_CALLED(Invoke_AMBIENT_SILENT);
3727     CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3728     CHECK_CALLED(Exec_ShellDocView_37);
3729     CHECK_CALLED(OnChanged_READYSTATE);
3730     CHECK_CALLED(Read);
3731
3732     test_timer(EXPECT_SETTITLE);
3733     test_GetCurMoniker(unk, NULL, about_blank_url);
3734
3735     IPersistStreamInit_Release(init);
3736 }
3737
3738 static void test_QueryInterface(IUnknown *unk)
3739 {
3740     IUnknown *qi;
3741     HRESULT hres;
3742
3743     static const IID IID_UndocumentedScriptIface =
3744         {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
3745
3746     qi = (void*)0xdeadbeef;
3747     hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&qi);
3748     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3749     ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
3750
3751     qi = (void*)0xdeadbeef;
3752     hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&qi);
3753     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3754     ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3755
3756     qi = (void*)0xdeadbeef;
3757     hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode2, (void**)&qi);
3758     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3759     ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3760
3761     qi = (void*)0xdeadbeef;
3762     hres = IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void**)&qi);
3763     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3764     ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3765
3766     qi = (void*)0xdeadbeef;
3767     hres = IUnknown_QueryInterface(unk, &IID_UndocumentedScriptIface, (void**)&qi);
3768     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3769     ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3770
3771     qi = (void*)0xdeadbeef;
3772     hres = IUnknown_QueryInterface(unk, &IID_IMarshal, (void**)&qi);
3773     ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
3774     ok(qi == NULL, "qi=%p, expected NULL\n", qi);
3775 }
3776
3777 static void init_test(enum load_state_t ls) {
3778     doc_unk = NULL;
3779     hwnd = last_hwnd = NULL;
3780     set_clientsite = FALSE;
3781     load_from_stream = FALSE;
3782     call_UIActivate = CallUIActivate_None;
3783     load_state = ls;
3784     editmode = FALSE;
3785     stream_read = 0;
3786     protocol_read = 0;
3787     ipsex = FALSE;
3788 }
3789
3790 static void test_HTMLDocument(BOOL do_load)
3791 {
3792     IUnknown *unk;
3793     HRESULT hres;
3794     ULONG ref;
3795
3796     trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load"));
3797
3798     init_test(do_load ? LD_DOLOAD : LD_NO);
3799
3800     hres = create_document(&unk);
3801     if(FAILED(hres))
3802         return;
3803     doc_unk = unk;
3804
3805     test_QueryInterface(unk);
3806     test_IsDirty(unk, S_FALSE);
3807     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3808     test_external(unk, FALSE);
3809     test_ConnectionPointContainer(unk);
3810     test_GetCurMoniker(unk, NULL, NULL);
3811     test_Persist(unk);
3812     if(!do_load)
3813         test_OnAmbientPropertyChange2(unk);
3814
3815     test_Activate(unk, CLIENTSITE_EXPECTPATH);
3816
3817     if(do_load) {
3818         test_download(FALSE, TRUE, TRUE);
3819         test_GetCurMoniker(unk, &Moniker, NULL);
3820     }
3821
3822     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3823     test_OleCommandTarget_fail(unk);
3824     test_OleCommandTarget(unk);
3825     test_OnAmbientPropertyChange(unk);
3826     test_Window(unk, TRUE);
3827     test_external(unk, TRUE);
3828
3829     test_UIDeactivate();
3830     test_OleCommandTarget(unk);
3831     test_Window(unk, TRUE);
3832     test_InPlaceDeactivate(unk, TRUE);
3833
3834     /* Calling test_OleCommandTarget here causes Segmentation Fault with native
3835      * MSHTML. It doesn't with Wine. */
3836
3837     test_Window(unk, FALSE);
3838     test_Hide();
3839     test_InPlaceDeactivate(unk, FALSE);
3840     test_CloseView();
3841     test_Close(unk, FALSE);
3842
3843     /* Activate HTMLDocument again */
3844     test_Activate(unk, CLIENTSITE_SETNULL);
3845     test_Window(unk, TRUE);
3846     test_OleCommandTarget(unk);
3847     test_UIDeactivate();
3848     test_InPlaceDeactivate(unk, TRUE);
3849     test_Close(unk, FALSE);
3850
3851     /* Activate HTMLDocument again, this time without UIActivate */
3852     call_UIActivate = CallUIActivate_None;
3853     test_Activate(unk, CLIENTSITE_SETNULL);
3854     test_Window(unk, TRUE);
3855
3856     test_UIDeactivate();
3857     test_InPlaceDeactivate(unk, TRUE);
3858     test_CloseView();
3859     test_CloseView();
3860     test_Close(unk, TRUE);
3861     test_OnAmbientPropertyChange2(unk);
3862     test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL);
3863
3864     if(!do_load) {
3865         /* Activate HTMLDocument again, calling UIActivate after showing the window */
3866         call_UIActivate = CallUIActivate_AfterShow;
3867         test_Activate(unk, 0);
3868         test_Window(unk, TRUE);
3869         test_OleCommandTarget(unk);
3870         test_UIDeactivate();
3871         test_InPlaceDeactivate(unk, TRUE);
3872         test_Close(unk, FALSE);
3873         call_UIActivate = CallUIActivate_None;
3874     }
3875
3876     if(view)
3877         IOleDocumentView_Release(view);
3878     view = NULL;
3879
3880     ok(IsWindow(hwnd), "hwnd is destroyed\n");
3881
3882     ref = IUnknown_Release(unk);
3883     ok(ref == 0, "ref=%d, expected 0\n", ref);
3884
3885     ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
3886 }
3887
3888 static void test_HTMLDocument_hlink(void)
3889 {
3890     IUnknown *unk;
3891     HRESULT hres;
3892     ULONG ref;
3893
3894     trace("Testing HTMLDocument (hlink)...\n");
3895
3896     init_test(LD_DOLOAD);
3897     ipsex = TRUE;
3898
3899     hres = create_document(&unk);
3900     if(FAILED(hres))
3901         return;
3902     doc_unk = unk;
3903
3904     test_ConnectionPointContainer(unk);
3905     test_GetCurMoniker(unk, NULL, NULL);
3906     test_Persist(unk);
3907     test_Navigate(unk);
3908     if(show_failed) {
3909         IUnknown_Release(unk);
3910         return;
3911     }
3912
3913     test_download(FALSE, TRUE, TRUE);
3914
3915     test_IsDirty(unk, S_FALSE);
3916     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3917
3918     test_exec_onunload(unk);
3919     test_Window(unk, TRUE);
3920     test_InPlaceDeactivate(unk, TRUE);
3921     test_Close(unk, FALSE);
3922     test_IsDirty(unk, S_FALSE);
3923     test_GetCurMoniker(unk, &Moniker, NULL);
3924
3925     if(view)
3926         IOleDocumentView_Release(view);
3927     view = NULL;
3928
3929     ref = IUnknown_Release(unk);
3930     ok(ref == 0, "ref=%d, expected 0\n", ref);
3931 }
3932
3933 static void test_HTMLDocument_StreamLoad(void)
3934 {
3935     IOleObject *oleobj;
3936     IUnknown *unk;
3937     HRESULT hres;
3938     ULONG ref;
3939
3940     trace("Testing HTMLDocument (IPersistStreamInit)...\n");
3941
3942     init_test(LD_DOLOAD);
3943     load_from_stream = TRUE;
3944
3945     hres = create_document(&unk);
3946     if(FAILED(hres))
3947         return;
3948     doc_unk = unk;
3949
3950     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
3951     ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
3952
3953     test_readyState(unk);
3954     test_IsDirty(unk, S_FALSE);
3955     test_ConnectionPointContainer(unk);
3956     test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
3957     test_DoVerb(oleobj);
3958     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3959
3960     IOleObject_Release(oleobj);
3961
3962     test_GetCurMoniker(unk, NULL, NULL);
3963     test_StreamLoad(unk);
3964     test_download(TRUE, FALSE, TRUE);
3965     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
3966
3967     test_UIDeactivate();
3968     test_InPlaceDeactivate(unk, TRUE);
3969     test_Close(unk, FALSE);
3970     test_IsDirty(unk, S_FALSE);
3971
3972     if(view) {
3973         IOleDocumentView_Release(view);
3974         view = NULL;
3975     }
3976
3977
3978     ref = IUnknown_Release(unk);
3979     ok(ref == 0, "ref=%d, expected 0\n", ref);
3980 }
3981
3982 static void test_edit_uiactivate(IOleObject *oleobj)
3983 {
3984     IOleDocumentView *docview;
3985     HRESULT hres;
3986
3987     hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
3988     ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08x\n", hres);
3989
3990     SET_EXPECT(OnFocus_TRUE);
3991     SET_EXPECT(SetActiveObject);
3992     SET_EXPECT(ShowUI);
3993     SET_EXPECT(InPlaceUIWindow_SetActiveObject);
3994     SET_EXPECT(InPlaceFrame_SetBorderSpace);
3995     expect_status_text = NULL;
3996
3997     hres = IOleDocumentView_UIActivate(docview, TRUE);
3998     ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08x\n", hres);
3999
4000     CHECK_CALLED(OnFocus_TRUE);
4001     CHECK_CALLED(SetActiveObject);
4002     CHECK_CALLED(ShowUI);
4003     CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
4004     CHECK_CALLED(InPlaceFrame_SetBorderSpace);
4005
4006     IOleDocumentView_Release(docview);
4007 }
4008
4009 static void test_editing_mode(BOOL do_load)
4010 {
4011     IUnknown *unk;
4012     IOleObject *oleobj;
4013     HRESULT hres;
4014     ULONG ref;
4015
4016     trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : "");
4017
4018     init_test(do_load ? LD_DOLOAD : LD_NO);
4019     call_UIActivate = CallUIActivate_AfterShow;
4020
4021     hres = create_document(&unk);
4022     if(FAILED(hres))
4023         return;
4024     doc_unk = unk;
4025
4026     hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
4027     ok(hres == S_OK, "Could not get IOleObject: %08x\n", hres);
4028
4029     test_readyState(unk);
4030     test_ConnectionPointContainer(unk);
4031     test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
4032     test_DoVerb(oleobj);
4033     test_edit_uiactivate(oleobj);
4034
4035     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4036     if(do_load)
4037         test_Persist(unk);
4038     stream_read = protocol_read = 0;
4039     test_exec_editmode(unk, do_load);
4040     test_UIDeactivate();
4041     call_UIActivate = CallUIActivate_None;
4042     IOleObject_Release(oleobj);
4043
4044     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED);
4045     test_download(TRUE, do_load, do_load);
4046
4047     SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
4048     test_timer(EXPECT_UPDATEUI);
4049     SET_CALLED(SetStatusText);
4050
4051     test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4052
4053     if(!do_load) {
4054         test_exec_fontname(unk, NULL, wszTimesNewRoman);
4055         test_exec_fontname(unk, wszArial, wszTimesNewRoman);
4056         test_timer(EXPECT_UPDATEUI);
4057         test_exec_fontname(unk, NULL, wszArial);
4058
4059         test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
4060         test_timer(EXPECT_UPDATEUI);
4061         if(!nogecko)
4062             test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4063                              OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4064
4065         test_exec_noargs(unk, IDM_JUSTIFYCENTER);
4066         test_timer(EXPECT_UPDATEUI);
4067         test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
4068                          OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4069         if(!nogecko)
4070             test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
4071                              OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
4072
4073         test_exec_noargs(unk, IDM_HORIZONTALLINE);
4074         test_timer(EXPECT_UPDATEUI);
4075         test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
4076                          OLECMDF_SUPPORTED|OLECMDF_ENABLED);
4077     }
4078
4079     test_UIDeactivate();
4080     test_InPlaceDeactivate(unk, TRUE);
4081     test_Close(unk, FALSE);
4082
4083     if(view) {
4084         IOleDocumentView_Release(view);
4085         view = NULL;
4086     }
4087
4088     ref = IUnknown_Release(unk);
4089     ok(ref == 0, "ref=%d, expected 0\n", ref);
4090 }
4091
4092 static void register_protocol(void)
4093 {
4094     IInternetSession *session;
4095     HRESULT hres;
4096
4097     static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
4098
4099     hres = CoInternetGetSession(0, &session, 0);
4100     ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
4101
4102     hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
4103             wsz_winetest, 0, NULL, 0);
4104     ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
4105
4106     IInternetSession_Release(session);
4107 }
4108
4109 static void gecko_installer_workaround(BOOL disable)
4110 {
4111     HKEY hkey;
4112     DWORD res;
4113
4114     static BOOL has_url = FALSE;
4115     static char url[2048];
4116
4117     if(!disable && !has_url)
4118         return;
4119
4120     res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
4121     if(res != ERROR_SUCCESS)
4122         return;
4123
4124     if(disable) {
4125         DWORD type, size = sizeof(url);
4126
4127         res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
4128         if(res == ERROR_SUCCESS && type == REG_SZ)
4129             has_url = TRUE;
4130
4131         RegDeleteValue(hkey, "GeckoUrl");
4132     }else {
4133         RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
4134     }
4135
4136     RegCloseKey(hkey);
4137 }
4138
4139 static void test_HTMLDoc_ISupportErrorInfo(void)
4140 {
4141     HRESULT hres;
4142     IUnknown *unk;
4143     ISupportErrorInfo *sinfo;
4144     LONG ref;
4145
4146     hres = create_document(&unk);
4147     if(FAILED(hres))
4148         return;
4149
4150     hres = IUnknown_QueryInterface(unk, &IID_ISupportErrorInfo, (void**)&sinfo);
4151     ok(hres == S_OK, "got %x\n", hres);
4152     ok(sinfo != NULL, "got %p\n", sinfo);
4153     if(sinfo)
4154     {
4155         hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
4156         ok(hres == S_FALSE, "Expected S_OK, got %x\n", hres);
4157         IUnknown_Release(sinfo);
4158     }
4159
4160     ref = IUnknown_Release(unk);
4161     ok(ref == 0, "ref=%d, expected 0\n", ref);
4162 }
4163
4164 static void test_IPersistHistory(void)
4165 {
4166     HRESULT hres;
4167     IUnknown *unk;
4168     LONG ref;
4169     IPersistHistory *phist;
4170
4171     hres = create_document(&unk);
4172     if(FAILED(hres))
4173         return;
4174
4175     hres = IUnknown_QueryInterface(unk, &IID_IPersistHistory, (void**)&phist);
4176     todo_wine ok(hres == S_OK, "QueryInterface returned %08x, expected S_OK\n", hres);
4177     if(hres == S_OK)
4178         IPersistHistory_Release(phist);
4179
4180     ref = IUnknown_Release(unk);
4181     ok(ref == 0, "ref=%d, expected 0\n", ref);
4182 }
4183
4184 START_TEST(htmldoc)
4185 {
4186     gecko_installer_workaround(TRUE);
4187
4188     CoInitialize(NULL);
4189     container_hwnd = create_container_window();
4190     register_protocol();
4191
4192     test_HTMLDocument_hlink();
4193     if(!show_failed) {
4194         test_HTMLDocument(FALSE);
4195         test_HTMLDocument(TRUE);
4196         test_HTMLDocument_StreamLoad();
4197         test_editing_mode(FALSE);
4198         test_editing_mode(TRUE);
4199     }
4200     test_HTMLDoc_ISupportErrorInfo();
4201     test_IPersistHistory();
4202
4203     DestroyWindow(container_hwnd);
4204     CoUninitialize();
4205
4206     gecko_installer_workaround(FALSE);
4207 }