mfplat/sample: Optimize copying to 2d buffer.
[wine.git] / dlls / mshtml / tests / htmldoc.c
blob4db4777dca40229a568f7831d1b6fd6787b9d328
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define CONST_VTABLE
22 #include <wine/test.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "initguid.h"
29 #include "ole2.h"
30 #include "shlwapi.h"
31 #include "mshtml.h"
32 #include "docobj.h"
33 #include "docobjectservice.h"
34 #include "wininet.h"
35 #include "mshtmhst.h"
36 #include "mshtmdid.h"
37 #include "mshtmcid.h"
38 #include "hlink.h"
39 #include "dispex.h"
40 #include "idispids.h"
41 #include "shlguid.h"
42 #include "shdeprecated.h"
43 #include "perhist.h"
44 #include "shobjidl.h"
45 #include "htiface.h"
46 #include "tlogstg.h"
47 #include "exdispid.h"
48 #include "mshtml_test.h"
49 #include "mscoree.h"
51 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
52 DEFINE_GUID(IID_IProxyManager,0x00000008,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
53 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
54 DEFINE_GUID(SID_SContainerDispatch,0xb722be00,0x4e68,0x101b,0xa2,0xbc,0x00,0xaa,0x00,0x40,0x47,0x70);
55 DEFINE_GUID(outer_test_iid,0xabcabc00,0,0,0,0,0,0,0,0,0,0x66);
57 #define DEFINE_EXPECT(func) \
58 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
60 #define SET_EXPECT(func) \
61 expect_ ## func = TRUE
63 #define SET_CALLED(func) \
64 called_ ## func = TRUE
66 #define CHECK_EXPECT2(func) \
67 do { \
68 ok(expect_ ##func, "unexpected call " #func "\n"); \
69 called_ ## func = TRUE; \
70 }while(0)
72 #define CHECK_EXPECT(func) \
73 do { \
74 CHECK_EXPECT2(func); \
75 expect_ ## func = FALSE; \
76 }while(0)
78 #define CHECK_CALLED(func) \
79 do { \
80 ok(called_ ## func, "expected " #func "\n"); \
81 expect_ ## func = called_ ## func = FALSE; \
82 }while(0)
84 #define CHECK_NOT_CALLED(func) \
85 do { \
86 ok(!called_ ## func, "unexpected " #func "\n"); \
87 expect_ ## func = called_ ## func = FALSE; \
88 }while(0)
90 #define CHECK_CALLED_BROKEN(func) \
91 do { \
92 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
93 expect_ ## func = called_ ## func = FALSE; \
94 }while(0)
96 #define CLEAR_CALLED(func) \
97 expect_ ## func = called_ ## func = FALSE
100 static IOleDocumentView *view = NULL;
101 static HWND container_hwnd = NULL, doc_hwnd = NULL, last_hwnd = NULL;
103 DEFINE_EXPECT(LockContainer);
104 DEFINE_EXPECT(SetActiveObject);
105 DEFINE_EXPECT(SetActiveObject_null);
106 DEFINE_EXPECT(GetWindow);
107 DEFINE_EXPECT(CanInPlaceActivate);
108 DEFINE_EXPECT(OnInPlaceActivate);
109 DEFINE_EXPECT(OnInPlaceActivateEx);
110 DEFINE_EXPECT(OnUIActivate);
111 DEFINE_EXPECT(GetWindowContext);
112 DEFINE_EXPECT(OnUIDeactivate);
113 DEFINE_EXPECT(OnInPlaceDeactivate);
114 DEFINE_EXPECT(OnInPlaceDeactivateEx);
115 DEFINE_EXPECT(GetContainer);
116 DEFINE_EXPECT(ShowUI);
117 DEFINE_EXPECT(ActivateMe);
118 DEFINE_EXPECT(GetHostInfo);
119 DEFINE_EXPECT(HideUI);
120 DEFINE_EXPECT(GetOptionKeyPath);
121 DEFINE_EXPECT(GetOverrideKeyPath);
122 DEFINE_EXPECT(SetStatusText);
123 DEFINE_EXPECT(QueryStatus_SETPROGRESSTEXT);
124 DEFINE_EXPECT(QueryStatus_OPEN);
125 DEFINE_EXPECT(QueryStatus_NEW);
126 DEFINE_EXPECT(Exec_SETPROGRESSMAX);
127 DEFINE_EXPECT(Exec_SETPROGRESSPOS);
128 DEFINE_EXPECT(Exec_HTTPEQUIV_DONE);
129 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_0);
130 DEFINE_EXPECT(Exec_SETDOWNLOADSTATE_1);
131 DEFINE_EXPECT(Exec_ShellDocView_37);
132 DEFINE_EXPECT(Exec_ShellDocView_62);
133 DEFINE_EXPECT(Exec_ShellDocView_63);
134 DEFINE_EXPECT(Exec_ShellDocView_67);
135 DEFINE_EXPECT(Exec_ShellDocView_84);
136 DEFINE_EXPECT(Exec_ShellDocView_103);
137 DEFINE_EXPECT(Exec_ShellDocView_105);
138 DEFINE_EXPECT(Exec_ShellDocView_138);
139 DEFINE_EXPECT(Exec_ShellDocView_140);
140 DEFINE_EXPECT(Exec_DocHostCommandHandler_2300);
141 DEFINE_EXPECT(Exec_UPDATECOMMANDS);
142 DEFINE_EXPECT(Exec_SETTITLE);
143 DEFINE_EXPECT(Exec_HTTPEQUIV);
144 DEFINE_EXPECT(Exec_MSHTML_PARSECOMPLETE);
145 DEFINE_EXPECT(Exec_Explorer_38);
146 DEFINE_EXPECT(Exec_Explorer_69);
147 DEFINE_EXPECT(Exec_DOCCANNAVIGATE);
148 DEFINE_EXPECT(Exec_DOCCANNAVIGATE_NULL);
149 DEFINE_EXPECT(Invoke_AMBIENT_USERMODE);
150 DEFINE_EXPECT(Invoke_AMBIENT_DLCONTROL);
151 DEFINE_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
152 DEFINE_EXPECT(Invoke_AMBIENT_SILENT);
153 DEFINE_EXPECT(Invoke_AMBIENT_USERAGENT);
154 DEFINE_EXPECT(Invoke_AMBIENT_PALETTE);
155 DEFINE_EXPECT(Invoke_OnReadyStateChange_Interactive);
156 DEFINE_EXPECT(Invoke_OnReadyStateChange_Loading);
157 DEFINE_EXPECT(Invoke_OnReadyStateChange_Complete);
158 DEFINE_EXPECT(GetDropTarget);
159 DEFINE_EXPECT(UpdateUI);
160 DEFINE_EXPECT(Navigate);
161 DEFINE_EXPECT(OnFrameWindowActivate);
162 DEFINE_EXPECT(OnChanged_READYSTATE);
163 DEFINE_EXPECT(OnChanged_1005);
164 DEFINE_EXPECT(OnChanged_1012);
165 DEFINE_EXPECT(OnChanged_1014);
166 DEFINE_EXPECT(GetDisplayName);
167 DEFINE_EXPECT(BindToStorage);
168 DEFINE_EXPECT(IsSystemMoniker);
169 DEFINE_EXPECT(GetBindResult);
170 DEFINE_EXPECT(GetClassID);
171 DEFINE_EXPECT(Abort);
172 DEFINE_EXPECT(Read);
173 DEFINE_EXPECT(CreateInstance);
174 DEFINE_EXPECT(Start);
175 DEFINE_EXPECT(Terminate);
176 DEFINE_EXPECT(Protocol_Read);
177 DEFINE_EXPECT(LockRequest);
178 DEFINE_EXPECT(UnlockRequest);
179 DEFINE_EXPECT(OnFocus_TRUE);
180 DEFINE_EXPECT(OnFocus_FALSE);
181 DEFINE_EXPECT(RequestUIActivate);
182 DEFINE_EXPECT(InPlaceFrame_SetBorderSpace);
183 DEFINE_EXPECT(InPlaceUIWindow_SetActiveObject);
184 DEFINE_EXPECT(GetExternal);
185 DEFINE_EXPECT(EnableModeless_TRUE);
186 DEFINE_EXPECT(EnableModeless_FALSE);
187 DEFINE_EXPECT(Frame_EnableModeless_TRUE);
188 DEFINE_EXPECT(Frame_EnableModeless_FALSE);
189 DEFINE_EXPECT(Frame_GetWindow);
190 DEFINE_EXPECT(TranslateUrl);
191 DEFINE_EXPECT(Advise_Close);
192 DEFINE_EXPECT(OnViewChange);
193 DEFINE_EXPECT(EvaluateNewWindow);
194 DEFINE_EXPECT(GetTravelLog);
195 DEFINE_EXPECT(UpdateBackForwardState);
196 DEFINE_EXPECT(FireBeforeNavigate2);
197 DEFINE_EXPECT(FireNavigateComplete2);
198 DEFINE_EXPECT(FireDocumentComplete);
199 DEFINE_EXPECT(GetPendingUrl);
200 DEFINE_EXPECT(ActiveElementChanged);
201 DEFINE_EXPECT(IsErrorUrl);
202 DEFINE_EXPECT(get_LocationURL);
203 DEFINE_EXPECT(CountEntries);
204 DEFINE_EXPECT(FindConnectionPoint);
205 DEFINE_EXPECT(EnumConnections);
206 DEFINE_EXPECT(EnumConnections_Next);
207 DEFINE_EXPECT(WindowClosing);
208 DEFINE_EXPECT(NavigateWithBindCtx);
209 DEFINE_EXPECT(outer_QI_IPersistMoniker);
210 DEFINE_EXPECT(outer_QI_test);
212 static BOOL is_ie9plus;
213 static IUnknown *doc_unk;
214 static IMoniker *doc_mon;
215 static BOOL expect_LockContainer_fLock;
216 static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE;
217 static BOOL ipsex, ipsw;
218 static BOOL set_clientsite, container_locked;
219 static BOOL readystate_set_loading = FALSE, readystate_set_interactive = FALSE, load_from_stream;
220 static BOOL editmode = FALSE, ignore_external_qi;
221 static BOOL inplace_deactivated, open_call;
222 static BOOL complete, loading_js, loading_hash, is_refresh, is_from_hist;
223 static DWORD status_code = HTTP_STATUS_OK;
224 static BOOL asynchronous_binding = FALSE;
225 static BOOL support_wbapp, allow_new_window, no_travellog;
226 static BOOL report_mime;
227 static BOOL testing_submit;
228 static BOOL resetting_document;
229 static BOOL is_error_url;
230 static BOOL is_mhtml;
231 static int stream_read, protocol_read;
232 static IStream *history_stream;
233 static enum load_state_t {
234 LD_DOLOAD,
235 LD_LOADING,
236 LD_LOADED,
237 LD_INTERACTIVE,
238 LD_COMPLETE,
239 LD_NO
240 } load_state;
242 static LPCOLESTR expect_status_text = NULL;
243 static const WCHAR *nav_url, *nav_serv_url, *prev_url;
245 static const char html_page[] =
246 "<html>"
247 "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\"></head>"
248 "<body><div>test</div></body>"
249 "</html>";
251 static const char mhtml_page[] =
252 "MIME-Version: 1.0\r\n"
253 "Content-Type: multipart/related; type:=\"text/html\"; boundary=\"----=_NextPart_000_00\"\r\n"
254 "\r\n"
255 "------=_NextPart_000_00\r\n"
256 "Content-Type: text/html; charset=\"Windows-1252\"\r\n"
257 "Content-Transfer-Encoding: quoted-printable\r\n"
258 "\r\n"
259 "<HTML></HTML>\r\n"
260 "------=_NextPart_000_00\r\n"
261 "Content-Type: Image/Jpeg\r\n"
262 "Content-Transfer-Encoding: base64\r\n"
263 "Content-Location: http://winehq.org/mhtmltest.html\r\n"
264 "\r\n\t\t\t\tVGVzdA==\r\n\r\n"
265 "------=_NextPart_000_00--";
267 static const char css_data[] = "body {color: red; margin: 0}";
269 static const WCHAR http_urlW[] =
270 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t','s','/','w','i','n','e','h','q','_','s','n','a','p','s','h','o','t','/',0};
272 static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c',0};
274 #define DOCHOST_DOCCANNAVIGATE 0
275 #define WM_CONTINUE_BINDING (WM_APP+1)
277 static HRESULT QueryInterface(REFIID riid, void **ppv);
278 static void test_MSHTML_QueryStatus(IHTMLDocument2*,DWORD);
280 #define test_readyState(u) _test_readyState(__LINE__,u)
281 static void _test_readyState(unsigned,IUnknown*);
283 static const WCHAR wszTimesNewRoman[] =
284 {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
285 static const WCHAR wszArial[] =
286 {'A','r','i','a','l',0};
288 /* Returns true if the user interface is in English. Note that this does not
289 * presume of the formatting of dates, numbers, etc.
291 static BOOL is_lang_english(void)
293 static HMODULE hkernel32 = NULL;
294 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
295 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
297 if (!hkernel32)
299 hkernel32 = GetModuleHandleA("kernel32.dll");
300 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
301 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
303 if (pGetThreadUILanguage)
304 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
305 if (pGetUserDefaultUILanguage)
306 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
308 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
311 static BOOL iface_cmp(IUnknown *iface1, IUnknown *iface2)
313 IUnknown *unk1, *unk2;
315 if(iface1 == iface2)
316 return TRUE;
318 IUnknown_QueryInterface(iface1, &IID_IUnknown, (void**)&unk1);
319 IUnknown_Release(unk1);
320 IUnknown_QueryInterface(iface2, &IID_IUnknown, (void**)&unk2);
321 IUnknown_Release(unk2);
323 return unk1 == unk2;
326 #define EXPECT_UPDATEUI 1
327 #define EXPECT_SETTITLE 2
329 static void test_timer(DWORD flags)
331 BOOL *b = &called_Exec_SETTITLE;
332 MSG msg;
334 if(flags & EXPECT_UPDATEUI) {
335 SET_EXPECT(UpdateUI);
336 SET_EXPECT(Exec_UPDATECOMMANDS);
337 b = &called_UpdateUI;
339 if(flags & EXPECT_SETTITLE)
340 SET_EXPECT(Exec_SETTITLE);
342 while(!*b && GetMessageA(&msg, doc_hwnd, 0, 0)) {
343 TranslateMessage(&msg);
344 DispatchMessageA(&msg);
347 if(flags & EXPECT_UPDATEUI) {
348 CHECK_CALLED(UpdateUI);
349 CHECK_CALLED(Exec_UPDATECOMMANDS);
351 if(flags & EXPECT_SETTITLE)
352 CHECK_CALLED(Exec_SETTITLE);
355 static IMoniker Moniker;
357 #define test_GetCurMoniker(u,m,v,t) _test_GetCurMoniker(__LINE__,u,m,v,t)
358 static void _test_GetCurMoniker(unsigned line, IUnknown *unk, IMoniker *exmon, const WCHAR *exurl, BOOL is_todo)
360 IHTMLDocument2 *doc;
361 IPersistMoniker *permon;
362 IMoniker *mon = (void*)0xdeadbeef;
363 BSTR doc_url = (void*)0xdeadbeef;
364 const WCHAR *ptr;
365 HRESULT hres;
367 if(open_call)
368 return; /* FIXME */
370 hres = IUnknown_QueryInterface(unk, &IID_IPersistMoniker, (void**)&permon);
371 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
372 if(FAILED(hres))
373 return;
375 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
376 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08lx\n", hres);
378 hres = IHTMLDocument2_get_URL(doc, &doc_url);
379 ok(hres == S_OK, "get_URL failed: %08lx\n", hres);
380 for(ptr = doc_url; *ptr && *ptr != '#'; ptr++);
382 hres = IPersistMoniker_GetCurMoniker(permon, &mon);
383 IPersistMoniker_Release(permon);
385 if(exmon) {
386 LPOLESTR url;
387 BOOL exb = expect_GetDisplayName;
388 BOOL clb = called_GetDisplayName;
390 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08lx\n", hres);
391 ok_(__FILE__,line)(mon == exmon, "mon(%p) != exmon(%p)\n", mon, exmon);
393 if(mon == &Moniker)
394 SET_EXPECT(GetDisplayName);
395 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
396 ok(hres == S_OK, "GetDisplayName failed: %08lx\n", hres);
397 if(mon == &Moniker)
398 CHECK_CALLED(GetDisplayName);
399 expect_GetDisplayName = exb;
400 called_GetDisplayName = clb;
402 if(!*ptr)
403 ok(!lstrcmpW(url, doc_url), "url %s != doc_url %s\n", wine_dbgstr_w(url), wine_dbgstr_w(doc_url));
404 else
405 ok(!lstrcmpW(url, nav_serv_url), "url = %s, expected %s\n", wine_dbgstr_w(url),
406 wine_dbgstr_w(nav_serv_url));
407 CoTaskMemFree(url);
408 }else if(exurl) {
409 LPOLESTR url;
411 ok_(__FILE__,line)(hres == S_OK, "GetCurrentMoniker failed: %08lx\n", hres);
413 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
414 ok(hres == S_OK, "GetDisplayName failed: %08lx\n", hres);
416 todo_wine_if(is_todo)
417 ok_(__FILE__,line)(!lstrcmpW(url, exurl), "unexpected url %s\n", wine_dbgstr_w(url));
418 if(!*ptr)
419 ok_(__FILE__,line)(!lstrcmpW(url, doc_url), "url %s != doc_url %s\n", wine_dbgstr_w(url), wine_dbgstr_w(doc_url));
421 CoTaskMemFree(url);
422 }else {
423 ok_(__FILE__,line)(hres == E_UNEXPECTED,
424 "GetCurrentMoniker failed: %08lx, expected E_UNEXPECTED\n", hres);
425 ok_(__FILE__,line)(mon == (IMoniker*)0xdeadbeef, "mon=%p\n", mon);
426 ok_(__FILE__,line)(!lstrcmpW(doc_url, L"about:blank"), "doc_url is not about:blank\n");
429 SysFreeString(doc_url);
430 IHTMLDocument2_Release(doc);
431 if(mon && mon != (void*)0xdeadbeef)
432 IMoniker_Release(mon);
435 #define test_current_url(a,b) _test_current_url(__LINE__,a,b)
436 static void _test_current_url(unsigned line, IUnknown *unk, const WCHAR *exurl)
438 IHTMLDocument2 *doc;
439 BSTR url;
440 HRESULT hres;
442 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
443 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08lx\n", hres);
445 hres = IHTMLDocument2_get_URL(doc, &url);
446 ok_(__FILE__,line)(hres == S_OK, "get_URL failed: %08lx\n", hres);
447 ok_(__FILE__,line)(!lstrcmpW(url, exurl), "Unexpected URL %s, expected %s\n", wine_dbgstr_w(url),
448 wine_dbgstr_w(exurl));
449 SysFreeString(url);
451 IHTMLDocument2_Release(doc);
454 #define test_performance_timing(a,b) _test_performance_timing(__LINE__,a,b)
455 static void _test_performance_timing(unsigned line, IUnknown *unk, const WCHAR *prop)
457 BOOL expect_non_zero = FALSE;
458 DISPPARAMS dp = { 0 };
459 IHTMLWindow2 *window;
460 IHTMLDocument2 *doc;
461 IDispatchEx *dispex;
462 DISPID dispid;
463 HRESULT hres;
464 VARIANT var;
465 BSTR bstr;
467 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
468 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08lx\n", hres);
470 hres = IHTMLDocument2_get_readyState(doc, &bstr);
471 ok_(__FILE__,line)(hres == S_OK, "get_readyState failed: %08lx\n", hres);
472 if(!wcscmp(bstr, L"interactive"))
473 expect_non_zero = !wcscmp(prop, L"domInteractive");
474 else if(!wcscmp(bstr, L"complete"))
475 expect_non_zero = TRUE;
476 SysFreeString(bstr);
478 hres = IHTMLDocument2_get_parentWindow(doc, &window);
479 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
480 IHTMLDocument2_Release(doc);
482 hres = IHTMLWindow2_QueryInterface(window, &IID_IDispatchEx, (void**)&dispex);
483 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IDispatchEx) failed: %08lx\n", hres);
484 IHTMLWindow2_Release(window);
486 bstr = SysAllocString(L"performance");
487 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &dispid);
488 ok_(__FILE__,line)(hres == S_OK, "GetDispID(performance) failed: %08lx\n", hres);
489 SysFreeString(bstr);
491 V_VT(&var) = VT_EMPTY;
492 hres = IDispatchEx_InvokeEx(dispex, dispid, 0, DISPATCH_PROPERTYGET, &dp, &var, NULL, NULL);
493 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(performance) failed: %08lx\n", hres);
494 ok_(__FILE__,line)(V_VT(&var) == VT_DISPATCH, "V_VT(performance) = %d\n", V_VT(&var));
495 ok_(__FILE__,line)(V_DISPATCH(&var) != NULL, "V_DISPATCH(performance) = NULL\n");
496 IDispatchEx_Release(dispex);
498 hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IDispatchEx, (void**)&dispex);
499 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IDispatchEx) failed: %08lx\n", hres);
500 VariantClear(&var);
502 bstr = SysAllocString(L"timing");
503 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &dispid);
504 ok_(__FILE__,line)(hres == S_OK, "GetDispID(timing) failed: %08lx\n", hres);
505 SysFreeString(bstr);
507 hres = IDispatchEx_InvokeEx(dispex, dispid, 0, DISPATCH_PROPERTYGET, &dp, &var, NULL, NULL);
508 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(timing) failed: %08lx\n", hres);
509 ok_(__FILE__,line)(V_VT(&var) == VT_DISPATCH, "V_VT(timing) = %d\n", V_VT(&var));
510 ok_(__FILE__,line)(V_DISPATCH(&var) != NULL, "V_DISPATCH(timing) = NULL\n");
511 IDispatchEx_Release(dispex);
513 hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IDispatchEx, (void**)&dispex);
514 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IDispatchEx) failed: %08lx\n", hres);
515 VariantClear(&var);
517 bstr = SysAllocString(prop);
518 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &dispid);
519 ok_(__FILE__,line)(hres == S_OK, "GetDispID(%s) failed: %08lx\n", wine_dbgstr_w(prop), hres);
520 SysFreeString(bstr);
522 hres = IDispatchEx_InvokeEx(dispex, dispid, 0, DISPATCH_PROPERTYGET, &dp, &var, NULL, NULL);
523 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(%s) failed: %08lx\n", wine_dbgstr_w(prop), hres);
524 ok_(__FILE__,line)(V_VT(&var) == VT_UI8, "V_VT(%s) = %d\n", wine_dbgstr_w(prop), V_VT(&var));
525 IDispatchEx_Release(dispex);
527 if(expect_non_zero)
528 ok_(__FILE__,line)(V_UI8(&var) != 0, "%s is 0\n", wine_dbgstr_w(prop));
529 else
530 ok_(__FILE__,line)(V_UI8(&var) == 0, "%s is not 0\n", wine_dbgstr_w(prop));
533 #define test_navigation_type(a) _test_navigation_type(__LINE__,a)
534 static void _test_navigation_type(unsigned line, IUnknown *unk)
536 IHTMLPerformanceNavigation *nav;
537 IHTMLPerformance *perf;
538 DISPPARAMS dp = { 0 };
539 ULONG type, expected;
540 IHTMLWindow2 *window;
541 IHTMLDocument2 *doc;
542 IDispatchEx *dispex;
543 DISPID dispid;
544 HRESULT hres;
545 VARIANT var;
546 BSTR bstr;
548 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&doc);
549 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08lx\n", hres);
551 hres = IHTMLDocument2_get_parentWindow(doc, &window);
552 ok_(__FILE__,line)(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
553 IHTMLDocument2_Release(doc);
555 hres = IHTMLWindow2_QueryInterface(window, &IID_IDispatchEx, (void**)&dispex);
556 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IDispatchEx) failed: %08lx\n", hres);
557 IHTMLWindow2_Release(window);
559 bstr = SysAllocString(L"performance");
560 hres = IDispatchEx_GetDispID(dispex, bstr, fdexNameCaseSensitive, &dispid);
561 ok_(__FILE__,line)(hres == S_OK, "GetDispID(performance) failed: %08lx\n", hres);
562 SysFreeString(bstr);
564 V_VT(&var) = VT_EMPTY;
565 hres = IDispatchEx_InvokeEx(dispex, dispid, 0, DISPATCH_PROPERTYGET, &dp, &var, NULL, NULL);
566 ok_(__FILE__,line)(hres == S_OK, "InvokeEx(performance) failed: %08lx\n", hres);
567 ok_(__FILE__,line)(V_VT(&var) == VT_DISPATCH, "V_VT(performance) = %d\n", V_VT(&var));
568 ok_(__FILE__,line)(V_DISPATCH(&var) != NULL, "V_DISPATCH(performance) = NULL\n");
569 IDispatchEx_Release(dispex);
571 hres = IDispatch_QueryInterface(V_DISPATCH(&var), &IID_IHTMLPerformance, (void**)&perf);
572 ok_(__FILE__,line)(hres == S_OK, "QueryInterface(IID_IHTMLPerformance) failed: %08lx\n", hres);
573 ok_(__FILE__,line)(perf != NULL, "performance is NULL\n");
574 VariantClear(&var);
576 hres = IHTMLPerformance_get_navigation(perf, &nav);
577 ok_(__FILE__,line)(hres == S_OK, "get_navigation failed: %08lx\n", hres);
578 ok_(__FILE__,line)(nav != NULL, "performance.navigation is NULL\n");
579 IHTMLPerformance_Release(perf);
581 hres = IHTMLPerformanceNavigation_get_type(nav, &type);
582 ok_(__FILE__,line)(hres == S_OK, "get_type failed: %08lx\n", hres);
583 IHTMLPerformanceNavigation_Release(nav);
585 expected = is_refresh || editmode ? 1 : is_from_hist ? 2 : 0;
586 ok_(__FILE__,line)(type == expected, "type = %lu, expected %lu\n", type, expected);
589 static BSTR get_mime_type_display_name(const WCHAR *content_type)
591 WCHAR buffer[128], ext[128], *str, *progid;
592 HKEY key, type_key = NULL;
593 DWORD type, len;
594 LSTATUS status;
595 HRESULT hres;
596 CLSID clsid;
597 BSTR ret;
599 status = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"MIME\\Database\\Content Type", 0, KEY_READ, &key);
600 if(status != ERROR_SUCCESS)
601 goto fail;
603 status = RegOpenKeyExW(key, content_type, 0, KEY_QUERY_VALUE, &type_key);
604 RegCloseKey(key);
605 if(status != ERROR_SUCCESS)
606 goto fail;
608 len = sizeof(ext);
609 status = RegQueryValueExW(type_key, L"Extension", NULL, &type, (BYTE*)ext, &len);
610 if(status != ERROR_SUCCESS || type != REG_SZ) {
611 len = sizeof(buffer);
612 status = RegQueryValueExW(type_key, L"CLSID", NULL, &type, (BYTE*)buffer, &len);
614 if(status != ERROR_SUCCESS || type != REG_SZ || CLSIDFromString(buffer, &clsid) != S_OK ||
615 ProgIDFromCLSID(&clsid, &progid) != S_OK)
616 goto fail;
617 }else {
618 /* For some reason w1064v1809 testbot VM uses .htm here, despite .html being set in the database */
619 if(!wcscmp(ext, L".html"))
620 wcscpy(ext, L".htm");
621 progid = ext;
624 len = ARRAY_SIZE(buffer);
625 str = buffer;
626 for(;;) {
627 hres = AssocQueryStringW(ASSOCF_NOTRUNCATE, ASSOCSTR_FRIENDLYDOCNAME, progid, NULL, str, &len);
628 if(hres == S_OK && len)
629 break;
630 if(str != buffer)
631 free(str);
632 if(hres != E_POINTER) {
633 if(progid != ext) {
634 CoTaskMemFree(progid);
635 goto fail;
638 /* Try from CLSID */
639 len = sizeof(buffer);
640 status = RegQueryValueExW(type_key, L"CLSID", NULL, &type, (BYTE*)buffer, &len);
642 if(status != ERROR_SUCCESS || type != REG_SZ || CLSIDFromString(buffer, &clsid) != S_OK ||
643 ProgIDFromCLSID(&clsid, &progid) != S_OK)
644 goto fail;
646 len = ARRAY_SIZE(buffer);
647 str = buffer;
648 continue;
650 str = malloc(len * sizeof(WCHAR));
652 if(progid != ext)
653 CoTaskMemFree(progid);
654 RegCloseKey(type_key);
656 ret = SysAllocString(str);
657 if(str != buffer)
658 free(str);
659 return ret;
661 fail:
662 RegCloseKey(type_key);
663 trace("Did not find MIME in database for %s\n", debugstr_w(content_type));
664 return SysAllocString(L"File");
667 DEFINE_GUID(IID_External_unk,0x30510406,0x98B5,0x11CF,0xBB,0x82,0x00,0xAA,0x00,0xBD,0xCE,0x0B);
669 static HRESULT WINAPI External_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
671 *ppv = NULL;
673 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
674 *ppv = iface;
675 return S_OK;
678 if(IsEqualGUID(&IID_IProxyManager, riid))
679 return E_NOINTERFACE; /* TODO */
680 if(IsEqualGUID(&IID_IDispatchEx, riid))
681 return E_NOINTERFACE; /* TODO */
682 if(IsEqualGUID(&IID_External_unk, riid))
683 return E_NOINTERFACE; /* TODO */
685 if(!ignore_external_qi)
686 ok(0, "unexpected riid: %s\n", wine_dbgstr_guid(riid));
687 return E_NOINTERFACE;
690 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
692 return 2;
695 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
697 return 1;
700 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
702 ok(0, "unexpected call\n");
703 return E_NOTIMPL;
706 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
707 ITypeInfo **ppTInfo)
709 ok(0, "unexpected call\n");
710 return E_NOTIMPL;
713 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
714 UINT cNames, LCID lcid, DISPID *rgDispId)
716 ok(0, "unexpected call\n");
717 return E_NOTIMPL;
720 static HRESULT WINAPI External_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
721 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
722 EXCEPINFO *pExcepInfo, UINT *puArgErr)
724 ok(0, "unexpected call\n");
725 return E_NOTIMPL;
728 static const IDispatchVtbl ExternalVtbl = {
729 External_QueryInterface,
730 Dispatch_AddRef,
731 Dispatch_Release,
732 Dispatch_GetTypeInfoCount,
733 Dispatch_GetTypeInfo,
734 Dispatch_GetIDsOfNames,
735 External_Invoke
738 static IDispatch External = { &ExternalVtbl };
740 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
742 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
743 *ppv = iface;
744 return S_OK;
747 *ppv = NULL;
748 return E_NOINTERFACE;
751 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
753 return 2;
756 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
758 return 1;
761 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
762 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
763 DWORD grfPI, HANDLE_PTR dwReserved)
765 BINDINFO bindinfo;
766 DWORD bindf = 0;
767 HRESULT hres;
769 static const WCHAR wszTextCss[] = {'t','e','x','t','/','c','s','s',0};
770 static const WCHAR empty_str = {0};
772 CHECK_EXPECT(Start);
774 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
775 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
776 ok(!grfPI, "grfPI = %lx\n", grfPI);
777 ok(!dwReserved, "dwReserved = %Ix\n", dwReserved);
778 if(is_mhtml)
779 ok(!lstrcmpW(szUrl, L"winetest:doc"), "unexpected URL %s\n", wine_dbgstr_w(szUrl));
781 memset(&bindinfo, 0, sizeof(bindinfo));
782 bindinfo.cbSize = sizeof(bindinfo);
783 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
784 ok(hres == S_OK, "GetBindInfo failed: %08lx\n", hres);
785 if(!testing_submit)
786 todo_wine_if(is_mhtml)
787 ok(bindf == (BINDF_FROMURLMON|BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
788 "bindf = %lx\n", bindf);
789 else
790 ok(bindf == (BINDF_FROMURLMON|BINDF_FORMS_SUBMIT|BINDF_PRAGMA_NO_CACHE|BINDF_HYPERLINK
791 |BINDF_PULLDATA|BINDF_NEEDFILE|BINDF_GETNEWESTVERSION|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS),
792 "bindf = %lx\n", bindf);
794 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%ld\n", bindinfo.cbSize);
795 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
796 /* TODO: test stgmedData */
797 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08lx\n", bindinfo.grfBindInfoF);
798 if(!testing_submit) {
799 ok(bindinfo.dwBindVerb == BINDVERB_GET, "bindinfo.dwBindVerb=%ld\n", bindinfo.dwBindVerb);
800 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%ld\n", bindinfo.cbstgmedData);
801 ok(bindinfo.stgmedData.tymed == TYMED_NULL, "bindinfo.stgmedData.tymed=%ld\n", bindinfo.stgmedData.tymed);
802 }else {
803 ok(bindinfo.dwBindVerb == BINDVERB_POST, "bindinfo.dwBindVerb=%ld\n", bindinfo.dwBindVerb);
804 ok(bindinfo.cbstgmedData == 8, "bindinfo.cbstgmedData=%ld\n", bindinfo.cbstgmedData);
805 ok(bindinfo.stgmedData.tymed == TYMED_HGLOBAL, "bindinfo.stgmedData.tymed=%ld\n", bindinfo.stgmedData.tymed);
806 ok(!memcmp(bindinfo.stgmedData.hGlobal, "cmd=TEST", 8), "unexpected hGlobal\n");
808 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
809 if(is_mhtml)
810 ok(!bindinfo.dwOptions, "bindinfo.dwOptions=%lx\n", bindinfo.dwOptions);
811 else
812 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000 /* win2k3 */ ||
813 bindinfo.dwOptions == 0x20000, "bindinfo.dwOptions=%lx\n", bindinfo.dwOptions);
814 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%ld\n", bindinfo.dwOptionsFlags);
815 /* TODO: test dwCodePage */
816 /* TODO: test securityAttributes */
817 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
818 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
819 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%ld\n", bindinfo.dwReserved);
821 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
822 BINDSTATUS_CACHEFILENAMEAVAILABLE, &empty_str);
823 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08lx\n", hres);
825 if(report_mime) {
826 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
827 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextCss);
828 ok(hres == S_OK,
829 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08lx\n", hres);
832 hres = IInternetProtocolSink_ReportData(pOIProtSink,
833 BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION, 13, 13);
834 ok(hres == S_OK, "ReportData failed: %08lx\n", hres);
836 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
837 ok(hres == S_OK, "ReportResult failed: %08lx\n", hres);
839 return S_OK;
842 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
843 PROTOCOLDATA *pProtocolData)
845 ok(0, "unexpected call\n");
846 return E_NOTIMPL;
849 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
850 DWORD dwOptions)
852 ok(0, "unexpected call\n");
853 return E_NOTIMPL;
856 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
858 CHECK_EXPECT(Terminate);
859 return S_OK;
862 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
864 ok(0, "unexpected call\n");
865 return E_NOTIMPL;
868 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
870 ok(0, "unexpected call\n");
871 return E_NOTIMPL;
874 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
875 ULONG cb, ULONG *pcbRead)
877 const char *data = is_mhtml ? mhtml_page : css_data;
878 unsigned data_len = strlen(data);
880 CHECK_EXPECT2(Protocol_Read);
882 ok(pv != NULL, "pv == NULL\n");
883 ok(cb > data_len, "cb < data_len\n");
884 ok(pcbRead != NULL, "pcbRead == NULL\n");
885 ok(!*pcbRead || *pcbRead == data_len, "*pcbRead=%ld\n", *pcbRead);
887 if(protocol_read) {
888 *pcbRead = 0;
889 return S_FALSE;
892 protocol_read += *pcbRead = data_len;
893 memcpy(pv, data, data_len);
895 return S_OK;
898 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
899 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
901 ok(0, "unexpected call\n");
902 return E_NOTIMPL;
905 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
907 CHECK_EXPECT(LockRequest);
908 return S_OK;
911 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
913 CHECK_EXPECT(UnlockRequest);
914 return S_OK;
917 static const IInternetProtocolVtbl ProtocolVtbl = {
918 Protocol_QueryInterface,
919 Protocol_AddRef,
920 Protocol_Release,
921 Protocol_Start,
922 Protocol_Continue,
923 Protocol_Abort,
924 Protocol_Terminate,
925 Protocol_Suspend,
926 Protocol_Resume,
927 Protocol_Read,
928 Protocol_Seek,
929 Protocol_LockRequest,
930 Protocol_UnlockRequest
933 static IInternetProtocol Protocol = { &ProtocolVtbl };
935 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
937 if(!IsEqualGUID(&IID_IInternetProtocolInfo, riid))
938 ok(0, "unexpected call\n");
939 return E_NOINTERFACE;
942 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
944 return 2;
947 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
949 return 1;
952 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
953 REFIID riid, void **ppv)
955 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
956 return E_NOINTERFACE;
958 CHECK_EXPECT(CreateInstance);
959 ok(ppv != NULL, "ppv == NULL\n");
961 *ppv = &Protocol;
962 return S_OK;
965 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
967 ok(0, "unexpected call\n");
968 return S_OK;
971 static const IClassFactoryVtbl ClassFactoryVtbl = {
972 ClassFactory_QueryInterface,
973 ClassFactory_AddRef,
974 ClassFactory_Release,
975 ClassFactory_CreateInstance,
976 ClassFactory_LockServer
979 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
981 static HRESULT WINAPI HlinkFrame_QueryInterface(IHlinkFrame *iface, REFIID riid, void **ppv)
983 ok(0, "unexpected call\n");
984 return E_NOTIMPL;
987 static ULONG WINAPI HlinkFrame_AddRef(IHlinkFrame *iface)
989 return 2;
992 static ULONG WINAPI HlinkFrame_Release(IHlinkFrame *iface)
994 return 1;
997 static HRESULT WINAPI HlinkFrame_SetBrowseContext(IHlinkFrame *iface,
998 IHlinkBrowseContext *pihlbc)
1000 ok(0, "unexpected call\n");
1001 return E_NOTIMPL;
1004 static HRESULT WINAPI HlinkFrame_GetBrowseContext(IHlinkFrame *iface,
1005 IHlinkBrowseContext **ppihlbc)
1007 ok(0, "unexpected call\n");
1008 return E_NOTIMPL;
1011 static HRESULT WINAPI HlinkFrame_Navigate(IHlinkFrame *iface, DWORD grfHLNF, LPBC pbc,
1012 IBindStatusCallback *pibsc, IHlink *pihlNavigate)
1014 HRESULT hres;
1016 CHECK_EXPECT(Navigate);
1018 ok(grfHLNF == 0, "grfHLNF=%ld, expected 0\n", grfHLNF);
1019 ok(pbc != NULL, "pbc == NULL\n");
1020 ok(pibsc != NULL, "pubsc == NULL\n");
1021 ok(pihlNavigate != NULL, "puhlNavigate == NULL\n");
1023 if(pihlNavigate) {
1024 LPWSTR frame_name = (LPWSTR)0xdeadbeef;
1025 LPWSTR location = (LPWSTR)0xdeadbeef;
1026 IHlinkSite *site;
1027 IMoniker *mon = NULL;
1028 DWORD site_data = 0xdeadbeef;
1030 hres = IHlink_GetTargetFrameName(pihlNavigate, &frame_name);
1031 ok(hres == S_FALSE, "GetTargetFrameName failed: %08lx\n", hres);
1032 ok(frame_name == NULL, "frame_name = %p\n", frame_name);
1034 hres = IHlink_GetMonikerReference(pihlNavigate, 1, &mon, &location);
1035 ok(hres == S_OK, "GetMonikerReference failed: %08lx\n", hres);
1036 ok(location == NULL, "location = %p\n", location);
1037 ok(mon != NULL, "mon == NULL\n");
1039 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &location);
1040 ok(hres == S_OK, "GetDisplayName failed: %08lx\n", hres);
1041 ok(!lstrcmpW(location, nav_url), "unexpected display name %s, expected %s\n", wine_dbgstr_w(location),
1042 wine_dbgstr_w(nav_url));
1043 CoTaskMemFree(location);
1044 IMoniker_Release(mon);
1046 hres = IHlink_GetHlinkSite(pihlNavigate, &site, &site_data);
1047 ok(hres == S_OK, "GetHlinkSite failed: %08lx\n", hres);
1048 ok(site == NULL, "site = %p\n, expected NULL\n", site);
1049 ok(site_data == 0xdeadbeef, "site_data = %lx\n", site_data);
1052 return S_OK;
1055 static HRESULT WINAPI HlinkFrame_OnNavigate(IHlinkFrame *iface, DWORD grfHLNF,
1056 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName, DWORD dwreserved)
1058 ok(0, "unexpected call\n");
1059 return E_NOTIMPL;
1062 static HRESULT WINAPI HlinkFrame_UpdateHlink(IHlinkFrame *iface, ULONG uHLID,
1063 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
1065 ok(0, "unexpected call\n");
1066 return E_NOTIMPL;
1069 static const IHlinkFrameVtbl HlinkFrameVtbl = {
1070 HlinkFrame_QueryInterface,
1071 HlinkFrame_AddRef,
1072 HlinkFrame_Release,
1073 HlinkFrame_SetBrowseContext,
1074 HlinkFrame_GetBrowseContext,
1075 HlinkFrame_Navigate,
1076 HlinkFrame_OnNavigate,
1077 HlinkFrame_UpdateHlink
1080 static IHlinkFrame HlinkFrame = { &HlinkFrameVtbl };
1082 static HRESULT WINAPI NewWindowManager_QueryInterface(INewWindowManager *iface, REFIID riid, void **ppv)
1084 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(riid, &IID_INewWindowManager)) {
1085 *ppv = iface;
1086 return S_OK;
1089 if(winetest_debug > 1) trace("NewWindowManager_QueryInterface %s\n", wine_dbgstr_guid(riid));
1090 *ppv = NULL;
1091 return E_NOINTERFACE;
1094 static ULONG WINAPI NewWindowManager_AddRef(INewWindowManager *iface)
1096 return 2;
1099 static ULONG WINAPI NewWindowManager_Release(INewWindowManager *iface)
1101 return 1;
1104 static HRESULT WINAPI NewWindowManager_EvaluateNewWindow(INewWindowManager *iface, LPCWSTR pszUrl,
1105 LPCWSTR pszName, LPCWSTR pszUrlContext, LPCWSTR pszFeatures, BOOL fReplace, DWORD dwFlags,
1106 DWORD dwUserActionTime)
1108 CHECK_EXPECT(EvaluateNewWindow);
1110 ok(!lstrcmpW(pszUrl, L"about:blank"), "pszUrl = %s\n", wine_dbgstr_w(pszUrl));
1111 ok(!lstrcmpW(pszName, L"test"), "pszName = %s\n", wine_dbgstr_w(pszName));
1112 ok(!lstrcmpW(pszUrlContext, prev_url), "pszUrlContext = %s\n", wine_dbgstr_w(pszUrlContext));
1113 ok(!pszFeatures, "pszFeatures = %s\n", wine_dbgstr_w(pszFeatures));
1114 ok(!fReplace, "fReplace = %x\n", fReplace);
1115 ok(dwFlags == (allow_new_window ? 0 : NWMF_FIRST), "dwFlags = %lx\n", dwFlags);
1116 ok(!dwUserActionTime, "dwUserActionime = %ld\n", dwUserActionTime);
1118 return allow_new_window ? S_OK : E_FAIL;
1121 static const INewWindowManagerVtbl NewWindowManagerVtbl = {
1122 NewWindowManager_QueryInterface,
1123 NewWindowManager_AddRef,
1124 NewWindowManager_Release,
1125 NewWindowManager_EvaluateNewWindow
1128 static INewWindowManager NewWindowManager = { &NewWindowManagerVtbl };
1130 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
1131 REFIID riid, void**ppv)
1133 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
1134 *ppv = iface;
1135 return S_OK;
1138 ok(0, "unexpected call\n");
1139 return E_NOINTERFACE;
1142 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
1144 return 2;
1147 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
1149 return 1;
1152 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
1154 if(resetting_document)
1155 return S_OK;
1157 switch(dispID) {
1158 case DISPID_READYSTATE:
1159 CHECK_EXPECT2(OnChanged_READYSTATE);
1161 if(!readystate_set_interactive)
1162 test_MSHTML_QueryStatus(NULL, OLECMDF_SUPPORTED
1163 | (editmode && (load_state == LD_INTERACTIVE || load_state == LD_COMPLETE)
1164 ? OLECMDF_ENABLED : 0));
1166 if(readystate_set_loading) {
1167 readystate_set_loading = FALSE;
1168 load_state = LD_LOADING;
1170 if(!editmode || load_state != LD_LOADING || !called_Exec_Explorer_69)
1171 test_readyState(NULL);
1172 return S_OK;
1173 case 1005:
1174 CHECK_EXPECT2(OnChanged_1005);
1175 if(!editmode)
1176 test_readyState(NULL);
1177 readystate_set_interactive = (load_state != LD_INTERACTIVE);
1179 if((!is_refresh && !editmode) || called_Exec_ShellDocView_37)
1180 test_navigation_type(doc_unk);
1182 /* w10pro64_ja has it set to zero despite readyState being interactive, for whatever reason */
1183 if(!is_mhtml)
1184 test_performance_timing(doc_unk, L"domInteractive");
1185 return S_OK;
1186 case 1012:
1187 CHECK_EXPECT2(OnChanged_1012);
1188 return S_OK;
1189 case 1014:
1190 CHECK_EXPECT2(OnChanged_1014);
1191 return S_OK;
1192 case 1029:
1193 case 1030:
1194 case 3000022:
1195 case 3000023:
1196 case 3000024:
1197 case 3000025:
1198 case 3000026:
1199 case 3000027:
1200 case 3000028:
1201 case 3000029:
1202 case 3000030:
1203 case 3000031:
1204 case 3000032:
1205 case 3000033:
1206 case 3000034:
1207 /* TODO */
1208 return S_OK;
1211 ok(0, "unexpected id %ld\n", dispID);
1212 return E_NOTIMPL;
1215 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
1217 ok(0, "unexpected call\n");
1218 return E_NOTIMPL;
1221 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
1222 PropertyNotifySink_QueryInterface,
1223 PropertyNotifySink_AddRef,
1224 PropertyNotifySink_Release,
1225 PropertyNotifySink_OnChanged,
1226 PropertyNotifySink_OnRequestEdit
1229 static IPropertyNotifySink PropertyNotifySink = { &PropertyNotifySinkVtbl };
1231 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
1233 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_ISequentialStream, riid) || IsEqualGUID(&IID_IStream, riid)) {
1234 *ppv = iface;
1235 return S_OK;
1238 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
1239 *ppv = NULL;
1240 return E_NOINTERFACE;
1243 static ULONG WINAPI Stream_AddRef(IStream *iface)
1245 return 2;
1248 static ULONG WINAPI Stream_Release(IStream *iface)
1250 return 1;
1253 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
1254 ULONG cb, ULONG *pcbRead)
1256 CHECK_EXPECT2(Read);
1257 ok(pv != NULL, "pv == NULL\n");
1258 ok(cb > sizeof(html_page), "cb = %ld\n", cb);
1259 ok(pcbRead != NULL, "pcbRead == NULL\n");
1260 ok(!*pcbRead, "*pcbRead = %ld\n", *pcbRead);
1262 if(stream_read)
1263 return S_FALSE;
1265 memcpy(pv, html_page, sizeof(html_page)-1);
1266 stream_read += *pcbRead = sizeof(html_page)-1;
1267 return S_OK;
1270 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
1271 ULONG cb, ULONG *pcbWritten)
1273 ok(0, "unexpected call\n");
1274 return E_NOTIMPL;
1277 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
1278 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1280 ok(0, "unexpected call\n");
1281 return E_NOTIMPL;
1284 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
1286 ok(0, "unexpected call\n");
1287 return E_NOTIMPL;
1290 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
1291 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
1293 ok(0, "unexpected call\n");
1294 return E_NOTIMPL;
1297 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
1299 ok(0, "unexpected call\n");
1300 return E_NOTIMPL;
1303 static HRESULT WINAPI Stream_Revert(IStream *iface)
1305 ok(0, "unexpected call\n");
1306 return E_NOTIMPL;
1309 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
1310 ULARGE_INTEGER cb, DWORD dwLockType)
1312 ok(0, "unexpected call\n");
1313 return E_NOTIMPL;
1316 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
1317 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
1319 ok(0, "unexpected call\n");
1320 return E_NOTIMPL;
1323 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
1324 DWORD dwStatFlag)
1326 ok(0, "unexpected call\n");
1327 return E_NOTIMPL;
1330 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
1332 ok(0, "unexpected call\n");
1333 return E_NOTIMPL;
1336 static const IStreamVtbl StreamVtbl = {
1337 Stream_QueryInterface,
1338 Stream_AddRef,
1339 Stream_Release,
1340 Stream_Read,
1341 Stream_Write,
1342 Stream_Seek,
1343 Stream_SetSize,
1344 Stream_CopyTo,
1345 Stream_Commit,
1346 Stream_Revert,
1347 Stream_LockRegion,
1348 Stream_UnlockRegion,
1349 Stream_Stat,
1350 Stream_Clone
1353 static IStream Stream = { &StreamVtbl };
1355 static HRESULT WINAPI WinInetHttpInfo_QueryInterface(
1356 IWinInetHttpInfo* This,
1357 REFIID riid,
1358 void **ppvObject)
1360 *ppvObject = NULL;
1362 if(IsEqualGUID(&IID_IGetBindHandle, riid))
1363 return E_NOINTERFACE;
1365 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
1366 return E_NOINTERFACE;
1369 static ULONG WINAPI WinInetHttpInfo_AddRef(
1370 IWinInetHttpInfo* This)
1372 return 2;
1375 static ULONG WINAPI WinInetHttpInfo_Release(
1376 IWinInetHttpInfo* This)
1378 return 1;
1381 static HRESULT WINAPI WinInetHttpInfo_QueryOption(
1382 IWinInetHttpInfo* This,
1383 DWORD dwOption,
1384 LPVOID pBuffer,
1385 DWORD *pcbBuf)
1387 return E_NOTIMPL; /* TODO */
1390 static HRESULT WINAPI WinInetHttpInfo_QueryInfo(
1391 IWinInetHttpInfo* This,
1392 DWORD dwOption,
1393 LPVOID pBuffer,
1394 DWORD *pcbBuf,
1395 DWORD *pdwFlags,
1396 DWORD *pdwReserved)
1398 ok(pdwReserved == NULL, "pdwReserved != NULL\n");
1400 if(dwOption == (HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER)) {
1401 ok(pBuffer != NULL, "pBuffer == NULL\n");
1402 ok(*pcbBuf == sizeof(DWORD), "*pcbBuf = %ld\n", *pcbBuf);
1403 ok(pdwFlags == NULL, "*pdwFlags != NULL\n");
1404 *((DWORD*)pBuffer) = status_code;
1405 return S_OK;
1408 return E_NOTIMPL; /* TODO */
1411 static const IWinInetHttpInfoVtbl WinInetHttpInfoVtbl = {
1412 WinInetHttpInfo_QueryInterface,
1413 WinInetHttpInfo_AddRef,
1414 WinInetHttpInfo_Release,
1415 WinInetHttpInfo_QueryOption,
1416 WinInetHttpInfo_QueryInfo
1419 static IWinInetHttpInfo WinInetHttpInfo = { &WinInetHttpInfoVtbl };
1421 DEFINE_GUID(IID_unk_binding, 0xf3d8f080,0xa5eb,0x476f,0x9d,0x19,0xa5,0xef,0x24,0xe5,0xc2,0xe6);
1423 static HRESULT WINAPI Binding_QueryInterface(IBinding *iface, REFIID riid, void **ppv)
1425 if(IsEqualGUID(&IID_IUnknown, riid)) {
1426 *ppv = iface;
1427 return S_OK;
1430 if(IsEqualGUID(&IID_IWinInetInfo, riid) || IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
1431 *ppv = &WinInetHttpInfo;
1432 return S_OK;
1435 if(IsEqualGUID(&IID_unk_binding, riid)) {
1436 *ppv = NULL;
1437 return E_NOINTERFACE;
1440 if(winetest_debug > 1) trace("Binding::QI(%s)\n", wine_dbgstr_guid(riid));
1441 *ppv = NULL;
1442 return E_NOINTERFACE;
1445 static ULONG WINAPI Binding_AddRef(IBinding *iface)
1447 return 2;
1450 static ULONG WINAPI Binding_Release(IBinding *iface)
1452 return 1;
1455 static HRESULT WINAPI Binding_Abort(IBinding *iface)
1457 CHECK_EXPECT(Abort);
1458 if(asynchronous_binding)
1459 PeekMessageA(NULL, container_hwnd, WM_CONTINUE_BINDING, WM_CONTINUE_BINDING, PM_REMOVE);
1460 return S_OK;
1463 static HRESULT WINAPI Binding_Suspend(IBinding *iface)
1465 ok(0, "unexpected call\n");
1466 return E_NOTIMPL;
1469 static HRESULT WINAPI Binding_Resume(IBinding *iface)
1471 ok(0, "unexpected call\n");
1472 return E_NOTIMPL;
1475 static HRESULT WINAPI Binding_SetPriority(IBinding *iface, LONG nPriority)
1477 ok(0, "unexpected call\n");
1478 return E_NOTIMPL;
1481 static HRESULT WINAPI Binding_GetPriority(IBinding *iface, LONG *pnPriority)
1483 ok(0, "unexpected call\n");
1484 return E_NOTIMPL;
1487 static HRESULT WINAPI Binding_GetBindResult(IBinding *iface, CLSID *pclsidProtocol,
1488 DWORD *pdwResult, LPOLESTR *pszResult, DWORD *pdwReserved)
1490 CHECK_EXPECT(GetBindResult);
1491 return E_NOTIMPL;
1494 static const IBindingVtbl BindingVtbl = {
1495 Binding_QueryInterface,
1496 Binding_AddRef,
1497 Binding_Release,
1498 Binding_Abort,
1499 Binding_Suspend,
1500 Binding_Resume,
1501 Binding_SetPriority,
1502 Binding_GetPriority,
1503 Binding_GetBindResult
1506 static IBinding Binding = { &BindingVtbl };
1508 DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52);
1509 DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B);
1511 static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
1513 *ppv = NULL;
1515 if(IsEqualGUID(&IID_IMoniker_unk, riid))
1516 return E_NOINTERFACE; /* TODO */
1517 if(IsEqualGUID(&IID_IMoniker_unk2, riid))
1518 return E_NOINTERFACE; /* TODO */
1520 ok(0, "unexpected riid: %s\n", wine_dbgstr_guid(riid));
1521 return E_NOINTERFACE;
1524 static ULONG WINAPI Moniker_AddRef(IMoniker *iface)
1526 return 2;
1529 static ULONG WINAPI Moniker_Release(IMoniker *iface)
1531 return 1;
1534 static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
1536 CHECK_EXPECT(GetClassID);
1537 ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", wine_dbgstr_guid(pClassID));
1538 return E_FAIL;
1541 static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface)
1543 ok(0, "unexpected call\n");
1544 return E_NOTIMPL;
1547 static HRESULT WINAPI Moniker_Load(IMoniker *iface, IStream *pStm)
1549 ok(0, "unexpected call\n");
1550 return E_NOTIMPL;
1553 static HRESULT WINAPI Moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
1555 ok(0, "unexpected call\n");
1556 return E_NOTIMPL;
1559 static HRESULT WINAPI Moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
1561 ok(0, "unexpected call\n");
1562 return E_NOTIMPL;
1565 static HRESULT WINAPI Moniker_BindToObject(IMoniker *iface, IBindCtx *pcb, IMoniker *pmkToLeft,
1566 REFIID riidResult, void **ppvResult)
1568 ok(0, "unexpected call\n");
1569 return E_NOTIMPL;
1572 static void test_binding_ui(IUnknown *unk)
1574 IWindowForBindingUI *binding_ui;
1575 IServiceProvider *serv_prov;
1576 HWND binding_hwnd;
1577 HRESULT hres;
1579 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&serv_prov);
1580 ok(hres == S_OK, "Could not get IServiceProvider: %08lx\n", hres);
1582 hres = IServiceProvider_QueryService(serv_prov, &IID_IWindowForBindingUI, &IID_IWindowForBindingUI,
1583 (void**)&binding_ui);
1584 ok(hres == S_OK, "Could not get IWindowForBindingUI: %08lx\n", hres);
1586 hres = IWindowForBindingUI_GetWindow(binding_ui, &IID_IHttpSecurity, &binding_hwnd);
1587 ok(hres == S_OK, "GetWindow(IID_IHttpSecurity) failed: %08lx\n", hres);
1588 if(doc_hwnd)
1589 ok(binding_hwnd == doc_hwnd, "binding_hwnd != doc_hwnd\n");
1590 else
1591 todo_wine ok(binding_hwnd != NULL, "binding_hwnd == NULL\n");
1593 hres = IWindowForBindingUI_GetWindow(binding_ui, &IID_IAuthenticate, &binding_hwnd);
1594 ok(hres == S_OK, "GetWindow(IID_IHttpSecurity) failed: %08lx\n", hres);
1595 if(doc_hwnd)
1596 ok(binding_hwnd == doc_hwnd, "binding_hwnd != doc_hwnd\n");
1597 else
1598 todo_wine ok(binding_hwnd != NULL, "binding_hwnd == NULL\n");
1600 hres = IWindowForBindingUI_GetWindow(binding_ui, &IID_IWindowForBindingUI, &binding_hwnd);
1601 ok(hres == S_OK, "GetWindow(IID_IHttpSecurity) failed: %08lx\n", hres);
1602 if(doc_hwnd)
1603 ok(binding_hwnd == doc_hwnd, "binding_hwnd != doc_hwnd\n");
1604 else
1605 todo_wine ok(binding_hwnd != NULL, "binding_hwnd == NULL\n");
1607 IWindowForBindingUI_Release(binding_ui);
1608 IServiceProvider_Release(serv_prov);
1611 static void continue_binding(IBindStatusCallback *callback)
1613 FORMATETC formatetc = {0xc02d, NULL, 1, -1, TYMED_ISTREAM};
1614 STGMEDIUM stgmedium;
1615 HRESULT hres;
1617 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
1619 test_binding_ui((IUnknown*)callback);
1621 if(report_mime) {
1622 hres = IBindStatusCallback_OnProgress(callback, 0, 0, BINDSTATUS_MIMETYPEAVAILABLE,
1623 wszTextHtml);
1624 ok(hres == S_OK, "OnProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08lx\n", hres);
1627 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1628 BINDSTATUS_BEGINDOWNLOADDATA, doc_url);
1629 ok(hres == S_OK, "OnProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08lx\n", hres);
1630 if(status_code != HTTP_STATUS_OK) {
1631 CHECK_CALLED_BROKEN(IsErrorUrl);
1632 SET_EXPECT(IsErrorUrl);
1635 SET_EXPECT(Read);
1636 stgmedium.tymed = TYMED_ISTREAM;
1637 stgmedium.pstm = &Stream;
1638 stgmedium.pUnkForRelease = (IUnknown*)&Moniker;
1639 hres = IBindStatusCallback_OnDataAvailable(callback,
1640 BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
1641 sizeof(html_page)-1, &formatetc, &stgmedium);
1642 ok(hres == S_OK, "OnDataAvailable failed: %08lx\n", hres);
1643 CHECK_CALLED(Read);
1645 hres = IBindStatusCallback_OnProgress(callback, sizeof(html_page)-1, sizeof(html_page)-1,
1646 BINDSTATUS_ENDDOWNLOADDATA, NULL);
1647 ok(hres == S_OK, "OnProgress(BINDSTATUS_ENDDOWNLOADDATA) failed: %08lx\n", hres);
1649 SET_EXPECT(GetBindResult);
1650 hres = IBindStatusCallback_OnStopBinding(callback, S_OK, NULL);
1651 ok(hres == S_OK, "OnStopBinding failed: %08lx\n", hres);
1652 CLEAR_CALLED(GetBindResult); /* IE7 */
1654 IBindStatusCallback_Release(callback);
1657 static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1658 REFIID riid, void **ppv)
1660 IBindStatusCallback *callback = NULL;
1661 IBindCallbackRedirect *redirect_callback;
1662 IServiceProvider *service_provider;
1663 BINDINFO bindinfo;
1664 DWORD bindf;
1665 HRESULT hres;
1667 static OLECHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
1669 CHECK_EXPECT(BindToStorage);
1671 load_state = LD_LOADING;
1673 ok(pbc != NULL, "pbc == NULL\n");
1674 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1675 ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n");
1676 ok(ppv != NULL, "ppv == NULL\n");
1677 ok(*ppv == NULL, "*ppv=%p\n", *ppv);
1679 hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&callback);
1680 ok(hres == S_OK, "GetObjectParam failed: %08lx\n", hres);
1681 ok(callback != NULL, "callback == NULL\n");
1683 memset(&bindinfo, 0xf0, sizeof(bindinfo));
1684 bindinfo.cbSize = sizeof(bindinfo);
1686 hres = IBindStatusCallback_GetBindInfo(callback, &bindf, &bindinfo);
1687 ok(hres == S_OK, "GetBindInfo failed: %08lx\n", hres);
1688 ok((bindf & ~BINDF_HYPERLINK /* IE9 */) == (BINDF_PULLDATA|BINDF_ASYNCSTORAGE|BINDF_ASYNCHRONOUS), "bindf = %08lx\n", bindf);
1689 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize=%ld\n", bindinfo.cbSize);
1690 ok(bindinfo.szExtraInfo == NULL, "bindinfo.szExtraInfo=%p\n", bindinfo.szExtraInfo);
1691 /* TODO: test stgmedData */
1692 ok(bindinfo.grfBindInfoF == 0, "bindinfo.grfBinfInfoF=%08lx\n", bindinfo.grfBindInfoF);
1693 ok(bindinfo.dwBindVerb == 0, "bindinfo.dwBindVerb=%ld\n", bindinfo.dwBindVerb);
1694 ok(bindinfo.szCustomVerb == 0, "bindinfo.szCustomVerb=%p\n", bindinfo.szCustomVerb);
1695 ok(bindinfo.cbstgmedData == 0, "bindinfo.cbstgmedData=%ld\n", bindinfo.cbstgmedData);
1696 ok(bindinfo.dwOptions == 0x80000 || bindinfo.dwOptions == 0x4080000 ||
1697 bindinfo.dwOptions == 0x20000, "bindinfo.dwOptions=%lx\n", bindinfo.dwOptions);
1698 ok(bindinfo.dwOptionsFlags == 0, "bindinfo.dwOptionsFlags=%ld\n", bindinfo.dwOptionsFlags);
1699 /* TODO: test dwCodePage */
1700 /* TODO: test securityAttributes */
1701 ok(IsEqualGUID(&IID_NULL, &bindinfo.iid), "unexpected bindinfo.iid\n");
1702 ok(bindinfo.pUnk == NULL, "bindinfo.pUnk=%p\n", bindinfo.pUnk);
1703 ok(bindinfo.dwReserved == 0, "bindinfo.dwReserved=%ld\n", bindinfo.dwReserved);
1705 hres = IBindStatusCallback_QueryInterface(callback, &IID_IServiceProvider, (void**)&service_provider);
1706 ok(hres == S_OK, "Could not get IServiceProvider iface: %08lx\n", hres);
1708 hres = IServiceProvider_QueryService(service_provider, &IID_IBindCallbackRedirect, &IID_IBindCallbackRedirect, (void**)&redirect_callback);
1709 ok(hres == S_OK, "QueryService(IID_IBindCallbackRedirect) returned %08lx\n", hres);
1711 IBindCallbackRedirect_Release(redirect_callback);
1712 IServiceProvider_Release(service_provider);
1714 hres = IBindStatusCallback_OnStartBinding(callback, 0, &Binding);
1715 ok(hres == S_OK, "OnStartBinding failed: %08lx\n", hres);
1717 if(asynchronous_binding) {
1718 PostMessageW(container_hwnd, WM_CONTINUE_BINDING, (WPARAM)callback, 0);
1719 return MK_S_ASYNCHRONOUS;
1722 continue_binding(callback);
1723 return S_OK;
1726 static HRESULT WINAPI Moniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar,
1727 IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
1729 ok(0, "unexpected call\n");
1730 return E_NOTIMPL;
1733 static HRESULT WINAPI Moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
1734 BOOL fOnlyIfNotGeneric, IMoniker **ppnkComposite)
1736 ok(0, "unexpected call\n");
1737 return E_NOTIMPL;
1740 static HRESULT WINAPI Moniker_Enum(IMoniker *iface, BOOL fForwrd, IEnumMoniker **ppenumMoniker)
1742 ok(0, "unexpected call\n");
1743 return E_NOTIMPL;
1746 static HRESULT WINAPI Moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
1748 ok(0, "unexpected call\n");
1749 return E_NOTIMPL;
1752 static HRESULT WINAPI Moniker_Hash(IMoniker *iface, DWORD *pdwHash)
1754 ok(0, "unexpected call\n");
1755 return E_NOTIMPL;
1758 static HRESULT WINAPI Moniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft,
1759 IMoniker *pmkNewlyRunning)
1761 ok(0, "unexpected call\n");
1762 return E_NOTIMPL;
1765 static HRESULT WINAPI Moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
1766 IMoniker *pmkToLeft, FILETIME *pFileTime)
1768 ok(0, "unexpected call\n");
1769 return E_NOTIMPL;
1772 static HRESULT WINAPI Moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
1774 ok(0, "unexpected call\n");
1775 return E_NOTIMPL;
1778 static HRESULT WINAPI Moniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther,
1779 IMoniker **ppmkPrefix)
1781 ok(0, "unexpected call\n");
1782 return E_NOTIMPL;
1785 static HRESULT WINAPI Moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
1786 IMoniker **pmkRelPath)
1788 ok(0, "unexpected call\n");
1789 return E_NOTIMPL;
1792 static HRESULT WINAPI Moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
1793 IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
1795 CHECK_EXPECT2(GetDisplayName);
1797 /* ok(pbc != NULL, "pbc == NULL\n"); */
1798 ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft);
1799 ok(ppszDisplayName != NULL, "ppszDisplayName == NULL\n");
1801 *ppszDisplayName = CoTaskMemAlloc(sizeof(doc_url));
1802 memcpy(*ppszDisplayName, doc_url, sizeof(doc_url));
1804 return S_OK;
1807 static HRESULT WINAPI Moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
1808 IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1810 ok(0, "unexpected call\n");
1811 return E_NOTIMPL;
1814 static HRESULT WINAPI Moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
1816 CHECK_EXPECT(IsSystemMoniker);
1817 return E_NOTIMPL;
1820 static const IMonikerVtbl MonikerVtbl = {
1821 Moniker_QueryInterface,
1822 Moniker_AddRef,
1823 Moniker_Release,
1824 Moniker_GetClassID,
1825 Moniker_IsDirty,
1826 Moniker_Load,
1827 Moniker_Save,
1828 Moniker_GetSizeMax,
1829 Moniker_BindToObject,
1830 Moniker_BindToStorage,
1831 Moniker_Reduce,
1832 Moniker_ComposeWith,
1833 Moniker_Enum,
1834 Moniker_IsEqual,
1835 Moniker_Hash,
1836 Moniker_IsRunning,
1837 Moniker_GetTimeOfLastChange,
1838 Moniker_Inverse,
1839 Moniker_CommonPrefixWith,
1840 Moniker_RelativePathTo,
1841 Moniker_GetDisplayName,
1842 Moniker_ParseDisplayName,
1843 Moniker_IsSystemMoniker
1846 static IMoniker Moniker = { &MonikerVtbl };
1848 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1850 return QueryInterface(riid, ppv);
1853 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1855 return 2;
1858 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1860 return 1;
1863 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
1864 LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
1866 ok(0, "unexpected call\n");
1867 return E_NOTIMPL;
1870 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
1871 IEnumUnknown **ppenum)
1873 ok(0, "unexpected call\n");
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1879 CHECK_EXPECT(LockContainer);
1880 ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
1881 return S_OK;
1884 static const IOleContainerVtbl OleContainerVtbl = {
1885 OleContainer_QueryInterface,
1886 OleContainer_AddRef,
1887 OleContainer_Release,
1888 OleContainer_ParseDisplayName,
1889 OleContainer_EnumObjects,
1890 OleContainer_LockContainer
1893 static IOleContainer OleContainer = { &OleContainerVtbl };
1895 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
1897 return QueryInterface(riid, ppv);
1900 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
1902 return 2;
1905 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
1907 return 1;
1910 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
1912 ok(0, "unexpected call\n");
1913 return E_NOTIMPL;
1916 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker,
1917 IMoniker **ppmon)
1919 ok(0, "unexpected call\n");
1920 return E_NOTIMPL;
1923 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
1925 CHECK_EXPECT(GetContainer);
1926 ok(ppContainer != NULL, "ppContainer = NULL\n");
1927 *ppContainer = &OleContainer;
1928 return S_OK;
1931 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
1933 ok(0, "unexpected call\n");
1934 return E_NOTIMPL;
1937 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
1939 ok(0, "unexpected call\n");
1940 return E_NOTIMPL;
1943 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
1945 ok(0, "unexpected call\n");
1946 return E_NOTIMPL;
1949 static const IOleClientSiteVtbl ClientSiteVtbl = {
1950 ClientSite_QueryInterface,
1951 ClientSite_AddRef,
1952 ClientSite_Release,
1953 ClientSite_SaveObject,
1954 ClientSite_GetMoniker,
1955 ClientSite_GetContainer,
1956 ClientSite_ShowObject,
1957 ClientSite_OnShowWindow,
1958 ClientSite_RequestNewObjectLayout
1961 static IOleClientSite ClientSite = { &ClientSiteVtbl };
1963 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
1965 static const GUID undocumented_frame_iid = {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
1967 if(!IsEqualGUID(&undocumented_frame_iid, riid))
1968 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
1970 *ppv = NULL;
1971 return E_NOINTERFACE;
1974 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
1976 return 2;
1979 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
1981 return 1;
1984 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
1986 CHECK_EXPECT(Frame_GetWindow);
1987 return E_NOTIMPL;
1990 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
1992 ok(0, "unexpected call\n");
1993 return E_NOTIMPL;
1996 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
1998 ok(0, "unexpected call\n");
1999 return E_NOTIMPL;
2002 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
2003 LPCBORDERWIDTHS pborderwidths)
2005 ok(0, "unexpected call\n");
2006 return E_NOTIMPL;
2009 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
2010 LPCBORDERWIDTHS pborderwidths)
2012 CHECK_EXPECT(InPlaceFrame_SetBorderSpace);
2013 return S_OK;
2016 static HRESULT WINAPI InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame *iface,
2017 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
2019 static const WCHAR wszHTML_Document[] =
2020 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
2022 CHECK_EXPECT2(InPlaceUIWindow_SetActiveObject);
2024 if(expect_InPlaceUIWindow_SetActiveObject_active) {
2025 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2026 if(pActiveObject && is_lang_english())
2027 ok(!lstrcmpW(wszHTML_Document, pszObjName), "%s != \"HTML Document\"\n", wine_dbgstr_w(pszObjName));
2029 else {
2030 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
2031 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
2033 expect_InPlaceUIWindow_SetActiveObject_active = !expect_InPlaceUIWindow_SetActiveObject_active;
2034 return S_OK;
2037 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
2038 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
2040 static const WCHAR wszHTML_Document[] =
2041 {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
2043 if(pActiveObject) {
2044 CHECK_EXPECT2(SetActiveObject);
2046 if(pActiveObject && is_lang_english())
2047 ok(!lstrcmpW(wszHTML_Document, pszObjName), "%s != \"HTML Document\"\n", wine_dbgstr_w(pszObjName));
2048 }else {
2049 CHECK_EXPECT(SetActiveObject_null);
2051 ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
2052 ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
2055 return S_OK;
2058 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
2059 LPOLEMENUGROUPWIDTHS lpMenuWidths)
2061 ok(0, "unexpected call\n");
2062 return E_NOTIMPL;
2065 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
2066 HOLEMENU holemenu, HWND hwndActiveObject)
2068 ok(0, "unexpected call\n");
2069 return E_NOTIMPL;
2072 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
2074 ok(0, "unexpected call\n");
2075 return E_NOTIMPL;
2078 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
2080 if(!resetting_document)
2081 CHECK_EXPECT2(SetStatusText);
2082 if(!expect_status_text)
2083 ok(pszStatusText == NULL, "pszStatusText=%p, expected NULL\n", pszStatusText);
2084 return S_OK;
2087 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
2089 if(fEnable)
2090 CHECK_EXPECT2(Frame_EnableModeless_TRUE);
2091 else
2092 CHECK_EXPECT2(Frame_EnableModeless_FALSE);
2093 return E_NOTIMPL;
2096 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
2098 ok(0, "unexpected call\n");
2099 return E_NOTIMPL;
2102 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
2103 InPlaceFrame_QueryInterface,
2104 InPlaceFrame_AddRef,
2105 InPlaceFrame_Release,
2106 InPlaceFrame_GetWindow,
2107 InPlaceFrame_ContextSensitiveHelp,
2108 InPlaceFrame_GetBorder,
2109 InPlaceFrame_RequestBorderSpace,
2110 InPlaceFrame_SetBorderSpace,
2111 InPlaceFrame_SetActiveObject,
2112 InPlaceFrame_InsertMenus,
2113 InPlaceFrame_SetMenu,
2114 InPlaceFrame_RemoveMenus,
2115 InPlaceFrame_SetStatusText,
2116 InPlaceFrame_EnableModeless,
2117 InPlaceFrame_TranslateAccelerator
2120 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
2122 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl = {
2123 InPlaceFrame_QueryInterface,
2124 InPlaceFrame_AddRef,
2125 InPlaceFrame_Release,
2126 InPlaceFrame_GetWindow,
2127 InPlaceFrame_ContextSensitiveHelp,
2128 InPlaceFrame_GetBorder,
2129 InPlaceFrame_RequestBorderSpace,
2130 InPlaceFrame_SetBorderSpace,
2131 InPlaceUIWindow_SetActiveObject,
2134 static IOleInPlaceFrame InPlaceUIWindow = { &InPlaceUIWindowVtbl };
2136 static HRESULT WINAPI InPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
2138 return QueryInterface(riid, ppv);
2141 static ULONG WINAPI InPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
2143 return 2;
2146 static ULONG WINAPI InPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
2148 return 1;
2151 static HRESULT WINAPI InPlaceSiteWindowless_GetWindow(
2152 IOleInPlaceSiteWindowless *iface, HWND *phwnd)
2154 IOleClientSite *client_site;
2155 IOleObject *ole_obj;
2156 HRESULT hres;
2158 CHECK_EXPECT2(GetWindow);
2159 ok(phwnd != NULL, "phwnd = NULL\n");
2160 *phwnd = container_hwnd;
2162 hres = IUnknown_QueryInterface(doc_unk, &IID_IOleObject, (void**)&ole_obj);
2163 ok(hres == S_OK, "Could not get IOleObject: %08lx\n", hres);
2165 hres = IOleObject_GetClientSite(ole_obj, &client_site);
2166 IOleObject_Release(ole_obj);
2167 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
2168 ok(client_site == &ClientSite, "client_site != ClientSite\n");
2169 IOleClientSite_Release(client_site);
2171 return S_OK;
2174 static HRESULT WINAPI InPlaceSiteWindowless_ContextSensitiveHelp(
2175 IOleInPlaceSiteWindowless *iface, BOOL fEnterMode)
2177 ok(0, "unexpected call\n");
2178 return E_NOTIMPL;
2181 static HRESULT WINAPI InPlaceSiteWindowless_CanInPlaceActivate(
2182 IOleInPlaceSiteWindowless *iface)
2184 CHECK_EXPECT(CanInPlaceActivate);
2185 return S_OK;
2188 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivate(
2189 IOleInPlaceSiteWindowless *iface)
2191 CHECK_EXPECT(OnInPlaceActivate);
2192 inplace_deactivated = FALSE;
2193 return S_OK;
2196 static HRESULT WINAPI InPlaceSiteWindowless_OnUIActivate(
2197 IOleInPlaceSiteWindowless *iface)
2199 CHECK_EXPECT(OnUIActivate);
2200 return S_OK;
2203 static HRESULT WINAPI InPlaceSiteWindowless_GetWindowContext(
2204 IOleInPlaceSiteWindowless *iface, IOleInPlaceFrame **ppFrame,
2205 IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
2206 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
2208 static const RECT rect = {0,0,500,500};
2210 CHECK_EXPECT(GetWindowContext);
2212 ok(ppFrame != NULL, "ppFrame = NULL\n");
2213 if(ppFrame)
2214 *ppFrame = &InPlaceFrame;
2215 ok(ppDoc != NULL, "ppDoc = NULL\n");
2216 if(ppDoc)
2217 *ppDoc = (IOleInPlaceUIWindow*)&InPlaceUIWindow;
2218 ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
2219 if(lprcPosRect)
2220 memcpy(lprcPosRect, &rect, sizeof(RECT));
2221 ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
2222 if(lprcClipRect)
2223 memcpy(lprcClipRect, &rect, sizeof(RECT));
2224 ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
2225 if(lpFrameInfo) {
2226 ok(lpFrameInfo->cb == sizeof(*lpFrameInfo), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo->cb, (unsigned)sizeof(*lpFrameInfo));
2227 lpFrameInfo->fMDIApp = FALSE;
2228 lpFrameInfo->hwndFrame = container_hwnd;
2229 lpFrameInfo->haccel = NULL;
2230 lpFrameInfo->cAccelEntries = 0;
2233 return S_OK;
2236 static HRESULT WINAPI InPlaceSiteWindowless_Scroll(
2237 IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
2239 ok(0, "unexpected call\n");
2240 return E_NOTIMPL;
2243 static HRESULT WINAPI InPlaceSiteWindowless_OnUIDeactivate(
2244 IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
2246 CHECK_EXPECT(OnUIDeactivate);
2247 ok(!fUndoable, "fUndoable = TRUE\n");
2248 return S_OK;
2251 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivate(
2252 IOleInPlaceSiteWindowless *iface)
2254 CHECK_EXPECT(OnInPlaceDeactivate);
2255 inplace_deactivated = TRUE;
2256 return S_OK;
2259 static HRESULT WINAPI InPlaceSiteWindowless_DiscardUndoState(
2260 IOleInPlaceSiteWindowless *iface)
2262 ok(0, "unexpected call\n");
2263 return E_NOTIMPL;
2266 static HRESULT WINAPI InPlaceSiteWindowless_DeactivateAndUndo(
2267 IOleInPlaceSiteWindowless *iface)
2269 ok(0, "unexpected call\n");
2270 return E_NOTIMPL;
2273 static HRESULT WINAPI InPlaceSiteWindowless_OnPosRectChange(
2274 IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
2276 ok(0, "unexpected call\n");
2277 return E_NOTIMPL;
2280 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceActivateEx(
2281 IOleInPlaceSiteWindowless *iface, BOOL *pfNoRedraw, DWORD dwFlags)
2283 CHECK_EXPECT(OnInPlaceActivateEx);
2285 ok(pfNoRedraw != NULL, "pfNoRedraw == NULL\n");
2286 ok(!*pfNoRedraw, "*pfNoRedraw == TRUE\n");
2287 ok(dwFlags == 0, "dwFlags = %08lx\n", dwFlags);
2289 return S_OK;
2292 static HRESULT WINAPI InPlaceSiteWindowless_OnInPlaceDeactivateEx(
2293 IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
2295 CHECK_EXPECT(OnInPlaceDeactivateEx);
2297 ok(fNoRedraw, "fNoRedraw == FALSE\n");
2299 return S_OK;
2302 static HRESULT WINAPI InPlaceSiteWindowless_RequestUIActivate(
2303 IOleInPlaceSiteWindowless *iface)
2305 CHECK_EXPECT2(RequestUIActivate);
2306 return S_OK;
2309 static HRESULT WINAPI InPlaceSiteWindowless_CanWindowlessActivate(
2310 IOleInPlaceSiteWindowless *iface)
2312 ok(0, "unexpected call\n");
2313 return E_NOTIMPL;
2316 static HRESULT WINAPI InPlaceSiteWindowless_GetCapture(
2317 IOleInPlaceSiteWindowless *iface)
2319 ok(0, "unexpected call\n");
2320 return E_NOTIMPL;
2323 static HRESULT WINAPI InPlaceSiteWindowless_SetCapture(
2324 IOleInPlaceSiteWindowless *iface, BOOL fCapture)
2326 ok(0, "unexpected call\n");
2327 return E_NOTIMPL;
2330 static HRESULT WINAPI InPlaceSiteWindowless_GetFocus(
2331 IOleInPlaceSiteWindowless *iface)
2333 ok(0, "unexpected call\n");
2334 return E_NOTIMPL;
2337 static HRESULT WINAPI InPlaceSiteWindowless_SetFocus(
2338 IOleInPlaceSiteWindowless *iface, BOOL fFocus)
2340 ok(0, "unexpected call\n");
2341 return E_NOTIMPL;
2344 static HRESULT WINAPI InPlaceSiteWindowless_GetDC(
2345 IOleInPlaceSiteWindowless *iface, LPCRECT pRect,
2346 DWORD grfFlags, HDC *phDC)
2348 ok(0, "unexpected call\n");
2349 return E_NOTIMPL;
2352 static HRESULT WINAPI InPlaceSiteWindowless_ReleaseDC(
2353 IOleInPlaceSiteWindowless *iface, HDC hDC)
2355 ok(0, "unexpected call\n");
2356 return E_NOTIMPL;
2359 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRect(
2360 IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
2362 ok(0, "unexpected call\n");
2363 return E_NOTIMPL;
2366 static HRESULT WINAPI InPlaceSiteWindowless_InvalidateRgn(
2367 IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
2369 ok(0, "unexpected call\n");
2370 return E_NOTIMPL;
2373 static HRESULT WINAPI InPlaceSiteWindowless_ScrollRect(
2374 IOleInPlaceSiteWindowless *iface, INT dx, INT dy,
2375 LPCRECT pRectScroll, LPCRECT pRectClip)
2377 ok(0, "unexpected call\n");
2378 return E_NOTIMPL;
2381 static HRESULT WINAPI InPlaceSiteWindowless_AdjustRect(
2382 IOleInPlaceSiteWindowless *iface, LPRECT prc)
2384 ok(0, "unexpected call\n");
2385 return E_NOTIMPL;
2388 static HRESULT WINAPI InPlaceSiteWindowless_OnDefWindowMessage(
2389 IOleInPlaceSiteWindowless *iface, UINT msg,
2390 WPARAM wParam, LPARAM lParam, LRESULT *plResult)
2392 ok(0, "unexpected call\n");
2393 return E_NOTIMPL;
2396 static const IOleInPlaceSiteWindowlessVtbl InPlaceSiteWindowlessVtbl = {
2397 InPlaceSiteWindowless_QueryInterface,
2398 InPlaceSiteWindowless_AddRef,
2399 InPlaceSiteWindowless_Release,
2400 InPlaceSiteWindowless_GetWindow,
2401 InPlaceSiteWindowless_ContextSensitiveHelp,
2402 InPlaceSiteWindowless_CanInPlaceActivate,
2403 InPlaceSiteWindowless_OnInPlaceActivate,
2404 InPlaceSiteWindowless_OnUIActivate,
2405 InPlaceSiteWindowless_GetWindowContext,
2406 InPlaceSiteWindowless_Scroll,
2407 InPlaceSiteWindowless_OnUIDeactivate,
2408 InPlaceSiteWindowless_OnInPlaceDeactivate,
2409 InPlaceSiteWindowless_DiscardUndoState,
2410 InPlaceSiteWindowless_DeactivateAndUndo,
2411 InPlaceSiteWindowless_OnPosRectChange,
2412 InPlaceSiteWindowless_OnInPlaceActivateEx,
2413 InPlaceSiteWindowless_OnInPlaceDeactivateEx,
2414 InPlaceSiteWindowless_RequestUIActivate,
2415 InPlaceSiteWindowless_CanWindowlessActivate,
2416 InPlaceSiteWindowless_GetCapture,
2417 InPlaceSiteWindowless_SetCapture,
2418 InPlaceSiteWindowless_GetFocus,
2419 InPlaceSiteWindowless_SetFocus,
2420 InPlaceSiteWindowless_GetDC,
2421 InPlaceSiteWindowless_ReleaseDC,
2422 InPlaceSiteWindowless_InvalidateRect,
2423 InPlaceSiteWindowless_InvalidateRgn,
2424 InPlaceSiteWindowless_ScrollRect,
2425 InPlaceSiteWindowless_AdjustRect,
2426 InPlaceSiteWindowless_OnDefWindowMessage
2429 static IOleInPlaceSiteWindowless InPlaceSiteWindowless = { &InPlaceSiteWindowlessVtbl };
2431 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
2433 return QueryInterface(riid, ppv);
2436 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
2438 return 2;
2441 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
2443 return 1;
2446 typedef enum
2448 CallUIActivate_None,
2449 CallUIActivate_ActivateMe,
2450 CallUIActivate_AfterShow,
2451 } CallUIActivate;
2453 static BOOL call_UIActivate = CallUIActivate_ActivateMe;
2454 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
2456 IOleDocument *document;
2457 HRESULT hres;
2459 CHECK_EXPECT(ActivateMe);
2460 ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
2462 hres = IOleDocumentView_QueryInterface(pViewToActivate, &IID_IOleDocument, (void**)&document);
2463 ok(hres == S_OK, "could not get IOleDocument: %08lx\n", hres);
2465 if(SUCCEEDED(hres)) {
2466 hres = IOleDocument_CreateView(document, (IOleInPlaceSite*)&InPlaceSiteWindowless, NULL, 0, &view);
2467 ok(hres == S_OK, "CreateView failed: %08lx\n", hres);
2469 if(SUCCEEDED(hres)) {
2470 IOleInPlaceActiveObject *activeobj = NULL;
2471 IOleInPlaceSite *inplacesite = NULL;
2472 HWND tmp_hwnd = NULL;
2473 static RECT rect = {0,0,400,500};
2475 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
2476 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
2477 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
2478 inplacesite, &InPlaceSiteWindowless);
2480 hres = IOleDocumentView_SetInPlaceSite(view, (IOleInPlaceSite*)&InPlaceSiteWindowless);
2481 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
2483 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
2484 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
2485 ok(inplacesite == (IOleInPlaceSite*)&InPlaceSiteWindowless, "inplacesite=%p, expected %p\n",
2486 inplacesite, &InPlaceSiteWindowless);
2488 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
2489 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08lx\n", hres);
2491 if(activeobj) {
2492 HWND hwnd = (void*)0xdeadbeef;
2493 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
2494 ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
2495 ok(hwnd == NULL, "hwnd=%p, expected NULL\n", hwnd);
2498 if(call_UIActivate == CallUIActivate_ActivateMe) {
2499 SET_EXPECT(CanInPlaceActivate);
2500 SET_EXPECT(GetWindowContext);
2501 SET_EXPECT(GetWindow);
2502 if(ipsex)
2503 SET_EXPECT(OnInPlaceActivateEx);
2504 else
2505 SET_EXPECT(OnInPlaceActivate);
2506 SET_EXPECT(SetStatusText);
2507 SET_EXPECT(Exec_SETPROGRESSMAX);
2508 SET_EXPECT(Exec_SETPROGRESSPOS);
2509 SET_EXPECT(OnUIActivate);
2510 SET_EXPECT(SetActiveObject);
2511 SET_EXPECT(ShowUI);
2512 expect_status_text = NULL;
2514 hres = IOleDocumentView_UIActivate(view, TRUE);
2515 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
2517 CHECK_CALLED(CanInPlaceActivate);
2518 CHECK_CALLED(GetWindowContext);
2519 CHECK_CALLED(GetWindow);
2520 if(ipsex)
2521 CHECK_CALLED(OnInPlaceActivateEx);
2522 else
2523 CHECK_CALLED(OnInPlaceActivate);
2524 CHECK_CALLED(SetStatusText);
2525 CHECK_CALLED(Exec_SETPROGRESSMAX);
2526 CHECK_CALLED(Exec_SETPROGRESSPOS);
2527 CHECK_CALLED(OnUIActivate);
2528 CHECK_CALLED(SetActiveObject);
2529 CHECK_CALLED(ShowUI);
2531 if(activeobj) {
2532 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &doc_hwnd);
2533 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
2534 ok(doc_hwnd != NULL, "hwnd == NULL\n");
2535 if(last_hwnd)
2536 ok(doc_hwnd == last_hwnd, "hwnd != last_hwnd\n");
2539 hres = IOleDocumentView_UIActivate(view, TRUE);
2540 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
2542 if(activeobj) {
2543 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
2544 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
2545 ok(tmp_hwnd == doc_hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, doc_hwnd);
2549 hres = IOleDocumentView_SetRect(view, &rect);
2550 ok(hres == S_OK, "SetRect failed: %08lx\n", hres);
2552 if(call_UIActivate == CallUIActivate_ActivateMe) {
2553 hres = IOleDocumentView_Show(view, TRUE);
2554 ok(hres == S_OK, "Show failed: %08lx\n", hres);
2555 }else {
2556 SET_EXPECT(CanInPlaceActivate);
2557 SET_EXPECT(GetWindowContext);
2558 SET_EXPECT(GetWindow);
2559 if(ipsex)
2560 SET_EXPECT(OnInPlaceActivateEx);
2561 else
2562 SET_EXPECT(OnInPlaceActivate);
2563 SET_EXPECT(SetStatusText);
2564 SET_EXPECT(Exec_SETPROGRESSMAX);
2565 SET_EXPECT(Exec_SETPROGRESSPOS);
2566 SET_EXPECT(OnUIActivate);
2567 expect_status_text = (load_state == LD_COMPLETE ? (LPCOLESTR)0xdeadbeef : NULL);
2569 hres = IOleDocumentView_Show(view, TRUE);
2570 ok(hres == S_OK, "Show failed: %08lx\n", hres);
2572 CHECK_CALLED(CanInPlaceActivate);
2573 CHECK_CALLED(GetWindowContext);
2574 CHECK_CALLED(GetWindow);
2575 if(ipsex)
2576 CHECK_CALLED(OnInPlaceActivateEx);
2577 else
2578 CHECK_CALLED(OnInPlaceActivate);
2579 CHECK_CALLED(SetStatusText);
2580 CHECK_CALLED(Exec_SETPROGRESSMAX);
2581 CHECK_CALLED(Exec_SETPROGRESSPOS);
2583 if(activeobj) {
2584 hres = IOleInPlaceActiveObject_GetWindow(activeobj, &doc_hwnd);
2585 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
2586 ok(doc_hwnd != NULL, "doc_hwnd == NULL\n");
2587 if(last_hwnd)
2588 ok(doc_hwnd == last_hwnd, "doc_hwnd != last_hwnd\n");
2592 test_timer(EXPECT_UPDATEUI | ((load_state == LD_LOADING) ? EXPECT_SETTITLE : 0));
2594 if(activeobj)
2595 IOleInPlaceActiveObject_Release(activeobj);
2598 IOleDocument_Release(document);
2601 return S_OK;
2604 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
2605 DocumentSite_QueryInterface,
2606 DocumentSite_AddRef,
2607 DocumentSite_Release,
2608 DocumentSite_ActivateMe
2611 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
2613 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
2615 return QueryInterface(riid, ppv);
2618 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
2620 return 2;
2623 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
2625 return 1;
2628 static HRESULT WINAPI OleControlSite_OnControlInfoChanged(IOleControlSite *iface)
2630 ok(0, "unexpected call\n");
2631 return E_NOTIMPL;
2634 static HRESULT WINAPI OleControlSite_LockInPlaceActive(IOleControlSite *iface, BOOL fLock)
2636 ok(0, "unexpected call\n");
2637 return E_NOTIMPL;
2640 static HRESULT WINAPI OleControlSite_GetExtendedControl(IOleControlSite *iface, IDispatch **ppDisp)
2642 ok(0, "unexpected call\n");
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI OleControlSite_TransformCoords(IOleControlSite *iface, POINTL *pPtHimetric,
2647 POINTF *pPtfContainer, DWORD dwFlags)
2649 ok(0, "unexpected call\n");
2650 return E_NOTIMPL;
2653 static HRESULT WINAPI OleControlSite_TranslateAccelerator(IOleControlSite *iface,
2654 MSG *pMsg, DWORD grfModifiers)
2656 ok(0, "unexpected call\n");
2657 return E_NOTIMPL;
2660 static HRESULT WINAPI OleControlSite_OnFocus(IOleControlSite *iface, BOOL fGotFocus)
2662 if(fGotFocus)
2663 CHECK_EXPECT(OnFocus_TRUE);
2664 else
2665 CHECK_EXPECT2(OnFocus_FALSE);
2666 return S_OK;
2669 static HRESULT WINAPI OleControlSite_ShowPropertyFrame(IOleControlSite *iface)
2671 ok(0, "unexpected call\n");
2672 return E_NOTIMPL;
2675 static const IOleControlSiteVtbl OleControlSiteVtbl = {
2676 OleControlSite_QueryInterface,
2677 OleControlSite_AddRef,
2678 OleControlSite_Release,
2679 OleControlSite_OnControlInfoChanged,
2680 OleControlSite_LockInPlaceActive,
2681 OleControlSite_GetExtendedControl,
2682 OleControlSite_TransformCoords,
2683 OleControlSite_TranslateAccelerator,
2684 OleControlSite_OnFocus,
2685 OleControlSite_ShowPropertyFrame
2688 static IOleControlSite OleControlSite = { &OleControlSiteVtbl };
2690 static IDocHostUIHandler2 *expect_uihandler_iface;
2692 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2694 return QueryInterface(riid, ppv);
2697 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
2699 return 2;
2702 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
2704 return 1;
2707 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
2708 IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
2710 ok(0, "unexpected call\n");
2711 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2712 return E_NOTIMPL;
2715 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
2717 if(!resetting_document)
2718 CHECK_EXPECT(GetHostInfo);
2719 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2720 ok(pInfo != NULL, "pInfo=NULL\n");
2721 if(pInfo) {
2722 ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%lu\n", pInfo->cbSize);
2723 ok(!pInfo->dwFlags, "pInfo->dwFlags=%08lx, expected 0\n", pInfo->dwFlags);
2724 pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
2725 | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
2726 | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
2727 ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08lx, expected 0\n", pInfo->dwDoubleClick);
2728 ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
2729 ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
2731 return S_OK;
2734 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
2735 IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
2736 IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
2738 CHECK_EXPECT(ShowUI);
2739 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2741 if (editmode)
2742 ok(dwID == DOCHOSTUITYPE_AUTHOR, "dwID=%ld, expected DOCHOSTUITYPE_AUTHOR\n", dwID);
2743 else
2744 ok(dwID == DOCHOSTUITYPE_BROWSE, "dwID=%ld, expected DOCHOSTUITYPE_BROWSE\n", dwID);
2745 ok(pActiveObject != NULL, "pActiveObject = NULL\n");
2746 ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
2747 ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
2748 if (expect_InPlaceUIWindow_SetActiveObject_active)
2749 ok(pDoc == (IOleInPlaceUIWindow *)&InPlaceUIWindow, "pDoc=%p, expected %p\n", pDoc, &InPlaceUIWindow);
2750 else
2751 ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
2753 return S_OK;
2756 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
2758 CHECK_EXPECT(HideUI);
2759 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2760 return S_OK;
2763 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
2765 CHECK_EXPECT(UpdateUI);
2766 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2767 return S_OK;
2770 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
2772 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2773 if(fEnable)
2774 CHECK_EXPECT2(EnableModeless_TRUE);
2775 else
2776 CHECK_EXPECT2(EnableModeless_FALSE);
2777 return E_NOTIMPL;
2780 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2782 ok(0, "unexpected call\n");
2783 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2784 return E_NOTIMPL;
2787 static BOOL expect_OnFrameWindowActivate_fActivate;
2788 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
2790 CHECK_EXPECT2(OnFrameWindowActivate);
2791 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2792 ok(fActivate == expect_OnFrameWindowActivate_fActivate, "fActivate=%x\n", fActivate);
2793 return S_OK;
2796 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
2797 IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
2799 ok(0, "unexpected call\n");
2800 return E_NOTIMPL;
2803 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
2804 const GUID *pguidCmdGroup, DWORD nCmdID)
2806 ok(0, "unexpected call\n");
2807 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2808 return E_NOTIMPL;
2811 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
2812 LPOLESTR *pchKey, DWORD dw)
2814 CHECK_EXPECT(GetOptionKeyPath);
2815 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2816 ok(pchKey != NULL, "pchKey = NULL\n");
2817 ok(!dw, "dw=%ld, expected 0\n", dw);
2818 if(pchKey)
2819 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2820 return S_OK;
2823 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
2824 IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
2826 CHECK_EXPECT(GetDropTarget);
2827 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2828 /* TODO */
2829 return E_NOTIMPL;
2832 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
2834 CHECK_EXPECT(GetExternal);
2835 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2836 *ppDispatch = &External;
2837 return S_FALSE;
2840 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
2841 OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
2843 CHECK_EXPECT(TranslateUrl);
2844 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2845 ok(!dwTranslate, "dwTranslate = %lx\n", dwTranslate);
2846 todo_wine_if(loading_hash)
2847 ok(!lstrcmpW(pchURLIn, nav_serv_url), "pchURLIn = %s, expected %s\n", wine_dbgstr_w(pchURLIn),
2848 wine_dbgstr_w(nav_serv_url));
2849 ok(ppchURLOut != NULL, "ppchURLOut == NULL\n");
2850 ok(!*ppchURLOut, "*ppchURLOut = %p\n", *ppchURLOut);
2852 /* Not related to hash navigation, just return NULL and S_OK in some cases. */
2853 if(loading_hash) {
2854 *ppchURLOut = NULL;
2855 return S_OK;
2858 return S_FALSE;
2861 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
2862 IDataObject **ppPORet)
2864 ok(0, "unexpected call\n");
2865 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2866 return E_NOTIMPL;
2869 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
2870 LPOLESTR *pchKey, DWORD dw)
2872 CHECK_EXPECT(GetOverrideKeyPath);
2873 ok(iface == expect_uihandler_iface, "called on unexpected iface\n");
2874 ok(pchKey != NULL, "pchKey = NULL\n");
2875 if(pchKey)
2876 ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
2877 ok(!dw, "dw=%ld, expected 0\n", dw);
2878 return S_OK;
2881 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
2882 DocHostUIHandler_QueryInterface,
2883 DocHostUIHandler_AddRef,
2884 DocHostUIHandler_Release,
2885 DocHostUIHandler_ShowContextMenu,
2886 DocHostUIHandler_GetHostInfo,
2887 DocHostUIHandler_ShowUI,
2888 DocHostUIHandler_HideUI,
2889 DocHostUIHandler_UpdateUI,
2890 DocHostUIHandler_EnableModeless,
2891 DocHostUIHandler_OnDocWindowActivate,
2892 DocHostUIHandler_OnFrameWindowActivate,
2893 DocHostUIHandler_ResizeBorder,
2894 DocHostUIHandler_TranslateAccelerator,
2895 DocHostUIHandler_GetOptionKeyPath,
2896 DocHostUIHandler_GetDropTarget,
2897 DocHostUIHandler_GetExternal,
2898 DocHostUIHandler_TranslateUrl,
2899 DocHostUIHandler_FilterDataObject,
2900 DocHostUIHandler_GetOverrideKeyPath
2903 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
2905 static HRESULT WINAPI CustomDocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
2907 if(IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
2908 *ppv = iface;
2909 return S_OK;
2912 *ppv = NULL;
2914 if(IsEqualGUID(&IID_IOleCommandTarget, riid))
2915 return E_NOINTERFACE;
2917 if(IsEqualGUID(&IID_IDocHostShowUI, riid))
2918 return E_NOINTERFACE; /* TODO */
2920 if(winetest_debug > 1) trace("CustomDocHostUIHandler::QI(%s)\n", wine_dbgstr_guid(riid));
2921 return E_NOINTERFACE;
2924 static const IDocHostUIHandler2Vtbl CustomDocHostUIHandlerVtbl = {
2925 CustomDocHostUIHandler_QueryInterface,
2926 DocHostUIHandler_AddRef,
2927 DocHostUIHandler_Release,
2928 DocHostUIHandler_ShowContextMenu,
2929 DocHostUIHandler_GetHostInfo,
2930 DocHostUIHandler_ShowUI,
2931 DocHostUIHandler_HideUI,
2932 DocHostUIHandler_UpdateUI,
2933 DocHostUIHandler_EnableModeless,
2934 DocHostUIHandler_OnDocWindowActivate,
2935 DocHostUIHandler_OnFrameWindowActivate,
2936 DocHostUIHandler_ResizeBorder,
2937 DocHostUIHandler_TranslateAccelerator,
2938 DocHostUIHandler_GetOptionKeyPath,
2939 DocHostUIHandler_GetDropTarget,
2940 DocHostUIHandler_GetExternal,
2941 DocHostUIHandler_TranslateUrl,
2942 DocHostUIHandler_FilterDataObject,
2943 DocHostUIHandler_GetOverrideKeyPath
2946 static IDocHostUIHandler2 CustomDocHostUIHandler = { &CustomDocHostUIHandlerVtbl };
2948 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface,
2949 REFIID riid, void **ppv)
2951 return QueryInterface(riid, ppv);
2954 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
2956 return 2;
2959 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
2961 return 1;
2964 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
2965 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
2967 ok(!pguidCmdGroup, "pguidCmdGroup != MULL\n");
2968 ok(cCmds == 1, "cCmds=%ld, expected 1\n", cCmds);
2969 ok(!pCmdText, "pCmdText != NULL\n");
2971 switch(prgCmds[0].cmdID) {
2972 case OLECMDID_SETPROGRESSTEXT:
2973 CHECK_EXPECT(QueryStatus_SETPROGRESSTEXT);
2974 prgCmds[0].cmdf = OLECMDF_ENABLED;
2975 return S_OK;
2976 case OLECMDID_OPEN:
2977 CHECK_EXPECT(QueryStatus_OPEN);
2978 prgCmds[0].cmdf = 0;
2979 return S_OK;
2980 case OLECMDID_NEW:
2981 CHECK_EXPECT(QueryStatus_NEW);
2982 prgCmds[0].cmdf = 0;
2983 return S_OK;
2984 default:
2985 ok(0, "unexpected command %ld\n", prgCmds[0].cmdID);
2988 return E_FAIL;
2991 static void test_save_history(IUnknown *unk)
2993 IPersistHistory *per_hist;
2994 LARGE_INTEGER li;
2995 IStream *stream;
2996 HRESULT hres;
2998 hres = IUnknown_QueryInterface(unk, &IID_IPersistHistory, (void**)&per_hist);
2999 ok(hres == S_OK, "Could not get IPersistHistory iface: %08lx\n", hres);
3001 hres = CreateStreamOnHGlobal(NULL, TRUE, &stream);
3002 ok(hres == S_OK, "CreateStreamOnHGlobal failed: %08lx\n", hres);
3004 hres = IPersistHistory_SaveHistory(per_hist, stream);
3005 ok(hres == S_OK, "SaveHistory failed: %08lx\n", hres);
3006 IPersistHistory_Release(per_hist);
3008 li.QuadPart = 0;
3009 hres = IStream_Seek(stream, li, STREAM_SEEK_SET, NULL);
3010 ok(hres == S_OK, "Stat failed: %08lx\n", hres);
3011 history_stream = stream;
3014 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
3015 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
3017 if(resetting_document)
3018 return E_FAIL;
3020 if(!pguidCmdGroup) {
3021 test_readyState(NULL);
3023 switch(nCmdID) {
3024 case OLECMDID_SETPROGRESSMAX:
3025 CHECK_EXPECT2(Exec_SETPROGRESSMAX);
3026 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08lx\n", nCmdexecopt);
3027 ok(pvaIn != NULL, "pvaIn == NULL\n");
3028 if(pvaIn) {
3029 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
3030 if(load_state == LD_NO)
3031 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%ld, expected 0\n", V_I4(pvaIn));
3033 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
3034 return S_OK;
3035 case OLECMDID_SETPROGRESSPOS:
3036 CHECK_EXPECT2(Exec_SETPROGRESSPOS);
3037 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08lx\n", nCmdexecopt);
3038 ok(pvaIn != NULL, "pvaIn == NULL\n");
3039 if(pvaIn) {
3040 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
3041 if(load_state == LD_NO)
3042 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%ld, expected 0\n", V_I4(pvaIn));
3044 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
3045 return S_OK;
3046 case OLECMDID_HTTPEQUIV_DONE:
3047 CHECK_EXPECT(Exec_HTTPEQUIV_DONE);
3048 ok(nCmdexecopt == 0, "nCmdexecopts=%08lx\n", nCmdexecopt);
3049 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
3050 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
3051 test_navigation_type(doc_unk);
3052 test_performance_timing(doc_unk, L"domComplete");
3053 readystate_set_loading = FALSE;
3054 readystate_set_interactive = FALSE;
3055 load_state = LD_COMPLETE;
3056 return S_OK;
3057 case OLECMDID_SETDOWNLOADSTATE:
3058 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08lx\n", nCmdexecopt);
3059 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
3060 ok(pvaIn != NULL, "pvaIn == NULL\n");
3061 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
3063 switch(V_I4(pvaIn)) {
3064 case 0:
3065 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_0);
3066 if(!loading_js)
3067 load_state = LD_INTERACTIVE;
3068 break;
3069 case 1:
3070 CHECK_EXPECT(Exec_SETDOWNLOADSTATE_1);
3071 readystate_set_interactive = (load_state != LD_INTERACTIVE);
3072 break;
3073 default:
3074 ok(0, "unexpected V_I4(pvaIn)=%ld\n", V_I4(pvaIn));
3077 return S_OK;
3078 case OLECMDID_UPDATECOMMANDS:
3079 CHECK_EXPECT(Exec_UPDATECOMMANDS);
3080 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08lx\n", nCmdexecopt);
3081 ok(pvaIn == NULL, "pvaIn=%p\n", pvaIn);
3082 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
3083 return S_OK;
3084 case OLECMDID_SETTITLE:
3085 CHECK_EXPECT2(Exec_SETTITLE);
3086 ok(nCmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER, "nCmdexecopts=%08lx\n", nCmdexecopt);
3087 ok(pvaIn != NULL, "pvaIn == NULL\n");
3088 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
3089 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
3090 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) == NULL\n"); /* TODO */
3091 return S_OK;
3092 case OLECMDID_HTTPEQUIV:
3093 CHECK_EXPECT2(Exec_HTTPEQUIV);
3094 ok(!nCmdexecopt, "nCmdexecopts=%08lx\n", nCmdexecopt);
3095 ok(pvaIn != NULL, "pvaIn == NULL\n");
3096 ok(pvaOut == NULL, "pvaOut=%p\n", pvaOut);
3097 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn)=%d\n", V_VT(pvaIn));
3098 ok(V_BSTR(pvaIn) != NULL, "V_BSTR(pvaIn) = NULL\n");
3099 test_readyState(NULL);
3100 return S_OK;
3101 case OLECMDID_UPDATETRAVELENTRY_DATARECOVERY:
3102 case OLECMDID_PAGEAVAILABLE:
3103 case 6058:
3104 return E_FAIL; /* FIXME */
3105 default:
3106 ok(0, "unexpected command %ld\n", nCmdID);
3107 return E_FAIL;
3111 if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
3112 ok(nCmdexecopt == 0, "nCmdexecopts=%08lx\n", nCmdexecopt);
3114 switch(nCmdID) {
3115 case 37:
3116 CHECK_EXPECT2(Exec_ShellDocView_37);
3118 if(is_refresh && load_state == LD_COMPLETE) {
3119 load_state = LD_DOLOAD;
3120 test_readyState(NULL);
3121 }else if(is_refresh && load_state == LD_DOLOAD) {
3122 test_readyState(NULL);
3123 load_state = LD_LOADING;
3124 }else {
3125 if(!is_refresh)
3126 test_readyState(NULL);
3127 if(nav_url)
3128 test_GetCurMoniker(doc_unk, NULL, nav_serv_url, FALSE);
3129 else if(load_from_stream)
3130 test_GetCurMoniker(doc_unk, NULL, L"about:blank", FALSE);
3131 else if(!editmode)
3132 test_GetCurMoniker(doc_unk, doc_mon, NULL, FALSE);
3135 ok(pvaOut == NULL, "pvaOut=%p, expected NULL\n", pvaOut);
3136 ok(pvaIn != NULL, "pvaIn == NULL\n");
3137 if(pvaIn) {
3138 ok(V_VT(pvaIn) == VT_I4, "V_VT(pvaIn)=%d, expected VT_I4\n", V_VT(pvaIn));
3139 ok(V_I4(pvaIn) == 0, "V_I4(pvaIn)=%ld, expected 0\n", V_I4(pvaIn));
3141 return S_OK;
3143 case 62:
3144 CHECK_EXPECT(Exec_ShellDocView_62);
3145 ok(!pvaIn, "pvaIn != NULL\n");
3146 ok(!pvaOut, "pvaOut != NULL\n");
3147 return S_OK;
3149 case 63: {
3150 IHTMLPrivateWindow *priv_window;
3151 HRESULT hres;
3153 CHECK_EXPECT(Exec_ShellDocView_63);
3154 ok(pvaIn != NULL, "pvaIn == NULL\n");
3155 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
3156 ok(V_UNKNOWN(pvaIn) != NULL, "VPUNKNOWN(pvaIn) = NULL\n");
3157 ok(pvaOut != NULL, "pvaOut == NULL\n");
3158 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
3160 hres = IUnknown_QueryInterface(V_UNKNOWN(pvaIn), &IID_IHTMLPrivateWindow, (void**)&priv_window);
3161 ok(hres == S_OK, "Could not get IHTMLPrivateWindow: %08lx\n", hres);
3162 if(SUCCEEDED(hres))
3163 IHTMLPrivateWindow_Release(priv_window);
3165 load_state = loading_js ? LD_COMPLETE : LD_LOADING;
3166 return S_OK; /* TODO */
3169 case 67:
3170 CHECK_EXPECT(Exec_ShellDocView_67);
3171 ok(pvaIn != NULL, "pvaIn == NULL\n");
3172 ok(V_VT(pvaIn) == VT_BSTR, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
3173 ok(!lstrcmpW(V_BSTR(pvaIn), nav_serv_url), "V_BSTR(pvaIn) = %s, expected \"%s\"\n",
3174 wine_dbgstr_w(V_BSTR(pvaIn)), wine_dbgstr_w(nav_serv_url));
3175 ok(pvaOut != NULL, "pvaOut == NULL\n");
3176 ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
3177 ok(V_BOOL(pvaOut) == VARIANT_TRUE, "V_BOOL(pvaOut) = %x\n", V_BOOL(pvaOut));
3178 if(!loading_hash)
3179 load_state = LD_DOLOAD;
3180 return S_OK;
3182 case 84:
3183 CHECK_EXPECT2(Exec_ShellDocView_84);
3185 ok(pvaIn == NULL, "pvaIn != NULL\n");
3186 ok(pvaOut != NULL, "pvaOut == NULL\n");
3187 if(pvaIn)
3188 ok(V_VT(pvaOut) == VT_EMPTY, "V_VT(pvaOut)=%d\n", V_VT(pvaOut));
3190 test_readyState(NULL);
3191 return E_NOTIMPL;
3193 case 103:
3194 CHECK_EXPECT2(Exec_ShellDocView_103);
3196 ok(pvaIn == NULL, "pvaIn != NULL\n");
3197 ok(pvaOut == NULL, "pvaOut != NULL\n");
3199 test_readyState(NULL);
3200 test_performance_timing(doc_unk, L"domComplete");
3201 return E_NOTIMPL;
3203 case 105:
3204 CHECK_EXPECT2(Exec_ShellDocView_105);
3206 ok(pvaIn != NULL, "pvaIn == NULL\n");
3207 ok(pvaOut == NULL, "pvaOut != NULL\n");
3209 test_readyState(NULL);
3210 return E_NOTIMPL;
3212 case 138:
3213 CHECK_EXPECT2(Exec_ShellDocView_138);
3214 ok(!pvaIn, "pvaIn != NULL\n");
3215 ok(!pvaOut, "pvaOut != NULL\n");
3216 test_readyState(NULL);
3217 return S_OK;
3219 case 140:
3220 CHECK_EXPECT2(Exec_ShellDocView_140);
3222 ok(pvaIn == NULL, "pvaIn != NULL\n");
3223 ok(pvaOut == NULL, "pvaOut != NULL\n");
3225 test_readyState(NULL);
3226 return E_NOTIMPL;
3228 case 83:
3229 case 101:
3230 case 102:
3231 case 132:
3232 case 133:
3233 case 134: /* TODO */
3234 case 135:
3235 case 136: /* TODO */
3236 case 137:
3237 case 139: /* TODO */
3238 case 143: /* TODO */
3239 case 144: /* TODO */
3240 case 178:
3241 case 179:
3242 case 180:
3243 case 181:
3244 case 182:
3245 case 183:
3246 return E_NOTIMPL;
3248 default:
3249 ok(0, "unexpected command %ld\n", nCmdID);
3250 return E_FAIL;
3254 if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) {
3255 test_readyState(NULL);
3256 ok(nCmdexecopt == 0, "nCmdexecopts=%08lx\n", nCmdexecopt);
3258 switch(nCmdID) {
3259 case IDM_PARSECOMPLETE:
3260 CHECK_EXPECT(Exec_MSHTML_PARSECOMPLETE);
3261 ok(pvaIn == NULL, "pvaIn != NULL\n");
3262 ok(pvaOut == NULL, "pvaOut != NULL\n");
3263 test_performance_timing(doc_unk, L"domComplete");
3264 return S_OK;
3265 default:
3266 ok(0, "unexpected command %ld\n", nCmdID);
3270 if(IsEqualGUID(&CGID_DocHostCmdPriv, pguidCmdGroup)) {
3271 switch(nCmdID) {
3272 case DOCHOST_DOCCANNAVIGATE:
3273 if(pvaIn) {
3274 CHECK_EXPECT(Exec_DOCCANNAVIGATE);
3275 ok(V_VT(pvaIn) == VT_UNKNOWN, "V_VT(pvaIn) != VT_UNKNOWN\n");
3276 /* FIXME: test V_UNKNOWN(pvaIn) == window */
3277 }else {
3278 CHECK_EXPECT(Exec_DOCCANNAVIGATE_NULL);
3281 test_readyState(NULL);
3282 ok(pvaOut == NULL, "pvaOut != NULL\n");
3283 return S_OK;
3284 case 1: {
3285 SAFEARRAY *sa;
3286 UINT dim;
3287 LONG ind=0;
3288 VARIANT var;
3289 HRESULT hres;
3291 test_readyState(NULL);
3293 ok(pvaIn != NULL, "pvaIn == NULL\n");
3294 ok(pvaOut != NULL || broken(!pvaOut), "pvaOut != NULL\n");
3295 ok(V_VT(pvaIn) == VT_ARRAY, "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
3296 if(pvaOut)
3297 ok(V_VT(pvaOut) == VT_BOOL, "V_VT(pvaOut) = %d\n", V_VT(pvaOut));
3298 sa = V_ARRAY(pvaIn);
3300 dim = SafeArrayGetDim(sa);
3301 ok(dim == 1, "dim = %d\n", dim);
3302 hres = SafeArrayGetLBound(sa, 1, &ind);
3303 ok(hres == S_OK, "SafeArrayGetLBound failed: %lx\n", hres);
3304 ok(ind == 0, "Lower bound = %ld\n", ind);
3305 hres = SafeArrayGetUBound(sa, 1, &ind);
3306 ok(hres == S_OK, "SafeArrayGetUBound failed: %lx\n", hres);
3307 ok(ind == 7 || ind == 8 /* IE11 */ ||broken(ind == 5), "Upper bound = %ld\n", ind);
3309 ind = 0;
3310 SafeArrayGetElement(sa, &ind, &var);
3311 ok(V_VT(&var) == VT_I4, "Incorrect data type: %d\n", V_VT(&var));
3312 ok(V_I4(&var) == status_code, "Incorrect error code: %ld\n", V_I4(&var));
3313 VariantClear(&var);
3314 ind = 1;
3315 SafeArrayGetElement(sa, &ind, &var);
3316 ok(V_VT(&var) == VT_BSTR, "Incorrect data type: %d\n", V_VT(&var));
3317 ok(!lstrcmpW(V_BSTR(&var), L"winetest:doc"), "Page address: %s\n", wine_dbgstr_w(V_BSTR(&var)));
3318 VariantClear(&var);
3319 ind = 2;
3320 SafeArrayGetElement(sa, &ind, &var);
3321 ok(V_VT(&var) == VT_UNKNOWN, "Incorrect data type: %d\n", V_VT(&var));
3322 VariantClear(&var);
3323 ind = 3;
3324 SafeArrayGetElement(sa, &ind, &var);
3325 ok(V_VT(&var) == VT_UNKNOWN, "Incorrect data type: %d\n", V_VT(&var));
3326 VariantClear(&var);
3327 ind = 4;
3328 SafeArrayGetElement(sa, &ind, &var);
3329 ok(V_VT(&var) == VT_BOOL, "Incorrect data type: %d\n", V_VT(&var));
3330 ok(!V_BOOL(&var), "Unknown value is incorrect\n");
3331 VariantClear(&var);
3332 ind = 5;
3333 SafeArrayGetElement(sa, &ind, &var);
3334 ok(V_VT(&var) == VT_BOOL, "Incorrect data type: %d\n", V_VT(&var));
3335 ok(!V_BOOL(&var), "Unknown value is incorrect\n");
3336 VariantClear(&var);
3338 default:
3339 return E_FAIL; /* TODO */
3343 if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
3344 test_readyState(NULL);
3345 ok(nCmdexecopt == 0, "nCmdexecopts=%08lx\n", nCmdexecopt);
3347 switch(nCmdID) {
3348 case 38:
3349 CHECK_EXPECT2(Exec_Explorer_38);
3350 ok(pvaIn != NULL, "pvaIn == NULL\n");
3351 ok(V_VT(pvaIn) == VT_I4 , "V_VT(pvaIn) = %d\n", V_VT(pvaIn));
3352 ok(!V_I4(pvaIn), "V_I4(pvaIn) = %ld\n", V_I4(pvaIn));
3353 ok(!pvaOut, "pvaOut != NULL\n");
3355 test_current_url(doc_unk, prev_url);
3356 if(!history_stream)
3357 test_save_history(doc_unk);
3359 return S_OK;
3360 case 69:
3361 CHECK_EXPECT2(Exec_Explorer_69);
3362 ok(pvaIn == NULL, "pvaIn != NULL\n");
3363 ok(pvaOut != NULL, "pvaOut == NULL\n");
3364 return E_NOTIMPL;
3365 case 109: /* TODO */
3366 return E_NOTIMPL;
3367 default:
3368 ok(0, "unexpected cmd %ld of CGID_Explorer\n", nCmdID);
3370 return E_NOTIMPL;
3373 if(IsEqualGUID(&CGID_DocHostCommandHandler, pguidCmdGroup)) {
3374 test_readyState(NULL);
3376 switch (nCmdID) {
3377 case OLECMDID_PAGEACTIONBLOCKED: /* win2k3 */
3378 SET_EXPECT(SetStatusText);
3379 ok(pvaIn == NULL, "pvaIn != NULL\n");
3380 ok(pvaOut == NULL, "pvaOut != NULL\n");
3381 return S_OK;
3382 case OLECMDID_SHOWSCRIPTERROR:
3383 /* TODO */
3384 return S_OK;
3385 case 2300:
3386 CHECK_EXPECT(Exec_DocHostCommandHandler_2300);
3387 return E_NOTIMPL;
3388 default:
3389 ok(0, "unexpected command %ld\n", nCmdID);
3390 return E_FAIL;
3394 ok(0, "unexpected pguidCmdGroup: %s\n", wine_dbgstr_guid(pguidCmdGroup));
3395 return E_NOTIMPL;
3398 static IOleCommandTargetVtbl OleCommandTargetVtbl = {
3399 OleCommandTarget_QueryInterface,
3400 OleCommandTarget_AddRef,
3401 OleCommandTarget_Release,
3402 OleCommandTarget_QueryStatus,
3403 OleCommandTarget_Exec
3406 static IOleCommandTarget OleCommandTarget = { &OleCommandTargetVtbl };
3408 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
3410 return QueryInterface(riid, ppv);
3413 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
3414 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
3415 EXCEPINFO *pExcepInfo, UINT *puArgErr)
3417 if(resetting_document)
3418 return E_FAIL;
3420 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
3421 ok(pDispParams != NULL, "pDispParams == NULL\n");
3422 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
3423 ok(puArgErr != NULL, "puArgErr == NULL\n");
3424 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult)=%d, expected 0\n", V_VT(pVarResult));
3425 ok(wFlags == DISPATCH_PROPERTYGET, "wFlags=%08x, expected DISPATCH_PROPERTYGET\n", wFlags);
3427 if(dispIdMember != DISPID_AMBIENT_SILENT && dispIdMember != DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)
3428 test_readyState(NULL);
3430 switch(dispIdMember) {
3431 case DISPID_AMBIENT_USERMODE:
3432 CHECK_EXPECT2(Invoke_AMBIENT_USERMODE);
3433 V_VT(pVarResult) = VT_BOOL;
3434 V_BOOL(pVarResult) = VARIANT_TRUE;
3435 return S_OK;
3436 case DISPID_AMBIENT_DLCONTROL:
3437 CHECK_EXPECT2(Invoke_AMBIENT_DLCONTROL);
3438 return E_FAIL;
3439 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
3440 CHECK_EXPECT2(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
3441 return E_FAIL;
3442 case DISPID_AMBIENT_SILENT:
3443 CHECK_EXPECT2(Invoke_AMBIENT_SILENT);
3444 V_VT(pVarResult) = VT_BOOL;
3445 V_BOOL(pVarResult) = VARIANT_FALSE;
3446 return S_OK;
3447 case DISPID_AMBIENT_USERAGENT:
3448 CHECK_EXPECT(Invoke_AMBIENT_USERAGENT);
3449 return E_FAIL;
3450 case DISPID_AMBIENT_PALETTE:
3451 CHECK_EXPECT(Invoke_AMBIENT_PALETTE);
3452 return E_FAIL;
3455 ok(0, "unexpected dispid %ld\n", dispIdMember);
3456 return E_FAIL;
3459 static const IDispatchVtbl DispatchVtbl = {
3460 Dispatch_QueryInterface,
3461 Dispatch_AddRef,
3462 Dispatch_Release,
3463 Dispatch_GetTypeInfoCount,
3464 Dispatch_GetTypeInfo,
3465 Dispatch_GetIDsOfNames,
3466 Dispatch_Invoke
3469 static IDispatch Dispatch = { &DispatchVtbl };
3471 static HRESULT WINAPI EventDispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
3473 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
3474 *ppv = iface;
3475 return S_OK;
3478 ok(0, "Unexpected call\n");
3479 return E_NOINTERFACE;
3482 static HRESULT WINAPI EventDispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
3483 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
3484 EXCEPINFO *pExcepInfo, UINT *puArgErr)
3486 HRESULT hres;
3487 IHTMLDocument2 *doc;
3488 BSTR state;
3490 if(resetting_document)
3491 return E_FAIL;
3493 ok(IsEqualGUID(&IID_NULL, riid), "riid = %s\n", wine_dbgstr_guid(riid));
3494 ok(pDispParams != NULL, "pDispParams == NULL\n");
3495 ok(pExcepInfo != NULL, "pExcepInfo == NULL\n");
3496 ok(puArgErr != NULL, "puArgErr == NULL\n");
3497 ok(V_VT(pVarResult) == 0, "V_VT(pVarResult) = %d\n", V_VT(pVarResult));
3498 ok(wFlags == DISPATCH_METHOD, "wFlags = %d, expected DISPATCH_METHOD\n", wFlags);
3500 hres = IUnknown_QueryInterface(doc_unk, &IID_IHTMLDocument2, (void**)&doc);
3501 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08lx\n", hres);
3503 switch(dispIdMember) {
3504 case DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE:
3505 hres = IHTMLDocument2_get_readyState(doc, &state);
3506 ok(hres == S_OK, "get_readyState failed: %08lx\n", hres);
3508 if(!lstrcmpW(state, L"interactive"))
3509 CHECK_EXPECT(Invoke_OnReadyStateChange_Interactive);
3510 else if(!lstrcmpW(state, L"loading"))
3511 CHECK_EXPECT(Invoke_OnReadyStateChange_Loading);
3512 else if(!lstrcmpW(state, L"complete")) {
3513 CHECK_EXPECT(Invoke_OnReadyStateChange_Complete);
3514 complete = TRUE;
3515 } else
3516 ok(0, "Unexpected readyState: %s\n", wine_dbgstr_w(state));
3518 SysFreeString(state);
3519 break;
3520 case DISPID_HTMLDOCUMENTEVENTS2_ONPROPERTYCHANGE:
3521 case 1026:
3522 case 1027:
3523 case 1034:
3524 case 1035:
3525 case 1037:
3526 case 1047:
3527 case 1045:
3528 case 1044:
3529 case 1048:
3530 case 1049:
3531 break; /* FIXME: Handle these events. */
3532 default:
3533 ok(0, "Unexpected DISPID: %ld\n", dispIdMember);
3536 IHTMLDocument2_Release(doc);
3537 return S_OK;
3540 static const IDispatchVtbl EventDispatchVtbl = {
3541 EventDispatch_QueryInterface,
3542 Dispatch_AddRef,
3543 Dispatch_Release,
3544 Dispatch_GetTypeInfoCount,
3545 Dispatch_GetTypeInfo,
3546 Dispatch_GetIDsOfNames,
3547 EventDispatch_Invoke
3550 static IDispatch EventDispatch = { &EventDispatchVtbl };
3552 static HRESULT WINAPI TravelLog_QueryInterface(ITravelLog *iface, REFIID riid, void **ppv)
3554 static const IID IID_IIETravelLog2 = {0xb67cefd2,0xe3f1,0x478a,{0x9b,0xfa,0xd8,0x93,0x70,0x37,0x5e,0x94}};
3555 static const IID IID_unk_travellog = {0x6afc8b7f,0xbc17,0x4a95,{0x90,0x2f,0x6f,0x5c,0xb5,0x54,0xc3,0xd8}};
3556 static const IID IID_unk_travellog2 = {0xf6d02767,0x9c80,0x428d,{0xb9,0x74,0x3f,0x17,0x29,0x45,0x3f,0xdb}};
3558 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_ITravelLog, riid)) {
3559 *ppv = iface;
3560 return S_OK;
3563 if(!IsEqualGUID(&IID_IIETravelLog2, riid) && !IsEqualGUID(&IID_unk_travellog, riid)
3564 && !IsEqualGUID(&IID_unk_travellog2, riid))
3565 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
3567 *ppv = NULL;
3568 return E_NOINTERFACE;
3571 static ULONG WINAPI TravelLog_AddRef(ITravelLog *iface)
3573 return 2;
3576 static ULONG WINAPI TravelLog_Release(ITravelLog *iface)
3578 return 1;
3581 static HRESULT WINAPI TravelLog_AddEntry(ITravelLog *iface, IUnknown *punk, BOOL fIsLocalAnchor)
3583 ok(0, "unexpected call\n");
3584 return E_NOTIMPL;
3587 static HRESULT WINAPI TravelLog_UpdateEntry(ITravelLog *iface, IUnknown *punk, BOOL fIsLocalAnchor)
3589 ok(0, "unexpected call\n");
3590 return E_NOTIMPL;
3593 static HRESULT WINAPI TravelLog_UpdateExternal(ITravelLog *iface, IUnknown *punk, IUnknown *punkHLBrowseContext)
3595 ok(0, "unexpected call\n");
3596 return E_NOTIMPL;
3599 static HRESULT WINAPI TravelLog_Travel(ITravelLog *iface, IUnknown *punk, int iOffset)
3601 ok(0, "unexpected call\n");
3602 return E_NOTIMPL;
3605 static HRESULT WINAPI TravelLog_GetTravelEntry(ITravelLog *iface, IUnknown *punk, int iOffset, ITravelEntry **ppte)
3607 ok(0, "unexpected call\n");
3608 return E_NOTIMPL;
3611 static HRESULT WINAPI TravelLog_FindTravelEntry(ITravelLog *iface, IUnknown *punk, LPCITEMIDLIST pidl, ITravelEntry **ppte)
3613 ok(0, "unexpected call\n");
3614 return E_NOTIMPL;
3617 static HRESULT WINAPI TravelLog_GetTooltipText(ITravelLog *iface, IUnknown *punk, int iOffset, int idsTemplate,
3618 LPWSTR pwzText, DWORD cchText)
3620 ok(0, "unexpected call\n");
3621 return E_NOTIMPL;
3624 static HRESULT WINAPI TravelLog_InsertMenuEntries(ITravelLog *iface, IUnknown *punk, HMENU hmenu, int nPos,
3625 int idFirst, int idLast, DWORD dwFlags)
3627 ok(0, "unexpected call\n");
3628 return E_NOTIMPL;
3631 static HRESULT WINAPI TravelLog_Clone(ITravelLog *iface, ITravelLog **pptl)
3633 ok(0, "unexpected call\n");
3634 return E_NOTIMPL;
3637 static IBrowserService BrowserService;
3638 static DWORD WINAPI TravelLog_CountEntries(ITravelLog *iface, IUnknown *punk)
3640 CHECK_EXPECT(CountEntries);
3642 ok(punk == (IUnknown*)&BrowserService, "punk != &BrowserService (%p)\n", punk);
3643 return 0;
3646 static HRESULT WINAPI TravelLog_Revert(ITravelLog *iface)
3648 ok(0, "unexpected call\n");
3649 return E_NOTIMPL;
3652 static const ITravelLogVtbl TravelLogVtbl = {
3653 TravelLog_QueryInterface,
3654 TravelLog_AddRef,
3655 TravelLog_Release,
3656 TravelLog_AddEntry,
3657 TravelLog_UpdateEntry,
3658 TravelLog_UpdateExternal,
3659 TravelLog_Travel,
3660 TravelLog_GetTravelEntry,
3661 TravelLog_FindTravelEntry,
3662 TravelLog_GetTooltipText,
3663 TravelLog_InsertMenuEntries,
3664 TravelLog_Clone,
3665 TravelLog_CountEntries,
3666 TravelLog_Revert
3669 static ITravelLog TravelLog = { &TravelLogVtbl };
3671 static HRESULT browserservice_qi(REFIID,void**);
3673 static HRESULT WINAPI DocObjectService_QueryInterface(IDocObjectService* This, REFIID riid, void **ppv)
3675 return browserservice_qi(riid, ppv);
3678 static ULONG WINAPI DocObjectService_AddRef(
3679 IDocObjectService* This)
3681 return 2;
3684 static ULONG WINAPI DocObjectService_Release(
3685 IDocObjectService* This)
3687 return 1;
3690 static HRESULT WINAPI DocObjectService_FireBeforeNavigate2(IDocObjectService *iface, IDispatch *pDispatch,
3691 LPCWSTR lpszUrl, DWORD dwFlags, LPCWSTR lpszFrameName, BYTE *pPostData, DWORD cbPostData,
3692 LPCWSTR lpszHeaders, BOOL fPlayNavSound, BOOL *pfCancel)
3694 CHECK_EXPECT(FireBeforeNavigate2);
3696 ok(!pDispatch, "pDispatch = %p\n", pDispatch);
3697 ok(!lstrcmpW(lpszUrl, nav_url), "lpszUrl = %s, expected %s\n", wine_dbgstr_w(lpszUrl), wine_dbgstr_w(nav_url));
3698 ok(dwFlags == 0x140 /* IE11*/ || dwFlags == 0x40 || !dwFlags || dwFlags == 0x50, "dwFlags = %lx\n", dwFlags);
3699 ok(!lpszFrameName, "lpszFrameName = %s\n", wine_dbgstr_w(lpszFrameName));
3700 if(!testing_submit) {
3701 ok(!pPostData, "pPostData = %p\n", pPostData);
3702 ok(!cbPostData, "cbPostData = %ld\n", cbPostData);
3703 ok(!lpszHeaders || !lstrcmpW(lpszHeaders, L"Referer: http://test.winehq.org/tests/winehq_snapshot/\r\n") ||
3704 !lstrcmpW(lpszHeaders, L"Referer: http://test.winehq.org/tests/hello.html\r\n"),
3705 "lpszHeaders = %s\n", wine_dbgstr_w(lpszHeaders));
3706 }else {
3707 ok(cbPostData == 9, "cbPostData = %ld\n", cbPostData);
3708 ok(!memcmp(pPostData, "cmd=TEST", cbPostData), "pPostData = %p\n", pPostData);
3709 ok(wcsstr(lpszHeaders, L"Content-Type: application/x-www-form-urlencoded\r\n") != NULL,
3710 "lpszHeaders = %s\n", wine_dbgstr_w(lpszHeaders));
3713 ok(fPlayNavSound, "fPlayNavSound = %x\n", fPlayNavSound);
3714 ok(pfCancel != NULL, "pfCancel = NULL\n");
3715 ok(!*pfCancel, "*pfCancel = %x\n", *pfCancel);
3717 return S_OK;
3720 static HRESULT WINAPI DocObjectService_FireNavigateComplete2(
3721 IDocObjectService* This,
3722 IHTMLWindow2 *pHTMLWindow2,
3723 DWORD dwFlags)
3725 CHECK_EXPECT(FireNavigateComplete2);
3726 test_readyState(NULL);
3727 test_navigation_type(doc_unk);
3728 test_performance_timing(doc_unk, L"domInteractive");
3730 if(loading_hash)
3731 ok(dwFlags == 0x10 || broken(!dwFlags), "dwFlags = %lx, expected 0x10\n", dwFlags);
3732 else
3733 ok(!(dwFlags &~1), "dwFlags = %lx\n", dwFlags);
3735 ok(pHTMLWindow2 != NULL, "pHTMLWindow2 = NULL\n");
3737 return S_OK;
3740 static HRESULT WINAPI DocObjectService_FireDownloadBegin(
3741 IDocObjectService* This)
3743 ok(0, "unexpected call\n");
3744 return E_NOTIMPL;
3747 static HRESULT WINAPI DocObjectService_FireDownloadComplete(
3748 IDocObjectService* This)
3750 ok(0, "unexpected call\n");
3751 return E_NOTIMPL;
3754 static HRESULT WINAPI DocObjectService_FireDocumentComplete(
3755 IDocObjectService* This,
3756 IHTMLWindow2 *pHTMLWindow,
3757 DWORD dwFlags)
3759 CHECK_EXPECT(FireDocumentComplete);
3761 ok(pHTMLWindow != NULL, "pHTMLWindow == NULL\n");
3762 ok(!dwFlags, "dwFlags = %lx\n", dwFlags);
3764 return S_OK;
3767 static HRESULT WINAPI DocObjectService_UpdateDesktopComponent(
3768 IDocObjectService* This,
3769 IHTMLWindow2 *pHTMLWindow)
3771 ok(0, "unexpected call\n");
3772 return E_NOTIMPL;
3775 static HRESULT WINAPI DocObjectService_GetPendingUrl(
3776 IDocObjectService* This,
3777 BSTR *pbstrPendingUrl)
3779 if(!resetting_document)
3780 CHECK_EXPECT(GetPendingUrl);
3781 return E_NOTIMPL;
3784 static HRESULT WINAPI DocObjectService_ActiveElementChanged(
3785 IDocObjectService* This,
3786 IHTMLElement *pHTMLElement)
3788 CHECK_EXPECT2(ActiveElementChanged);
3789 return E_NOTIMPL;
3792 static HRESULT WINAPI DocObjectService_GetUrlSearchComponent(
3793 IDocObjectService* This,
3794 BSTR *pbstrSearch)
3796 ok(0, "unexpected call\n");
3797 return E_NOTIMPL;
3800 static HRESULT WINAPI DocObjectService_IsErrorUrl(
3801 IDocObjectService* This,
3802 LPCWSTR lpszUrl,
3803 BOOL *pfIsError)
3805 CHECK_EXPECT2(IsErrorUrl);
3806 *pfIsError = is_error_url;
3807 return S_OK;
3810 static IDocObjectServiceVtbl DocObjectServiceVtbl = {
3811 DocObjectService_QueryInterface,
3812 DocObjectService_AddRef,
3813 DocObjectService_Release,
3814 DocObjectService_FireBeforeNavigate2,
3815 DocObjectService_FireNavigateComplete2,
3816 DocObjectService_FireDownloadBegin,
3817 DocObjectService_FireDownloadComplete,
3818 DocObjectService_FireDocumentComplete,
3819 DocObjectService_UpdateDesktopComponent,
3820 DocObjectService_GetPendingUrl,
3821 DocObjectService_ActiveElementChanged,
3822 DocObjectService_GetUrlSearchComponent,
3823 DocObjectService_IsErrorUrl
3826 static IDocObjectService DocObjectService = { &DocObjectServiceVtbl };
3828 static HRESULT WINAPI ShellBrowser_QueryInterface(IShellBrowser *iface, REFIID riid, void **ppv)
3830 return browserservice_qi(riid, ppv);
3833 static ULONG WINAPI ShellBrowser_AddRef(IShellBrowser *iface)
3835 return 2;
3838 static ULONG WINAPI ShellBrowser_Release(IShellBrowser *iface)
3840 return 1;
3843 static HRESULT WINAPI ShellBrowser_GetWindow(IShellBrowser *iface, HWND *phwnd)
3845 ok(0, "unexpected call\n");
3846 return E_NOTIMPL;
3849 static HRESULT WINAPI ShellBrowser_ContextSensitiveHelp(IShellBrowser *iface, BOOL fEnterMode)
3851 ok(0, "unexpected call\n");
3852 return E_NOTIMPL;
3855 static HRESULT WINAPI ShellBrowser_InsertMenusSB(IShellBrowser *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
3857 ok(0, "unexpected call\n");
3858 return E_NOTIMPL;
3861 static HRESULT WINAPI ShellBrowser_SetMenuSB(IShellBrowser *iface, HMENU hmenuShared, HOLEMENU holemenuReserved,
3862 HWND hwndActiveObject)
3864 ok(0, "unexpected call\n");
3865 return E_NOTIMPL;
3868 static HRESULT WINAPI ShellBrowser_RemoveMenusSB(IShellBrowser *iface, HMENU hmenuShared)
3870 ok(0, "unexpected call\n");
3871 return E_NOTIMPL;
3874 static HRESULT WINAPI ShellBrowser_SetStatusTextSB(IShellBrowser *iface, LPCOLESTR pszStatusText)
3876 ok(0, "unexpected call\n");
3877 return E_NOTIMPL;
3880 static HRESULT WINAPI ShellBrowser_EnableModelessSB(IShellBrowser *iface, BOOL fEnable)
3882 ok(0, "unexpected call\n");
3883 return E_NOTIMPL;
3886 static HRESULT WINAPI ShellBrowser_TranslateAcceleratorSB(IShellBrowser *iface, MSG *pmsg, WORD wID)
3888 ok(0, "unexpected call\n");
3889 return E_NOTIMPL;
3892 static HRESULT WINAPI ShellBrowser_BrowseObject(IShellBrowser *iface, LPCITEMIDLIST pidl, UINT wFlags)
3894 ok(0, "unexpected call\n");
3895 return E_NOTIMPL;
3898 static HRESULT WINAPI ShellBrowser_GetViewStateStream(IShellBrowser *iface, DWORD grfMode, IStream **ppStrm)
3900 ok(0, "unexpected call\n");
3901 return E_NOTIMPL;
3904 static HRESULT WINAPI ShellBrowser_GetControlWindow(IShellBrowser *iface, UINT id, HWND *phwnd)
3906 ok(0, "unexpected call\n");
3907 return E_NOTIMPL;
3910 static HRESULT WINAPI ShellBrowser_SendControlMsg(IShellBrowser *iface, UINT id, UINT uMsg, WPARAM wParam,
3911 LPARAM lParam, LRESULT *pret)
3913 ok(0, "unexpected call\n");
3914 return E_NOTIMPL;
3917 static HRESULT WINAPI ShellBrowser_QueryActiveShellView(IShellBrowser *iface, IShellView **ppshv)
3919 ok(0, "unexpected call\n");
3920 return E_NOTIMPL;
3923 static HRESULT WINAPI ShellBrowser_OnViewWindowActive(IShellBrowser* iface, IShellView *pshv)
3925 ok(0, "unexpected call\n");
3926 return E_NOTIMPL;
3929 static HRESULT WINAPI ShellBrowser_SetToolbarItems(IShellBrowser *iface, LPTBBUTTONSB lpButtons,
3930 UINT nButtons, UINT uFlags)
3932 ok(0, "unexpected call\n");
3933 return E_NOTIMPL;
3936 static const IShellBrowserVtbl ShellBrowserVtbl = {
3937 ShellBrowser_QueryInterface,
3938 ShellBrowser_AddRef,
3939 ShellBrowser_Release,
3940 ShellBrowser_GetWindow,
3941 ShellBrowser_ContextSensitiveHelp,
3942 ShellBrowser_InsertMenusSB,
3943 ShellBrowser_SetMenuSB,
3944 ShellBrowser_RemoveMenusSB,
3945 ShellBrowser_SetStatusTextSB,
3946 ShellBrowser_EnableModelessSB,
3947 ShellBrowser_TranslateAcceleratorSB,
3948 ShellBrowser_BrowseObject,
3949 ShellBrowser_GetViewStateStream,
3950 ShellBrowser_GetControlWindow,
3951 ShellBrowser_SendControlMsg,
3952 ShellBrowser_QueryActiveShellView,
3953 ShellBrowser_OnViewWindowActive,
3954 ShellBrowser_SetToolbarItems
3957 static IShellBrowser ShellBrowser = { &ShellBrowserVtbl };
3959 static HRESULT WINAPI BrowserService_QueryInterface(IBrowserService *iface, REFIID riid, void **ppv)
3961 return browserservice_qi(riid, ppv);
3964 static ULONG WINAPI BrowserService_AddRef(
3965 IBrowserService* This)
3967 return 2;
3970 static ULONG WINAPI BrowserService_Release(
3971 IBrowserService* This)
3973 return 1;
3976 static HRESULT WINAPI BrowserService_GetParentSite(
3977 IBrowserService* This,
3978 IOleInPlaceSite **ppipsite)
3980 ok(0, "unexpected call\n");
3981 return E_NOTIMPL;
3984 static HRESULT WINAPI BrowserService_SetTitle(
3985 IBrowserService* This,
3986 IShellView *psv,
3987 LPCWSTR pszName)
3989 ok(0, "unexpected call\n");
3990 return E_NOTIMPL;
3993 static HRESULT WINAPI BrowserService_GetTitle(
3994 IBrowserService* This,
3995 IShellView *psv,
3996 LPWSTR pszName,
3997 DWORD cchName)
3999 ok(0, "unexpected call\n");
4000 return E_NOTIMPL;
4003 static HRESULT WINAPI BrowserService_GetOleObject(
4004 IBrowserService* This,
4005 IOleObject **ppobjv)
4007 ok(0, "unexpected call\n");
4008 return E_NOTIMPL;
4011 static HRESULT WINAPI BrowserService_GetTravelLog(IBrowserService* This, ITravelLog **pptl)
4013 CHECK_EXPECT(GetTravelLog);
4015 ok(pptl != NULL, "pptl = NULL\n");
4017 if(!support_wbapp)
4018 return E_NOTIMPL;
4020 *pptl = &TravelLog;
4021 return S_OK;
4024 static HRESULT WINAPI BrowserService_ShowControlWindow(
4025 IBrowserService* This,
4026 UINT id,
4027 BOOL fShow)
4029 ok(0, "unexpected call\n");
4030 return E_NOTIMPL;
4033 static HRESULT WINAPI BrowserService_IsControlWindowShown(
4034 IBrowserService* This,
4035 UINT id,
4036 BOOL *pfShown)
4038 ok(0, "unexpected call\n");
4039 return E_NOTIMPL;
4042 static HRESULT WINAPI BrowserService_IEGetDisplayName(
4043 IBrowserService* This,
4044 PCIDLIST_ABSOLUTE pidl,
4045 LPWSTR pwszName,
4046 UINT uFlags)
4048 ok(0, "unexpected call\n");
4049 return E_NOTIMPL;
4052 static HRESULT WINAPI BrowserService_IEParseDisplayName(
4053 IBrowserService* This,
4054 UINT uiCP,
4055 LPCWSTR pwszPath,
4056 PIDLIST_ABSOLUTE *ppidlOut)
4058 ok(0, "unexpected call\n");
4059 return E_NOTIMPL;
4062 static HRESULT WINAPI BrowserService_DisplayParseError(
4063 IBrowserService* This,
4064 HRESULT hres,
4065 LPCWSTR pwszPath)
4067 ok(0, "unexpected call\n");
4068 return E_NOTIMPL;
4071 static HRESULT WINAPI BrowserService_NavigateToPidl(
4072 IBrowserService* This,
4073 PCIDLIST_ABSOLUTE pidl,
4074 DWORD grfHLNF)
4076 ok(0, "unexpected call\n");
4077 return E_NOTIMPL;
4080 static HRESULT WINAPI BrowserService_SetNavigateState(
4081 IBrowserService* This,
4082 BNSTATE bnstate)
4084 ok(0, "unexpected call\n");
4085 return E_NOTIMPL;
4088 static HRESULT WINAPI BrowserService_GetNavigateState(
4089 IBrowserService* This,
4090 BNSTATE *pbnstate)
4092 ok(0, "unexpected call\n");
4093 return E_NOTIMPL;
4096 static HRESULT WINAPI BrowserService_NotifyRedirect(
4097 IBrowserService* This,
4098 IShellView *psv,
4099 PCIDLIST_ABSOLUTE pidl,
4100 BOOL *pfDidBrowse)
4102 ok(0, "unexpected call\n");
4103 return E_NOTIMPL;
4106 static HRESULT WINAPI BrowserService_UpdateWindowList(
4107 IBrowserService* This)
4109 ok(0, "unexpected call\n");
4110 return E_NOTIMPL;
4113 static HRESULT WINAPI BrowserService_UpdateBackForwardState(
4114 IBrowserService* This)
4116 CHECK_EXPECT(UpdateBackForwardState);
4117 return S_OK;
4120 static HRESULT WINAPI BrowserService_SetFlags(
4121 IBrowserService* This,
4122 DWORD dwFlags,
4123 DWORD dwFlagMask)
4125 ok(0, "unexpected call\n");
4126 return E_NOTIMPL;
4129 static HRESULT WINAPI BrowserService_GetFlags(
4130 IBrowserService* This,
4131 DWORD *pdwFlags)
4133 ok(0, "unexpected call\n");
4134 return E_NOTIMPL;
4137 static HRESULT WINAPI BrowserService_CanNavigateNow(
4138 IBrowserService* This)
4140 ok(0, "unexpected call\n");
4141 return E_NOTIMPL;
4144 static HRESULT WINAPI BrowserService_GetPidl(
4145 IBrowserService* This,
4146 PIDLIST_ABSOLUTE *ppidl)
4148 ok(0, "unexpected call\n");
4149 return E_NOTIMPL;
4152 static HRESULT WINAPI BrowserService_SetReferrer(
4153 IBrowserService* This,
4154 PCIDLIST_ABSOLUTE pidl)
4156 ok(0, "unexpected call\n");
4157 return E_NOTIMPL;
4160 static DWORD WINAPI BrowserService_GetBrowserIndex(
4161 IBrowserService* This)
4163 ok(0, "unexpected call\n");
4164 return E_NOTIMPL;
4167 static HRESULT WINAPI BrowserService_GetBrowserByIndex(
4168 IBrowserService* This,
4169 DWORD dwID,
4170 IUnknown **ppunk)
4172 ok(0, "unexpected call\n");
4173 return E_NOTIMPL;
4176 static HRESULT WINAPI BrowserService_GetHistoryObject(
4177 IBrowserService* This,
4178 IOleObject **ppole,
4179 IStream **pstm,
4180 IBindCtx **ppbc)
4182 ok(0, "unexpected call\n");
4183 return E_NOTIMPL;
4186 static HRESULT WINAPI BrowserService_SetHistoryObject(
4187 IBrowserService* This,
4188 IOleObject *pole,
4189 BOOL fIsLocalAnchor)
4191 ok(0, "unexpected call\n");
4192 return E_NOTIMPL;
4195 static HRESULT WINAPI BrowserService_CacheOLEServer(
4196 IBrowserService* This,
4197 IOleObject *pole)
4199 ok(0, "unexpected call\n");
4200 return E_NOTIMPL;
4203 static HRESULT WINAPI BrowserService_GetSetCodePage(
4204 IBrowserService* This,
4205 VARIANT *pvarIn,
4206 VARIANT *pvarOut)
4208 ok(0, "unexpected call\n");
4209 return E_NOTIMPL;
4212 static HRESULT WINAPI BrowserService_OnHttpEquiv(
4213 IBrowserService* This,
4214 IShellView *psv,
4215 BOOL fDone,
4216 VARIANT *pvarargIn,
4217 VARIANT *pvarargOut)
4219 ok(0, "unexpected call\n");
4220 return E_NOTIMPL;
4223 static HRESULT WINAPI BrowserService_GetPalette(
4224 IBrowserService* This,
4225 HPALETTE *hpal)
4227 ok(0, "unexpected call\n");
4228 return E_NOTIMPL;
4231 static HRESULT WINAPI BrowserService_RegisterWindow(
4232 IBrowserService* This,
4233 BOOL fForceRegister,
4234 int swc)
4236 ok(0, "unexpected call\n");
4237 return E_NOTIMPL;
4240 static IBrowserServiceVtbl BrowserServiceVtbl = {
4241 BrowserService_QueryInterface,
4242 BrowserService_AddRef,
4243 BrowserService_Release,
4244 BrowserService_GetParentSite,
4245 BrowserService_SetTitle,
4246 BrowserService_GetTitle,
4247 BrowserService_GetOleObject,
4248 BrowserService_GetTravelLog,
4249 BrowserService_ShowControlWindow,
4250 BrowserService_IsControlWindowShown,
4251 BrowserService_IEGetDisplayName,
4252 BrowserService_IEParseDisplayName,
4253 BrowserService_DisplayParseError,
4254 BrowserService_NavigateToPidl,
4255 BrowserService_SetNavigateState,
4256 BrowserService_GetNavigateState,
4257 BrowserService_NotifyRedirect,
4258 BrowserService_UpdateWindowList,
4259 BrowserService_UpdateBackForwardState,
4260 BrowserService_SetFlags,
4261 BrowserService_GetFlags,
4262 BrowserService_CanNavigateNow,
4263 BrowserService_GetPidl,
4264 BrowserService_SetReferrer,
4265 BrowserService_GetBrowserIndex,
4266 BrowserService_GetBrowserByIndex,
4267 BrowserService_GetHistoryObject,
4268 BrowserService_SetHistoryObject,
4269 BrowserService_CacheOLEServer,
4270 BrowserService_GetSetCodePage,
4271 BrowserService_OnHttpEquiv,
4272 BrowserService_GetPalette,
4273 BrowserService_RegisterWindow
4276 static IBrowserService BrowserService = { &BrowserServiceVtbl };
4278 DEFINE_GUID(IID_ITabBrowserService, 0x5E8FA523,0x83D4,0x4DBE,0x81,0x99,0x4C,0x18,0xE4,0x85,0x87,0x25);
4280 static HRESULT browserservice_qi(REFIID riid, void **ppv)
4282 if(IsEqualGUID(&IID_IShellBrowser, riid)) {
4283 *ppv = &ShellBrowser;
4284 return S_OK;
4287 if(IsEqualGUID(&IID_IDocObjectService, riid)) {
4288 *ppv = &DocObjectService;
4289 return S_OK;
4292 if(IsEqualGUID(&IID_IBrowserService, riid)) {
4293 *ppv = &BrowserService;
4294 return S_OK;
4297 *ppv = NULL;
4298 return E_NOINTERFACE;
4301 static HRESULT WINAPI WBE2Sink_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
4303 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
4304 *ppv = iface;
4305 return S_OK;
4308 *ppv = NULL;
4309 ok(0, "unexpected riid: %s\n", wine_dbgstr_guid(riid));
4310 return E_NOINTERFACE;
4313 static HRESULT WINAPI WBE2Sink_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
4314 LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pVarResult,
4315 EXCEPINFO *pExcepInfo, UINT *puArgErr)
4317 ok(IsEqualGUID(&IID_NULL, riid), "riid != IID_NULL\n");
4318 ok(pdp != NULL, "pDispParams == NULL\n");
4319 ok(pExcepInfo == NULL, "pExcepInfo=%p, expected NULL\n", pExcepInfo);
4320 ok(puArgErr == NULL, "puArgErr != NULL\n");
4321 ok(pVarResult == NULL, "pVarResult != NULL\n");
4322 ok(wFlags == DISPATCH_METHOD, "wFlags=%08x, expected DISPATCH_METHOD\n", wFlags);
4323 ok(!pdp->cNamedArgs, "pdp->cNamedArgs = %d\n", pdp->cNamedArgs);
4324 ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs = %p\n", pdp->rgdispidNamedArgs);
4326 switch(dispIdMember) {
4327 case DISPID_WINDOWCLOSING: {
4328 VARIANT *is_child = pdp->rgvarg+1, *cancel = pdp->rgvarg;
4330 CHECK_EXPECT(WindowClosing);
4332 ok(pdp->cArgs == 2, "pdp->cArgs = %d\n", pdp->cArgs);
4333 ok(V_VT(is_child) == VT_BOOL, "V_VT(is_child) = %d\n", V_VT(is_child));
4334 ok(!V_BOOL(is_child), "V_BOOL(is_child) = %x\n", V_BOOL(is_child));
4335 ok(V_VT(cancel) == (VT_BYREF|VT_BOOL), "V_VT(cancel) = %d\n", V_VT(cancel));
4336 ok(!*V_BOOLREF(cancel), "*V_BOOLREF(cancel) = %x\n", *V_BOOLREF(cancel));
4338 *V_BOOLREF(cancel) = VARIANT_TRUE;
4339 return S_OK;
4341 default:
4342 ok(0, "unexpected id %ld\n", dispIdMember);
4345 return E_NOTIMPL;
4348 static const IDispatchVtbl WBE2SinkVtbl = {
4349 WBE2Sink_QueryInterface,
4350 Dispatch_AddRef,
4351 Dispatch_Release,
4352 Dispatch_GetTypeInfoCount,
4353 Dispatch_GetTypeInfo,
4354 Dispatch_GetIDsOfNames,
4355 WBE2Sink_Invoke
4358 static IDispatch WBE2Sink = { &WBE2SinkVtbl };
4360 static HRESULT WINAPI EnumConnections_QueryInterface(IEnumConnections *iface, REFIID riid, LPVOID *ppv)
4362 ok(0, "unexpected call\n");
4363 return E_NOINTERFACE;
4366 static ULONG WINAPI EnumConnections_AddRef(IEnumConnections *iface)
4368 return 2;
4371 static ULONG WINAPI EnumConnections_Release(IEnumConnections *iface)
4373 return 1;
4376 static BOOL next_called;
4378 static HRESULT WINAPI EnumConnections_Next(IEnumConnections *iface, ULONG cConnections, CONNECTDATA *rgcd, ULONG *pcFetched)
4380 CHECK_EXPECT2(EnumConnections_Next);
4382 ok(cConnections == 1, "cConnections = %ld\n", cConnections);
4383 ok(pcFetched != NULL, "pcFetched == NULL\n");
4385 if(next_called) {
4386 *pcFetched = 0;
4387 return S_FALSE;
4390 next_called = TRUE;
4391 rgcd->pUnk = (IUnknown*)&WBE2Sink;
4392 rgcd->dwCookie = 0xdeadbeef;
4393 *pcFetched = 1;
4394 return S_OK;
4397 static HRESULT WINAPI EnumConnections_Skip(IEnumConnections *iface, ULONG ulConnections)
4399 ok(0, "unexpected call\n");
4400 return E_NOINTERFACE;
4403 static HRESULT WINAPI EnumConnections_Reset(IEnumConnections *iface)
4405 ok(0, "unexpected call\n");
4406 return E_NOINTERFACE;
4409 static HRESULT WINAPI EnumConnections_Clone(IEnumConnections *iface, IEnumConnections **ppEnum)
4411 ok(0, "unexpected call\n");
4412 return E_NOINTERFACE;
4415 static const IEnumConnectionsVtbl EnumConnectionsVtbl = {
4416 EnumConnections_QueryInterface,
4417 EnumConnections_AddRef,
4418 EnumConnections_Release,
4419 EnumConnections_Next,
4420 EnumConnections_Skip,
4421 EnumConnections_Reset,
4422 EnumConnections_Clone
4425 static IEnumConnections EnumConnections = { &EnumConnectionsVtbl };
4427 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, LPVOID *ppv)
4429 ok(0, "unexpected call\n");
4430 return E_NOINTERFACE;
4433 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
4435 return 2;
4438 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
4440 return 1;
4443 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
4445 ok(0, "unexpected call\n");
4446 return E_NOTIMPL;
4449 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
4450 IConnectionPointContainer **ppCPC)
4452 ok(0, "unexpected call\n");
4453 return E_NOTIMPL;
4456 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink, DWORD *pdwCookie)
4458 ok(0, "unexpected call\n");
4459 return E_NOTIMPL;
4462 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
4464 ok(0, "unexpected call\n");
4465 return E_NOTIMPL;
4468 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface, IEnumConnections **ppEnum)
4470 CHECK_EXPECT(EnumConnections);
4472 *ppEnum = &EnumConnections;
4473 next_called = FALSE;
4474 return S_OK;
4477 static const IConnectionPointVtbl ConnectionPointVtbl =
4479 ConnectionPoint_QueryInterface,
4480 ConnectionPoint_AddRef,
4481 ConnectionPoint_Release,
4482 ConnectionPoint_GetConnectionInterface,
4483 ConnectionPoint_GetConnectionPointContainer,
4484 ConnectionPoint_Advise,
4485 ConnectionPoint_Unadvise,
4486 ConnectionPoint_EnumConnections
4489 static IConnectionPoint ConnectionPointWBE2 = { &ConnectionPointVtbl };
4491 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
4492 REFIID riid, void **ppv)
4494 ok(0, "unexpected call\n");
4495 return E_NOINTERFACE;
4498 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
4500 return 2;
4503 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
4505 return 1;
4508 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
4509 IEnumConnectionPoints **ppEnum)
4511 ok(0, "unexpected call\n");
4512 return E_NOTIMPL;
4515 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
4516 REFIID riid, IConnectionPoint **ppCP)
4518 CHECK_EXPECT(FindConnectionPoint);
4520 if(IsEqualGUID(riid, &DIID_DWebBrowserEvents2)) {
4521 *ppCP = &ConnectionPointWBE2;
4522 return S_OK;
4525 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
4526 return E_NOTIMPL;
4529 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
4530 ConnectionPointContainer_QueryInterface,
4531 ConnectionPointContainer_AddRef,
4532 ConnectionPointContainer_Release,
4533 ConnectionPointContainer_EnumConnectionPoints,
4534 ConnectionPointContainer_FindConnectionPoint
4537 static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
4539 static void test_NavigateWithBindCtx(BSTR uri, VARIANT *flags, VARIANT *target_frame, VARIANT *post_data,
4540 VARIANT *headers, IBindCtx *bind_ctx, LPOLESTR url_fragment)
4542 ok(!lstrcmpW(uri, nav_url), "uri = %s\n", wine_dbgstr_w(uri));
4543 ok(V_VT(flags) == VT_I4, "V_VT(flags) = %d\n", V_VT(flags));
4544 ok(V_I4(flags) == navHyperlink, "V_I4(flags) = %lx\n", V_I4(flags));
4545 ok(!target_frame, "target_frame != NULL\n");
4546 ok(!post_data, "post_data != NULL\n");
4547 ok(!headers, "headers != NULL\n");
4548 ok(bind_ctx != NULL, "bind_ctx == NULL\n");
4549 ok(!url_fragment, "url_dragment = %s\n", wine_dbgstr_w(url_fragment));
4552 static HRESULT wb_qi(REFIID riid, void **ppv);
4554 static HRESULT WINAPI WebBrowserPriv_QueryInterface(IWebBrowserPriv *iface, REFIID riid, void **ppv)
4556 return wb_qi(riid, ppv);
4559 static ULONG WINAPI WebBrowserPriv_AddRef(IWebBrowserPriv *iface)
4561 return 2;
4564 static ULONG WINAPI WebBrowserPriv_Release(IWebBrowserPriv *iface)
4566 return 1;
4569 static HRESULT WINAPI WebBrowserPriv_NavigateWithBindCtx(IWebBrowserPriv *iface, VARIANT *uri, VARIANT *flags,
4570 VARIANT *target_frame, VARIANT *post_data, VARIANT *headers, IBindCtx *bind_ctx, LPOLESTR url_fragment)
4572 trace("NavigateWithBindCtx\n");
4574 CHECK_EXPECT(NavigateWithBindCtx);
4575 test_navigation_type(doc_unk);
4577 ok(V_VT(uri) == VT_BSTR, "V_VT(uri) = %d\n", V_VT(uri));
4578 test_NavigateWithBindCtx(V_BSTR(uri), flags, target_frame, post_data, headers, bind_ctx, url_fragment);
4579 return S_OK;
4582 static HRESULT WINAPI WebBrowserPriv_OnClose(IWebBrowserPriv *iface)
4584 ok(0, "unexpected call\n");
4585 return E_NOTIMPL;
4588 static const IWebBrowserPrivVtbl WebBrowserPrivVtbl = {
4589 WebBrowserPriv_QueryInterface,
4590 WebBrowserPriv_AddRef,
4591 WebBrowserPriv_Release,
4592 WebBrowserPriv_NavigateWithBindCtx,
4593 WebBrowserPriv_OnClose
4596 static IWebBrowserPriv WebBrowserPriv = { &WebBrowserPrivVtbl };
4598 static HRESULT WINAPI WebBrowserPriv2IE8_QueryInterface(IWebBrowserPriv2IE8 *iface, REFIID riid, void **ppv)
4600 return wb_qi(riid, ppv);
4603 static ULONG WINAPI WebBrowserPriv2IE8_AddRef(IWebBrowserPriv2IE8 *iface)
4605 return 2;
4608 static ULONG WINAPI WebBrowserPriv2IE8_Release(IWebBrowserPriv2IE8 *iface)
4610 return 1;
4613 static HRESULT WINAPI WebBrowserPriv2IE8_NavigateWithBindCtx2(IWebBrowserPriv2IE8 *iface, IUri *uri, VARIANT *flags,
4614 VARIANT *target_frame, VARIANT *post_data, VARIANT *headers, IBindCtx *bind_ctx, LPOLESTR url_fragment)
4616 BSTR str;
4617 HRESULT hres;
4619 trace("IE8: NavigateWithBindCtx2\n");
4621 CHECK_EXPECT(NavigateWithBindCtx);
4623 hres = IUri_GetDisplayUri(uri, &str);
4624 ok(hres == S_OK, "GetDisplayUri failed: %08lx\n", hres);
4625 test_NavigateWithBindCtx(str, flags, target_frame, post_data, headers, bind_ctx, url_fragment);
4626 SysFreeString(str);
4627 return S_OK;
4630 static HRESULT WINAPI WebBrowserPriv2IE8_SetBrowserFrameOptions(IWebBrowserPriv2IE8 *iface, DWORD opt1, DWORD opt2)
4632 ok(0, "unexpected call\n");
4633 return E_NOTIMPL;
4636 static HRESULT WINAPI WebBrowserPriv2IE8_DetachConnectionPoints(IWebBrowserPriv2IE8 *iface)
4638 ok(0, "unexpected call\n");
4639 return E_NOTIMPL;
4642 static HRESULT WINAPI WebBrowserPriv2IE8_GetProcessId(IWebBrowserPriv2IE8 *iface, DWORD *pid)
4644 ok(0, "unexpected call\n");
4645 return E_NOTIMPL;
4648 static HRESULT WINAPI WebBrowserPriv2IE8_CompatAttachEditEvents(IWebBrowserPriv2IE8 *iface)
4650 ok(0, "unexpected call\n");
4651 return E_NOTIMPL;
4654 static HRESULT WINAPI WebBrowserPriv2IE8_HandleOpenOptions(IWebBrowserPriv2IE8 *iface, IUnknown *obj, BSTR bstr, int options)
4656 ok(0, "unexpected call\n");
4657 return E_NOTIMPL;
4660 static HRESULT WINAPI WebBrowserPriv2IE8_SetSearchTerm(IWebBrowserPriv2IE8 *iface, BSTR term)
4662 ok(0, "unexpected call\n");
4663 return E_NOTIMPL;
4666 static HRESULT WINAPI WebBrowserPriv2IE8_GetSearchTerm(IWebBrowserPriv2IE8 *iface, BSTR *term)
4668 ok(0, "unexpected call\n");
4669 return E_NOTIMPL;
4672 static HRESULT WINAPI WebBrowserPriv2IE8_GetCurrentDocument(IWebBrowserPriv2IE8 *iface, IDispatch **doc)
4674 ok(0, "unexpected call\n");
4675 return E_NOTIMPL;
4678 static const IWebBrowserPriv2IE8Vtbl WebBrowserPriv2IE8Vtbl = {
4679 WebBrowserPriv2IE8_QueryInterface,
4680 WebBrowserPriv2IE8_AddRef,
4681 WebBrowserPriv2IE8_Release,
4682 WebBrowserPriv2IE8_NavigateWithBindCtx2,
4683 WebBrowserPriv2IE8_SetBrowserFrameOptions,
4684 WebBrowserPriv2IE8_DetachConnectionPoints,
4685 WebBrowserPriv2IE8_GetProcessId,
4686 WebBrowserPriv2IE8_CompatAttachEditEvents,
4687 WebBrowserPriv2IE8_HandleOpenOptions,
4688 WebBrowserPriv2IE8_SetSearchTerm,
4689 WebBrowserPriv2IE8_GetSearchTerm,
4690 WebBrowserPriv2IE8_GetCurrentDocument
4693 static IWebBrowserPriv2IE8 WebBrowserPriv2IE8 = { &WebBrowserPriv2IE8Vtbl };
4695 static HRESULT WINAPI WebBrowserPriv2IE9_QueryInterface(IWebBrowserPriv2IE9 *iface, REFIID riid, void **ppv)
4697 return wb_qi(riid, ppv);
4700 static ULONG WINAPI WebBrowserPriv2IE9_AddRef(IWebBrowserPriv2IE9 *iface)
4702 return 2;
4705 static ULONG WINAPI WebBrowserPriv2IE9_Release(IWebBrowserPriv2IE9 *iface)
4707 return 1;
4710 static HRESULT WINAPI WebBrowserPriv2IE9_NavigateWithBindCtx2(IWebBrowserPriv2IE9 *iface, IUri *uri, VARIANT *flags,
4711 VARIANT *target_frame, VARIANT *post_data, VARIANT *headers, IBindCtx *bind_ctx, LPOLESTR url_fragment, DWORD unknown)
4713 BSTR str;
4714 HRESULT hres;
4716 trace("IE9: NavigateWithBindCtx2\n");
4718 CHECK_EXPECT(NavigateWithBindCtx);
4720 hres = IUri_GetDisplayUri(uri, &str);
4721 ok(hres == S_OK, "GetDisplayUri failed: %08lx\n", hres);
4722 test_NavigateWithBindCtx(str, flags, target_frame, post_data, headers, bind_ctx, url_fragment);
4723 SysFreeString(str);
4724 return S_OK;
4727 static const IWebBrowserPriv2IE9Vtbl WebBrowserPriv2IE9Vtbl = {
4728 WebBrowserPriv2IE9_QueryInterface,
4729 WebBrowserPriv2IE9_AddRef,
4730 WebBrowserPriv2IE9_Release,
4731 WebBrowserPriv2IE9_NavigateWithBindCtx2
4734 static IWebBrowserPriv2IE9 WebBrowserPriv2IE9 = { &WebBrowserPriv2IE9Vtbl };
4736 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, void **ppv)
4738 return wb_qi(riid, ppv);
4741 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
4743 return 2;
4746 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
4748 return 1;
4751 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
4753 ok(0, "unexpected call\n");
4754 return E_NOTIMPL;
4757 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
4758 LPTYPEINFO *ppTInfo)
4760 ok(0, "unexpected call\n");
4761 return E_NOTIMPL;
4764 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
4765 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
4767 ok(0, "unexpected call\n");
4768 return E_NOTIMPL;
4771 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
4772 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
4773 EXCEPINFO *pExepInfo, UINT *puArgErr)
4775 ok(0, "unexpected call\n");
4776 return E_NOTIMPL;
4779 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
4781 ok(0, "unexpected call\n");
4782 return E_NOTIMPL;
4785 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
4787 ok(0, "unexpected call\n");
4788 return E_NOTIMPL;
4791 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
4793 ok(0, "unexpected call\n");
4794 return E_NOTIMPL;
4797 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
4799 ok(0, "unexpected call\n");
4800 return E_NOTIMPL;
4803 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
4804 VARIANT *Flags, VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
4806 ok(0, "unexpected call\n");
4807 return E_NOTIMPL;
4810 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
4812 ok(0, "unexpected call\n");
4813 return E_NOTIMPL;
4816 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
4818 ok(0, "unexpected call\n");
4819 return E_NOTIMPL;
4822 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
4824 ok(0, "unexpected call\n");
4825 return E_NOTIMPL;
4828 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
4830 ok(0, "unexpected call\n");
4831 return E_NOTIMPL;
4834 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
4836 ok(0, "unexpected call\n");
4837 return E_NOTIMPL;
4840 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
4842 ok(0, "unexpected call\n");
4843 return E_NOTIMPL;
4846 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
4848 ok(0, "unexpected call\n");
4849 return E_NOTIMPL;
4852 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
4854 ok(0, "unexpected call\n");
4855 return E_NOTIMPL;
4858 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
4860 ok(0, "unexpected call\n");
4861 return E_NOTIMPL;
4864 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
4866 ok(0, "unexpected call\n");
4867 return E_NOTIMPL;
4870 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
4872 ok(0, "unexpected call\n");
4873 return E_NOTIMPL;
4876 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
4878 ok(0, "unexpected call\n");
4879 return E_NOTIMPL;
4882 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
4884 ok(0, "unexpected call\n");
4885 return E_NOTIMPL;
4888 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
4890 ok(0, "unexpected call\n");
4891 return E_NOTIMPL;
4894 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
4896 ok(0, "unexpected call\n");
4897 return E_NOTIMPL;
4900 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
4902 ok(0, "unexpected call\n");
4903 return E_NOTIMPL;
4906 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
4908 ok(0, "unexpected call\n");
4909 return E_NOTIMPL;
4912 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
4914 ok(0, "unexpected call\n");
4915 return E_NOTIMPL;
4918 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
4920 CHECK_EXPECT(get_LocationURL);
4921 return E_NOTIMPL;
4924 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
4926 ok(0, "unexpected call\n");
4927 return E_NOTIMPL;
4930 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
4932 ok(0, "unexpected call\n");
4933 return E_NOTIMPL;
4936 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
4938 ok(0, "unexpected call\n");
4939 return E_NOTIMPL;
4942 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
4944 ok(0, "unexpected call\n");
4945 return E_NOTIMPL;
4948 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
4950 ok(0, "unexpected call\n");
4951 return E_NOTIMPL;
4954 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
4956 ok(0, "unexpected call\n");
4957 return E_NOTIMPL;
4960 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
4962 ok(0, "unexpected call\n");
4963 return E_NOTIMPL;
4966 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
4968 ok(0, "unexpected call\n");
4969 return E_NOTIMPL;
4972 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
4974 ok(0, "unexpected call\n");
4975 return E_NOTIMPL;
4978 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
4980 ok(0, "unexpected call\n");
4981 return E_NOTIMPL;
4984 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
4986 ok(0, "unexpected call\n");
4987 return E_NOTIMPL;
4990 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
4992 ok(0, "unexpected call\n");
4993 return E_NOTIMPL;
4996 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
4998 ok(0, "unexpected call\n");
4999 return E_NOTIMPL;
5002 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
5004 ok(0, "unexpected call\n");
5005 return E_NOTIMPL;
5008 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
5010 ok(0, "unexpected call\n");
5011 return E_NOTIMPL;
5014 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
5016 ok(0, "unexpected call\n");
5017 return E_NOTIMPL;
5020 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
5022 ok(0, "unexpected call\n");
5023 return E_NOTIMPL;
5026 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
5028 ok(0, "unexpected call\n");
5029 return E_NOTIMPL;
5032 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
5034 ok(0, "unexpected call\n");
5035 return E_NOTIMPL;
5038 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
5040 ok(0, "unexpected call\n");
5041 return E_NOTIMPL;
5044 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
5046 ok(0, "unexpected call\n");
5047 return E_NOTIMPL;
5050 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
5051 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
5053 ok(0, "unexpected call\n");
5054 return E_NOTIMPL;
5057 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
5059 ok(0, "unexpected call\n");
5060 return E_NOTIMPL;
5063 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
5064 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
5066 ok(0, "unexpected call\n");
5067 return E_NOTIMPL;
5070 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
5071 VARIANT *pvarShow, VARIANT *pvarSize)
5073 ok(0, "unexpected call\n");
5074 return E_NOTIMPL;
5077 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
5079 ok(0, "unexpected call\n");
5080 return E_NOTIMPL;
5083 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
5085 ok(0, "unexpected call\n");
5086 return E_NOTIMPL;
5089 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
5091 ok(0, "unexpected call\n");
5092 return E_NOTIMPL;
5095 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
5097 ok(0, "unexpected call\n");
5098 return E_NOTIMPL;
5101 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
5103 ok(0, "unexpected call\n");
5104 return E_NOTIMPL;
5107 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
5108 VARIANT_BOOL *pbRegister)
5110 ok(0, "unexpected call\n");
5111 return E_NOTIMPL;
5114 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
5115 VARIANT_BOOL bRegister)
5117 ok(0, "unexpected call\n");
5118 return E_NOTIMPL;
5121 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
5122 VARIANT_BOOL *pbRegister)
5124 ok(0, "unexpected call\n");
5125 return E_NOTIMPL;
5128 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
5129 VARIANT_BOOL bRegister)
5131 ok(0, "unexpected call\n");
5132 return E_NOTIMPL;
5135 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
5137 ok(0, "unexpected call\n");
5138 return E_NOTIMPL;
5141 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
5143 ok(0, "unexpected call\n");
5144 return E_NOTIMPL;
5147 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
5149 trace("get_AddressBar: ignoring\n"); /* Some old IEs call it */
5150 return E_NOTIMPL;
5153 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
5155 ok(0, "unexpected call\n");
5156 return E_NOTIMPL;
5159 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
5161 ok(0, "unexpected call\n");
5162 return E_NOTIMPL;
5165 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
5167 ok(0, "unexpected call\n");
5168 return E_NOTIMPL;
5171 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
5173 WebBrowser_QueryInterface,
5174 WebBrowser_AddRef,
5175 WebBrowser_Release,
5176 WebBrowser_GetTypeInfoCount,
5177 WebBrowser_GetTypeInfo,
5178 WebBrowser_GetIDsOfNames,
5179 WebBrowser_Invoke,
5180 WebBrowser_GoBack,
5181 WebBrowser_GoForward,
5182 WebBrowser_GoHome,
5183 WebBrowser_GoSearch,
5184 WebBrowser_Navigate,
5185 WebBrowser_Refresh,
5186 WebBrowser_Refresh2,
5187 WebBrowser_Stop,
5188 WebBrowser_get_Application,
5189 WebBrowser_get_Parent,
5190 WebBrowser_get_Container,
5191 WebBrowser_get_Document,
5192 WebBrowser_get_TopLevelContainer,
5193 WebBrowser_get_Type,
5194 WebBrowser_get_Left,
5195 WebBrowser_put_Left,
5196 WebBrowser_get_Top,
5197 WebBrowser_put_Top,
5198 WebBrowser_get_Width,
5199 WebBrowser_put_Width,
5200 WebBrowser_get_Height,
5201 WebBrowser_put_Height,
5202 WebBrowser_get_LocationName,
5203 WebBrowser_get_LocationURL,
5204 WebBrowser_get_Busy,
5205 WebBrowser_Quit,
5206 WebBrowser_ClientToWindow,
5207 WebBrowser_PutProperty,
5208 WebBrowser_GetProperty,
5209 WebBrowser_get_Name,
5210 WebBrowser_get_HWND,
5211 WebBrowser_get_FullName,
5212 WebBrowser_get_Path,
5213 WebBrowser_get_Visible,
5214 WebBrowser_put_Visible,
5215 WebBrowser_get_StatusBar,
5216 WebBrowser_put_StatusBar,
5217 WebBrowser_get_StatusText,
5218 WebBrowser_put_StatusText,
5219 WebBrowser_get_ToolBar,
5220 WebBrowser_put_ToolBar,
5221 WebBrowser_get_MenuBar,
5222 WebBrowser_put_MenuBar,
5223 WebBrowser_get_FullScreen,
5224 WebBrowser_put_FullScreen,
5225 WebBrowser_Navigate2,
5226 WebBrowser_QueryStatusWB,
5227 WebBrowser_ExecWB,
5228 WebBrowser_ShowBrowserBar,
5229 WebBrowser_get_ReadyState,
5230 WebBrowser_get_Offline,
5231 WebBrowser_put_Offline,
5232 WebBrowser_get_Silent,
5233 WebBrowser_put_Silent,
5234 WebBrowser_get_RegisterAsBrowser,
5235 WebBrowser_put_RegisterAsBrowser,
5236 WebBrowser_get_RegisterAsDropTarget,
5237 WebBrowser_put_RegisterAsDropTarget,
5238 WebBrowser_get_TheaterMode,
5239 WebBrowser_put_TheaterMode,
5240 WebBrowser_get_AddressBar,
5241 WebBrowser_put_AddressBar,
5242 WebBrowser_get_Resizable,
5243 WebBrowser_put_Resizable
5246 static IWebBrowser2 WebBrowser2 = { &WebBrowser2Vtbl };
5248 static HRESULT wb_qi(REFIID riid, void **ppv)
5250 static const IID IID_IWebBrowserPriv2IE7 = {0x1af32b6c, 0xa3ba,0x48b9,{0xb2,0x4e,0x8a,0xa9,0xc4,0x1f,0x6e,0xcd}};
5251 static const IID IID_IWebBrowserPriv2IE8XP = {0x486f6159,0x9f3f,0x4827,{0x82,0xd4,0x28,0x3c,0xef,0x39,0x77,0x33}};
5252 static const IID IID_WB_undoc = {0xd9befc84,0xf21e,0x4166,{0x87,0x4b,0xa8,0xd3,0x01,0x0d,0xc7,0x64}};
5254 *ppv = NULL;
5256 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IWebBrowser, riid)
5257 || IsEqualGUID(&IID_IWebBrowserApp, riid) || IsEqualGUID(&IID_IWebBrowser2, riid)) {
5258 *ppv = &WebBrowser2;
5259 return S_OK;
5262 if(IsEqualGUID(riid, &IID_IOleObject))
5263 return E_NOINTERFACE; /* TODO */
5265 if(IsEqualGUID(riid, &IID_IConnectionPointContainer)) {
5266 *ppv = &ConnectionPointContainer;
5267 return S_OK;
5270 if(IsEqualGUID(riid, &IID_IWebBrowserPriv)) {
5271 *ppv = &WebBrowserPriv;
5272 return S_OK;
5275 if(IsEqualGUID(riid, &IID_IWebBrowserPriv2IE8)) {
5276 /* IE8 and IE9 versions use the same IID, but have different declarations. */
5277 *ppv = is_ie9plus ? (void*)&WebBrowserPriv2IE9 : (void*)&WebBrowserPriv2IE8;
5278 return S_OK;
5281 if(IsEqualGUID(riid, &IID_IWebBrowserPriv2IE7)) {
5282 trace("QI(IID_IWebBrowserPriv2IE7)\n");
5283 return E_NOINTERFACE;
5286 if(IsEqualGUID(riid, &IID_IWebBrowserPriv2IE8XP)) {
5287 trace("QI(IID_IWebBrowserPriv2IE8XP)\n");
5288 return E_NOINTERFACE;
5291 if(!IsEqualGUID(riid, &IID_WB_undoc))
5292 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
5293 return E_NOINTERFACE;
5296 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface,
5297 REFIID riid, void **ppv)
5299 return QueryInterface(riid, ppv);
5302 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
5304 return 2;
5307 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
5309 return 1;
5312 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
5313 REFIID riid, void **ppv)
5316 * Services used by HTMLDocument:
5318 * IOleUndoManager
5319 * IInternetSecurityManager
5320 * ITargetFrame
5321 * {D5F78C80-5252-11CF-90FA-00AA0042106E}
5322 * HTMLFrameBase
5323 * IShellObject
5324 * {3050F312-98B5-11CF-BB82-00AA00BDCE0B}
5325 * {53A2D5B1-D2FC-11D0-84E0-006097C9987D}
5326 * {AD7F6C62-F6BD-11D2-959B-006097C553C8}
5327 * DefView (?)
5328 * {6D12FE80-7911-11CF-9534-0000C05BAE0B}
5329 * IElementBehaviorFactory
5330 * {3050F429-98B5-11CF-BB82-00AA00BDCE0B}
5331 * STopLevelBrowser
5332 * IHTMLWindow2
5333 * IInternetProtocol
5334 * UrlHistory
5335 * IHTMLEditHost
5336 * IHlinkFrame
5339 if(IsEqualGUID(&IID_IHlinkFrame, guidService)) {
5340 ok(IsEqualGUID(&IID_IHlinkFrame, riid), "unexpected riid\n");
5341 *ppv = &HlinkFrame;
5342 return S_OK;
5345 if(IsEqualGUID(&SID_SNewWindowManager, guidService)) {
5346 ok(IsEqualGUID(&IID_INewWindowManager, riid), "unexpected riid\n");
5347 *ppv = &NewWindowManager;
5348 return S_OK;
5351 if(IsEqualGUID(&IID_IShellBrowser, guidService)) {
5352 ok(IsEqualGUID(&IID_IBrowserService, riid), "unexpected riid\n");
5353 *ppv = &BrowserService;
5354 return S_OK;
5357 if(support_wbapp && IsEqualGUID(&IID_IWebBrowserApp, guidService)) {
5358 if(IsEqualGUID(riid, &IID_IWebBrowser2)) {
5359 *ppv = &WebBrowser2;
5360 return S_OK;
5362 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
5365 return E_NOINTERFACE;
5368 static const IServiceProviderVtbl ServiceProviderVtbl = {
5369 ServiceProvider_QueryInterface,
5370 ServiceProvider_AddRef,
5371 ServiceProvider_Release,
5372 ServiceProvider_QueryService
5375 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
5377 static HRESULT WINAPI AdviseSink_QueryInterface(IAdviseSinkEx *iface,
5378 REFIID riid, void **ppv)
5380 return QueryInterface(riid, ppv);
5383 static ULONG WINAPI AdviseSink_AddRef(IAdviseSinkEx *iface)
5385 return 2;
5388 static ULONG WINAPI AdviseSink_Release(IAdviseSinkEx *iface)
5390 return 1;
5393 static void WINAPI AdviseSink_OnDataChange(IAdviseSinkEx *iface,
5394 FORMATETC *pFormatetc, STGMEDIUM *pStgmed)
5396 ok(0, "unexpected call\n");
5399 static void WINAPI AdviseSink_OnViewChange(IAdviseSinkEx *iface,
5400 DWORD dwAspect, LONG lindex)
5402 ok(0, "unexpected call\n");
5405 static void WINAPI AdviseSink_OnRename(IAdviseSinkEx *iface, IMoniker *pmk)
5407 ok(0, "unexpected call\n");
5410 static void WINAPI AdviseSink_OnSave(IAdviseSinkEx *iface)
5412 ok(0, "unexpected call\n");
5415 static void WINAPI AdviseSink_OnClose(IAdviseSinkEx *iface)
5417 ok(0, "unexpected call\n");
5420 static void WINAPI AdviseSinkEx_OnViewStatusChange(IAdviseSinkEx *iface, DWORD dwViewStatus)
5422 ok(0, "unexpected call\n");
5425 static void WINAPI ObjectAdviseSink_OnClose(IAdviseSinkEx *iface)
5427 CHECK_EXPECT(Advise_Close);
5430 static const IAdviseSinkExVtbl AdviseSinkVtbl = {
5431 AdviseSink_QueryInterface,
5432 AdviseSink_AddRef,
5433 AdviseSink_Release,
5434 AdviseSink_OnDataChange,
5435 AdviseSink_OnViewChange,
5436 AdviseSink_OnRename,
5437 AdviseSink_OnSave,
5438 ObjectAdviseSink_OnClose,
5439 AdviseSinkEx_OnViewStatusChange
5442 static IAdviseSinkEx AdviseSink = { &AdviseSinkVtbl };
5444 static HRESULT WINAPI ViewAdviseSink_QueryInterface(IAdviseSinkEx *iface,
5445 REFIID riid, void **ppv)
5447 if(IsEqualGUID(&IID_IAdviseSinkEx, riid)) {
5448 *ppv = iface;
5449 return S_OK;
5452 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
5453 *ppv = NULL;
5454 return E_NOINTERFACE;
5457 static void WINAPI ViewAdviseSink_OnViewChange(IAdviseSinkEx *iface,
5458 DWORD dwAspect, LONG lindex)
5460 CHECK_EXPECT2(OnViewChange);
5462 ok(dwAspect == DVASPECT_CONTENT, "dwAspect = %ld\n", dwAspect);
5463 ok(lindex == -1, "lindex = %ld\n", lindex);
5466 static const IAdviseSinkExVtbl ViewAdviseSinkVtbl = {
5467 ViewAdviseSink_QueryInterface,
5468 AdviseSink_AddRef,
5469 AdviseSink_Release,
5470 AdviseSink_OnDataChange,
5471 ViewAdviseSink_OnViewChange,
5472 AdviseSink_OnRename,
5473 AdviseSink_OnSave,
5474 AdviseSink_OnClose,
5475 AdviseSinkEx_OnViewStatusChange
5478 static IAdviseSinkEx ViewAdviseSink = { &ViewAdviseSinkVtbl };
5480 DEFINE_GUID(IID_unk1, 0xD48A6EC6,0x6A4A,0x11CF,0x94,0xA7,0x44,0x45,0x53,0x54,0x00,0x00); /* HTMLWindow2 ? */
5481 DEFINE_GUID(IID_IThumbnailView, 0x7BB0B520,0xB1A7,0x11D2,0xBB,0x23,0x00,0xC0,0x4F,0x79,0xAB,0xCD);
5482 DEFINE_GUID(IID_IRenMailEditor, 0x000670BA,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
5483 DEFINE_GUID(IID_unk4, 0x305104a6,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
5484 DEFINE_GUID(IID_IDocHostUIHandlerPriv, 0xf0d241d1,0x5d0e,0x4e85,0xbc,0xb4,0xfa,0xd7,0xf7,0xc5,0x52,0x8c);
5485 DEFINE_GUID(IID_unk5, 0x5f95accc,0xd7a1,0x4574,0xbc,0xcb,0x69,0x71,0x35,0xbc,0x41,0xde);
5487 static HRESULT QueryInterface(REFIID riid, void **ppv)
5489 *ppv = NULL;
5491 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
5492 *ppv = &ClientSite;
5493 else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
5494 *ppv = &DocumentSite;
5495 else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid))
5496 *ppv = &DocHostUIHandler;
5497 else if(IsEqualGUID(&IID_IOleContainer, riid))
5498 *ppv = &OleContainer;
5499 else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
5500 *ppv = &InPlaceSiteWindowless;
5501 else if(IsEqualGUID(&IID_IOleCommandTarget , riid))
5502 *ppv = &OleCommandTarget;
5503 else if(IsEqualGUID(&IID_IDispatch, riid))
5504 *ppv = &Dispatch;
5505 else if(IsEqualGUID(&IID_IServiceProvider, riid))
5506 *ppv = &ServiceProvider;
5507 else if(IsEqualGUID(&IID_IOleInPlaceSiteEx, riid))
5508 *ppv = ipsex ? &InPlaceSiteWindowless : NULL;
5509 else if(IsEqualGUID(&IID_IOleInPlaceSiteWindowless, riid))
5510 *ppv = ipsw ? &InPlaceSiteWindowless : NULL;
5511 else if(IsEqualGUID(&IID_IOleControlSite, riid))
5512 *ppv = &OleControlSite;
5513 else if(IsEqualGUID(&IID_IDocHostShowUI, riid))
5514 return E_NOINTERFACE; /* TODO */
5515 else if(IsEqualGUID(&IID_IProxyManager, riid))
5516 return E_NOINTERFACE; /* ? */
5517 else if(IsEqualGUID(&IID_unk1, riid))
5518 return E_NOINTERFACE; /* HTMLWindow2 ? */
5519 else if(IsEqualGUID(&IID_IThumbnailView, riid))
5520 return E_NOINTERFACE; /* ? */
5521 else if(IsEqualGUID(&IID_IRenMailEditor, riid))
5522 return E_NOINTERFACE; /* ? */
5523 else if(IsEqualGUID(&IID_unk4, riid))
5524 return E_NOINTERFACE; /* ? */
5525 else if(IsEqualGUID(&IID_unk5, riid))
5526 return E_NOINTERFACE; /* IE10 */
5527 else if(IsEqualGUID(&IID_IDocHostUIHandlerPriv, riid))
5528 return E_NOINTERFACE; /* ? */
5529 else if(winetest_debug > 1)
5530 trace("QI(%s)\n", wine_dbgstr_guid(riid));
5532 if(*ppv)
5533 return S_OK;
5534 return E_NOINTERFACE;
5537 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
5539 if(msg == WM_CONTINUE_BINDING) {
5540 IBindStatusCallback *callback = (IBindStatusCallback*)wParam;
5541 continue_binding(callback);
5544 return DefWindowProcW(hwnd, msg, wParam, lParam);
5547 static void test_doscroll(IUnknown *unk)
5549 IHTMLDocument3 *doc;
5550 IHTMLElement2 *elem2;
5551 IHTMLElement *elem;
5552 VARIANT v;
5553 HRESULT hres;
5555 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument3, (void**)&doc);
5556 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08lx\n", hres);
5557 if(FAILED(hres))
5558 return;
5560 hres = IHTMLDocument3_get_documentElement(doc, &elem);
5561 IHTMLDocument3_Release(doc);
5562 ok(hres == S_OK, "get_documentElement failed: %08lx\n", hres);
5563 switch(load_state) {
5564 case LD_DOLOAD:
5565 case LD_NO:
5566 if(!nav_url && !editmode)
5567 ok(!elem, "elem != NULL\n");
5568 default:
5569 break;
5570 case LD_INTERACTIVE:
5571 case LD_COMPLETE:
5572 ok(elem != NULL, "elem == NULL\n");
5574 if(!elem)
5575 return;
5577 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
5578 IHTMLElement_Release(elem);
5579 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08lx\n", hres);
5581 V_VT(&v) = VT_BSTR;
5582 V_BSTR(&v) = SysAllocString(L"left");
5583 hres = IHTMLElement2_doScroll(elem2, v);
5584 SysFreeString(V_BSTR(&v));
5585 IHTMLElement2_Release(elem2);
5587 if(inplace_deactivated)
5588 ok(hres == E_PENDING, "doScroll failed: %08lx\n", hres);
5589 else if(load_state == LD_COMPLETE)
5590 ok(hres == S_OK, "doScroll failed: %08lx\n", hres);
5591 else
5592 ok(hres == E_PENDING || hres == S_OK, "doScroll failed: %08lx\n", hres);
5595 static void _test_readyState(unsigned line, IUnknown *unk)
5597 IHTMLDocument2 *htmldoc;
5598 DISPPARAMS dispparams;
5599 IDispatchEx *dispex;
5600 IHTMLElement *elem;
5601 BSTR state;
5602 VARIANT out;
5603 HRESULT hres;
5605 static const LPCWSTR expected_state[] = {
5606 L"uninitialized",
5607 L"loading",
5608 NULL,
5609 L"interactive",
5610 L"complete",
5611 L"uninitialized"
5614 if(open_call || resetting_document)
5615 return; /* FIXME */
5617 if(!unk)
5618 unk = doc_unk;
5620 hres = IUnknown_QueryInterface(unk, &IID_IHTMLDocument2, (void**)&htmldoc);
5621 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument2) failed: %08lx\n", hres);
5622 if(FAILED(hres))
5623 return;
5625 hres = IHTMLDocument2_get_readyState(htmldoc, NULL);
5626 ok(hres == E_POINTER, "get_readyState failed: %08lx, expected\n", hres);
5628 hres = IHTMLDocument2_get_readyState(htmldoc, &state);
5629 ok(hres == S_OK, "get_ReadyState failed: %08lx\n", hres);
5631 if(!lstrcmpW(state, L"interactive") && load_state == LD_LOADING)
5632 load_state = LD_INTERACTIVE;
5634 ok_(__FILE__, line)
5635 (!lstrcmpW(state, expected_state[load_state]), "unexpected state %s, expected %d\n",
5636 wine_dbgstr_w(state), load_state);
5637 SysFreeString(state);
5639 hres = IHTMLDocument2_get_body(htmldoc, &elem);
5640 ok_(__FILE__,line)(hres == S_OK, "get_body failed: %08lx\n", hres);
5641 if(elem) {
5642 IHTMLElement2 *elem2;
5643 VARIANT var;
5645 hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLElement2, (void**)&elem2);
5646 IHTMLElement_Release(elem);
5647 ok(hres == S_OK, "Could not get IHTMLElement2 iface: %08lx\n", hres);
5649 hres = IHTMLElement2_get_readyState(elem2, &var);
5650 IHTMLElement2_Release(elem2);
5651 ok(hres == S_OK, "get_readyState failed: %08lx\n", hres);
5652 ok(V_VT(&var) == VT_BSTR, "V_VT(state) = %d\n", V_VT(&var));
5653 ok(!lstrcmpW(V_BSTR(&var), L"complete"), "unexpected body state %s\n", wine_dbgstr_w(V_BSTR(&var)));
5654 VariantClear(&var);
5655 }else {
5656 ok_(__FILE__,line)(load_state != LD_COMPLETE, "body is NULL in complete state\n");
5659 dispparams.cArgs = 0;
5660 dispparams.cNamedArgs = 0;
5661 dispparams.rgdispidNamedArgs = NULL;
5662 dispparams.rgvarg = NULL;
5664 VariantInit(&out);
5666 hres = IHTMLDocument2_Invoke(htmldoc, DISPID_READYSTATE, &IID_NULL, 0, DISPATCH_PROPERTYGET,
5667 &dispparams, &out, NULL, NULL);
5668 ok(hres == S_OK, "Invoke(DISPID_READYSTATE) failed: %08lx\n", hres);
5670 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
5671 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%ld, expected %d\n", V_I4(&out), load_state%5);
5673 hres = IHTMLDocument2_QueryInterface(htmldoc, &IID_IDispatchEx, (void**)&dispex);
5674 ok(hres == S_OK, "QueryInterface(IID_IDispatchEx) failed: %08lx\n", hres);
5675 hres = IDispatchEx_InvokeEx(dispex, DISPID_READYSTATE, 0, DISPATCH_PROPERTYGET, &dispparams, &out, NULL, NULL);
5676 ok(hres == S_OK, "InvokeEx(DISPID_READYSTATE) failed: %08lx\n", hres);
5677 IDispatchEx_Release(dispex);
5679 ok_(__FILE__,line) (V_VT(&out) == VT_I4, "V_VT(out)=%d\n", V_VT(&out));
5680 ok_(__FILE__,line) (V_I4(&out) == load_state%5, "VT_I4(out)=%ld, expected %d\n", V_I4(&out), load_state%5);
5682 test_doscroll((IUnknown*)htmldoc);
5684 IHTMLDocument2_Release(htmldoc);
5687 static void test_ViewAdviseSink(IHTMLDocument2 *doc)
5689 IViewObject *view;
5690 HRESULT hres;
5692 hres = IHTMLDocument2_QueryInterface(doc, &IID_IViewObject, (void**)&view);
5693 ok(hres == S_OK, "QueryInterface(IID_IViewObject) failed: %08lx\n", hres);
5695 hres = IViewObject_SetAdvise(view, DVASPECT_CONTENT, ADVF_PRIMEFIRST, (IAdviseSink*)&ViewAdviseSink);
5696 ok(hres == S_OK, "SetAdvise failed: %08lx\n", hres);
5698 IViewObject_Release(view);
5701 static void test_ConnectionPoint(IConnectionPointContainer *container, REFIID riid)
5703 IConnectionPointContainer *tmp_container = NULL;
5704 IConnectionPoint *cp;
5705 IID iid;
5706 HRESULT hres;
5707 DWORD cookie;
5709 hres = IConnectionPointContainer_FindConnectionPoint(container, riid, &cp);
5710 ok(hres == S_OK, "FindConnectionPoint failed: %08lx\n", hres);
5711 if(FAILED(hres))
5712 return;
5714 hres = IConnectionPoint_GetConnectionInterface(cp, &iid);
5715 ok(hres == S_OK, "GetConnectionInterface failed: %08lx\n", hres);
5716 ok(IsEqualGUID(riid, &iid), "wrong iid\n");
5718 hres = IConnectionPoint_GetConnectionInterface(cp, NULL);
5719 ok(hres == E_POINTER, "GetConnectionInterface failed: %08lx, expected E_POINTER\n", hres);
5721 hres = IConnectionPoint_GetConnectionPointContainer(cp, &tmp_container);
5722 ok(hres == S_OK, "GetConnectionPointContainer failed: %08lx\n", hres);
5723 ok(tmp_container == container, "container != tmp_container\n");
5724 if(SUCCEEDED(hres))
5725 IConnectionPointContainer_Release(tmp_container);
5727 hres = IConnectionPoint_GetConnectionPointContainer(cp, NULL);
5728 ok(hres == E_POINTER, "GetConnectionPointContainer failed: %08lx, expected E_POINTER\n", hres);
5730 if(IsEqualGUID(&IID_IPropertyNotifySink, riid)) {
5731 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, &cookie);
5732 ok(hres == S_OK, "Advise failed: %08lx\n", hres);
5733 hres = IConnectionPoint_Unadvise(cp, cookie);
5734 ok(hres == S_OK, "Unadvise failed: %08lx\n", hres);
5735 hres = IConnectionPoint_Advise(cp, (IUnknown*)&PropertyNotifySink, NULL);
5736 ok(hres == S_OK, "Advise failed: %08lx\n", hres);
5737 } else if(IsEqualGUID(&IID_IDispatch, riid)) {
5738 IEnumConnections *enum_conn;
5739 CONNECTDATA conn_data;
5740 ULONG fetched;
5742 hres = IConnectionPoint_Advise(cp, (IUnknown*)&EventDispatch, &cookie);
5743 ok(hres == S_OK, "Advise failed: %08lx\n", hres);
5745 hres = IConnectionPoint_EnumConnections(cp, &enum_conn);
5746 ok(hres == S_OK, "EnumConnections failed: %08lx\n", hres);
5748 fetched = 0;
5749 hres = IEnumConnections_Next(enum_conn, 1, &conn_data, &fetched);
5750 ok(hres == S_OK, "Next failed: %08lx\n", hres);
5751 ok(conn_data.pUnk == (IUnknown*)&EventDispatch, "conn_data.pUnk == EventDispatch\n");
5752 ok(conn_data.dwCookie == cookie, "conn_data.dwCookie != cookie\n");
5753 IUnknown_Release(conn_data.pUnk);
5755 fetched = 0xdeadbeef;
5756 hres = IEnumConnections_Next(enum_conn, 1, &conn_data, &fetched);
5757 ok(hres == S_FALSE, "Next failed: %08lx\n", hres);
5758 ok(!fetched, "fetched = %ld\n", fetched);
5760 IEnumConnections_Release(enum_conn);
5763 IConnectionPoint_Release(cp);
5766 static void test_ConnectionPointContainer(IHTMLDocument2 *doc)
5768 IConnectionPointContainer *container;
5769 HRESULT hres;
5771 hres = IHTMLDocument2_QueryInterface(doc, &IID_IConnectionPointContainer, (void**)&container);
5772 ok(hres == S_OK, "QueryInterface(IID_IConnectionPointContainer) failed: %08lx\n", hres);
5773 if(FAILED(hres))
5774 return;
5776 test_ConnectionPoint(container, &IID_IDispatch);
5777 test_ConnectionPoint(container, &IID_IPropertyNotifySink);
5778 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents);
5779 test_ConnectionPoint(container, &DIID_HTMLDocumentEvents2);
5781 IConnectionPointContainer_Release(container);
5784 static void set_custom_uihandler(IHTMLDocument2 *doc, IDocHostUIHandler2 *uihandler)
5786 ICustomDoc *custom_doc;
5787 HRESULT hres;
5789 hres = IHTMLDocument2_QueryInterface(doc, &IID_ICustomDoc, (void**)&custom_doc);
5790 ok(hres == S_OK, "Could not get ICustomDoc iface: %08lx\n", hres);
5792 expect_uihandler_iface = uihandler;
5794 hres = ICustomDoc_SetUIHandler(custom_doc, (IDocHostUIHandler*)uihandler);
5795 ICustomDoc_Release(custom_doc);
5796 ok(hres == S_OK, "SetUIHandler failed: %08lx\n", hres);
5799 static void test_Load(IPersistMoniker *persist, IMoniker *mon)
5801 IBindCtx *bind;
5802 HRESULT hres;
5803 WCHAR sz_html_clientsite_objectparam[MAX_PATH];
5805 lstrcpyW(sz_html_clientsite_objectparam, SZ_HTML_CLIENTSITE_OBJECTPARAM);
5807 test_readyState((IUnknown*)persist);
5809 doc_mon = mon;
5811 CreateBindCtx(0, &bind);
5812 IBindCtx_RegisterObjectParam(bind, sz_html_clientsite_objectparam,
5813 (IUnknown*)&ClientSite);
5815 if(mon == &Moniker)
5816 SET_EXPECT(GetDisplayName);
5817 if(!set_clientsite) {
5818 SET_EXPECT(Invoke_AMBIENT_USERMODE);
5819 SET_EXPECT(GetHostInfo);
5820 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
5821 SET_EXPECT(Invoke_AMBIENT_SILENT);
5822 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5823 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
5824 SET_EXPECT(Invoke_AMBIENT_PALETTE);
5825 SET_EXPECT(GetOptionKeyPath);
5826 SET_EXPECT(GetOverrideKeyPath);
5827 SET_EXPECT(GetWindow);
5828 SET_EXPECT(Exec_DOCCANNAVIGATE);
5829 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
5830 SET_EXPECT(Exec_SETPROGRESSMAX);
5831 SET_EXPECT(Exec_SETPROGRESSPOS);
5832 SET_EXPECT(Exec_ShellDocView_37);
5834 if(!container_locked) {
5835 SET_EXPECT(GetContainer);
5836 SET_EXPECT(LockContainer);
5838 SET_EXPECT(OnChanged_READYSTATE);
5839 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
5840 SET_EXPECT(IsSystemMoniker);
5841 if(!is_mhtml && mon == &Moniker)
5842 SET_EXPECT(BindToStorage);
5843 SET_EXPECT(SetActiveObject);
5844 if(set_clientsite) {
5845 SET_EXPECT(Invoke_AMBIENT_SILENT);
5846 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5847 SET_EXPECT(Exec_ShellDocView_37);
5848 SET_EXPECT(IsErrorUrl);
5849 }else {
5850 SET_EXPECT(GetTravelLog);
5852 SET_EXPECT(Exec_ShellDocView_84);
5853 SET_EXPECT(GetPendingUrl);
5854 if(is_mhtml) {
5855 SET_EXPECT(CreateInstance);
5856 SET_EXPECT(Start);
5857 SET_EXPECT(Protocol_Read);
5858 SET_EXPECT(LockRequest);
5859 SET_EXPECT(Terminate);
5860 SET_EXPECT(UnlockRequest);
5862 load_state = LD_DOLOAD;
5863 expect_LockContainer_fLock = TRUE;
5864 readystate_set_loading = TRUE;
5866 hres = IPersistMoniker_Load(persist, FALSE, mon, bind, 0x12);
5867 ok(hres == S_OK, "Load failed: %08lx\n", hres);
5869 if(mon == &Moniker)
5870 CHECK_CALLED(GetDisplayName);
5871 if(!set_clientsite) {
5872 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
5873 CHECK_CALLED(GetHostInfo);
5874 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
5875 CHECK_CALLED(Invoke_AMBIENT_SILENT);
5876 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5877 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
5878 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* not called on IE9 */
5879 CLEAR_CALLED(GetOptionKeyPath); /* not called on some IE9 */
5880 CHECK_CALLED(GetOverrideKeyPath);
5881 CHECK_CALLED(GetWindow);
5882 CHECK_CALLED(Exec_DOCCANNAVIGATE);
5883 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
5884 CHECK_CALLED(Exec_SETPROGRESSMAX);
5885 CHECK_CALLED(Exec_SETPROGRESSPOS);
5886 CHECK_CALLED(Exec_ShellDocView_37);
5888 if(!container_locked) {
5889 CHECK_CALLED(GetContainer);
5890 CHECK_CALLED(LockContainer);
5891 container_locked = TRUE;
5893 CHECK_CALLED(OnChanged_READYSTATE);
5894 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
5895 CLEAR_CALLED(IsSystemMoniker); /* IE7 */
5896 if(!is_mhtml && mon == &Moniker)
5897 CHECK_CALLED(BindToStorage);
5898 CLEAR_CALLED(SetActiveObject); /* FIXME */
5899 if(set_clientsite) {
5900 CHECK_CALLED(Invoke_AMBIENT_SILENT);
5901 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5902 CHECK_CALLED(Exec_ShellDocView_37);
5903 todo_wine CHECK_CALLED_BROKEN(IsErrorUrl);
5904 }else {
5905 CHECK_CALLED(GetTravelLog);
5907 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
5908 todo_wine CHECK_CALLED(GetPendingUrl);
5909 if(is_mhtml) {
5910 CHECK_CALLED(CreateInstance);
5911 CHECK_CALLED(Start);
5912 CHECK_CALLED(Protocol_Read);
5913 CHECK_CALLED(LockRequest);
5914 CHECK_CALLED(Terminate);
5915 CHECK_CALLED(UnlockRequest);
5918 set_clientsite = container_locked = TRUE;
5920 if(!is_mhtml)
5921 test_GetCurMoniker((IUnknown*)persist, mon, NULL, FALSE);
5922 else
5923 test_GetCurMoniker((IUnknown*)persist, NULL, L"mhtml:winetest:doc", FALSE);
5925 IBindCtx_Release(bind);
5927 test_readyState((IUnknown*)persist);
5930 #define DWL_VERBDONE 0x0001
5931 #define DWL_CSS 0x0002
5932 #define DWL_TRYCSS 0x0004
5933 #define DWL_HTTP 0x0008
5934 #define DWL_EMPTY 0x0010
5935 #define DWL_JAVASCRIPT 0x0020
5936 #define DWL_ONREADY_LOADING 0x0040
5937 #define DWL_EXPECT_HISTUPDATE 0x0080
5938 #define DWL_FROM_HISTORY 0x0100
5939 #define DWL_REFRESH 0x0200
5940 #define DWL_EX_GETHOSTINFO 0x0400
5941 #define DWL_EXTERNAL 0x0800
5943 static void test_download(DWORD flags)
5945 const BOOL is_extern = (flags & DWL_EXTERNAL) != 0;
5946 const BOOL is_js = (flags & DWL_JAVASCRIPT) != 0;
5947 HWND hwnd;
5948 BOOL *b;
5949 MSG msg;
5951 if(is_js)
5952 b = &called_Exec_SETDOWNLOADSTATE_0;
5953 else if(is_extern)
5954 b = &called_NavigateWithBindCtx;
5955 else
5956 b = &called_Exec_HTTPEQUIV_DONE;
5957 is_refresh = (flags & DWL_REFRESH) != 0;
5958 is_from_hist = (flags & DWL_FROM_HISTORY) != 0;
5960 hwnd = FindWindowA("Internet Explorer_Hidden", NULL);
5961 ok(hwnd != NULL, "Could not find hidden window\n");
5963 test_readyState(NULL);
5965 if(flags & DWL_REFRESH) {
5966 SET_EXPECT(Invoke_AMBIENT_SILENT);
5967 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
5969 if(is_mhtml || (flags & (DWL_VERBDONE|DWL_HTTP)))
5970 SET_EXPECT(Exec_SETPROGRESSMAX);
5971 if(flags & DWL_EX_GETHOSTINFO)
5972 SET_EXPECT(GetHostInfo);
5973 SET_EXPECT(SetStatusText);
5974 if(!(flags & DWL_EMPTY))
5975 SET_EXPECT(Exec_SETDOWNLOADSTATE_1);
5976 if(is_js)
5977 SET_EXPECT(GetExternal);
5978 SET_EXPECT(OnViewChange);
5979 SET_EXPECT(GetDropTarget);
5980 if((flags & DWL_TRYCSS) && !(flags & DWL_EMPTY))
5981 SET_EXPECT(Exec_ShellDocView_84);
5982 if(flags & DWL_CSS) {
5983 SET_EXPECT(CreateInstance);
5984 SET_EXPECT(Start);
5985 SET_EXPECT(LockRequest);
5986 SET_EXPECT(Terminate);
5987 SET_EXPECT(Protocol_Read);
5988 SET_EXPECT(UnlockRequest);
5990 if(flags & DWL_ONREADY_LOADING)
5991 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
5992 if(!(flags & (DWL_EMPTY|DWL_JAVASCRIPT)))
5993 SET_EXPECT(Invoke_OnReadyStateChange_Interactive);
5994 if(!is_js && !is_extern)
5995 SET_EXPECT(Invoke_OnReadyStateChange_Complete);
5996 SET_EXPECT(Exec_Explorer_69);
5997 SET_EXPECT(EnableModeless_TRUE); /* IE7 */
5998 SET_EXPECT(Frame_EnableModeless_TRUE); /* IE7 */
5999 SET_EXPECT(EnableModeless_FALSE); /* IE7 */
6000 SET_EXPECT(Frame_EnableModeless_FALSE); /* IE7 */
6001 if((nav_url && !is_js && !is_extern) || (flags & (DWL_CSS|DWL_HTTP)))
6002 SET_EXPECT(Exec_ShellDocView_37);
6003 if(flags & DWL_HTTP) {
6004 if(!(flags & DWL_FROM_HISTORY))
6005 SET_EXPECT(OnChanged_1012);
6006 SET_EXPECT(Exec_HTTPEQUIV);
6007 SET_EXPECT(Exec_SETTITLE);
6009 if(!is_js && !is_extern)
6010 SET_EXPECT(OnChanged_1005);
6011 SET_EXPECT(OnChanged_READYSTATE);
6012 SET_EXPECT(Exec_SETPROGRESSPOS);
6013 if(!(flags & DWL_EMPTY))
6014 SET_EXPECT(Exec_SETDOWNLOADSTATE_0);
6015 SET_EXPECT(Exec_ShellDocView_103);
6016 SET_EXPECT(Exec_ShellDocView_105);
6017 SET_EXPECT(Exec_ShellDocView_140);
6018 if(!is_js && !is_extern) {
6019 SET_EXPECT(Exec_MSHTML_PARSECOMPLETE);
6020 if(support_wbapp) /* Called on some Vista installations */
6021 SET_EXPECT(CountEntries);
6022 SET_EXPECT(Exec_HTTPEQUIV_DONE);
6024 if(nav_url || support_wbapp || editmode) {
6025 SET_EXPECT(UpdateUI);
6026 SET_EXPECT(Exec_UPDATECOMMANDS);
6027 SET_EXPECT(Exec_SETTITLE);
6029 if(nav_url || support_wbapp) {
6030 if(flags & DWL_EXPECT_HISTUPDATE)
6031 SET_EXPECT(Exec_Explorer_38);
6032 SET_EXPECT(UpdateBackForwardState);
6034 if(!is_js && !is_extern) {
6035 if(!editmode && !(flags & DWL_REFRESH)) {
6036 if(!is_mhtml && !(flags & DWL_EMPTY))
6037 SET_EXPECT(FireNavigateComplete2);
6038 SET_EXPECT(FireDocumentComplete);
6040 SET_EXPECT(ActiveElementChanged);
6042 SET_EXPECT(IsErrorUrl);
6043 if(is_extern) {
6044 SET_EXPECT(Exec_ShellDocView_62);
6045 SET_EXPECT(Exec_DOCCANNAVIGATE_NULL);
6046 SET_EXPECT(NavigateWithBindCtx);
6047 SET_EXPECT(Exec_Explorer_38); /* todo_wine */
6049 if(editmode || is_refresh)
6050 SET_EXPECT(Exec_ShellDocView_138);
6051 expect_status_text = (LPWSTR)0xdeadbeef; /* TODO */
6053 while(!*b && GetMessageW(&msg, NULL, 0, 0)) {
6054 TranslateMessage(&msg);
6055 DispatchMessageA(&msg);
6058 if(flags & DWL_REFRESH) {
6059 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6060 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6062 if(is_mhtml || (flags & DWL_VERBDONE))
6063 CHECK_CALLED(Exec_SETPROGRESSMAX);
6064 if(flags & DWL_HTTP)
6065 SET_CALLED(Exec_SETPROGRESSMAX);
6066 if(flags & DWL_EX_GETHOSTINFO) {
6067 todo_wine_if(nav_url)
6068 CHECK_CALLED(GetHostInfo);
6070 CHECK_CALLED(SetStatusText);
6071 if(!(flags & DWL_EMPTY))
6072 CHECK_CALLED(Exec_SETDOWNLOADSTATE_1);
6073 if(is_js)
6074 CHECK_CALLED(GetExternal);
6075 CHECK_CALLED(OnViewChange);
6076 CLEAR_CALLED(GetDropTarget);
6077 if((flags & DWL_TRYCSS) && !(flags & DWL_EMPTY))
6078 todo_wine CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6079 if(flags & DWL_CSS) {
6080 CHECK_CALLED(CreateInstance);
6081 CHECK_CALLED(Start);
6082 CHECK_CALLED(LockRequest);
6083 CHECK_CALLED(Terminate);
6084 CHECK_CALLED(Protocol_Read);
6085 CHECK_CALLED(UnlockRequest);
6087 if(flags & DWL_ONREADY_LOADING)
6088 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
6089 if(!(flags & (DWL_EMPTY|DWL_JAVASCRIPT))) {
6090 todo_wine_if(is_extern)
6091 CHECK_CALLED(Invoke_OnReadyStateChange_Interactive);
6093 if(!is_js && !is_extern)
6094 CHECK_CALLED(Invoke_OnReadyStateChange_Complete);
6095 SET_CALLED(Exec_Explorer_69);
6096 SET_CALLED(EnableModeless_TRUE); /* IE7 */
6097 SET_CALLED(Frame_EnableModeless_TRUE); /* IE7 */
6098 SET_CALLED(EnableModeless_FALSE); /* IE7 */
6099 SET_CALLED(Frame_EnableModeless_FALSE); /* IE7 */
6100 if(nav_url && !is_js && !is_extern && !(flags & DWL_REFRESH))
6101 todo_wine CHECK_CALLED(Exec_ShellDocView_37);
6102 else if(flags & (DWL_CSS|DWL_HTTP))
6103 CLEAR_CALLED(Exec_ShellDocView_37); /* Called by IE9 */
6104 if(flags & DWL_HTTP) {
6105 if(!(flags & DWL_FROM_HISTORY))
6106 todo_wine CHECK_CALLED(OnChanged_1012);
6107 todo_wine CHECK_CALLED(Exec_HTTPEQUIV);
6108 todo_wine_if(!(flags & DWL_REFRESH))
6109 CHECK_CALLED(Exec_SETTITLE);
6111 if(!is_js) {
6112 if(!is_extern)
6113 CHECK_CALLED(OnChanged_1005);
6114 CHECK_CALLED(OnChanged_READYSTATE);
6115 CHECK_CALLED(Exec_SETPROGRESSPOS);
6116 }else {
6117 CLEAR_CALLED(OnChanged_READYSTATE); /* sometimes called */
6118 todo_wine CHECK_CALLED(Exec_SETPROGRESSPOS);
6120 if(!(flags & DWL_EMPTY)) {
6121 todo_wine_if(is_extern)
6122 CHECK_CALLED(Exec_SETDOWNLOADSTATE_0);
6124 CLEAR_CALLED(Exec_ShellDocView_103);
6125 CLEAR_CALLED(Exec_ShellDocView_105);
6126 CLEAR_CALLED(Exec_ShellDocView_140);
6127 if(!is_js && !is_extern) {
6128 CHECK_CALLED(Exec_MSHTML_PARSECOMPLETE);
6129 if(support_wbapp) /* Called on some Vista installations */
6130 CLEAR_CALLED(CountEntries);
6131 CHECK_CALLED(Exec_HTTPEQUIV_DONE);
6133 SET_CALLED(SetStatusText);
6134 if(nav_url || support_wbapp || editmode) { /* avoiding race, FIXME: find better way */
6135 CLEAR_CALLED(UpdateUI);
6136 CLEAR_CALLED(Exec_UPDATECOMMANDS);
6137 CLEAR_CALLED(Exec_SETTITLE);
6139 if(nav_url || support_wbapp) {
6140 if(flags & DWL_EXPECT_HISTUPDATE) {
6141 if(flags & DWL_FROM_HISTORY)
6142 CHECK_CALLED_BROKEN(Exec_Explorer_38); /* Some old IEs don't call it. */
6143 else
6144 CHECK_CALLED(Exec_Explorer_38);
6146 todo_wine CHECK_CALLED_BROKEN(UpdateBackForwardState);
6148 if(!is_js && !is_extern) {
6149 if(!editmode && !(flags & DWL_REFRESH)) {
6150 if(!is_mhtml && !(flags & DWL_EMPTY)) {
6151 todo_wine_if(!support_wbapp)
6152 CHECK_CALLED(FireNavigateComplete2);
6154 CHECK_CALLED(FireDocumentComplete);
6156 todo_wine CHECK_CALLED(ActiveElementChanged);
6158 todo_wine CHECK_CALLED_BROKEN(IsErrorUrl);
6159 if(is_extern) {
6160 CHECK_CALLED(Exec_ShellDocView_62);
6161 CHECK_CALLED(Exec_DOCCANNAVIGATE_NULL);
6162 CHECK_CALLED(NavigateWithBindCtx);
6163 todo_wine CHECK_NOT_CALLED(Exec_Explorer_38);
6165 if(editmode || is_refresh)
6166 CLEAR_CALLED(Exec_ShellDocView_138); /* IE11 */
6168 if(!is_extern)
6169 load_state = LD_COMPLETE;
6171 test_readyState(NULL);
6174 static void test_Persist(IHTMLDocument2 *doc, IMoniker *mon)
6176 IPersistMoniker *persist_mon;
6177 IPersistFile *persist_file;
6178 GUID guid;
6179 HRESULT hres;
6181 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistFile, (void**)&persist_file);
6182 ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
6183 if(SUCCEEDED(hres)) {
6184 hres = IPersistFile_GetClassID(persist_file, NULL);
6185 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
6187 hres = IPersistFile_GetClassID(persist_file, &guid);
6188 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
6189 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
6191 IPersistFile_Release(persist_file);
6194 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker, (void**)&persist_mon);
6195 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
6196 if(SUCCEEDED(hres)) {
6197 hres = IPersistMoniker_GetClassID(persist_mon, NULL);
6198 ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
6200 hres = IPersistMoniker_GetClassID(persist_mon, &guid);
6201 ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
6202 ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
6204 if(load_state == LD_DOLOAD)
6205 test_Load(persist_mon, mon);
6207 test_readyState((IUnknown*)doc);
6209 IPersistMoniker_Release(persist_mon);
6213 static void test_put_href(IHTMLDocument2 *doc, BOOL use_replace, const WCHAR *href, const WCHAR *new_nav_url, BOOL is_js,
6214 BOOL is_hash, DWORD dwl_flags)
6216 const WCHAR *prev_nav_url = NULL;
6217 IHTMLPrivateWindow *priv_window;
6218 IHTMLLocation *location;
6219 IHTMLWindow2 *window;
6220 BSTR str, str2;
6221 HRESULT hres;
6223 trace("put_href %s...\n", wine_dbgstr_w(new_nav_url));
6225 loading_js = is_js;
6226 loading_hash = is_hash;
6228 location = NULL;
6229 hres = IHTMLDocument2_get_location(doc, &location);
6230 ok(hres == S_OK, "get_location failed: %08lx\n", hres);
6231 ok(location != NULL, "location == NULL\n");
6233 prev_url = prev_nav_url = nav_url;
6234 nav_url = new_nav_url;
6235 if(!loading_hash)
6236 nav_serv_url = new_nav_url;
6237 if(!href)
6238 href = new_nav_url;
6240 str = SysAllocString(href);
6241 SET_EXPECT(TranslateUrl);
6242 if(support_wbapp) {
6243 SET_EXPECT(FireBeforeNavigate2);
6244 SET_EXPECT(Exec_ShellDocView_67);
6245 if(!is_hash) {
6246 SET_EXPECT(Invoke_AMBIENT_SILENT);
6247 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6248 SET_EXPECT(Exec_ShellDocView_63);
6249 SET_EXPECT(Exec_ShellDocView_84);
6250 }else {
6251 SET_EXPECT(FireNavigateComplete2);
6252 SET_EXPECT(FireDocumentComplete);
6254 }else {
6255 SET_EXPECT(Navigate);
6257 if(use_replace) {
6258 hres = IHTMLLocation_replace(location, str);
6259 ok(hres == S_OK, "put_href failed: %08lx\n", hres);
6260 }else {
6261 hres = IHTMLLocation_put_href(location, str);
6262 if(is_js && hres == E_ACCESSDENIED)
6263 win_skip("put_href: got E_ACCESSDENIED\n");
6264 else
6265 ok(hres == S_OK, "put_href failed: %08lx\n", hres);
6267 SysFreeString(str);
6268 if(hres == S_OK) {
6269 CHECK_CALLED(TranslateUrl);
6270 if(support_wbapp) {
6271 CHECK_CALLED(FireBeforeNavigate2);
6272 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6273 if(!is_hash) {
6274 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6275 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6276 CHECK_CALLED(Exec_ShellDocView_63);
6277 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6278 }else {
6279 CHECK_CALLED(FireNavigateComplete2);
6280 CHECK_CALLED(FireDocumentComplete);
6282 }else {
6283 CHECK_CALLED(Navigate);
6285 }else {
6286 CLEAR_CALLED(TranslateUrl);
6287 if(support_wbapp) {
6288 CLEAR_CALLED(FireBeforeNavigate2);
6289 SET_CALLED(Exec_ShellDocView_67);
6290 if(!is_hash) {
6291 CLEAR_CALLED(Invoke_AMBIENT_SILENT);
6292 CLEAR_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6293 CLEAR_CALLED(Exec_ShellDocView_63);
6294 todo_wine CLEAR_CALLED(Exec_ShellDocView_84);
6295 }else {
6296 CLEAR_CALLED(FireNavigateComplete2);
6297 CLEAR_CALLED(FireDocumentComplete);
6299 }else {
6300 CLEAR_CALLED(Navigate);
6304 IHTMLLocation_Release(location);
6306 if(is_js && hres == E_ACCESSDENIED) {
6307 nav_url = prev_nav_url;
6308 return;
6311 hres = IHTMLDocument2_get_parentWindow(doc, &window);
6312 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
6314 hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window);
6315 IHTMLWindow2_Release(window);
6316 ok(hres == S_OK, "QueryInterface(IID_IHTMLPrivateWindow) failed: %08lx\n", hres);
6318 if(!support_wbapp) {
6319 VARIANT vempty;
6321 readystate_set_loading = TRUE;
6322 SET_EXPECT(TranslateUrl);
6323 SET_EXPECT(Exec_ShellDocView_67);
6324 SET_EXPECT(Invoke_AMBIENT_SILENT);
6325 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6326 SET_EXPECT(Exec_ShellDocView_63);
6327 SET_EXPECT(Exec_ShellDocView_84);
6329 str = SysAllocString(nav_url);
6330 str2 = SysAllocString(L"");
6331 V_VT(&vempty) = VT_EMPTY;
6332 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, str2, NULL, NULL, &vempty, &vempty, 0);
6333 SysFreeString(str);
6334 SysFreeString(str2);
6335 ok(hres == S_OK, "SuperNavigate failed: %08lx\n", hres);
6337 CHECK_CALLED(TranslateUrl);
6338 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6339 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6340 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6341 CHECK_CALLED(Exec_ShellDocView_63);
6342 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6345 if(doc_mon) {
6346 test_GetCurMoniker(doc_unk, doc_mon, NULL, FALSE);
6347 doc_mon = NULL;
6350 if(!is_hash) {
6351 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str2);
6352 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6353 ok(!lstrcmpW(str2, prev_nav_url), "unexpected address bar url: %s, expected %s\n", wine_dbgstr_w(str2),
6354 wine_dbgstr_w(prev_nav_url));
6355 SysFreeString(str2);
6357 if(is_js) {
6358 ignore_external_qi = TRUE;
6359 dwl_flags |= DWL_JAVASCRIPT;
6360 }else {
6361 if(!(dwl_flags & DWL_EXTERNAL))
6362 dwl_flags |= DWL_EX_GETHOSTINFO;
6363 dwl_flags |= DWL_ONREADY_LOADING;
6365 test_download(DWL_VERBDONE | dwl_flags);
6366 if(is_js)
6367 ignore_external_qi = FALSE;
6371 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str2);
6372 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6373 if(is_js)
6374 ok(!lstrcmpW(str2, prev_nav_url), "unexpected address bar url: %s\n", wine_dbgstr_w(str2));
6375 else if (dwl_flags & DWL_EXTERNAL)
6376 todo_wine ok(!lstrcmpW(str2, prev_nav_url), "unexpected address bar url: %s\n", wine_dbgstr_w(str2));
6377 else
6378 ok(!lstrcmpW(str2, nav_url), "unexpected address bar url: %s\n", wine_dbgstr_w(str2));
6379 SysFreeString(str2);
6380 IHTMLPrivateWindow_Release(priv_window);
6382 loading_js = FALSE;
6383 if(is_js)
6384 nav_url = prev_nav_url;
6387 static void test_load_history(IHTMLDocument2 *doc)
6389 IPersistHistory *per_hist;
6390 HRESULT hres;
6392 trace("LoadHistory...\n");
6394 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistHistory, (void**)&per_hist);
6395 ok(hres == S_OK, "Could not get IPersistHistory iface: %08lx\n", hres);
6397 prev_url = nav_url;
6398 nav_url = L"http://test.winehq.org/tests/winehq_snapshot/#test";
6399 nav_serv_url = L"http://test.winehq.org/tests/winehq_snapshot/";
6401 SET_EXPECT(Exec_ShellDocView_138);
6402 SET_EXPECT(Exec_ShellDocView_67);
6403 SET_EXPECT(FireBeforeNavigate2);
6404 SET_EXPECT(Invoke_AMBIENT_SILENT);
6405 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6407 hres = IPersistHistory_LoadHistory(per_hist, history_stream, NULL);
6408 ok(hres == S_OK, "LoadHistory failed: %08lx\n", hres);
6410 CLEAR_CALLED(Exec_ShellDocView_138); /* Not called by IE11 */
6411 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6412 CHECK_CALLED(FireBeforeNavigate2);
6413 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6414 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6416 load_state = LD_LOADING;
6417 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
6419 test_download(DWL_VERBDONE|DWL_HTTP|DWL_EXPECT_HISTUPDATE|DWL_ONREADY_LOADING|DWL_FROM_HISTORY|DWL_EX_GETHOSTINFO);
6421 IPersistHistory_Release(per_hist);
6422 IStream_Release(history_stream);
6423 history_stream = NULL;
6426 static void test_OmHistory(IHTMLDocument2 *doc)
6428 IHTMLWindow2 *win;
6429 IOmHistory *hist;
6430 short len;
6431 HRESULT hres;
6433 hres = IHTMLDocument2_get_parentWindow(doc, &win);
6434 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
6436 hres = IHTMLWindow2_get_history(win, &hist);
6437 ok(hres == S_OK, "get_history failed: %08lx\n", hres);
6438 IHTMLWindow2_Release(win);
6440 SET_EXPECT(CountEntries);
6441 hres = IOmHistory_get_length(hist, &len);
6442 CHECK_CALLED(CountEntries);
6443 ok(hres == S_OK, "get_length failed: %08lx\n", hres);
6444 ok(len == 0, "len = %d\n", len);
6446 IOmHistory_Release(hist);
6449 static void test_refresh(IHTMLDocument2 *doc)
6451 IOleCommandTarget *cmdtrg;
6452 VARIANT vin, vout;
6453 HRESULT hres;
6455 trace("Refresh...\n");
6457 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
6458 ok(hres == S_OK, "Could not get IOleCommandTarget iface: %08lx\n", hres);
6460 V_VT(&vin) = VT_EMPTY;
6461 V_VT(&vout) = VT_EMPTY;
6462 SET_EXPECT(Exec_DocHostCommandHandler_2300);
6463 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_REFRESH, OLECMDEXECOPT_PROMPTUSER, &vin, &vout);
6464 ok(hres == S_OK, "Exec failed: %08lx\n", hres);
6465 ok(V_VT(&vout) == VT_EMPTY, "V_VT(vout) = %d\n", V_VT(&vout));
6466 CHECK_CALLED(Exec_DocHostCommandHandler_2300);
6468 IOleCommandTarget_Release(cmdtrg);
6470 test_download(DWL_VERBDONE|DWL_HTTP|DWL_ONREADY_LOADING|DWL_REFRESH|DWL_EX_GETHOSTINFO);
6473 static void test_reload(IHTMLDocument2 *doc)
6475 IHTMLLocation *location;
6476 HRESULT hres;
6478 trace("Reload...\n");
6480 location = NULL;
6481 hres = IHTMLDocument2_get_location(doc, &location);
6482 ok(hres == S_OK, "get_location failed: %08lx\n", hres);
6483 ok(location != NULL, "location == NULL\n");
6485 hres = IHTMLLocation_reload(location, VARIANT_FALSE);
6486 IHTMLLocation_Release(location);
6488 test_download(DWL_VERBDONE|DWL_HTTP|DWL_ONREADY_LOADING|DWL_REFRESH|DWL_EX_GETHOSTINFO);
6491 static void test_super_navigate(IHTMLDocument2 *doc)
6493 IHTMLElementCollection *elem_col;
6494 IHTMLPrivateWindow *priv_window;
6495 IHTMLDocument2 *doc2;
6496 IHTMLDocument3 *doc3;
6497 IHTMLWindow2 *window;
6498 HRESULT hres;
6499 VARIANT var;
6500 BSTR str;
6502 trace("SuperNavigate...\n");
6504 hres = IHTMLDocument2_get_parentWindow(doc, &window);
6505 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
6507 hres = IHTMLWindow2_QueryInterface(window, &IID_IHTMLPrivateWindow, (void**)&priv_window);
6508 ok(hres == S_OK, "QueryInterface(IID_IHTMLPrivateWindow) failed: %08lx\n", hres);
6510 prev_url = nav_url;
6511 nav_serv_url = nav_url = L"http://test.winehq.org/tests/hello.html";
6513 readystate_set_loading = TRUE;
6514 SET_EXPECT(TranslateUrl);
6515 SET_EXPECT(FireBeforeNavigate2);
6516 SET_EXPECT(Exec_ShellDocView_67);
6517 SET_EXPECT(Invoke_AMBIENT_SILENT);
6518 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6519 SET_EXPECT(Exec_ShellDocView_63);
6520 SET_EXPECT(Exec_ShellDocView_84);
6522 str = SysAllocString(L"http://test.winehq.org/tests/hello.html");
6523 V_VT(&var) = VT_EMPTY;
6524 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, NULL, NULL, NULL, &var, &var, 1);
6525 ok(hres == S_OK, "SuperNavigate failed: %08lx\n", hres);
6526 SysFreeString(str);
6528 CHECK_CALLED(TranslateUrl);
6529 todo_wine CHECK_CALLED(FireBeforeNavigate2);
6530 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6531 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6532 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6533 CHECK_CALLED(Exec_ShellDocView_63);
6534 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6536 test_download(DWL_VERBDONE | DWL_ONREADY_LOADING | DWL_EXPECT_HISTUPDATE | DWL_EX_GETHOSTINFO);
6538 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str);
6539 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6540 ok(!wcscmp(str, L"http://test.winehq.org/tests/hello.html"), "unexpected address bar url: %s\n", wine_dbgstr_w(str));
6541 SysFreeString(str);
6543 prev_url = nav_url;
6544 nav_serv_url = nav_url = L"about:blank";
6546 readystate_set_loading = TRUE;
6547 SET_EXPECT(TranslateUrl);
6548 SET_EXPECT(Exec_ShellDocView_67);
6549 SET_EXPECT(Invoke_AMBIENT_SILENT);
6550 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6551 SET_EXPECT(Exec_ShellDocView_63);
6552 SET_EXPECT(Exec_ShellDocView_84);
6554 str = SysAllocString(L"about:blank");
6555 V_VT(&var) = VT_EMPTY;
6556 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, NULL, NULL, NULL, &var, &var, 4);
6557 ok(hres == S_OK, "SuperNavigate failed: %08lx\n", hres);
6558 SysFreeString(str);
6560 CHECK_CALLED(TranslateUrl);
6561 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6562 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6563 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6564 CHECK_CALLED(Exec_ShellDocView_63);
6565 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6567 test_download(DWL_VERBDONE | DWL_ONREADY_LOADING | DWL_EXPECT_HISTUPDATE | DWL_EX_GETHOSTINFO);
6569 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str);
6570 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6571 ok(!wcscmp(str, L"about:blank"), "unexpected address bar url: %s\n", wine_dbgstr_w(str));
6572 SysFreeString(str);
6574 prev_url = nav_url;
6575 nav_serv_url = nav_url = L"http://test.winehq.org/tests/hello.html";
6577 readystate_set_loading = TRUE;
6578 SET_EXPECT(TranslateUrl);
6579 SET_EXPECT(FireBeforeNavigate2);
6580 SET_EXPECT(Exec_ShellDocView_67);
6581 SET_EXPECT(Invoke_AMBIENT_SILENT);
6582 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6583 SET_EXPECT(Exec_ShellDocView_63);
6584 SET_EXPECT(Exec_ShellDocView_84);
6586 str = SysAllocString(L"http://test.winehq.org/tests/hello.html");
6587 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, NULL, NULL, NULL, &var, &var, 2 | 1);
6588 ok(hres == S_OK, "SuperNavigate failed: %08lx\n", hres);
6589 SysFreeString(str);
6591 CHECK_CALLED(TranslateUrl);
6592 todo_wine CHECK_CALLED(FireBeforeNavigate2);
6593 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6594 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6595 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6596 CHECK_CALLED(Exec_ShellDocView_63);
6597 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6599 test_download(DWL_VERBDONE | DWL_ONREADY_LOADING | DWL_EX_GETHOSTINFO);
6601 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str);
6602 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6603 ok(!wcscmp(str, L"http://test.winehq.org/tests/hello.html"), "unexpected address bar url: %s\n", wine_dbgstr_w(str));
6604 SysFreeString(str);
6606 hres = IHTMLWindow2_get_document(window, &doc2);
6607 ok(hres == S_OK, "get_document failed: %08lx\n", hres);
6609 hres = IHTMLDocument2_QueryInterface(doc2, &IID_IHTMLDocument3, (void**)&doc3);
6610 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument3) failed: %08lx\n", hres);
6611 IHTMLDocument2_Release(doc2);
6613 str = SysAllocString(L"H1");
6614 hres = IHTMLDocument3_getElementsByTagName(doc3, str, &elem_col);
6615 ok(hres == S_OK, "getElementsByTagName failed: %08lx\n", hres);
6616 ok(elem_col != NULL, "elem_col = NULL\n");
6617 IHTMLElementCollection_Release(elem_col);
6618 IHTMLDocument3_Release(doc3);
6619 SysFreeString(str);
6621 prev_url = nav_url;
6622 nav_serv_url = nav_url = L"about:blank";
6624 readystate_set_loading = TRUE;
6625 SET_EXPECT(TranslateUrl);
6626 SET_EXPECT(Exec_ShellDocView_67);
6627 SET_EXPECT(Invoke_AMBIENT_SILENT);
6628 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6629 SET_EXPECT(Exec_ShellDocView_63);
6630 SET_EXPECT(Exec_ShellDocView_84);
6632 str = SysAllocString(L"about:blank");
6633 V_VT(&var) = VT_EMPTY;
6634 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, NULL, NULL, NULL, &var, &var, 2 | 4);
6635 ok(hres == S_OK, "SuperNavigate failed: %08lx\n", hres);
6636 SysFreeString(str);
6638 CHECK_CALLED(TranslateUrl);
6639 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6640 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6641 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6642 CHECK_CALLED(Exec_ShellDocView_63);
6643 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6645 test_download(DWL_VERBDONE | DWL_ONREADY_LOADING | DWL_EX_GETHOSTINFO);
6647 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str);
6648 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6649 ok(!wcscmp(str, L"about:blank"), "unexpected address bar url: %s\n", wine_dbgstr_w(str));
6650 SysFreeString(str);
6652 prev_url = nav_url;
6653 nav_serv_url = nav_url = L"http://test.winehq.org/tests/hello.html";
6654 is_error_url = TRUE;
6656 readystate_set_loading = TRUE;
6657 SET_EXPECT(TranslateUrl);
6658 SET_EXPECT(Exec_ShellDocView_67);
6659 SET_EXPECT(Invoke_AMBIENT_SILENT);
6660 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6661 SET_EXPECT(Exec_ShellDocView_63);
6662 SET_EXPECT(Exec_ShellDocView_84);
6664 str = SysAllocString(L"http://test.winehq.org/tests/hello.html");
6665 V_VT(&var) = VT_EMPTY;
6666 hres = IHTMLPrivateWindow_SuperNavigate(priv_window, str, NULL, NULL, NULL, &var, &var, 2);
6667 ok(hres == S_OK, "SuperNavigate failed: %08lx\n", hres);
6668 SysFreeString(str);
6670 CHECK_CALLED(TranslateUrl);
6671 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
6672 CHECK_CALLED(Invoke_AMBIENT_SILENT);
6673 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
6674 CHECK_CALLED(Exec_ShellDocView_63);
6675 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
6677 test_download(DWL_VERBDONE | DWL_ONREADY_LOADING | DWL_EX_GETHOSTINFO);
6679 hres = IHTMLPrivateWindow_GetAddressBarUrl(priv_window, &str);
6680 ok(hres == S_OK, "GetAddressBarUrl failed: %08lx\n", hres);
6681 ok(!wcscmp(str, L"http://test.winehq.org/tests/hello.html"), "unexpected address bar url: %s\n", wine_dbgstr_w(str));
6682 SysFreeString(str);
6683 is_error_url = FALSE;
6685 IHTMLPrivateWindow_Release(priv_window);
6686 IHTMLWindow2_Release(window);
6689 static void test_open_window(IHTMLDocument2 *doc, BOOL do_block)
6691 IHTMLWindow2 *window, *new_window;
6692 BSTR name, url;
6693 HRESULT hres;
6695 allow_new_window = !do_block;
6697 hres = IHTMLDocument2_get_parentWindow(doc, &window);
6698 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
6700 url = SysAllocString(nav_serv_url = nav_url = L"about:blank");
6701 name = SysAllocString(L"test");
6702 new_window = (void*)0xdeadbeef;
6704 trace("open...\n");
6705 open_call = TRUE;
6707 if(support_wbapp)
6708 SET_EXPECT(get_LocationURL);
6709 SET_EXPECT(TranslateUrl);
6710 SET_EXPECT(GetOverrideKeyPath);
6711 SET_EXPECT(EvaluateNewWindow);
6713 hres = IHTMLWindow2_open(window, url, name, NULL, VARIANT_FALSE, &new_window);
6714 open_call = FALSE;
6715 SysFreeString(url);
6716 SysFreeString(name);
6718 if(support_wbapp)
6719 todo_wine CHECK_CALLED_BROKEN(get_LocationURL);
6720 todo_wine
6721 CHECK_CALLED(TranslateUrl);
6722 CLEAR_CALLED(GetOverrideKeyPath);
6724 if(!called_EvaluateNewWindow) {
6725 win_skip("INewWindowManager not supported\n");
6726 if(SUCCEEDED(hres) && new_window)
6727 IHTMLWindow2_Release(new_window);
6728 IHTMLWindow2_Release(window);
6729 return;
6731 CHECK_CALLED(EvaluateNewWindow);
6733 ok(hres == S_OK, "open failed: %08lx\n", hres);
6734 if (hres != S_OK) {
6735 IHTMLWindow2_Release(window);
6736 return;
6739 if(do_block) {
6740 ok(!new_window, "new_window != NULL\n");
6741 }else {
6742 ok(new_window != NULL, "new_window == NULL\n");
6744 hres = IHTMLWindow2_close(new_window);
6745 ok(hres == S_OK, "close failed: %08lx\n", hres);
6746 IHTMLWindow2_Release(new_window);
6749 IHTMLWindow2_Release(window);
6752 static void test_window_close(IHTMLDocument2 *doc)
6754 IHTMLWindow2 *window;
6755 HRESULT hres;
6757 hres = IHTMLDocument2_get_parentWindow(doc, &window);
6758 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
6760 SET_EXPECT(FindConnectionPoint);
6761 SET_EXPECT(EnumConnections);
6762 SET_EXPECT(EnumConnections_Next);
6763 SET_EXPECT(WindowClosing);
6765 hres = IHTMLWindow2_close(window);
6766 ok(hres == S_OK, "close failed: %08lx\n", hres);
6768 CHECK_CALLED(FindConnectionPoint);
6769 CHECK_CALLED(EnumConnections);
6770 CHECK_CALLED(EnumConnections_Next);
6771 CHECK_CALLED(WindowClosing);
6773 IHTMLWindow2_Release(window);
6776 static void test_elem_from_point(IHTMLDocument2 *doc)
6778 IHTMLElement *elem;
6779 BSTR tag;
6780 HRESULT hres;
6782 elem = NULL;
6783 hres = IHTMLDocument2_elementFromPoint(doc, 3, 3, &elem);
6784 ok(hres == S_OK, "elementFromPoint failed: %08lx\n", hres);
6785 ok(elem != NULL, "elem == NULL\n");
6787 hres = IHTMLElement_get_tagName(elem, &tag);
6788 IHTMLElement_Release(elem);
6789 ok(hres == S_OK, "get_tagName failed: %08lx\n", hres);
6790 ok(!lstrcmpW(tag, L"DIV"), "tag = %s\n", wine_dbgstr_w(tag));
6793 static void test_clear(IHTMLDocument2 *doc)
6795 HRESULT hres;
6797 hres = IHTMLDocument2_clear(doc);
6798 ok(hres == S_OK, "clear failed: %08lx\n", hres);
6801 static const OLECMDF expect_cmds[] = {
6803 OLECMDF_SUPPORTED, /* OLECMDID_OPEN */
6804 OLECMDF_SUPPORTED, /* OLECMDID_NEW */
6805 OLECMDF_SUPPORTED, /* OLECMDID_SAVE */
6806 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SAVEAS */
6807 OLECMDF_SUPPORTED, /* OLECMDID_SAVECOPYAS */
6808 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINT */
6809 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PRINTPREVIEW */
6810 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PAGESETUP */
6811 OLECMDF_SUPPORTED, /* OLECMDID_SPELL */
6812 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_PROPERTIES */
6813 OLECMDF_SUPPORTED, /* OLECMDID_CUT */
6814 OLECMDF_SUPPORTED, /* OLECMDID_COPY */
6815 OLECMDF_SUPPORTED, /* OLECMDID_PASTE */
6816 OLECMDF_SUPPORTED, /* OLECMDID_PASTESPECIAL */
6817 OLECMDF_SUPPORTED, /* OLECMDID_UNDO */
6818 OLECMDF_SUPPORTED, /* OLECMDID_REDO */
6819 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_SELECTALL */
6820 OLECMDF_SUPPORTED, /* OLECMDID_CLEARSELECTION */
6821 OLECMDF_SUPPORTED, /* OLECMDID_ZOOM */
6822 OLECMDF_SUPPORTED, /* OLECMDID_GETZOOMRANGE */
6824 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_REFRESH */
6825 OLECMDF_SUPPORTED|OLECMDF_ENABLED, /* OLECMDID_STOP */
6826 0,0,0,0,0,0,
6827 OLECMDF_SUPPORTED, /* OLECMDID_STOPDOWNLOAD */
6828 0,0,
6829 OLECMDF_SUPPORTED, /* OLECMDID_DELETE */
6830 0,0,
6831 OLECMDF_SUPPORTED, /* OLECMDID_ENABLE_INTERACTION */
6832 OLECMDF_SUPPORTED, /* OLECMDID_ONUNLOAD */
6833 0,0,0,0,0,
6834 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPAGESETUP */
6835 OLECMDF_SUPPORTED, /* OLECMDID_SHOWPRINT */
6836 0,0,
6837 OLECMDF_SUPPORTED, /* OLECMDID_CLOSE */
6838 0,0,0,
6839 OLECMDF_SUPPORTED, /* OLECMDID_SETPRINTTEMPLATE */
6840 OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */
6843 #define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf)
6844 static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf)
6846 IOleCommandTarget *cmdtrg;
6847 OLECMD olecmd = {cmdid, 0};
6848 HRESULT hres;
6850 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
6851 ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08lx\n", hres);
6852 if(FAILED(hres))
6853 return;
6855 hres = IOleCommandTarget_QueryStatus(cmdtrg, cgid, 1, &olecmd, NULL);
6856 ok(hres == (cmdf ? S_OK : OLECMDERR_E_NOTSUPPORTED), "QueryStatus(%lu) failed: %08lx\n", cmdid, hres);
6858 IOleCommandTarget_Release(cmdtrg);
6860 ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n");
6861 ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%lu) cmdf=%08lx, expected %08lx\n", cmdid, olecmd.cmdf, cmdf);
6864 static void test_MSHTML_QueryStatus(IHTMLDocument2 *doc, DWORD cmdf)
6866 IUnknown *unk = doc ? (IUnknown*)doc : doc_unk;
6868 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTNAME, cmdf);
6869 test_QueryStatus(unk, &CGID_MSHTML, IDM_FONTSIZE, cmdf);
6870 test_QueryStatus(unk, &CGID_MSHTML, IDM_SELECTALL, cmdf|OLECMDF_ENABLED);
6871 test_QueryStatus(unk, &CGID_MSHTML, IDM_BOLD, cmdf);
6872 test_QueryStatus(unk, &CGID_MSHTML, IDM_FORECOLOR, cmdf);
6873 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, cmdf);
6874 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYLEFT, cmdf);
6875 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, cmdf);
6876 test_QueryStatus(unk, &CGID_MSHTML, IDM_ITALIC, cmdf);
6877 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNDERLINE, cmdf);
6878 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, cmdf);
6879 test_QueryStatus(unk, &CGID_MSHTML, IDM_ORDERLIST, cmdf);
6880 test_QueryStatus(unk, &CGID_MSHTML, IDM_UNORDERLIST, cmdf);
6881 test_QueryStatus(unk, &CGID_MSHTML, IDM_INDENT, cmdf);
6882 test_QueryStatus(unk, &CGID_MSHTML, IDM_OUTDENT, cmdf);
6883 test_QueryStatus(unk, &CGID_MSHTML, IDM_DELETE, cmdf);
6886 static void test_OleCommandTarget(IHTMLDocument2 *doc)
6888 IOleCommandTarget *cmdtrg;
6889 OLECMD cmds[ARRAY_SIZE(expect_cmds)-1];
6890 int i;
6891 HRESULT hres;
6893 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
6894 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08lx\n", hres);
6895 if(FAILED(hres))
6896 return;
6898 for(i=0; i < ARRAY_SIZE(cmds); i++) {
6899 cmds[i].cmdID = i+1;
6900 cmds[i].cmdf = 0xf0f0;
6903 SET_EXPECT(QueryStatus_OPEN);
6904 SET_EXPECT(QueryStatus_NEW);
6905 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, ARRAY_SIZE(cmds), cmds, NULL);
6906 ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
6907 CHECK_CALLED(QueryStatus_OPEN);
6908 CHECK_CALLED(QueryStatus_NEW);
6910 for(i=0; i < ARRAY_SIZE(cmds); i++) {
6911 ok(cmds[i].cmdID == i+1, "cmds[%d].cmdID canged to %lx\n", i, cmds[i].cmdID);
6912 if(i+1 == OLECMDID_FIND)
6913 continue;
6914 ok(cmds[i].cmdf == expect_cmds[i+1], "cmds[%d].cmdf=%lx, expected %x\n",
6915 i+1, cmds[i].cmdf, expect_cmds[i+1]);
6918 ok(!cmds[OLECMDID_FIND-1].cmdf || cmds[OLECMDID_FIND-1].cmdf == (OLECMDF_SUPPORTED|OLECMDF_ENABLED),
6919 "cmds[OLECMDID_FIND].cmdf=%lx\n", cmds[OLECMDID_FIND-1].cmdf);
6921 IOleCommandTarget_Release(cmdtrg);
6924 static void test_OleCommandTarget_fail(IHTMLDocument2 *doc)
6926 IOleCommandTarget *cmdtrg;
6927 int i;
6928 HRESULT hres;
6930 OLECMD cmd[2] = {
6931 {OLECMDID_OPEN, 0xf0f0},
6932 {OLECMDID_GETPRINTTEMPLATE+1, 0xf0f0}
6935 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
6936 ok(hres == S_OK, "QueryInterface(IIDIOleCommandTarget failed: %08lx\n", hres);
6937 if(FAILED(hres))
6938 return;
6940 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 0, NULL, NULL);
6941 ok(hres == S_OK, "QueryStatus failed: %08lx\n", hres);
6943 SET_EXPECT(QueryStatus_OPEN);
6944 hres = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 2, cmd, NULL);
6945 CHECK_CALLED(QueryStatus_OPEN);
6947 ok(hres == OLECMDERR_E_NOTSUPPORTED,
6948 "QueryStatus failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
6949 ok(cmd[1].cmdID == OLECMDID_GETPRINTTEMPLATE+1,
6950 "cmd[0].cmdID=%ld, expected OLECMDID_GETPRINTTEMPLATE+1\n", cmd[0].cmdID);
6951 ok(cmd[1].cmdf == 0, "cmd[0].cmdf=%lx, expected 0\n", cmd[0].cmdf);
6952 ok(cmd[0].cmdf == OLECMDF_SUPPORTED,
6953 "cmd[1].cmdf=%lx, expected OLECMDF_SUPPORTED\n", cmd[1].cmdf);
6955 hres = IOleCommandTarget_QueryStatus(cmdtrg, &IID_IHTMLDocument2, 2, cmd, NULL);
6956 ok(hres == OLECMDERR_E_UNKNOWNGROUP,
6957 "QueryStatus failed: %08lx, expected OLECMDERR_E_UNKNOWNGROUP\n", hres);
6959 for(i=0; i<OLECMDID_GETPRINTTEMPLATE; i++) {
6960 if(!expect_cmds[i]) {
6961 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_UPDATECOMMANDS,
6962 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
6963 ok(hres == OLECMDERR_E_NOTSUPPORTED,
6964 "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
6968 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_GETPRINTTEMPLATE+1,
6969 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
6970 ok(hres == OLECMDERR_E_NOTSUPPORTED,
6971 "Exec failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED\n", hres);
6973 IOleCommandTarget_Release(cmdtrg);
6976 static void test_exec_onunload(IHTMLDocument2 *doc)
6978 IOleCommandTarget *cmdtrg;
6979 VARIANT var;
6980 HRESULT hres;
6982 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
6983 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08lx\n", hres);
6984 if(FAILED(hres))
6985 return;
6987 memset(&var, 0x0a, sizeof(var));
6988 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
6989 OLECMDEXECOPT_DODEFAULT, NULL, &var);
6990 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08lx\n", hres);
6991 ok(V_VT(&var) == VT_BOOL, "V_VT(var)=%d, expected VT_BOOL\n", V_VT(&var));
6992 ok(V_BOOL(&var) == VARIANT_TRUE, "V_BOOL(var)=%x, expected VARIANT_TRUE\n", V_BOOL(&var));
6994 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_ONUNLOAD,
6995 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
6996 ok(hres == S_OK, "Exec(..., OLECMDID_ONUNLOAD, ...) failed: %08lx\n", hres);
6998 IOleCommandTarget_Release(cmdtrg);
7001 static void test_exec_editmode(IUnknown *unk, BOOL loaded)
7003 IOleCommandTarget *cmdtrg;
7004 HRESULT hres;
7006 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
7007 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08lx\n", hres);
7008 if(FAILED(hres))
7009 return;
7011 editmode = TRUE;
7013 if(loaded) {
7014 load_state = LD_DOLOAD;
7015 SET_EXPECT(GetClassID);
7017 SET_EXPECT(SetStatusText);
7018 SET_EXPECT(Exec_ShellDocView_37);
7019 SET_EXPECT(GetHostInfo);
7020 if(loaded)
7021 SET_EXPECT(GetDisplayName);
7022 SET_EXPECT(Invoke_AMBIENT_SILENT);
7023 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
7024 SET_EXPECT(OnChanged_READYSTATE);
7025 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
7026 SET_EXPECT(IsSystemMoniker);
7027 SET_EXPECT(Exec_ShellDocView_84);
7028 if(loaded)
7029 SET_EXPECT(BindToStorage);
7030 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
7031 SET_EXPECT(HideUI);
7032 SET_EXPECT(ShowUI);
7033 SET_EXPECT(InPlaceFrame_SetBorderSpace);
7035 expect_status_text = NULL;
7036 readystate_set_loading = TRUE;
7038 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
7039 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
7040 ok(hres == S_OK, "Exec failed: %08lx\n", hres);
7042 if(loaded)
7043 CHECK_CALLED(GetClassID);
7044 CHECK_CALLED(SetStatusText);
7045 CHECK_CALLED(Exec_ShellDocView_37);
7046 CHECK_CALLED(GetHostInfo);
7047 if(loaded)
7048 CHECK_CALLED(GetDisplayName);
7049 CHECK_CALLED(Invoke_AMBIENT_SILENT);
7050 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
7051 CHECK_CALLED(OnChanged_READYSTATE);
7052 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
7053 CLEAR_CALLED(IsSystemMoniker); /* IE7 */
7054 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
7055 if(loaded)
7056 CHECK_CALLED(BindToStorage);
7057 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
7058 CHECK_CALLED(HideUI);
7059 CHECK_CALLED(ShowUI);
7060 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
7062 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
7064 IOleCommandTarget_Release(cmdtrg);
7066 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_EDITMODE,
7067 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
7068 ok(hres == S_OK, "Exec failed: %08lx\n", hres);
7071 static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname)
7073 IOleCommandTarget *cmdtrg;
7074 VARIANT *in = NULL, _in, *out = NULL, _out;
7075 HRESULT hres;
7077 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
7078 ok(hres == S_OK, "QueryInterface(IIDIOleM=CommandTarget failed: %08lx\n", hres);
7079 if(FAILED(hres))
7080 return;
7082 if(name) {
7083 in = &_in;
7084 V_VT(in) = VT_BSTR;
7085 V_BSTR(in) = SysAllocString(name);
7088 if(exname) {
7089 out = &_out;
7090 V_VT(out) = VT_I4;
7091 V_I4(out) = 0xdeadbeef;
7094 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, IDM_FONTNAME, 0, in, out);
7095 ok(hres == S_OK, "Exec(IDM_FONTNAME) failed: %08lx\n", hres);
7097 if(in)
7098 VariantClear(in);
7100 if(out) {
7101 ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out));
7102 if(V_VT(out) == VT_BSTR) {
7103 if(exname)
7104 ok(!lstrcmpW(V_BSTR(out), name ? name : exname),
7105 "unexpected fontname %s\n", wine_dbgstr_w(name));
7106 else
7107 ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n");
7109 VariantClear(out);
7112 IOleCommandTarget_Release(cmdtrg);
7115 static void test_exec_noargs(IUnknown *unk, DWORD cmdid)
7117 IOleCommandTarget *cmdtrg;
7118 HRESULT hres;
7120 hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg);
7121 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08lx\n", hres);
7122 if(FAILED(hres))
7123 return;
7125 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_MSHTML, cmdid,
7126 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
7127 ok(hres == S_OK, "Exec failed: %08lx\n", hres);
7129 IOleCommandTarget_Release(cmdtrg);
7132 static void test_exec_optical_zoom(IHTMLDocument2 *doc, int factor)
7134 IOleCommandTarget *cmdtrg;
7135 VARIANT v, out;
7136 HRESULT hres;
7138 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleCommandTarget, (void**)&cmdtrg);
7139 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) failed: %08lx\n", hres);
7140 if(FAILED(hres))
7141 return;
7143 V_VT(&v) = VT_I4;
7144 V_I4(&v) = factor;
7146 SET_EXPECT(GetOverrideKeyPath);
7147 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_OPTICAL_ZOOM,
7148 OLECMDEXECOPT_DODEFAULT, &v, &out);
7149 ok(hres == S_OK || broken(hres == OLECMDERR_E_NOTSUPPORTED) /* IE6 */, "Exec failed: %08lx\n", hres);
7150 CLEAR_CALLED(GetOverrideKeyPath);
7152 if(hres != OLECMDERR_E_NOTSUPPORTED) {
7153 ok(V_VT(&out) == VT_I4, "V_VT(&out) = %d\n", V_VT(&out));
7154 ok(V_I4(&out) == factor, "V_I4(&out) = %ld, expected %d\n", V_I4(&out), factor);
7156 SET_EXPECT(GetOverrideKeyPath);
7157 hres = IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_OPTICAL_ZOOM,
7158 OLECMDEXECOPT_DODEFAULT, NULL, &out);
7159 ok(hres == S_OK, "Exec failed: %08lx\n", hres);
7160 ok(V_VT(&out) == VT_I4, "V_VT(&out) = %d\n", V_VT(&out));
7161 ok(V_I4(&out) == factor, "V_I4(&out) = %ld, expected %d\n", V_I4(&out), factor);
7162 CLEAR_CALLED(GetOverrideKeyPath);
7165 IOleCommandTarget_Release(cmdtrg);
7167 test_QueryStatus((IUnknown*)doc, NULL, OLECMDID_OPTICAL_ZOOM, 0);
7170 static void test_IsDirty(IHTMLDocument2 *doc, HRESULT exhres)
7172 IPersistStreamInit *perinit;
7173 IPersistMoniker *permon;
7174 IPersistFile *perfile;
7175 HRESULT hres;
7177 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&perinit);
7178 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit failed: %08lx\n", hres);
7179 if(SUCCEEDED(hres)) {
7180 hres = IPersistStreamInit_IsDirty(perinit);
7181 ok(hres == exhres, "IsDirty() = %08lx, expected %08lx\n", hres, exhres);
7182 IPersistStreamInit_Release(perinit);
7185 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistMoniker, (void**)&permon);
7186 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker failed: %08lx\n", hres);
7187 if(SUCCEEDED(hres)) {
7188 hres = IPersistMoniker_IsDirty(permon);
7189 ok(hres == exhres, "IsDirty() = %08lx, expected %08lx\n", hres, exhres);
7190 IPersistMoniker_Release(permon);
7193 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistFile, (void**)&perfile);
7194 ok(hres == S_OK, "QueryInterface(IID_IPersistFile failed: %08lx\n", hres);
7195 if(SUCCEEDED(hres)) {
7196 hres = IPersistFile_IsDirty(perfile);
7197 ok(hres == exhres, "IsDirty() = %08lx, expected %08lx\n", hres, exhres);
7198 IPersistFile_Release(perfile);
7202 static HWND create_container_window(void)
7204 static const WCHAR wszHTMLDocumentTest[] =
7205 {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
7206 static WNDCLASSEXW wndclass = {
7207 sizeof(WNDCLASSEXW),
7209 wnd_proc,
7210 0, 0, NULL, NULL, NULL, NULL, NULL,
7211 wszHTMLDocumentTest,
7212 NULL
7215 RegisterClassExW(&wndclass);
7216 return CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
7217 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
7218 515, 530, NULL, NULL, NULL, NULL);
7221 static void test_DoVerb(IOleObject *oleobj)
7223 RECT rect = {0,0,500,500};
7224 HRESULT hres;
7226 if(!container_locked) {
7227 SET_EXPECT(GetContainer);
7228 SET_EXPECT(LockContainer);
7230 SET_EXPECT(ActivateMe);
7231 expect_LockContainer_fLock = TRUE;
7233 hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
7234 ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
7236 if(!container_locked) {
7237 CHECK_CALLED(GetContainer);
7238 CHECK_CALLED(LockContainer);
7239 container_locked = TRUE;
7241 CHECK_CALLED(ActivateMe);
7244 #define CLIENTSITE_EXPECTPATH 0x00000001
7245 #define CLIENTSITE_SETNULL 0x00000002
7246 #define CLIENTSITE_DONTSET 0x00000004
7248 static void test_ClientSite(IOleObject *oleobj, DWORD flags)
7250 IOleClientSite *clientsite;
7251 HRESULT hres;
7253 if(flags & CLIENTSITE_SETNULL) {
7254 hres = IOleObject_GetClientSite(oleobj, &clientsite);
7255 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
7256 if(set_clientsite)
7257 ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
7258 else
7259 ok(!clientsite, "clientsite != NULL\n");
7261 SET_EXPECT(GetOverrideKeyPath);
7262 hres = IOleObject_SetClientSite(oleobj, NULL);
7263 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
7264 CLEAR_CALLED(GetOverrideKeyPath); /* IE9 sometimes calls it */
7266 set_clientsite = FALSE;
7269 if(flags & CLIENTSITE_DONTSET)
7270 return;
7272 if(!expect_uihandler_iface)
7273 expect_uihandler_iface = &DocHostUIHandler;
7275 hres = IOleObject_GetClientSite(oleobj, &clientsite);
7276 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
7277 ok(clientsite == (set_clientsite ? &ClientSite : NULL), "GetClientSite() = %p, expected %p\n",
7278 clientsite, set_clientsite ? &ClientSite : NULL);
7280 if(!set_clientsite) {
7281 if(expect_uihandler_iface)
7282 SET_EXPECT(GetHostInfo);
7283 if(flags & CLIENTSITE_EXPECTPATH) {
7284 SET_EXPECT(GetOptionKeyPath);
7285 SET_EXPECT(GetOverrideKeyPath);
7287 SET_EXPECT(GetWindow);
7288 if(flags & CLIENTSITE_EXPECTPATH)
7289 SET_EXPECT(Exec_DOCCANNAVIGATE);
7290 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
7291 SET_EXPECT(Exec_SETPROGRESSMAX);
7292 SET_EXPECT(Exec_SETPROGRESSPOS);
7293 SET_EXPECT(Invoke_AMBIENT_USERMODE);
7294 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
7295 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
7296 SET_EXPECT(Invoke_AMBIENT_SILENT);
7297 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
7298 SET_EXPECT(Invoke_AMBIENT_PALETTE);
7299 SET_EXPECT(GetOverrideKeyPath);
7300 SET_EXPECT(GetTravelLog);
7301 SET_EXPECT(Exec_ShellDocView_84);
7303 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
7304 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
7306 if(expect_uihandler_iface)
7307 CHECK_CALLED(GetHostInfo);
7308 if(flags & CLIENTSITE_EXPECTPATH) {
7309 CLEAR_CALLED(GetOptionKeyPath); /* not called on some IE9 */
7310 CHECK_CALLED(GetOverrideKeyPath);
7312 CHECK_CALLED(GetWindow);
7313 if(flags & CLIENTSITE_EXPECTPATH)
7314 CHECK_CALLED(Exec_DOCCANNAVIGATE);
7315 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
7316 CHECK_CALLED(Exec_SETPROGRESSMAX);
7317 CHECK_CALLED(Exec_SETPROGRESSPOS);
7318 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
7319 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
7320 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
7321 CHECK_CALLED(Invoke_AMBIENT_SILENT);
7322 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
7323 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* not called on IE9 */
7324 CLEAR_CALLED(GetOverrideKeyPath); /* Called by IE9 */
7325 CHECK_CALLED(GetTravelLog);
7326 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
7328 set_clientsite = TRUE;
7331 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
7332 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
7334 hres = IOleObject_GetClientSite(oleobj, &clientsite);
7335 ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
7336 ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
7339 static void test_OnAmbientPropertyChange(IHTMLDocument2 *doc)
7341 IOleControl *control = NULL;
7342 HRESULT hres;
7344 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleControl, (void**)&control);
7345 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08lx\n", hres);
7346 if(FAILED(hres))
7347 return;
7349 SET_EXPECT(Invoke_AMBIENT_USERMODE);
7350 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERMODE);
7351 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
7352 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
7354 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
7355 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_DLCONTROL);
7356 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
7357 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
7359 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
7360 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
7361 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
7362 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
7363 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
7364 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
7366 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
7367 SET_EXPECT(Invoke_AMBIENT_SILENT);
7368 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_SILENT);
7369 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
7370 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
7371 CHECK_CALLED(Invoke_AMBIENT_SILENT);
7373 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
7374 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_USERAGENT);
7375 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
7376 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
7378 SET_EXPECT(Invoke_AMBIENT_PALETTE);
7379 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
7380 ok(hres == S_OK, "OnAmbientChange failed: %08lx\n", hres);
7381 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* not called on IE9 */
7383 IOleControl_Release(control);
7388 static void test_GetSetExtent(IHTMLDocument2 *doc)
7390 IOleObject *oleobj = NULL;
7391 HRESULT hres;
7392 SIZE extent;
7394 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
7395 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
7396 if(FAILED(hres))
7397 return;
7399 extent.cx = extent.cy = 0xdeadbeef;
7400 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7401 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7402 ok(extent.cx == 1 && extent.cy == 1, "size = {%ld %ld} (expected {1 1})\n",
7403 extent.cx, extent.cy);
7405 extent.cx = extent.cy = 0xdeadbeef;
7406 hres = IOleObject_GetExtent(oleobj, 0, &extent);
7407 ok(hres == E_INVALIDARG, "GetExtent failed: %08lx\n", hres);
7408 ok(extent.cx == 0xdeadbeef && extent.cy == 0xdeadbeef, "size = {%ld %ld}\n", extent.cx, extent.cy);
7410 extent.cx = extent.cy = 0xdeadbeef;
7411 hres = IOleObject_GetExtent(oleobj, 7, &extent);
7412 ok(hres == E_INVALIDARG, "GetExtent failed: %08lx\n", hres);
7413 ok(extent.cx == 0xdeadbeef && extent.cy == 0xdeadbeef, "size = {%ld %ld}\n", extent.cx, extent.cy);
7415 extent.cx = 800;
7416 extent.cy = 700;
7417 hres = IOleObject_SetExtent(oleobj, 0, &extent);
7418 ok(hres == E_INVALIDARG, "SetExtent failed: %08lx\n", hres);
7420 extent.cx = extent.cy = 0xdeadbeef;
7421 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7422 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7423 ok(extent.cx == 1 && extent.cy == 1, "size = {%ld %ld} (expected {1 1})\n",
7424 extent.cx, extent.cy);
7426 extent.cx = 800;
7427 extent.cy = 700;
7428 hres = IOleObject_SetExtent(oleobj, 7, &extent);
7429 ok(hres == E_INVALIDARG, "SetExtent failed: %08lx\n", hres);
7431 extent.cx = extent.cy = 0xdeadbeef;
7432 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7433 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7434 ok(extent.cx == 1 && extent.cy == 1, "size = {%ld %ld} (expected {1 1})\n",
7435 extent.cx, extent.cy);
7437 extent.cx = extent.cy = 0xdeadbeef;
7438 hres = IOleObject_SetExtent(oleobj, 0, &extent);
7439 todo_wine ok(hres == E_FAIL, "SetExtent failed: %08lx\n", hres);
7441 extent.cx = extent.cy = 0xdeadbeef;
7442 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7443 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7444 ok(extent.cx == 1 && extent.cy == 1, "size = {%ld %ld} (expected {1 1})\n",
7445 extent.cx, extent.cy);
7447 extent.cx = extent.cy = 0xdeadbeef;
7448 hres = IOleObject_SetExtent(oleobj, 7, &extent);
7449 todo_wine ok(hres == E_FAIL, "SetExtent failed: %08lx\n", hres);
7451 extent.cx = extent.cy = 0xdeadbeef;
7452 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7453 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7454 ok(extent.cx == 1 && extent.cy == 1, "size = {%ld %ld} (expected {1 1})\n",
7455 extent.cx, extent.cy);
7457 extent.cx = extent.cy = 0xdeadbeef;
7458 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &extent);
7459 todo_wine ok(hres == E_FAIL, "SetExtent failed: %08lx\n", hres);
7461 extent.cx = extent.cy = 0xdeadbeef;
7462 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7463 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7464 todo_wine ok(extent.cx == 1 && extent.cy == 1, "size = {%ld %ld} (expected {1 1})\n",
7465 extent.cx, extent.cy);
7467 extent.cx = 800;
7468 extent.cy = 700;
7469 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &extent);
7470 ok(hres == S_OK, "SetExtent failed: %08lx\n", hres);
7472 extent.cx = extent.cy = 0xdeadbeef;
7473 hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent);
7474 ok(hres == S_OK, "GetExtent failed: %08lx\n", hres);
7475 ok(extent.cx == 800 && extent.cy == 700, "size = {%ld %ld} (expected {800 700})\n",
7476 extent.cx, extent.cy );
7478 extent.cx = 1;
7479 extent.cy = 1;
7480 hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &extent);
7481 ok(hres == S_OK, "SetExtent failed: %08lx\n", hres);
7483 IOleObject_Release(oleobj);
7486 static void test_OnAmbientPropertyChange2(IHTMLDocument2 *doc)
7488 IOleControl *control = NULL;
7489 HRESULT hres;
7491 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleControl, (void**)&control);
7492 ok(hres == S_OK, "QueryInterface(IID_IOleControl failed: %08lx\n", hres);
7493 if(FAILED(hres))
7494 return;
7496 hres = IOleControl_OnAmbientPropertyChange(control, DISPID_AMBIENT_PALETTE);
7497 ok(hres == S_OK, "OnAmbientPropertyChange failed: %08lx\n", hres);
7499 IOleControl_Release(control);
7502 static void test_Close(IHTMLDocument2 *doc, BOOL set_client)
7504 IOleObject *oleobj = NULL;
7505 HRESULT hres;
7507 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
7508 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
7509 if(FAILED(hres))
7510 return;
7512 SET_EXPECT(GetContainer);
7513 SET_EXPECT(LockContainer);
7514 expect_LockContainer_fLock = FALSE;
7515 hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
7516 ok(hres == S_OK, "Close failed: %08lx\n", hres);
7517 CHECK_CALLED(GetContainer);
7518 CHECK_CALLED(LockContainer);
7519 container_locked = FALSE;
7521 if(set_client)
7522 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
7524 IOleObject_Release(oleobj);
7527 static void test_Advise(IHTMLDocument2 *doc)
7529 IOleObject *oleobj = NULL;
7530 IEnumSTATDATA *enum_advise = (void*)0xdeadbeef;
7531 DWORD conn;
7532 HRESULT hres;
7534 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
7535 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
7536 if(FAILED(hres))
7537 return;
7539 hres = IOleObject_Unadvise(oleobj, 0);
7540 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08lx\n", hres);
7542 hres = IOleObject_EnumAdvise(oleobj, &enum_advise);
7543 ok(hres == S_OK, "EnumAdvise returned: %08lx\n", hres);
7544 ok(enum_advise == NULL, "enum_advise != NULL\n");
7546 conn = -1;
7547 hres = IOleObject_Advise(oleobj, NULL, &conn);
7548 /* Old IE returns S_OK and sets conn to 1 */
7549 ok(hres == E_INVALIDARG || hres == S_OK, "Advise returned: %08lx\n", hres);
7550 ok(conn == 0 || conn == 1, "conn = %ld\n", conn);
7552 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, NULL);
7553 ok(hres == E_INVALIDARG, "Advise returned: %08lx\n", hres);
7555 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
7556 ok(hres == S_OK, "Advise returned: %08lx\n", hres);
7557 ok(conn == 1, "conn = %ld\n", conn);
7559 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
7560 ok(hres == S_OK, "Advise returned: %08lx\n", hres);
7561 ok(conn == 2, "conn = %ld\n", conn);
7563 hres = IOleObject_Unadvise(oleobj, 1);
7564 ok(hres == S_OK, "Unadvise returned: %08lx\n", hres);
7566 hres = IOleObject_Unadvise(oleobj, 1);
7567 ok(hres == OLE_E_NOCONNECTION, "Unadvise returned: %08lx\n", hres);
7569 hres = IOleObject_Unadvise(oleobj, 2);
7570 ok(hres == S_OK, "Unadvise returned: %08lx\n", hres);
7572 IOleObject_Release(oleobj);
7575 static void test_OnFrameWindowActivate(IUnknown *unk)
7577 IOleInPlaceActiveObject *inplaceact;
7578 HRESULT hres;
7580 hres = IUnknown_QueryInterface(unk, &IID_IOleInPlaceActiveObject, (void**)&inplaceact);
7581 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceActiveObject) failed: %08lx\n", hres);
7582 if(FAILED(hres))
7583 return;
7585 if(set_clientsite) {
7586 expect_OnFrameWindowActivate_fActivate = TRUE;
7587 SET_EXPECT(OnFrameWindowActivate);
7588 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
7589 ok(hres == S_OK, "OnFrameWindowActivate failed: %08lx\n", hres);
7590 CHECK_CALLED(OnFrameWindowActivate);
7592 SET_EXPECT(OnFrameWindowActivate);
7593 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
7594 ok(hres == S_OK, "OnFrameWindowActivate failed: %08lx\n", hres);
7595 CHECK_CALLED(OnFrameWindowActivate);
7597 expect_OnFrameWindowActivate_fActivate = FALSE;
7598 SET_EXPECT(OnFrameWindowActivate);
7599 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
7600 ok(hres == S_OK, "OnFrameWindowActivate failed: %08lx\n", hres);
7601 CHECK_CALLED(OnFrameWindowActivate);
7603 expect_OnFrameWindowActivate_fActivate = TRUE;
7604 SET_EXPECT(OnFrameWindowActivate);
7605 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
7606 ok(hres == S_OK, "OnFrameWindowActivate failed: %08lx\n", hres);
7607 CHECK_CALLED(OnFrameWindowActivate);
7608 }else {
7609 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, FALSE);
7610 ok(hres == S_OK, "OnFrameWindowActivate failed: %08lx\n", hres);
7612 hres = IOleInPlaceActiveObject_OnFrameWindowActivate(inplaceact, TRUE);
7613 ok(hres == S_OK, "OnFrameWindowActivate failed: %08lx\n", hres);
7616 IOleInPlaceActiveObject_Release(inplaceact);
7619 static void test_object_rects(IHTMLDocument2 *doc)
7621 IOleInPlaceObjectWindowless *windowlessobj;
7622 IOleDocumentView *view;
7623 RECT r, doc_rect;
7624 HRESULT hres;
7626 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless,
7627 (void**)&windowlessobj);
7628 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08lx\n", hres);
7630 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleDocumentView,
7631 (void**)&view);
7632 ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08lx\n", hres);
7634 r.top = 1;
7635 r.left = 2;
7636 r.bottom = 200;
7637 r.right = 201;
7638 hres = IOleInPlaceObjectWindowless_SetObjectRects(windowlessobj, &r, NULL);
7639 ok(hres == S_OK, "SetObjectRects failed: %08lx\n", hres);
7641 GetWindowRect(doc_hwnd, &doc_rect);
7642 MapWindowPoints(HWND_DESKTOP, container_hwnd, (POINT*)&doc_rect, 2);
7643 ok(EqualRect(&r, &doc_rect), "unexpected doc rect %s expected %s\n",
7644 wine_dbgstr_rect(&doc_rect), wine_dbgstr_rect(&r));
7646 memset(&doc_rect, 0xc0, sizeof(doc_rect));
7647 hres = IOleDocumentView_GetRect(view, &doc_rect);
7648 ok(hres == S_OK, "GetRect failed: %08lx\n", hres);
7649 ok(EqualRect(&r, &doc_rect), "unexpected doc rect %s expected %s\n",
7650 wine_dbgstr_rect(&doc_rect), wine_dbgstr_rect(&r));
7652 r.top = 3;
7653 r.left = 4;
7654 r.bottom = 205;
7655 r.right = 206;
7656 hres = IOleDocumentView_SetRect(view, &r);
7657 ok(hres == S_OK, "SetObjectRects failed: %08lx\n", hres);
7659 GetWindowRect(doc_hwnd, &doc_rect);
7660 MapWindowPoints(HWND_DESKTOP, container_hwnd, (POINT*)&doc_rect, 2);
7661 ok(EqualRect(&r, &doc_rect), "unexpected doc rect %s expected %s\n",
7662 wine_dbgstr_rect(&doc_rect), wine_dbgstr_rect(&r));
7664 memset(&doc_rect, 0xc0, sizeof(doc_rect));
7665 hres = IOleDocumentView_GetRect(view, &doc_rect);
7666 ok(hres == S_OK, "GetRect failed: %08lx\n", hres);
7667 ok(EqualRect(&r, &doc_rect), "unexpected doc rect %s expected %s\n",
7668 wine_dbgstr_rect(&doc_rect), wine_dbgstr_rect(&r));
7670 IOleInPlaceObjectWindowless_Release(windowlessobj);
7671 IOleDocumentView_Release(view);
7674 static void test_InPlaceDeactivate(IHTMLDocument2 *doc, BOOL expect_call)
7676 IOleInPlaceObjectWindowless *windowlessobj = NULL;
7677 HRESULT hres;
7679 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleInPlaceObjectWindowless,
7680 (void**)&windowlessobj);
7681 ok(hres == S_OK, "QueryInterface(IID_IOleInPlaceObjectWindowless) failed: %08lx\n", hres);
7682 if(FAILED(hres))
7683 return;
7685 if(expect_call) {
7686 SET_EXPECT(SetStatusText);
7687 SET_EXPECT(OnFocus_FALSE);
7688 if(ipsex)
7689 SET_EXPECT(OnInPlaceDeactivateEx);
7690 else
7691 SET_EXPECT(OnInPlaceDeactivate);
7693 hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
7694 ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
7695 if(expect_call) {
7696 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
7697 CHECK_CALLED(OnFocus_FALSE);
7698 if(ipsex)
7699 CHECK_CALLED(OnInPlaceDeactivateEx);
7700 else
7701 CHECK_CALLED(OnInPlaceDeactivate);
7704 IOleInPlaceObjectWindowless_Release(windowlessobj);
7707 static void test_Activate(IHTMLDocument2 *doc, DWORD flags)
7709 IOleObject *oleobj = NULL;
7710 IOleDocumentView *docview;
7711 GUID guid;
7712 HRESULT hres;
7714 last_hwnd = doc_hwnd;
7716 if(view)
7717 IOleDocumentView_Release(view);
7718 view = NULL;
7720 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
7721 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
7723 hres = IOleObject_GetUserClassID(oleobj, NULL);
7724 ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
7726 hres = IOleObject_GetUserClassID(oleobj, &guid);
7727 ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
7728 ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
7730 test_OnFrameWindowActivate((IUnknown*)doc);
7732 test_ClientSite(oleobj, flags);
7733 test_InPlaceDeactivate(doc, FALSE);
7734 test_DoVerb(oleobj);
7736 if(call_UIActivate == CallUIActivate_AfterShow) {
7737 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
7738 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08lx\n", hres);
7740 SET_EXPECT(OnFocus_TRUE);
7741 SET_EXPECT(SetActiveObject);
7742 SET_EXPECT(ShowUI);
7743 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
7744 SET_EXPECT(InPlaceFrame_SetBorderSpace);
7745 expect_status_text = NULL;
7747 hres = IOleDocumentView_UIActivate(docview, TRUE);
7748 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08lx\n", hres);
7750 CHECK_CALLED(OnFocus_TRUE);
7751 CHECK_CALLED(SetActiveObject);
7752 CHECK_CALLED(ShowUI);
7753 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
7754 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
7756 IOleDocumentView_Release(docview);
7759 IOleObject_Release(oleobj);
7761 test_OnFrameWindowActivate((IUnknown*)doc);
7764 static void test_Window(IHTMLDocument2 *doc, BOOL expect_success)
7766 IOleInPlaceActiveObject *activeobject = NULL;
7767 HWND tmp_hwnd;
7768 HRESULT hres;
7770 hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
7771 ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
7772 if(FAILED(hres))
7773 return;
7775 hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
7777 if(expect_success) {
7778 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
7779 ok(tmp_hwnd == doc_hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, doc_hwnd);
7780 }else {
7781 ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
7782 ok(IsWindow(doc_hwnd), "hwnd is destroyed\n");
7785 IOleInPlaceActiveObject_Release(activeobject);
7788 static void test_CloseView(void)
7790 IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
7791 HRESULT hres;
7793 if(!view)
7794 return;
7796 hres = IOleDocumentView_Show(view, FALSE);
7797 ok(hres == S_OK, "Show failed: %08lx\n", hres);
7799 hres = IOleDocumentView_CloseView(view, 0);
7800 ok(hres == S_OK, "CloseView failed: %08lx\n", hres);
7802 hres = IOleDocumentView_SetInPlaceSite(view, NULL);
7803 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
7805 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
7806 ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
7807 ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
7810 static void test_UIDeactivate(void)
7812 HRESULT hres;
7814 if(call_UIActivate == CallUIActivate_AfterShow) {
7815 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
7817 if(call_UIActivate != CallUIActivate_None) {
7818 SET_EXPECT(SetActiveObject_null);
7819 SET_EXPECT(HideUI);
7820 SET_EXPECT(OnUIDeactivate);
7823 hres = IOleDocumentView_UIActivate(view, FALSE);
7824 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
7826 if(call_UIActivate != CallUIActivate_None) {
7827 CHECK_CALLED(SetActiveObject_null);
7828 CHECK_CALLED(HideUI);
7829 CHECK_CALLED(OnUIDeactivate);
7831 if(call_UIActivate == CallUIActivate_AfterShow) {
7832 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
7836 static void test_Hide(void)
7838 HRESULT hres;
7840 if(!view)
7841 return;
7843 hres = IOleDocumentView_Show(view, FALSE);
7844 ok(hres == S_OK, "Show failed: %08lx\n", hres);
7847 static IHTMLDocument2 *create_document(void)
7849 IHTMLDocument2 *doc;
7850 HRESULT hres;
7852 hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
7853 &IID_IHTMLDocument2, (void**)&doc);
7854 #if !defined(__i386__) && !defined(__x86_64__)
7855 todo_wine
7856 #endif
7857 ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
7858 if(FAILED(hres))
7859 return NULL;
7861 return doc;
7864 static void release_document(IHTMLDocument2 *doc)
7866 IUnknown *unk;
7867 ULONG ref;
7868 HRESULT hres;
7870 /* Some broken IEs don't like if the last released reference is IHTMLDocument2 iface.
7871 * To workaround it, we release it via IUnknown iface */
7872 hres = IHTMLDocument2_QueryInterface(doc, &IID_IUnknown, (void**)&unk);
7873 ok(hres == S_OK, "Could not get IUnknown iface: %08lx\n", hres);
7875 IHTMLDocument2_Release(doc);
7876 ref = IUnknown_Release(unk);
7877 ok(!ref, "ref = %ld\n", ref);
7880 static void test_Navigate(IHTMLDocument2 *doc)
7882 IHlinkTarget *hlink;
7883 HRESULT hres;
7885 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHlinkTarget, (void**)&hlink);
7886 ok(hres == S_OK, "QueryInterface(IID_IHlinkTarget) failed: %08lx\n", hres);
7888 SET_EXPECT(ActivateMe);
7889 hres = IHlinkTarget_Navigate(hlink, 0, NULL);
7890 ok(hres == S_OK, "Navigate failed: %08lx\n", hres);
7891 CHECK_CALLED(ActivateMe);
7893 IHlinkTarget_Release(hlink);
7896 static void test_external(IHTMLDocument2 *doc, BOOL initialized)
7898 IDispatch *external;
7899 IHTMLWindow2 *htmlwin;
7900 HRESULT hres;
7902 hres = IHTMLDocument2_get_parentWindow(doc, &htmlwin);
7903 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
7905 if(initialized)
7906 SET_EXPECT(GetExternal);
7907 external = (void*)0xdeadbeef;
7908 hres = IHTMLWindow2_get_external(htmlwin, &external);
7909 if(initialized) {
7910 ok(hres == S_FALSE || hres == S_OK, "get_external failed: %08lx\n", hres);
7911 CHECK_CALLED(GetExternal);
7912 ok(external != NULL, "external == NULL\n");
7913 }else {
7914 ok(hres == S_OK, "get_external failed: %08lx\n", hres);
7915 ok(external == NULL, "external != NULL\n");
7918 IHTMLWindow2_Release(htmlwin);
7921 static void test_enum_objects(IOleContainer *container)
7923 IEnumUnknown *enum_unknown;
7924 IUnknown *buf[100] = {(void*)0xdeadbeef};
7925 ULONG fetched;
7926 HRESULT hres;
7928 enum_unknown = NULL;
7929 hres = IOleContainer_EnumObjects(container, OLECONTF_EMBEDDINGS, &enum_unknown);
7930 ok(hres == S_OK, "EnumObjects failed: %08lx\n", hres);
7931 ok(enum_unknown != NULL, "enum_unknown == NULL\n");
7933 fetched = 0xdeadbeef;
7934 hres = IEnumUnknown_Next(enum_unknown, ARRAY_SIZE(buf), buf, &fetched);
7935 ok(hres == S_FALSE, "Next returned %08lx\n", hres);
7936 ok(!fetched, "fetched = %ld\n", fetched);
7937 ok(buf[0] == (void*)0xdeadbeef, "buf[0] = %p\n", buf[0]);
7939 fetched = 0xdeadbeef;
7940 hres = IEnumUnknown_Next(enum_unknown, 1, buf, &fetched);
7941 ok(hres == S_FALSE, "Next returned %08lx\n", hres);
7942 ok(!fetched, "fetched = %ld\n", fetched);
7944 hres = IEnumUnknown_Next(enum_unknown, 1, buf, NULL);
7945 ok(hres == S_FALSE, "Next returned %08lx\n", hres);
7947 IEnumUnknown_Release(enum_unknown);
7950 static void test_target_container(IHTMLDocument2 *doc)
7952 IOleContainer *ole_container, *doc_ole_container;
7953 ITargetContainer *target_container;
7954 HRESULT hres;
7956 hres = IHTMLDocument2_QueryInterface(doc, &IID_ITargetContainer, (void**)&target_container);
7957 ok(hres == S_OK, "Could not get ITargetContainer iface: %08lx\n", hres);
7959 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleContainer, (void**)&doc_ole_container);
7960 ok(hres == S_OK, "Could not get ITargetContainer iface: %08lx\n", hres);
7962 ole_container = (void*)0xdeadbeef;
7963 hres = ITargetContainer_GetFramesContainer(target_container, &ole_container);
7964 ok(hres == S_OK, "GetFramesContainer failed: %08lx\n", hres);
7965 ok(ole_container != NULL, "ole_container == NULL\n");
7966 ok(iface_cmp((IUnknown*)ole_container, (IUnknown*)doc_ole_container), "ole_container != doc_ole_container\n");
7967 test_enum_objects(ole_container);
7968 IOleContainer_Release(ole_container);
7970 ITargetContainer_Release(target_container);
7971 IOleContainer_Release(doc_ole_container);
7974 static void test_travellog(IHTMLDocument2 *doc)
7976 ITravelLogClient *travellog_client;
7977 IHTMLWindow2 *window, *top_window;
7978 IUnknown *unk;
7979 HRESULT hres;
7981 window = NULL;
7982 hres = IHTMLDocument2_get_parentWindow(doc, &window);
7983 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
7984 ok(window != NULL, "window = NULL\n");
7986 hres = IHTMLWindow2_get_top(window, &top_window);
7987 IHTMLWindow2_Release(window);
7988 ok(hres == S_OK, "get_top failed: %08lx\n", hres);
7990 hres = IHTMLWindow2_QueryInterface(top_window, &IID_ITravelLogClient, (void**)&travellog_client);
7991 IHTMLWindow2_Release(top_window);
7992 if(hres == E_NOINTERFACE) {
7993 win_skip("ITravelLogClient not supported\n");
7994 no_travellog = TRUE;
7995 return;
7997 ok(hres == S_OK, "Could not get ITraveLogClient iface: %08lx\n", hres);
7999 unk = (void*)0xdeadbeef;
8000 hres = ITravelLogClient_FindWindowByIndex(travellog_client, 0, &unk);
8001 ok(hres == E_FAIL, "FindWindowByIndex failed: %08lx\n", hres);
8002 ok(!unk, "unk != NULL\n");
8004 ITravelLogClient_Release(travellog_client);
8007 static void test_StreamLoad(IHTMLDocument2 *doc)
8009 IPersistStreamInit *init;
8010 HRESULT hres;
8012 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
8013 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08lx\n", hres);
8014 if(FAILED(hres))
8015 return;
8017 SET_EXPECT(Invoke_AMBIENT_SILENT);
8018 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8019 SET_EXPECT(Exec_ShellDocView_37);
8020 SET_EXPECT(OnChanged_READYSTATE);
8021 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
8022 SET_EXPECT(Read);
8023 SET_EXPECT(GetPendingUrl);
8024 readystate_set_loading = TRUE;
8026 hres = IPersistStreamInit_Load(init, &Stream);
8027 ok(hres == S_OK, "Load failed: %08lx\n", hres);
8029 CHECK_CALLED(Invoke_AMBIENT_SILENT);
8030 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8031 CHECK_CALLED(Exec_ShellDocView_37);
8032 CHECK_CALLED(OnChanged_READYSTATE);
8033 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
8034 CHECK_CALLED(Read);
8035 todo_wine CHECK_CALLED(GetPendingUrl);
8037 test_timer(EXPECT_SETTITLE);
8038 test_GetCurMoniker((IUnknown*)doc, NULL, L"about:blank", FALSE);
8040 IPersistStreamInit_Release(init);
8043 static void test_StreamInitNew(IHTMLDocument2 *doc)
8045 IPersistStreamInit *init;
8046 HRESULT hres;
8048 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
8049 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08lx\n", hres);
8050 if(FAILED(hres))
8051 return;
8053 SET_EXPECT(Invoke_AMBIENT_SILENT);
8054 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8055 SET_EXPECT(Exec_ShellDocView_37);
8056 SET_EXPECT(OnChanged_READYSTATE);
8057 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
8058 SET_EXPECT(GetPendingUrl);
8059 readystate_set_loading = TRUE;
8061 hres = IPersistStreamInit_InitNew(init);
8062 ok(hres == S_OK, "Load failed: %08lx\n", hres);
8064 CHECK_CALLED(Invoke_AMBIENT_SILENT);
8065 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8066 CHECK_CALLED(Exec_ShellDocView_37);
8067 CHECK_CALLED(OnChanged_READYSTATE);
8068 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
8069 todo_wine CHECK_CALLED(GetPendingUrl);
8071 test_timer(EXPECT_SETTITLE);
8072 test_GetCurMoniker((IUnknown*)doc, NULL, L"about:blank", FALSE);
8074 IPersistStreamInit_Release(init);
8077 static void test_QueryInterface(IHTMLDocument2 *htmldoc)
8079 IUnknown *qi, *doc = (IUnknown*)htmldoc;
8080 HRESULT hres;
8082 static const IID IID_UndocumentedScriptIface =
8083 {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
8085 qi = (void*)0xdeadbeef;
8086 hres = IUnknown_QueryInterface(doc, &IID_IRunnableObject, (void**)&qi);
8087 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8088 ok(qi == NULL, "qirunnable=%p, expected NULL\n", qi);
8090 qi = (void*)0xdeadbeef;
8091 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode, (void**)&qi);
8092 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8093 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8095 qi = (void*)0xdeadbeef;
8096 hres = IUnknown_QueryInterface(doc, &IID_IHTMLDOMNode2, (void**)&qi);
8097 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8098 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8100 qi = (void*)0xdeadbeef;
8101 hres = IUnknown_QueryInterface(doc, &IID_IPersistPropertyBag, (void**)&qi);
8102 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8103 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8105 qi = (void*)0xdeadbeef;
8106 hres = IUnknown_QueryInterface(doc, &IID_UndocumentedScriptIface, (void**)&qi);
8107 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8108 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8110 qi = (void*)0xdeadbeef;
8111 hres = IUnknown_QueryInterface(doc, &IID_IMarshal, (void**)&qi);
8112 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8113 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8115 qi = (void*)0xdeadbeef;
8116 hres = IUnknown_QueryInterface(doc, &IID_IExternalConnection, (void**)&qi);
8117 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8118 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8120 qi = (void*)0xdeadbeef;
8121 hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi);
8122 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8123 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8125 qi = (void*)0xdeadbeef;
8126 hres = IUnknown_QueryInterface(doc, &IID_ITargetFrame, (void**)&qi);
8127 ok(hres == E_NOINTERFACE, "QueryInterface returned %08lx, expected E_NOINTERFACE\n", hres);
8128 ok(qi == NULL, "qi=%p, expected NULL\n", qi);
8130 hres = IUnknown_QueryInterface(doc, &IID_IDispatch, (void**)&qi);
8131 ok(hres == S_OK, "Could not get IDispatch interface: %08lx\n", hres);
8132 ok(qi != doc, "disp == doc\n");
8133 IUnknown_Release(qi);
8136 static void test_mimeType(IHTMLDocument2 *doc, const WCHAR *content_type)
8138 BSTR mime_type = (BSTR)0xdeadbeef;
8139 HRESULT hres;
8141 hres = IHTMLDocument2_get_mimeType(doc, &mime_type);
8142 if(content_type) {
8143 BSTR display_name = get_mime_type_display_name(content_type);
8144 ok(hres == S_OK, "get_mimeType returned %08lx\n", hres);
8145 ok(!wcscmp(mime_type, display_name), "mime type = %s, expected %s\n",
8146 debugstr_w(mime_type), debugstr_w(display_name));
8147 SysFreeString(display_name);
8148 }else {
8149 ok(hres == S_OK || broken(hres == E_FAIL), "get_mimeType returned %08lx\n", hres);
8150 ok(!mime_type || !mime_type[0], "mime type = %s\n", debugstr_w(mime_type));
8152 SysFreeString(mime_type);
8155 static void init_test(enum load_state_t ls) {
8156 doc_unk = NULL;
8157 doc_hwnd = last_hwnd = NULL;
8158 set_clientsite = FALSE;
8159 load_from_stream = FALSE;
8160 call_UIActivate = CallUIActivate_None;
8161 load_state = ls;
8162 editmode = FALSE;
8163 stream_read = 0;
8164 protocol_read = 0;
8165 nav_url = NULL;
8166 ipsex = FALSE;
8167 inplace_deactivated = FALSE;
8168 complete = FALSE;
8169 testing_submit = FALSE;
8170 expect_uihandler_iface = &DocHostUIHandler;
8171 is_mhtml = FALSE;
8174 static void test_HTMLDocument(BOOL do_load, BOOL mime)
8176 IHTMLDocument2 *doc;
8178 trace("Testing HTMLDocument (%s, %s)...\n", (do_load ? "load" : "no load"),
8179 (report_mime ? "mime" : "no mime"));
8181 init_test(do_load ? LD_DOLOAD : LD_NO);
8182 report_mime = mime;
8184 doc = create_document();
8185 doc_unk = (IUnknown*)doc;
8187 test_QueryInterface(doc);
8188 test_GetSetExtent(doc);
8189 test_Advise(doc);
8190 test_IsDirty(doc, S_FALSE);
8191 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8192 test_external(doc, FALSE);
8193 test_ViewAdviseSink(doc);
8194 test_ConnectionPointContainer(doc);
8195 test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
8196 test_Persist(doc, &Moniker);
8197 if(!do_load)
8198 test_OnAmbientPropertyChange2(doc);
8200 test_Activate(doc, CLIENTSITE_EXPECTPATH);
8202 if(do_load) {
8203 set_custom_uihandler(doc, &CustomDocHostUIHandler);
8204 test_download(DWL_CSS|DWL_TRYCSS);
8205 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL, FALSE);
8206 test_elem_from_point(doc);
8208 test_mimeType(doc, do_load ? L"text/html" : NULL);
8210 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8211 test_OleCommandTarget_fail(doc);
8212 test_OleCommandTarget(doc);
8213 test_exec_optical_zoom(doc, 200);
8214 test_exec_optical_zoom(doc, 100);
8215 test_OnAmbientPropertyChange(doc);
8216 test_Window(doc, TRUE);
8217 test_external(doc, TRUE);
8218 test_target_container(doc);
8219 test_object_rects(doc);
8221 test_UIDeactivate();
8222 test_OleCommandTarget(doc);
8223 test_Window(doc, TRUE);
8224 test_InPlaceDeactivate(doc, TRUE);
8226 /* Calling test_OleCommandTarget here causes Segmentation Fault with native
8227 * MSHTML. It doesn't with Wine. */
8229 test_Window(doc, FALSE);
8230 test_Hide();
8231 test_InPlaceDeactivate(doc, FALSE);
8232 test_CloseView();
8233 test_Close(doc, FALSE);
8235 /* Activate HTMLDocument again */
8236 test_Activate(doc, CLIENTSITE_SETNULL);
8237 test_Window(doc, TRUE);
8238 test_OleCommandTarget(doc);
8239 test_UIDeactivate();
8240 test_InPlaceDeactivate(doc, TRUE);
8241 test_Close(doc, FALSE);
8243 /* Activate HTMLDocument again, this time without UIActivate */
8244 call_UIActivate = CallUIActivate_None;
8245 test_Activate(doc, CLIENTSITE_SETNULL);
8246 test_Window(doc, TRUE);
8248 test_external(doc, TRUE);
8249 set_custom_uihandler(doc, NULL);
8250 test_external(doc, FALSE);
8252 test_UIDeactivate();
8253 test_InPlaceDeactivate(doc, TRUE);
8254 test_CloseView();
8255 test_CloseView();
8256 test_Close(doc, TRUE);
8257 test_OnAmbientPropertyChange2(doc);
8258 test_GetCurMoniker((IUnknown*)doc, do_load ? &Moniker : NULL, NULL, FALSE);
8260 if(!do_load) {
8261 /* Activate HTMLDocument again, calling UIActivate after showing the window */
8262 call_UIActivate = CallUIActivate_AfterShow;
8263 test_Activate(doc, 0);
8264 test_Window(doc, TRUE);
8265 test_OleCommandTarget(doc);
8266 test_UIDeactivate();
8267 test_InPlaceDeactivate(doc, TRUE);
8268 test_Close(doc, FALSE);
8269 call_UIActivate = CallUIActivate_None;
8272 if(view)
8273 IOleDocumentView_Release(view);
8274 view = NULL;
8276 ok(IsWindow(doc_hwnd), "hwnd is destroyed\n");
8277 release_document(doc);
8278 ok(!IsWindow(doc_hwnd), "hwnd is not destroyed\n");
8281 static void test_MHTMLDocument(void)
8283 IHTMLDocument2 *doc;
8284 IOleObject *oleobj;
8285 HRESULT hres;
8287 if(!is_ie9plus) {
8288 win_skip("Skipping MHTML document tests on too old IE.\n");
8289 return;
8292 trace("Testing MHTMLDocument...\n");
8294 init_test(LD_DOLOAD);
8295 is_mhtml = TRUE;
8296 nav_url = nav_serv_url = L"mhtml:winetest:doc";
8298 hres = CoCreateInstance(&CLSID_MHTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
8299 &IID_IHTMLDocument2, (void**)&doc);
8300 ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
8302 doc_unk = (IUnknown*)doc;
8304 test_QueryInterface(doc);
8305 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8306 test_ViewAdviseSink(doc);
8307 test_ConnectionPointContainer(doc);
8309 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
8310 ok(hres == S_OK, "Could not get IOleObject iface: %08lx\n", hres);
8311 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
8312 test_DoVerb(oleobj);
8313 IOleObject_Release(oleobj);
8315 test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
8316 test_Persist(doc, &Moniker);
8317 set_custom_uihandler(doc, &CustomDocHostUIHandler);
8318 test_GetCurMoniker((IUnknown*)doc, NULL, L"mhtml:winetest:doc", FALSE);
8319 test_download(0);
8320 test_mimeType(doc, L"text/html");
8322 test_exec_onunload(doc);
8323 test_UIDeactivate();
8324 test_InPlaceDeactivate(doc, TRUE);
8325 test_InPlaceDeactivate(doc, FALSE);
8326 test_CloseView();
8327 test_Close(doc, TRUE);
8329 if(view)
8330 IOleDocumentView_Release(view);
8331 view = NULL;
8333 release_document(doc);
8336 static void test_HTMLDocument_hlink(DWORD status)
8338 IHTMLDocument2 *doc;
8340 trace("Testing HTMLDocument (hlink)...\n");
8342 init_test(LD_DOLOAD);
8343 ipsex = TRUE;
8345 doc = create_document();
8346 doc_unk = (IUnknown*)doc;
8348 set_custom_uihandler(doc, &CustomDocHostUIHandler);
8349 test_ViewAdviseSink(doc);
8350 test_ConnectionPointContainer(doc);
8351 test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
8352 test_Persist(doc, &Moniker);
8353 test_Navigate(doc);
8355 status_code = status;
8356 test_download(DWL_CSS|DWL_TRYCSS);
8357 status_code = HTTP_STATUS_OK;
8359 test_IsDirty(doc, S_FALSE);
8360 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8362 test_exec_onunload(doc);
8363 test_Window(doc, TRUE);
8364 test_InPlaceDeactivate(doc, TRUE);
8365 test_Close(doc, FALSE);
8366 test_IsDirty(doc, S_FALSE);
8367 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL, FALSE);
8368 test_clear(doc);
8369 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL, FALSE);
8371 if(view)
8372 IOleDocumentView_Release(view);
8373 view = NULL;
8375 release_document(doc);
8378 static void test_cookies(IHTMLDocument2 *doc)
8380 WCHAR buf[1024];
8381 DWORD size;
8382 BSTR str, str2;
8383 BOOL b;
8384 HRESULT hres;
8386 hres = IHTMLDocument2_get_cookie(doc, &str);
8387 ok(hres == S_OK, "get_cookie failed: %08lx\n", hres);
8388 if(str) {
8389 size = ARRAY_SIZE(buf);
8390 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
8391 ok(b, "InternetGetCookieW failed: %08lx\n", GetLastError());
8392 ok(!lstrcmpW(buf, str), "cookie = %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(buf));
8393 SysFreeString(str);
8396 str = SysAllocString(L"test=testval");
8397 hres = IHTMLDocument2_put_cookie(doc, str);
8398 ok(hres == S_OK, "put_cookie failed: %08lx\n", hres);
8400 str2 = NULL;
8401 hres = IHTMLDocument2_get_cookie(doc, &str2);
8402 ok(hres == S_OK, "get_cookie failed: %08lx\n", hres);
8403 ok(str2 != NULL, "cookie = NULL\n");
8404 size = ARRAY_SIZE(buf);
8405 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
8406 ok(b, "InternetGetCookieW failed: %08lx\n", GetLastError());
8407 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
8408 if(str2)
8409 ok(wcsstr(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
8410 SysFreeString(str);
8411 SysFreeString(str2);
8413 str = SysAllocString(L"test=testval2");
8414 hres = IHTMLDocument2_put_cookie(doc, str);
8415 ok(hres == S_OK, "put_cookie failed: %08lx\n", hres);
8417 str2 = NULL;
8418 hres = IHTMLDocument2_get_cookie(doc, &str2);
8419 ok(hres == S_OK, "get_cookie failed: %08lx\n", hres);
8420 ok(str2 != NULL, "cookie = NULL\n");
8421 size = ARRAY_SIZE(buf);
8422 b = InternetGetCookieW(http_urlW, NULL, buf, &size);
8423 ok(b, "InternetGetCookieW failed: %08lx\n", GetLastError());
8424 ok(!lstrcmpW(buf, str2), "cookie = %s, expected %s\n", wine_dbgstr_w(str2), wine_dbgstr_w(buf));
8425 if(str2)
8426 ok(wcsstr(str2, str) != NULL, "could not find %s in %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str2));
8427 SysFreeString(str);
8428 SysFreeString(str2);
8431 static void test_doc_domain(IHTMLDocument2 *doc)
8433 BSTR str;
8434 HRESULT hres;
8436 hres = IHTMLDocument2_get_domain(doc, &str);
8437 ok(hres == S_OK, "get_domain failed: %08lx\n", hres);
8438 ok(!lstrcmpW(str, L"test.winehq.org"), "domain = %s\n", wine_dbgstr_w(str));
8439 SysFreeString(str);
8441 str = SysAllocString(L"winehq.org");
8442 hres = IHTMLDocument2_put_domain(doc, str);
8443 ok(hres == S_OK, "put_domain failed: %08lx\n", hres);
8444 SysFreeString(str);
8446 hres = IHTMLDocument2_get_domain(doc, &str);
8447 ok(hres == S_OK, "get_domain failed: %08lx\n", hres);
8448 ok(!lstrcmpW(str, L"winehq.org"), "domain = %s\n", wine_dbgstr_w(str));
8449 SysFreeString(str);
8451 str = SysAllocString(L"winehq.com");
8452 hres = IHTMLDocument2_put_domain(doc, str);
8453 ok(hres == E_INVALIDARG, "put_domain failed: %08lx, expected E_INVALIDARG\n", hres);
8454 SysFreeString(str);
8456 hres = IHTMLDocument2_get_domain(doc, &str);
8457 ok(hres == S_OK, "get_domain failed: %08lx\n", hres);
8458 ok(!lstrcmpW(str, L"winehq.org"), "domain = %s\n", wine_dbgstr_w(str));
8459 SysFreeString(str);
8462 static void test_HTMLDocument_http(BOOL with_wbapp)
8464 IHTMLDocument2 *doc, *doc_node;
8465 IHTMLWindow2 *window;
8466 IMoniker *http_mon;
8467 HRESULT hres;
8468 ULONG ref;
8469 BSTR bstr;
8471 trace("Testing HTMLDocument (http%s)...\n", with_wbapp ? " with IWebBrowserApp" : "");
8473 support_wbapp = with_wbapp;
8475 if(!winetest_interactive && is_ie_hardened()) {
8476 win_skip("IE running in Enhanced Security Configuration\n");
8477 return;
8480 init_test(LD_DOLOAD);
8481 ipsex = TRUE;
8483 doc = create_document();
8484 doc_unk = (IUnknown*)doc;
8486 hres = CreateURLMoniker(NULL, http_urlW, &http_mon);
8487 ok(hres == S_OK, "CreateURLMoniker failed: %08lx\n", hres);
8489 test_ViewAdviseSink(doc);
8490 test_ConnectionPointContainer(doc);
8491 test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
8492 test_Persist(doc, http_mon);
8493 test_Navigate(doc);
8494 test_download(DWL_HTTP);
8495 test_cookies(doc);
8496 test_IsDirty(doc, S_FALSE);
8497 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8498 test_GetCurMoniker((IUnknown*)doc, http_mon, NULL, FALSE);
8499 test_travellog(doc);
8500 test_binding_ui((IUnknown*)doc);
8501 test_doc_domain(doc);
8503 nav_url = nav_serv_url = L"http://test.winehq.org/tests/winehq_snapshot/"; /* for valid prev nav_url */
8504 if(support_wbapp) {
8505 test_put_href(doc, FALSE, L"#test", L"http://test.winehq.org/tests/winehq_snapshot/#test", FALSE, TRUE, 0);
8506 test_travellog(doc);
8507 test_refresh(doc);
8508 test_reload(doc);
8510 test_put_href(doc, FALSE, NULL, L"javascript:external%20&&undefined", TRUE, FALSE, 0);
8511 test_put_href(doc, FALSE, NULL, L"about:blank", FALSE, FALSE, support_wbapp ? DWL_EXPECT_HISTUPDATE : 0);
8512 test_put_href(doc, TRUE, NULL, L"about:replace", FALSE, FALSE, 0);
8513 if(support_wbapp) {
8514 test_load_history(doc);
8515 test_OmHistory(doc);
8516 test_put_href(doc, FALSE, NULL, L"about:blank", FALSE, FALSE, support_wbapp ? DWL_EXPECT_HISTUPDATE : 0);
8519 prev_url = nav_serv_url;
8520 test_open_window(doc, TRUE);
8521 if(!support_wbapp) /* FIXME */
8522 test_open_window(doc, FALSE);
8523 if(support_wbapp) {
8524 test_super_navigate(doc);
8525 test_put_href(doc, FALSE, NULL, L"http://test.winehq.org/tests/file.winetest", FALSE, FALSE, DWL_EXTERNAL);
8526 test_window_close(doc);
8529 test_InPlaceDeactivate(doc, TRUE);
8530 test_Close(doc, FALSE);
8531 test_IsDirty(doc, S_FALSE);
8532 test_GetCurMoniker((IUnknown*)doc, NULL, prev_url, support_wbapp);
8534 hres = IHTMLDocument2_get_parentWindow(doc, &window);
8535 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
8537 hres = IHTMLWindow2_get_document(window, &doc_node);
8538 ok(hres == S_OK, "get_document failed: %08lx\n", hres);
8540 hres = IHTMLDocument2_get_readyState(doc_node, &bstr);
8541 ok(hres == S_OK, "get_readyState failed: %08lx\n", hres);
8542 todo_wine_if(support_wbapp)
8543 ok(!wcscmp(bstr, support_wbapp ? L"interactive" : L"complete"), "readyState = %s\n", wine_dbgstr_w(bstr));
8544 SysFreeString(bstr);
8546 if(view)
8547 IOleDocumentView_Release(view);
8548 view = NULL;
8550 release_document(doc);
8552 hres = IHTMLWindow2_get_document(window, &doc);
8553 ok(hres == S_OK, "get_document failed: %08lx\n", hres);
8554 ok(doc != doc_node, "doc == doc_node\n");
8556 hres = IHTMLDocument2_get_readyState(doc_node, &bstr);
8557 ok(hres == S_OK, "get_readyState failed: %08lx\n", hres);
8558 ok(!wcscmp(bstr, L"uninitialized"), "readyState = %s\n", wine_dbgstr_w(bstr));
8559 SysFreeString(bstr);
8561 hres = IHTMLDocument2_get_readyState(doc, &bstr);
8562 ok(hres == S_OK, "get_readyState failed: %08lx\n", hres);
8563 ok(!wcscmp(bstr, L"uninitialized"), "readyState = %s\n", wine_dbgstr_w(bstr));
8564 SysFreeString(bstr);
8566 IHTMLDocument2_Release(doc_node);
8567 IHTMLDocument2_Release(doc);
8568 IHTMLWindow2_Release(window);
8570 ref = IMoniker_Release(http_mon);
8571 ok(!ref, "ref=%ld, expected 0\n", ref);
8574 static void put_inner_html(IHTMLElement *elem, const WCHAR *html)
8576 BSTR str = SysAllocString(html);
8577 HRESULT hres;
8579 hres = IHTMLElement_put_innerHTML(elem, str);
8580 ok(hres == S_OK, "put_innerHTML failed: %08lx\n", hres);
8582 SysFreeString(str);
8585 static IHTMLElement *get_elem_by_id(IHTMLDocument2 *doc, const WCHAR *id)
8587 IHTMLDocument3 *doc3;
8588 BSTR str = SysAllocString(id);
8589 IHTMLElement *ret;
8590 HRESULT hres;
8592 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
8593 ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08lx\n", hres);
8595 hres = IHTMLDocument3_getElementById(doc3, str, &ret);
8596 ok(hres == S_OK, "getElementById failed: %08lx\n", hres);
8598 IHTMLDocument3_Release(doc3);
8599 return ret;
8602 static void reset_document(IHTMLDocument2 *doc)
8604 IPersistStreamInit *init;
8605 HRESULT hres;
8607 hres = IHTMLDocument2_QueryInterface(doc, &IID_IPersistStreamInit, (void**)&init);
8608 ok(hres == S_OK, "QueryInterface(IID_IPersistStreamInit) failed: %08lx\n", hres);
8609 if(FAILED(hres))
8610 return;
8612 resetting_document = TRUE;
8614 hres = IPersistStreamInit_InitNew(init);
8615 ok(hres == S_OK, "Load failed: %08lx\n", hres);
8617 resetting_document = FALSE;
8619 test_GetCurMoniker((IUnknown*)doc, NULL, L"about:blank", FALSE);
8621 IPersistStreamInit_Release(init);
8624 static void test_submit(void)
8626 IHTMLElement *body, *form_elem;
8627 IHTMLFormElement *form;
8628 IHTMLDocument2 *doc;
8629 HRESULT hres;
8631 if(no_travellog)
8632 return;
8634 trace("Testing submit...\n");
8636 support_wbapp = TRUE;
8638 if(!winetest_interactive && is_ie_hardened()) {
8639 win_skip("IE running in Enhanced Security Configuration\n");
8640 return;
8643 init_test(LD_DOLOAD);
8644 ipsex = TRUE;
8646 doc = create_document();
8647 doc_unk = (IUnknown*)doc;
8649 test_ConnectionPointContainer(doc);
8650 test_ViewAdviseSink(doc);
8651 test_Persist(doc, &Moniker);
8652 test_Navigate(doc);
8653 test_download(DWL_CSS|DWL_TRYCSS);
8655 hres = IHTMLDocument2_get_body(doc, &body);
8656 ok(hres == S_OK, "get_body failed: %08lx\n", hres);
8657 ok(body != NULL, "body = NULL\n");
8659 put_inner_html(body, L"<form action='test_submit' method='post' id='fid'><input type='hidden' name='cmd' value='TEST'></form>");
8660 IHTMLElement_Release(body);
8662 form_elem = get_elem_by_id(doc, L"fid");
8663 ok(form_elem != NULL, "form = NULL\n");
8665 hres = IHTMLElement_QueryInterface(form_elem, &IID_IHTMLFormElement, (void**)&form);
8666 ok(hres == S_OK, "Could not get IHTMLFormElement: %08lx\n", hres);
8667 IHTMLElement_Release(form_elem);
8669 nav_url = nav_serv_url = L"winetest:test_submit";
8670 testing_submit = TRUE;
8672 SET_EXPECT(TranslateUrl);
8673 SET_EXPECT(FireBeforeNavigate2);
8674 SET_EXPECT(Exec_ShellDocView_67);
8675 SET_EXPECT(Invoke_AMBIENT_SILENT);
8676 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8677 SET_EXPECT(Exec_ShellDocView_63);
8678 SET_EXPECT(Exec_ShellDocView_84);
8679 SET_EXPECT(CreateInstance);
8680 SET_EXPECT(Start);
8681 SET_EXPECT(Protocol_Read);
8682 SET_EXPECT(LockRequest);
8683 SET_EXPECT(GetClassID);
8684 SET_EXPECT(Exec_ShellDocView_138);
8685 SET_EXPECT(OnViewChange);
8687 SET_EXPECT(UnlockRequest);
8688 SET_EXPECT(Terminate);
8690 hres = IHTMLFormElement_submit(form);
8691 ok(hres == S_OK, "submit failed: %08lx\n", hres);
8693 CHECK_CALLED(TranslateUrl);
8694 CHECK_CALLED(FireBeforeNavigate2);
8695 CLEAR_CALLED(Exec_ShellDocView_67); /* Not called by IE11 */
8696 CHECK_CALLED(Invoke_AMBIENT_SILENT);
8697 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8698 CHECK_CALLED(Exec_ShellDocView_63);
8699 CLEAR_CALLED(Exec_ShellDocView_84); /* Not called by IE11 */
8700 CHECK_CALLED(CreateInstance);
8701 CHECK_CALLED(Start);
8702 CHECK_CALLED(Protocol_Read);
8703 CHECK_CALLED(LockRequest);
8704 todo_wine CHECK_CALLED(GetClassID);
8705 CLEAR_CALLED(Exec_ShellDocView_138); /* called only by some versions */
8706 CLEAR_CALLED(OnViewChange); /* called only by some versions */
8708 todo_wine CHECK_NOT_CALLED(UnlockRequest);
8709 todo_wine CHECK_NOT_CALLED(Terminate);
8711 IHTMLFormElement_Release(form);
8713 test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL, FALSE);
8715 SET_EXPECT(UnlockRequest);
8716 reset_document(doc);
8717 todo_wine CHECK_CALLED(UnlockRequest);
8719 test_InPlaceDeactivate(doc, TRUE);
8720 test_Close(doc, FALSE);
8722 if(view)
8723 IOleDocumentView_Release(view);
8724 view = NULL;
8726 release_document(doc);
8729 static void test_QueryService(IHTMLDocument2 *doc, BOOL success)
8731 IHTMLWindow2 *window, *sp_window;
8732 IServiceProvider *sp;
8733 IHlinkFrame *hf;
8734 HRESULT hres;
8736 hres = IHTMLDocument2_QueryInterface(doc, &IID_IServiceProvider, (void**)&sp);
8737 ok(hres == S_OK, "QueryService returned %08lx\n", hres);
8739 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
8740 if(!success) {
8741 ok(hres == E_NOINTERFACE, "QueryService returned %08lx, expected E_NOINTERFACE\n", hres);
8742 IServiceProvider_Release(sp);
8743 return;
8746 ok(hres == S_OK, "QueryService(IID_IHlinkFrame) failed: %08lx\n", hres);
8747 ok(hf == &HlinkFrame, "hf != HlinkFrame\n");
8748 IHlinkFrame_Release(hf);
8750 IServiceProvider_Release(sp);
8752 hres = IHTMLDocument2_get_parentWindow(doc, &window);
8753 ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
8755 hres = IHTMLWindow2_QueryInterface(window, &IID_IServiceProvider, (void**)&sp);
8756 ok(hres == S_OK, "Could not get IServiceProvider iface: %08lx\n", hres);
8758 hres = IServiceProvider_QueryService(sp, &IID_IHTMLWindow2, &IID_IHTMLWindow2, (void**)&sp_window);
8759 ok(hres == S_OK, "QueryService(IID_IHTMLWindow2) failed: %08lx\n", hres);
8760 /* FIXME: test returned window */
8761 IHTMLWindow2_Release(sp_window);
8763 hres = IServiceProvider_QueryService(sp, &IID_IHlinkFrame, &IID_IHlinkFrame, (void**)&hf);
8764 ok(hres == S_OK, "QueryService(IID_IHlinkFrame) failed: %08lx\n", hres);
8765 ok(hf == &HlinkFrame, "hf != HlinkFrame\n");
8766 IHlinkFrame_Release(hf);
8768 IServiceProvider_Release(sp);
8769 IHTMLWindow2_Release(window);
8772 static void test_HTMLDocument_StreamLoad(void)
8774 IHTMLDocument2 *doc;
8775 IOleObject *oleobj;
8776 DWORD conn;
8777 HRESULT hres;
8779 trace("Testing HTMLDocument (IPersistStreamInit)...\n");
8781 init_test(LD_DOLOAD);
8782 load_from_stream = TRUE;
8784 doc = create_document();
8785 doc_unk = (IUnknown*)doc;
8787 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
8788 ok(hres == S_OK, "Could not get IOleObject: %08lx\n", hres);
8790 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
8791 ok(hres == S_OK, "Advise failed: %08lx\n", hres);
8793 test_readyState((IUnknown*)doc);
8794 test_IsDirty(doc, S_FALSE);
8795 test_ViewAdviseSink(doc);
8796 test_ConnectionPointContainer(doc);
8797 test_QueryService(doc, FALSE);
8798 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
8799 test_QueryService(doc, TRUE);
8800 test_DoVerb(oleobj);
8801 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8803 test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
8804 test_StreamLoad(doc);
8805 test_download(DWL_VERBDONE|DWL_TRYCSS);
8806 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8808 test_UIDeactivate();
8809 test_InPlaceDeactivate(doc, TRUE);
8810 SET_EXPECT(Advise_Close);
8811 test_Close(doc, TRUE);
8812 CHECK_CALLED(Advise_Close);
8813 test_external(doc, FALSE);
8814 test_IsDirty(doc, S_FALSE);
8816 set_custom_uihandler(doc, &CustomDocHostUIHandler);
8817 test_ClientSite(oleobj, CLIENTSITE_SETNULL);
8818 test_external(doc, TRUE);
8819 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
8820 test_external(doc, TRUE);
8821 set_custom_uihandler(doc, NULL);
8822 test_ClientSite(oleobj, CLIENTSITE_SETNULL|CLIENTSITE_DONTSET);
8824 IOleObject_Release(oleobj);
8825 if(view) {
8826 IOleDocumentView_Release(view);
8827 view = NULL;
8830 release_document(doc);
8833 static void test_HTMLDocument_StreamInitNew(void)
8835 IHTMLDocument2 *doc;
8836 IOleObject *oleobj;
8837 DWORD conn;
8838 HRESULT hres;
8840 trace("Testing HTMLDocument (IPersistStreamInit::InitNew)...\n");
8842 init_test(LD_DOLOAD);
8843 load_from_stream = TRUE;
8845 doc = create_document();
8846 doc_unk = (IUnknown*)doc;
8848 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
8849 ok(hres == S_OK, "Could not get IOleObject: %08lx\n", hres);
8851 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
8852 ok(hres == S_OK, "Advise failed: %08lx\n", hres);
8854 test_readyState((IUnknown*)doc);
8855 test_IsDirty(doc, S_FALSE);
8856 test_ViewAdviseSink(doc);
8857 test_ConnectionPointContainer(doc);
8858 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
8859 test_DoVerb(oleobj);
8860 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8862 IOleObject_Release(oleobj);
8864 test_GetCurMoniker((IUnknown*)doc, NULL, NULL, FALSE);
8865 test_StreamInitNew(doc);
8867 SET_EXPECT(Invoke_OnReadyStateChange_Interactive);
8868 test_download(DWL_VERBDONE|DWL_TRYCSS|DWL_EMPTY);
8869 todo_wine CHECK_NOT_CALLED(Invoke_OnReadyStateChange_Interactive);
8871 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8873 test_UIDeactivate();
8874 test_InPlaceDeactivate(doc, TRUE);
8875 SET_EXPECT(Advise_Close);
8876 test_Close(doc, FALSE);
8877 CHECK_CALLED(Advise_Close);
8878 test_IsDirty(doc, S_FALSE);
8880 if(view) {
8881 IOleDocumentView_Release(view);
8882 view = NULL;
8885 release_document(doc);
8888 static void test_edit_uiactivate(IOleObject *oleobj)
8890 IOleDocumentView *docview;
8891 HRESULT hres;
8893 hres = IOleObject_QueryInterface(oleobj, &IID_IOleDocumentView, (void **)&docview);
8894 ok(hres == S_OK, "IOleObject_QueryInterface failed with error 0x%08lx\n", hres);
8896 SET_EXPECT(OnFocus_TRUE);
8897 SET_EXPECT(SetActiveObject);
8898 SET_EXPECT(ShowUI);
8899 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
8900 SET_EXPECT(InPlaceFrame_SetBorderSpace);
8901 expect_status_text = NULL;
8903 hres = IOleDocumentView_UIActivate(docview, TRUE);
8904 ok(hres == S_OK, "IOleDocumentView_UIActivate failed with error 0x%08lx\n", hres);
8906 CHECK_CALLED(OnFocus_TRUE);
8907 CHECK_CALLED(SetActiveObject);
8908 CHECK_CALLED(ShowUI);
8909 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
8910 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
8912 IOleDocumentView_Release(docview);
8915 static void test_editing_mode(BOOL do_load, BOOL use_design_mode)
8917 IHTMLDocument2 *doc;
8918 IUnknown *unk;
8919 IOleObject *oleobj;
8920 DWORD conn;
8921 HRESULT hres;
8923 trace("Testing HTMLDocument (edit%s%s)...\n", do_load ? " load" : "", use_design_mode ? " using designMode" : "");
8925 init_test(do_load ? LD_DOLOAD : LD_NO);
8926 call_UIActivate = CallUIActivate_AfterShow;
8928 doc = create_document();
8929 unk = doc_unk = (IUnknown*)doc;
8931 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
8932 ok(hres == S_OK, "Could not get IOleObject: %08lx\n", hres);
8934 hres = IOleObject_Advise(oleobj, (IAdviseSink*)&AdviseSink, &conn);
8935 ok(hres == S_OK, "Advise failed: %08lx\n", hres);
8937 test_readyState((IUnknown*)doc);
8938 test_ViewAdviseSink(doc);
8939 test_ConnectionPointContainer(doc);
8940 test_ClientSite(oleobj, CLIENTSITE_EXPECTPATH);
8941 test_DoVerb(oleobj);
8942 test_edit_uiactivate(oleobj);
8944 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
8945 if(do_load)
8946 test_Persist(doc, &Moniker);
8947 stream_read = protocol_read = 0;
8949 if(!use_design_mode) {
8950 test_exec_editmode(unk, do_load);
8951 test_UIDeactivate();
8952 call_UIActivate = CallUIActivate_None;
8953 }else {
8954 BSTR on;
8956 SET_EXPECT(Exec_SETTITLE);
8957 test_download(DWL_VERBDONE|DWL_CSS|DWL_TRYCSS);
8958 CLEAR_CALLED(Exec_SETTITLE);
8960 editmode = TRUE;
8961 load_state = LD_DOLOAD;
8962 readystate_set_loading = TRUE;
8964 SET_EXPECT(OnChanged_1005);
8965 SET_EXPECT(ActiveElementChanged);
8966 SET_EXPECT(GetClassID);
8967 SET_EXPECT(SetStatusText);
8968 SET_EXPECT(Exec_ShellDocView_37);
8969 SET_EXPECT(GetHostInfo);
8970 SET_EXPECT(GetDisplayName);
8971 SET_EXPECT(Invoke_AMBIENT_SILENT);
8972 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8973 SET_EXPECT(OnChanged_READYSTATE);
8974 SET_EXPECT(Invoke_OnReadyStateChange_Loading);
8975 SET_EXPECT(IsSystemMoniker);
8976 SET_EXPECT(Exec_ShellDocView_84);
8977 SET_EXPECT(BindToStorage);
8978 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
8979 SET_EXPECT(HideUI);
8980 SET_EXPECT(ShowUI);
8981 SET_EXPECT(InPlaceFrame_SetBorderSpace);
8982 SET_EXPECT(OnChanged_1014);
8984 on = SysAllocString(L"On");
8985 hres = IHTMLDocument2_put_designMode(doc, on);
8986 SysFreeString(on);
8987 ok(hres == S_OK, "put_designMode failed: %08lx\n", hres);
8989 todo_wine CHECK_CALLED(OnChanged_1005);
8990 todo_wine CHECK_CALLED(ActiveElementChanged);
8991 CHECK_CALLED(GetClassID);
8992 CHECK_CALLED(SetStatusText);
8993 CHECK_CALLED(Exec_ShellDocView_37);
8994 CHECK_CALLED(GetHostInfo);
8995 CHECK_CALLED(GetDisplayName);
8996 CHECK_CALLED(Invoke_AMBIENT_SILENT);
8997 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
8998 CHECK_CALLED(OnChanged_READYSTATE);
8999 CHECK_CALLED(Invoke_OnReadyStateChange_Loading);
9000 CLEAR_CALLED(IsSystemMoniker); /* IE7 */
9001 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
9002 CHECK_CALLED(BindToStorage);
9003 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
9004 CHECK_CALLED(HideUI);
9005 CHECK_CALLED(ShowUI);
9006 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
9007 CHECK_CALLED(OnChanged_1014);
9009 test_timer(EXPECT_UPDATEUI|EXPECT_SETTITLE);
9012 IOleObject_Release(oleobj);
9014 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);
9015 test_download(DWL_VERBDONE | DWL_EX_GETHOSTINFO | (do_load ? DWL_CSS|DWL_TRYCSS : 0));
9017 SET_EXPECT(SetStatusText); /* ignore race in native mshtml */
9018 test_timer(EXPECT_UPDATEUI);
9019 CLEAR_CALLED(SetStatusText);
9021 test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED|OLECMDF_ENABLED);
9023 if(!do_load) {
9024 test_exec_fontname(unk, wszArial, wszTimesNewRoman);
9025 test_timer(EXPECT_UPDATEUI);
9026 test_exec_fontname(unk, NULL, wszArial);
9028 test_exec_noargs(unk, IDM_JUSTIFYRIGHT);
9029 test_timer(EXPECT_UPDATEUI);
9030 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
9031 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
9033 test_exec_noargs(unk, IDM_JUSTIFYCENTER);
9034 test_timer(EXPECT_UPDATEUI);
9035 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT,
9036 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
9037 test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER,
9038 OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED);
9040 test_exec_noargs(unk, IDM_HORIZONTALLINE);
9041 test_timer(EXPECT_UPDATEUI);
9042 test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE,
9043 OLECMDF_SUPPORTED|OLECMDF_ENABLED);
9046 test_UIDeactivate();
9047 test_InPlaceDeactivate(doc, TRUE);
9048 SET_EXPECT(Advise_Close);
9049 test_Close(doc, FALSE);
9050 CHECK_CALLED(Advise_Close);
9052 if(view) {
9053 IOleDocumentView_Release(view);
9054 view = NULL;
9057 release_document(doc);
9060 static void test_UIActivate(BOOL do_load, BOOL use_ipsex, BOOL use_ipsw)
9062 IHTMLDocument2 *doc;
9063 IOleObject *oleobj;
9064 IOleInPlaceSite *inplacesite;
9065 HRESULT hres;
9067 trace("Running OleDocumentView_UIActivate tests (%d %d %d)\n", do_load, use_ipsex, use_ipsw);
9069 init_test(do_load ? LD_DOLOAD : LD_NO);
9071 doc = create_document();
9072 doc_unk = (IUnknown*)doc;
9074 ipsex = use_ipsex;
9075 ipsw = use_ipsw;
9077 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
9078 ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
9080 hres = IHTMLDocument2_QueryInterface(doc, &IID_IOleDocumentView, (void**)&view);
9081 ok(hres == S_OK, "QueryInterface(IID_IOleDocumentView) failed: %08lx\n", hres);
9083 SET_EXPECT(Invoke_AMBIENT_USERMODE);
9084 SET_EXPECT(GetHostInfo);
9085 SET_EXPECT(Invoke_AMBIENT_DLCONTROL);
9086 SET_EXPECT(Invoke_AMBIENT_SILENT);
9087 SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
9088 SET_EXPECT(Invoke_AMBIENT_USERAGENT);
9089 SET_EXPECT(Invoke_AMBIENT_PALETTE);
9090 SET_EXPECT(GetOptionKeyPath);
9091 SET_EXPECT(GetOverrideKeyPath);
9092 SET_EXPECT(GetWindow);
9093 SET_EXPECT(Exec_DOCCANNAVIGATE);
9094 SET_EXPECT(QueryStatus_SETPROGRESSTEXT);
9095 SET_EXPECT(Exec_SETPROGRESSMAX);
9096 SET_EXPECT(Exec_SETPROGRESSPOS);
9097 SET_EXPECT(GetTravelLog);
9098 SET_EXPECT(Exec_ShellDocView_84);
9100 hres = IOleObject_SetClientSite(oleobj, &ClientSite);
9101 ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
9102 set_clientsite = TRUE;
9104 CHECK_CALLED(Invoke_AMBIENT_USERMODE);
9105 CHECK_CALLED(GetHostInfo);
9106 CHECK_CALLED(Invoke_AMBIENT_DLCONTROL);
9107 CHECK_CALLED(Invoke_AMBIENT_SILENT);
9108 CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
9109 CHECK_CALLED(Invoke_AMBIENT_USERAGENT);
9110 CLEAR_CALLED(Invoke_AMBIENT_PALETTE); /* not called on IE9 */
9111 CLEAR_CALLED(GetOptionKeyPath); /* not called on some IE9 */
9112 CHECK_CALLED(GetOverrideKeyPath);
9113 CHECK_CALLED(GetWindow);
9114 CHECK_CALLED(Exec_DOCCANNAVIGATE);
9115 CHECK_CALLED(QueryStatus_SETPROGRESSTEXT);
9116 CHECK_CALLED(Exec_SETPROGRESSMAX);
9117 CHECK_CALLED(Exec_SETPROGRESSPOS);
9118 CHECK_CALLED(GetTravelLog);
9119 CHECK_CALLED_BROKEN(Exec_ShellDocView_84);
9121 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
9122 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
9123 ok(inplacesite == NULL, "inplacesite = %p, expected NULL\n", inplacesite);
9125 SET_EXPECT(GetContainer);
9126 SET_EXPECT(LockContainer);
9127 SET_EXPECT(CanInPlaceActivate);
9128 SET_EXPECT(GetWindowContext);
9129 SET_EXPECT(GetWindow);
9130 if(use_ipsex) {
9131 SET_EXPECT(OnInPlaceActivateEx);
9132 SET_EXPECT(RequestUIActivate);
9134 else
9135 SET_EXPECT(OnInPlaceActivate);
9136 SET_EXPECT(OnUIActivate);
9137 SET_EXPECT(SetStatusText);
9138 SET_EXPECT(Exec_SETPROGRESSMAX);
9139 SET_EXPECT(Exec_SETPROGRESSPOS);
9140 SET_EXPECT(ShowUI);
9141 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
9142 SET_EXPECT(InPlaceFrame_SetBorderSpace);
9143 SET_EXPECT(OnFocus_TRUE);
9144 SET_EXPECT(SetActiveObject);
9145 expect_LockContainer_fLock = TRUE;
9147 hres = IOleDocumentView_UIActivate(view, TRUE);
9148 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
9150 CHECK_CALLED(GetContainer);
9151 CHECK_CALLED(LockContainer);
9152 CHECK_CALLED(CanInPlaceActivate);
9153 CHECK_CALLED(GetWindowContext);
9154 CHECK_CALLED(GetWindow);
9155 if(use_ipsex) {
9156 CHECK_CALLED(OnInPlaceActivateEx);
9157 SET_EXPECT(RequestUIActivate);
9159 else
9160 CHECK_CALLED(OnInPlaceActivate);
9161 CHECK_CALLED(OnUIActivate);
9162 CHECK_CALLED(SetStatusText);
9163 CHECK_CALLED(Exec_SETPROGRESSMAX);
9164 CHECK_CALLED(Exec_SETPROGRESSPOS);
9165 CHECK_CALLED(ShowUI);
9166 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
9167 CHECK_CALLED(InPlaceFrame_SetBorderSpace);
9168 CHECK_CALLED(OnFocus_TRUE);
9169 CHECK_CALLED(SetActiveObject);
9170 container_locked = TRUE;
9172 SET_EXPECT(SetActiveObject_null);
9173 SET_EXPECT(InPlaceUIWindow_SetActiveObject);
9174 SET_EXPECT(HideUI);
9175 SET_EXPECT(OnUIDeactivate);
9177 hres = IOleDocumentView_UIActivate(view, FALSE);
9178 ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
9180 CHECK_CALLED(SetActiveObject_null);
9181 CHECK_CALLED(InPlaceUIWindow_SetActiveObject);
9182 CHECK_CALLED(HideUI);
9183 CHECK_CALLED(OnUIDeactivate);
9185 hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
9186 ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
9187 ok(inplacesite != NULL, "inplacesite = NULL\n");
9188 IOleInPlaceSite_Release(inplacesite);
9190 SET_EXPECT(SetStatusText);
9191 SET_EXPECT(OnFocus_FALSE);
9192 if(use_ipsex)
9193 SET_EXPECT(OnInPlaceDeactivateEx);
9194 else
9195 SET_EXPECT(OnInPlaceDeactivate);
9197 test_CloseView();
9199 CLEAR_CALLED(SetStatusText); /* Called by IE9 */
9200 CHECK_CALLED(OnFocus_FALSE);
9201 if(use_ipsex)
9202 CHECK_CALLED(OnInPlaceDeactivateEx);
9203 else
9204 CHECK_CALLED(OnInPlaceDeactivate);
9206 test_Close(doc, TRUE);
9208 IOleObject_Release(oleobj);
9209 IOleDocumentView_Release(view);
9210 view = NULL;
9212 release_document(doc);
9215 static void register_protocol(void)
9217 IInternetSession *session;
9218 HRESULT hres;
9220 static const WCHAR wsz_winetest[] = {'w','i','n','e','t','e','s','t',0};
9222 hres = CoInternetGetSession(0, &session, 0);
9223 ok(hres == S_OK, "CoInternetGetSession failed: %08lx\n", hres);
9225 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL,
9226 wsz_winetest, 0, NULL, 0);
9227 ok(hres == S_OK, "RegisterNameSpace failed: %08lx\n", hres);
9229 IInternetSession_Release(session);
9232 static void test_HTMLDoc_ISupportErrorInfo(void)
9234 IHTMLDocument2 *doc;
9235 HRESULT hres;
9236 ISupportErrorInfo *sinfo;
9238 doc = create_document();
9240 hres = IHTMLDocument2_QueryInterface(doc, &IID_ISupportErrorInfo, (void**)&sinfo);
9241 ok(hres == S_OK, "got %lx\n", hres);
9242 ok(sinfo != NULL, "got %p\n", sinfo);
9243 if(sinfo)
9245 hres = ISupportErrorInfo_InterfaceSupportsErrorInfo(sinfo, &IID_IErrorInfo);
9246 ok(hres == S_FALSE, "Expected S_OK, got %lx\n", hres);
9247 ISupportErrorInfo_Release(sinfo);
9250 release_document(doc);
9253 static BOOL check_ie(void)
9255 IHTMLDocument2 *doc;
9256 IHTMLDocument5 *doc5;
9257 IHTMLDocument7 *doc7;
9258 HRESULT hres;
9260 doc = create_document();
9261 if(!doc)
9262 return FALSE;
9264 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument7, (void**)&doc7);
9265 if(SUCCEEDED(hres)) {
9266 is_ie9plus = TRUE;
9267 IHTMLDocument7_Release(doc7);
9270 trace("is_ie9plus %x\n", is_ie9plus);
9272 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
9273 if(SUCCEEDED(hres))
9274 IHTMLDocument5_Release(doc5);
9276 release_document(doc);
9277 return SUCCEEDED(hres);
9280 static void test_ServiceProvider(void)
9282 IHTMLDocument3 *doc3, *doc3_2;
9283 IServiceProvider *provider;
9284 IHTMLDocument2 *doc, *doc2;
9285 IUnknown *unk;
9286 HRESULT hres;
9288 doc = create_document();
9289 if(!doc)
9290 return;
9292 hres = IHTMLDocument2_QueryInterface(doc, &IID_IServiceProvider, (void**)&provider);
9293 ok(hres == S_OK, "got 0x%08lx\n", hres);
9295 hres = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument2, (void**)&doc2);
9296 ok(hres == S_OK, "got 0x%08lx\n", hres);
9297 ok(iface_cmp((IUnknown*)doc2, (IUnknown*)doc), "got wrong pointer\n");
9298 IHTMLDocument2_Release(doc2);
9300 hres = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IHTMLDocument3, (void**)&doc3);
9301 ok(hres == S_OK, "got 0x%08lx\n", hres);
9302 ok(iface_cmp((IUnknown*)doc3, (IUnknown*)doc), "got wrong pointer\n");
9304 hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3_2);
9305 ok(hres == S_OK, "got 0x%08lx\n", hres);
9306 ok(iface_cmp((IUnknown*)doc3_2, (IUnknown*)doc), "got wrong pointer\n");
9307 ok(iface_cmp((IUnknown*)doc3_2, (IUnknown*)doc3), "got wrong pointer\n");
9308 IHTMLDocument3_Release(doc3);
9309 IHTMLDocument3_Release(doc3_2);
9311 hres = IServiceProvider_QueryService(provider, &SID_SContainerDispatch, &IID_IUnknown, (void**)&unk);
9312 ok(hres == S_OK, "got 0x%08lx\n", hres);
9313 ok(iface_cmp((IUnknown*)doc, unk), "got wrong pointer\n");
9314 IUnknown_Release(unk);
9316 hres = IServiceProvider_QueryService(provider, &SID_SHTMLEditServices, &IID_IHTMLEditServices, (void**)&unk);
9317 ok(hres == S_OK, "QueryService(HTMLEditServices) failed: %08lx\n", hres);
9318 IUnknown_Release(unk);
9320 IServiceProvider_Release(provider);
9321 release_document(doc);
9324 static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
9326 if(IsEqualGUID(riid, &IID_IPersistMoniker)) {
9327 CHECK_EXPECT(outer_QI_IPersistMoniker);
9328 *ppv = NULL;
9329 return E_NOINTERFACE;
9331 if(IsEqualGUID(riid, &outer_test_iid)) {
9332 CHECK_EXPECT(outer_QI_test);
9333 *ppv = (IUnknown*)0xdeadbeef;
9334 return S_OK;
9336 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
9337 return E_NOINTERFACE;
9340 static ULONG WINAPI outer_AddRef(IUnknown *iface)
9342 return 2;
9345 static ULONG WINAPI outer_Release(IUnknown *iface)
9347 return 1;
9350 static const IUnknownVtbl outer_vtbl = {
9351 outer_QueryInterface,
9352 outer_AddRef,
9353 outer_Release
9356 static void test_com_aggregation(const CLSID *clsid)
9358 IUnknown outer = { &outer_vtbl };
9359 IClassFactory *class_factory;
9360 IUnknown *unk, *unk2, *unk3;
9361 HRESULT hres;
9363 hres = CoGetClassObject(clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&class_factory);
9364 ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres);
9366 SET_EXPECT(outer_QI_IPersistMoniker); /* Some IE version QI for that. */
9367 hres = IClassFactory_CreateInstance(class_factory, &outer, &IID_IUnknown, (void**)&unk);
9368 ok(hres == S_OK, "CreateInstance returned: %08lx\n", hres);
9369 SET_CALLED(outer_QI_IPersistMoniker);
9371 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&unk2);
9372 ok(hres == S_OK, "Could not get IDispatch iface: %08lx\n", hres);
9374 SET_EXPECT(outer_QI_test);
9375 hres = IUnknown_QueryInterface(unk2, &outer_test_iid, (void**)&unk3);
9376 CHECK_CALLED(outer_QI_test);
9377 ok(hres == S_OK, "Could not get IInternetProtocol iface: %08lx\n", hres);
9378 ok(unk3 == (IUnknown*)0xdeadbeef, "unexpected unk2\n");
9380 IUnknown_Release(unk2);
9381 IUnknown_Release(unk);
9383 unk = (void*)0xdeadbeef;
9384 hres = IClassFactory_CreateInstance(class_factory, &outer, &IID_IDispatch, (void**)&unk);
9385 ok(hres == E_INVALIDARG, "CreateInstance returned: %08lx\n", hres);
9386 ok(!unk, "unk = %p\n", unk);
9388 IClassFactory_Release(class_factory);
9391 START_TEST(htmldoc)
9393 CoInitialize(NULL);
9395 if(!check_ie()) {
9396 CoUninitialize();
9397 #if !defined(__i386__) && !defined(__x86_64__)
9398 todo_wine
9399 #endif
9400 win_skip("Too old IE\n");
9401 return;
9404 container_hwnd = create_container_window();
9405 register_protocol();
9407 asynchronous_binding = TRUE;
9408 test_HTMLDocument_hlink(HTTP_STATUS_NOT_FOUND);
9410 asynchronous_binding = FALSE;
9411 test_HTMLDocument_hlink(HTTP_STATUS_OK);
9412 test_HTMLDocument(FALSE, TRUE);
9413 test_HTMLDocument(TRUE, FALSE);
9414 test_HTMLDocument(TRUE, TRUE);
9415 test_HTMLDocument_StreamLoad();
9416 test_HTMLDocument_StreamInitNew();
9417 test_MHTMLDocument();
9418 test_editing_mode(FALSE, FALSE);
9419 test_editing_mode(TRUE, FALSE);
9420 test_editing_mode(TRUE, TRUE);
9421 test_HTMLDocument_http(FALSE);
9422 test_HTMLDocument_http(TRUE);
9423 test_submit();
9424 test_UIActivate(FALSE, FALSE, FALSE);
9425 test_UIActivate(FALSE, TRUE, FALSE);
9426 test_UIActivate(FALSE, TRUE, TRUE);
9427 test_UIActivate(TRUE, FALSE, FALSE);
9428 test_UIActivate(TRUE, TRUE, FALSE);
9429 test_UIActivate(TRUE, TRUE, TRUE);
9430 test_HTMLDoc_ISupportErrorInfo();
9431 test_ServiceProvider();
9432 test_com_aggregation(&CLSID_HTMLDocument);
9434 DestroyWindow(container_hwnd);
9435 CoUninitialize();