2 * Copyright 2008-2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
35 #define DEFINE_EXPECT(func) \
36 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
38 #define SET_EXPECT(func) \
39 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
41 #define CHECK_EXPECT2(func) \
44 ok(expect_ ##func, "unexpected call " #func "\n"); \
45 called_ ## func = TRUE; \
48 #define CHECK_EXPECT(func) \
50 CHECK_EXPECT2(func); \
51 expect_ ## func = FALSE; \
54 #define CHECK_CALLED(func) \
56 ok(called_ ## func, "expected " #func "\n"); \
57 expect_ ## func = called_ ## func = FALSE; \
60 DEFINE_EXPECT(document_onclick
);
61 DEFINE_EXPECT(body_onclick
);
62 DEFINE_EXPECT(doc_onclick_attached
);
63 DEFINE_EXPECT(div_onclick
);
64 DEFINE_EXPECT(div_onclick_attached
);
65 DEFINE_EXPECT(div_onclick_capture
);
66 DEFINE_EXPECT(div_onclick_bubble
);
67 DEFINE_EXPECT(timeout
);
68 DEFINE_EXPECT(doccp_onclick
);
69 DEFINE_EXPECT(doccp2_onclick
);
70 DEFINE_EXPECT(doccp_onclick_cancel
);
71 DEFINE_EXPECT(div_onclick_disp
);
72 DEFINE_EXPECT(invoke_onclick
);
73 DEFINE_EXPECT(iframe_onreadystatechange_loading
);
74 DEFINE_EXPECT(iframe_onreadystatechange_interactive
);
75 DEFINE_EXPECT(iframe_onreadystatechange_complete
);
76 DEFINE_EXPECT(iframedoc_onreadystatechange
);
77 DEFINE_EXPECT(img_onload
);
78 DEFINE_EXPECT(img_onerror
);
79 DEFINE_EXPECT(link_onload
);
80 DEFINE_EXPECT(input_onfocus
);
81 DEFINE_EXPECT(input_onblur
);
82 DEFINE_EXPECT(div_onfocusin
);
83 DEFINE_EXPECT(div_onfocusout
);
84 DEFINE_EXPECT(form_onsubmit
);
85 DEFINE_EXPECT(form_onclick
);
86 DEFINE_EXPECT(submit_onclick
);
87 DEFINE_EXPECT(submit_onclick_cancel
);
88 DEFINE_EXPECT(submit_onclick_attached
);
89 DEFINE_EXPECT(submit_onclick_attached_check_cancel
);
90 DEFINE_EXPECT(submit_onclick_setret
);
91 DEFINE_EXPECT(elem2_cp_onclick
);
92 DEFINE_EXPECT(iframe_onload
);
94 static HWND container_hwnd
= NULL
;
95 static IHTMLWindow2
*window
;
96 static IOleDocumentView
*view
;
97 static BOOL is_ie9plus
;
98 static int document_mode
;
99 static unsigned in_fire_event
;
108 static const xy_test_t no_xy
= {-10,-10,-10,-10};
110 static const char empty_doc_str
[] =
113 static const char empty_doc_ie9_str
[] =
115 "<head><meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" /></head>"
118 static const char readystate_doc_str
[] =
119 "<html><body><iframe id=\"iframe\"></iframe></body></html>";
121 static const char readystate_doc_ie9_str
[] =
123 "<head><meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" /></head>"
124 "<body><iframe id=\"iframe\"></iframe></body></html>";
126 static const char img_doc_str
[] =
127 "<html><body><img id=\"imgid\"></img></body></html>";
129 static const char link_doc_str
[] =
130 "<html><body><link id=\"linkid\" rel=\"stylesheet\" type=\"text/css\"></link></body></html>";
132 static const char input_doc_str
[] =
133 "<html><body><div id=\"divid\"><input id=\"inputid\"></input></div></body></html>";
135 static const char iframe_doc_str
[] =
136 "<html><body><iframe id=\"ifr\">Testing</iframe></body></html>";
138 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
140 IUnknown
*unk1
, *unk2
;
145 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
146 IUnknown_Release(unk1
);
147 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
148 IUnknown_Release(unk2
);
153 #define test_disp(u,id) _test_disp(__LINE__,u,id)
154 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
)
161 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
162 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
167 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
168 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
169 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
171 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
172 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
174 if(SUCCEEDED(hres
)) {
177 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
178 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
180 ok_(__FILE__
,line
) (IsEqualGUID(&type_attr
->guid
, diid
), "unexpected guid %s\n",
181 wine_dbgstr_guid(&type_attr
->guid
));
183 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
184 ITypeInfo_Release(typeinfo
);
187 IDispatchEx_Release(dispex
);
190 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
191 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IUnknown
*unk
)
193 IHTMLDocument3
*doc3
;
196 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument3
, (void**)&doc3
);
197 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
202 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
203 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
208 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
209 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement iface: %08x\n", hres
);
214 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
215 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
217 IHTMLElement2
*elem2
;
220 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem2
);
221 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2 iface: %08x\n", hres
);
226 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
227 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
229 IHTMLElement3
*elem3
;
232 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem3
);
233 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3 iface: %08x\n", hres
);
238 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
239 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
241 IHTMLElement4
*elem4
;
244 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem4
);
245 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4 iface: %08x\n", hres
);
250 #define get_iframe_iface(u) _get_iframe_iface(__LINE__,u)
251 static IHTMLIFrameElement
*_get_iframe_iface(unsigned line
, IUnknown
*unk
)
253 IHTMLIFrameElement
*iframe
;
256 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement
, (void**)&iframe
);
257 ok_(__FILE__
,line
)(hres
== S_OK
, "QueryInterface(IID_IHTMLIFrameElement) failed: %08x\n", hres
);
262 #define doc_get_body(d) _doc_get_body(__LINE__,d)
263 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
265 IHTMLElement
*body
= NULL
;
268 hres
= IHTMLDocument2_get_body(doc
, &body
);
269 ok_(__FILE__
,line
) (hres
== S_OK
, "get_body failed: %08x\n", hres
);
270 ok_(__FILE__
,line
) (body
!= NULL
, "body == NULL\n");
275 #define get_elem_id(d,i) _get_elem_id(__LINE__,d,i)
276 static IHTMLElement
*_get_elem_id(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*id
)
278 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, (IUnknown
*)doc
);
283 str
= SysAllocString(id
);
284 hres
= IHTMLDocument3_getElementById(doc3
, str
, &elem
);
286 IHTMLDocument3_Release(doc3
);
287 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementById failed: %08x\n", hres
);
288 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
293 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
294 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const WCHAR
*extag
)
296 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
300 hres
= IHTMLElement_get_tagName(elem
, &tag
);
301 IHTMLElement_Release(elem
);
302 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
303 ok_(__FILE__
, line
) (!lstrcmpW(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), wine_dbgstr_w(extag
));
308 #define get_event_obj() _get_event_obj(__LINE__)
309 static IHTMLEventObj
*_get_event_obj(unsigned line
)
311 IHTMLEventObj
*event
= NULL
;
314 hres
= IHTMLWindow2_get_event(window
, &event
);
315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_event failed: %08x\n", hres
);
316 ok_(__FILE__
,line
) (event
!= NULL
, "event = NULL\n");
318 /* Native IE uses an undocumented DIID in IE9+ mode */
319 _test_disp(line
, (IUnknown
*)event
, document_mode
< 9 ? &DIID_DispCEventObj
: NULL
);
324 #define set_elem_innerhtml(e,t) _set_elem_innerhtml(__LINE__,e,t)
325 static void _set_elem_innerhtml(unsigned line
, IHTMLElement
*elem
, const WCHAR
*inner_html
)
330 html
= SysAllocString(inner_html
);
331 hres
= IHTMLElement_put_innerHTML(elem
, html
);
332 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08x\n", hres
);
336 #define elem_fire_event(a,b,c) _elem_fire_event(__LINE__,a,b,c)
337 static void _elem_fire_event(unsigned line
, IUnknown
*unk
, const WCHAR
*event
, VARIANT
*evobj
)
339 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
345 str
= SysAllocString(event
);
347 hres
= IHTMLElement3_fireEvent(elem3
, str
, evobj
, &b
);
350 ok_(__FILE__
,line
)(hres
== S_OK
, "fireEvent failed: %08x\n", hres
);
351 ok_(__FILE__
,line
)(b
== VARIANT_TRUE
, "fireEvent returned %x\n", b
);
354 #define test_event_args(a,b,c,d,e,f,g) _test_event_args(__LINE__,a,b,c,d,e,f,g)
355 static void _test_event_args(unsigned line
, const IID
*dispiid
, DISPID id
, WORD wFlags
, DISPPARAMS
*pdp
,
356 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
358 ok_(__FILE__
,line
) (id
== DISPID_VALUE
, "id = %d\n", id
);
359 ok_(__FILE__
,line
) (wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
360 ok_(__FILE__
,line
) (pdp
!= NULL
, "pdp == NULL\n");
361 ok_(__FILE__
,line
) (pdp
->cArgs
== (document_mode
< 9 ? 1 : 2), "pdp->cArgs = %d\n", pdp
->cArgs
);
362 ok_(__FILE__
,line
) (pdp
->cNamedArgs
== 1, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
363 ok_(__FILE__
,line
) (pdp
->rgdispidNamedArgs
[0] == DISPID_THIS
, "pdp->rgdispidNamedArgs[0] = %d\n",
364 pdp
->rgdispidNamedArgs
[0]);
365 ok_(__FILE__
,line
) (V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
367 ok_(__FILE__
,line
) (V_VT(pdp
->rgvarg
+1) == VT_DISPATCH
, "V_VT(rgvarg) = %d\n", V_VT(pdp
->rgvarg
+1));
368 ok_(__FILE__
,line
) (pvarRes
!= NULL
, "pvarRes == NULL\n");
369 ok_(__FILE__
,line
) (pei
!= NULL
, "pei == NULL\n");
370 ok_(__FILE__
,line
) (!pspCaller
, "pspCaller != NULL\n");
373 _test_disp(line
, (IUnknown
*)V_DISPATCH(pdp
->rgvarg
), dispiid
);
376 IHTMLEventObj
*window_event
, *event_obj
;
380 hres
= IDispatch_QueryInterface(V_DISPATCH(pdp
->rgvarg
+1), &IID_IDOMEvent
, (void**)&event
);
382 ok(hres
== E_NOINTERFACE
, "QI(IID_IDOMEvent) returned %08x\n", hres
);
384 ok(hres
== S_OK
, "Could not get IDOMEvent iface: %08x\n", hres
);
386 hres
= IDispatch_QueryInterface(V_DISPATCH(pdp
->rgvarg
+1), &IID_IHTMLEventObj
, (void**)&event_obj
);
388 ok(hres
== S_OK
, "Could not get IDOMEventObj iface: %08x\n", hres
);
390 ok(hres
== E_NOINTERFACE
, "QI(IID_IHTMLEventObj) returned %08x\n", hres
);
393 IDOMEvent_Release(event
);
395 IHTMLEventObj_Release(event_obj
);
397 hres
= IHTMLWindow2_get_event(window
, &window_event
);
398 ok(hres
== S_OK
, "get_event failed: %08x\n", hres
);
400 todo_wine_if(in_fire_event
)
401 ok(!iface_cmp((IUnknown
*)V_DISPATCH(pdp
->rgvarg
+1), (IUnknown
*)window_event
),
402 "window_event != event arg\n");
403 IHTMLEventObj_Release(window_event
);
408 #define test_attached_event_args(a,b,c,d,e) _test_attached_event_args(__LINE__,a,b,c,d,e)
409 static void _test_attached_event_args(unsigned line
, DISPID id
, WORD wFlags
, DISPPARAMS
*pdp
,
410 VARIANT
*pvarRes
, EXCEPINFO
*pei
)
412 IHTMLEventObj
*event
;
414 ok(id
== DISPID_VALUE
, "id = %d\n", id
);
415 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
416 ok(pdp
!= NULL
, "pDispParams == NULL\n");
417 ok(pdp
->cArgs
== 1, "pdp->cArgs = %d\n", pdp
->cArgs
);
418 ok(!pdp
->cNamedArgs
, "pdp->cNamedArgs = %d\n", pdp
->cNamedArgs
);
419 ok(!pdp
->rgdispidNamedArgs
, "pdp->rgdispidNamedArgs = %p\n", pdp
->rgdispidNamedArgs
);
420 ok(pdp
->rgvarg
!= NULL
, "rgvarg = NULL\n");
421 ok(pvarRes
!= NULL
, "pvarRes = NULL\n");
422 ok(pei
!= NULL
, "pei = NULL\n");
423 ok(V_VT(pvarRes
) == VT_EMPTY
, "V_VT(pVarRes) = %d\n", V_VT(pvarRes
));
424 ok(V_VT(pdp
->rgvarg
) == VT_DISPATCH
, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp
->rgvarg
));
425 ok(V_DISPATCH(pdp
->rgvarg
) != NULL
, "V_DISPATCH(pdp->rgvarg) = %p\n", V_DISPATCH(pdp
->rgvarg
));
427 event
= _get_event_obj(line
);
429 ok(!iface_cmp((IUnknown
*)event
, (IUnknown
*)V_DISPATCH(pdp
->rgvarg
)), "event != arg0\n");
430 IHTMLEventObj_Release(event
);
433 #define get_event_src() _get_event_src(__LINE__)
434 static IHTMLElement
*_get_event_src(unsigned line
)
436 IHTMLEventObj
*event
= _get_event_obj(line
);
437 IHTMLElement
*src_elem
= NULL
;
440 hres
= IHTMLEventObj_get_srcElement(event
, &src_elem
);
441 IHTMLEventObj_Release(event
);
442 ok_(__FILE__
,line
) (hres
== S_OK
, "get_srcElement failed: %08x\n", hres
);
447 #define test_event_src(t) _test_event_src(__LINE__,t)
448 static void _test_event_src(unsigned line
, const WCHAR
*src_tag
)
450 IHTMLElement
*src_elem
= _get_event_src(line
);
453 ok_(__FILE__
,line
) (src_elem
!= NULL
, "src_elem = NULL\n");
454 _test_elem_tag(line
, (IUnknown
*)src_elem
, src_tag
);
455 IHTMLElement_Release(src_elem
);
457 ok_(__FILE__
,line
) (!src_elem
, "src_elem != NULL\n");
461 static void _test_event_altkey(unsigned line
, IHTMLEventObj
*event
, VARIANT_BOOL exval
)
466 hres
= IHTMLEventObj_get_altKey(event
, &b
);
467 ok_(__FILE__
,line
)(hres
== S_OK
, "get_altKey failed: %08x\n", hres
);
468 ok_(__FILE__
,line
)(b
== exval
, "altKey = %x, expected %x\n", b
, exval
);
471 static void _test_event_ctrlkey(unsigned line
, IHTMLEventObj
*event
, VARIANT_BOOL exval
)
476 hres
= IHTMLEventObj_get_ctrlKey(event
, &b
);
477 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ctrlKey failed: %08x\n", hres
);
478 ok_(__FILE__
,line
)(b
== exval
, "ctrlKey = %x, expected %x\n", b
, exval
);
481 static void _test_event_shiftkey(unsigned line
, IHTMLEventObj
*event
, VARIANT_BOOL exval
)
486 hres
= IHTMLEventObj_get_shiftKey(event
, &b
);
487 ok_(__FILE__
,line
)(hres
== S_OK
, "get_shiftKey failed: %08x\n", hres
);
488 ok_(__FILE__
,line
)(b
== exval
, "shiftKey = %x, expected %x\n", b
, exval
);
491 #define test_event_cancelbubble(a,b) _test_event_cancelbubble(__LINE__,a,b)
492 static void _test_event_cancelbubble(unsigned line
, IHTMLEventObj
*event
, VARIANT_BOOL exval
)
497 hres
= IHTMLEventObj_get_cancelBubble(event
, &b
);
498 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cancelBubble failed: %08x\n", hres
);
499 ok_(__FILE__
,line
)(b
== exval
, "cancelBubble = %x, expected %x\n", b
, exval
);
502 static void _test_event_fromelem(unsigned line
, IHTMLEventObj
*event
, const WCHAR
*from_tag
)
507 hres
= IHTMLEventObj_get_fromElement(event
, &elem
);
508 ok_(__FILE__
,line
)(hres
== S_OK
, "get_fromElement failed: %08x\n", hres
);
510 _test_elem_tag(line
, (IUnknown
*)elem
, from_tag
);
512 ok_(__FILE__
,line
)(elem
== NULL
, "fromElement != NULL\n");
514 IHTMLElement_Release(elem
);
517 static void _test_event_toelem(unsigned line
, IHTMLEventObj
*event
, const WCHAR
*to_tag
)
522 hres
= IHTMLEventObj_get_toElement(event
, &elem
);
523 ok_(__FILE__
,line
)(hres
== S_OK
, "get_toElement failed: %08x\n", hres
);
525 _test_elem_tag(line
, (IUnknown
*)elem
, to_tag
);
527 ok_(__FILE__
,line
)(elem
== NULL
, "toElement != NULL\n");
529 IHTMLElement_Release(elem
);
532 static void _test_event_keycode(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
537 hres
= IHTMLEventObj_get_keyCode(event
, &l
);
538 ok_(__FILE__
,line
)(hres
== S_OK
, "get_keyCode failed: %08x\n", hres
);
539 ok_(__FILE__
,line
)(l
== exl
, "keyCode = %x, expected %x\n", l
, exl
);
542 static void _test_event_button(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
547 hres
= IHTMLEventObj_get_button(event
, &l
);
548 ok_(__FILE__
,line
)(hres
== S_OK
, "get_button failed: %08x\n", hres
);
549 ok_(__FILE__
,line
)(l
== exl
, "button = %x, expected %x\n", l
, exl
);
552 static void _test_event_reason(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
557 hres
= IHTMLEventObj_get_reason(event
, &l
);
558 ok_(__FILE__
,line
)(hres
== S_OK
, "get_reason failed: %08x\n", hres
);
559 ok_(__FILE__
,line
)(l
== exl
, "reason = %x, expected %x\n", l
, exl
);
562 static void _test_event_x(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
567 hres
= IHTMLEventObj_get_x(event
, &l
);
568 ok_(__FILE__
,line
)(hres
== S_OK
, "get_x failed: %08x\n", hres
);
569 if(exl
!= -10) /* don't test the exact value */
570 ok_(__FILE__
,line
)(l
== exl
, "x = %d, expected %d\n", l
, exl
);
573 static void _test_event_y(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
578 hres
= IHTMLEventObj_get_y(event
, &l
);
579 ok_(__FILE__
,line
)(hres
== S_OK
, "get_y failed: %08x\n", hres
);
580 if(exl
!= -10) /* don't test the exact value */
581 ok_(__FILE__
,line
)(l
== exl
, "y = %d, expected %d\n", l
, exl
);
584 static void _test_event_clientx(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
589 hres
= IHTMLEventObj_get_clientX(event
, &l
);
590 ok_(__FILE__
,line
)(hres
== S_OK
, "get_clientX failed: %08x\n", hres
);
591 if(exl
!= -10) /* don't test the exact value */
592 ok_(__FILE__
,line
)(l
== exl
, "clientX = %d, expected %d\n", l
, exl
);
595 static void _test_event_clienty(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
600 hres
= IHTMLEventObj_get_clientY(event
, &l
);
601 ok_(__FILE__
,line
)(hres
== S_OK
, "get_clientY failed: %08x\n", hres
);
602 if(exl
!= -10) /* don't test the exact value */
603 ok_(__FILE__
,line
)(l
== exl
, "clientY = %d, expected %d\n", l
, exl
);
606 static void _test_event_offsetx(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
611 hres
= IHTMLEventObj_get_offsetX(event
, &l
);
612 ok_(__FILE__
,line
)(hres
== S_OK
, "get_offsetX failed: %08x\n", hres
);
613 if(exl
!= -10) /* don't test the exact value */
614 ok_(__FILE__
,line
)(l
== exl
, "offsetX = %d, expected %d\n", l
, exl
);
617 static void _test_event_offsety(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
622 hres
= IHTMLEventObj_get_offsetY(event
, &l
);
623 ok_(__FILE__
,line
)(hres
== S_OK
, "get_offsetY failed: %08x\n", hres
);
624 if(exl
!= -10) /* don't test the exact value */
625 ok_(__FILE__
,line
)(l
== exl
, "offsetY = %d, expected %d\n", l
, exl
);
628 static void _test_event_screenx(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
633 hres
= IHTMLEventObj_get_screenX(event
, &l
);
634 ok_(__FILE__
,line
)(hres
== S_OK
, "get_screenX failed: %08x\n", hres
);
635 if(exl
!= -10) /* don't test the exact value */
636 ok_(__FILE__
,line
)(l
== exl
, "screenX = %d, expected %d\n", l
, exl
);
639 static void _test_event_screeny(unsigned line
, IHTMLEventObj
*event
, LONG exl
)
644 hres
= IHTMLEventObj_get_screenY(event
, &l
);
645 ok_(__FILE__
,line
)(hres
== S_OK
, "get_screenY failed: %08x\n", hres
);
646 if(exl
!= -10) /* don't test the exact value for -10 */
647 ok_(__FILE__
,line
)(l
== exl
, "screenY = %d, expected %d\n", l
, exl
);
650 static void _test_event_type(unsigned line
, IHTMLEventObj
*event
, const WCHAR
*exstr
)
655 hres
= IHTMLEventObj_get_type(event
, &str
);
656 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08x\n", hres
);
657 ok_(__FILE__
,line
)(!lstrcmpW(str
, exstr
), "type = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exstr
));
660 static void _test_event_qualifier(unsigned line
, IHTMLEventObj
*event
, const WCHAR
*exstr
)
665 hres
= IHTMLEventObj_get_qualifier(event
, &str
);
666 ok_(__FILE__
,line
)(hres
== S_OK
, "get_qualifier failed: %08x\n", hres
);
668 ok_(__FILE__
,line
)(!lstrcmpW(str
, exstr
), "qualifier = %s, expected %s\n", wine_dbgstr_w(str
),
669 wine_dbgstr_w(exstr
));
671 ok_(__FILE__
,line
)(!str
, "qualifier != NULL\n");
674 static void _test_event_srcfilter(unsigned line
, IHTMLEventObj
*event
)
679 hres
= IHTMLEventObj_get_srcFilter(event
, &disp
);
680 ok_(__FILE__
,line
)(hres
== S_OK
, "get_srcFilter failed: %08x\n", hres
);
681 ok_(__FILE__
,line
)(!disp
, "srcFilter != NULL\n");
684 #define test_event_obj(t,x) _test_event_obj(__LINE__,t,x)
685 static void _test_event_obj(unsigned line
, const WCHAR
*type
, const xy_test_t
*xy
)
687 IHTMLEventObj
*event
= _get_event_obj(line
);
688 IDOMEvent
*dom_event
;
692 _test_event_altkey(line
, event
, VARIANT_FALSE
);
693 _test_event_ctrlkey(line
, event
, VARIANT_FALSE
);
694 _test_event_shiftkey(line
, event
, VARIANT_FALSE
);
695 _test_event_cancelbubble(line
, event
, VARIANT_FALSE
);
696 _test_event_fromelem(line
, event
, NULL
);
697 _test_event_toelem(line
, event
, NULL
);
698 _test_event_keycode(line
, event
, 0);
699 _test_event_button(line
, event
, 0);
700 _test_event_type(line
, event
, type
);
701 _test_event_qualifier(line
, event
, NULL
);
702 _test_event_reason(line
, event
, 0);
703 _test_event_srcfilter(line
, event
);
704 _test_event_x(line
, event
, xy
->x
);
705 _test_event_y(line
, event
, xy
->y
);
706 _test_event_clientx(line
, event
, -10);
707 _test_event_clienty(line
, event
, -10);
708 _test_event_offsetx(line
, event
, xy
->offset_x
);
709 _test_event_offsety(line
, event
, xy
->offset_y
);
710 _test_event_screenx(line
, event
, -10);
711 _test_event_screeny(line
, event
, -10);
714 hres
= IHTMLEventObj_get_returnValue(event
, &v
);
715 ok_(__FILE__
,line
)(hres
== S_OK
, "get_returnValue failed: %08x\n", hres
);
716 /* Depending on source of event, returnValue may be true bool in IE9+ mode */
717 ok_(__FILE__
,line
)(V_VT(&v
) == VT_EMPTY
|| (document_mode
>= 9 && V_VT(&v
) == VT_BOOL
),
718 "V_VT(returnValue) = %d\n", V_VT(&v
));
719 if(V_VT(&v
) == VT_BOOL
)
720 ok_(__FILE__
,line
)(V_BOOL(&v
) == VARIANT_TRUE
, "V_BOOL(returnValue) = %x\n", V_BOOL(&v
));
722 hres
= IHTMLEventObj_QueryInterface(event
, &IID_IDOMEvent
, (void**)&dom_event
);
723 ok(hres
== E_NOINTERFACE
, "Could not get IDOMEvent iface: %08x\n", hres
);
725 IHTMLEventObj_Release(event
);
728 #define elem_attach_event(a,b,c) _elem_attach_event(__LINE__,a,b,c)
729 static void _elem_attach_event(unsigned line
, IUnknown
*unk
, const WCHAR
*namew
, IDispatch
*disp
)
731 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
736 name
= SysAllocString(namew
);
737 hres
= IHTMLElement2_attachEvent(elem
, name
, disp
, &res
);
738 IHTMLElement2_Release(elem
);
740 ok_(__FILE__
,line
)(hres
== S_OK
, "attachEvent failed: %08x\n", hres
);
741 ok_(__FILE__
,line
)(res
== VARIANT_TRUE
, "attachEvent returned %x\n", res
);
744 #define add_event_listener(a,b,c,d) _add_event_listener(__LINE__,a,b,c,d)
745 static void _add_event_listener(unsigned line
, IUnknown
*unk
, const WCHAR
*type
, IDispatch
*listener
, VARIANT_BOOL use_capture
)
747 IEventTarget
*event_target
;
751 hres
= IUnknown_QueryInterface(unk
, &IID_IEventTarget
, (void**)&event_target
);
752 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEventTarget iface: %08x\n", hres
);
754 str
= SysAllocString(type
);
755 hres
= IEventTarget_addEventListener(event_target
, str
, listener
, use_capture
);
757 ok_(__FILE__
,line
)(hres
== S_OK
, "addEventListener failed: %08x\n", hres
);
759 IEventTarget_Release(event_target
);
762 #define remove_event_listener(a,b,c,d) _remove_event_listener(__LINE__,a,b,c,d)
763 static void _remove_event_listener(unsigned line
, IUnknown
*unk
, const WCHAR
*type
, IDispatch
*listener
, VARIANT_BOOL use_capture
)
765 IEventTarget
*event_target
;
769 hres
= IUnknown_QueryInterface(unk
, &IID_IEventTarget
, (void**)&event_target
);
770 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEventTarget iface: %08x\n", hres
);
772 str
= SysAllocString(type
);
773 hres
= IEventTarget_removeEventListener(event_target
, str
, listener
, use_capture
);
775 ok_(__FILE__
,line
)(hres
== S_OK
, "removeEventListener failed: %08x\n", hres
);
777 IEventTarget_Release(event_target
);
780 #define elem_detach_event(a,b,c) _elem_detach_event(__LINE__,a,b,c)
781 static void _elem_detach_event(unsigned line
, IUnknown
*unk
, const WCHAR
*namew
, IDispatch
*disp
)
783 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
787 name
= SysAllocString(namew
);
788 hres
= IHTMLElement2_detachEvent(elem
, name
, disp
);
789 IHTMLElement2_Release(elem
);
791 ok_(__FILE__
,line
)(hres
== S_OK
, "detachEvent failed: %08x\n", hres
);
794 #define doc_attach_event(a,b,c) _doc_attach_event(__LINE__,a,b,c)
795 static void _doc_attach_event(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*namew
, IDispatch
*disp
)
797 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, (IUnknown
*)doc
);
802 name
= SysAllocString(namew
);
803 hres
= IHTMLDocument3_attachEvent(doc3
, name
, disp
, &res
);
804 IHTMLDocument3_Release(doc3
);
806 ok_(__FILE__
,line
)(hres
== S_OK
, "attachEvent failed: %08x\n", hres
);
807 ok_(__FILE__
,line
)(res
== VARIANT_TRUE
, "attachEvent returned %x\n", res
);
810 #define doc_detach_event(a,b,c) _doc_detach_event(__LINE__,a,b,c)
811 static void _doc_detach_event(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*namew
, IDispatch
*disp
)
813 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, (IUnknown
*)doc
);
817 name
= SysAllocString(namew
);
818 hres
= IHTMLDocument3_detachEvent(doc3
, name
, disp
);
819 IHTMLDocument3_Release(doc3
);
821 ok_(__FILE__
,line
)(hres
== S_OK
, "detachEvent failed: %08x\n", hres
);
824 static HRESULT WINAPI
DispatchEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
826 if(IsEqualGUID(riid
, &IID_IUnknown
)
827 || IsEqualGUID(riid
, &IID_IDispatch
)
828 || IsEqualGUID(riid
, &IID_IDispatchEx
))
832 return E_NOINTERFACE
;
838 static HRESULT WINAPI
Dispatch_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
840 if(IsEqualGUID(riid
, &IID_IUnknown
)
841 || IsEqualGUID(riid
, &IID_IDispatch
)) {
845 return E_NOINTERFACE
;
851 static ULONG WINAPI
DispatchEx_AddRef(IDispatchEx
*iface
)
856 static ULONG WINAPI
DispatchEx_Release(IDispatchEx
*iface
)
861 static HRESULT WINAPI
DispatchEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
863 ok(0, "unexpected call\n");
867 static HRESULT WINAPI
DispatchEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
868 LCID lcid
, ITypeInfo
**ppTInfo
)
870 ok(0, "unexpected call\n");
874 static HRESULT WINAPI
DispatchEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
875 LPOLESTR
*rgszNames
, UINT cNames
,
876 LCID lcid
, DISPID
*rgDispId
)
878 ok(0, "unexpected call\n");
882 static HRESULT WINAPI
DispatchEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
883 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
884 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
886 ok(0, "unexpected call\n");
890 static HRESULT WINAPI
DispatchEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
892 ok(0, "unexpected call\n");
896 static HRESULT WINAPI
DispatchEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
897 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
899 ok(0, "unexpected call\n");
903 static HRESULT WINAPI
DispatchEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
905 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName
), grfdex
);
909 static HRESULT WINAPI
DispatchEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
911 ok(0, "unexpected call\n");
915 static HRESULT WINAPI
DispatchEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
917 ok(0, "unexpected call\n");
921 static HRESULT WINAPI
DispatchEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
923 ok(0, "unexpected call\n");
927 static HRESULT WINAPI
DispatchEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
929 ok(0, "unexpected call\n");
933 static HRESULT WINAPI
DispatchEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
935 ok(0, "unexpected call\n");
939 #define EVENT_HANDLER_FUNC_OBJ(event) \
940 static IDispatchExVtbl event ## FuncVtbl = { \
941 DispatchEx_QueryInterface, \
943 DispatchEx_Release, \
944 DispatchEx_GetTypeInfoCount, \
945 DispatchEx_GetTypeInfo, \
946 DispatchEx_GetIDsOfNames, \
948 DispatchEx_GetDispID, \
950 DispatchEx_DeleteMemberByName, \
951 DispatchEx_DeleteMemberByDispID, \
952 DispatchEx_GetMemberProperties, \
953 DispatchEx_GetMemberName, \
954 DispatchEx_GetNextDispID, \
955 DispatchEx_GetNameSpaceParent \
957 static IDispatchEx event ## _obj = { &event ## FuncVtbl };
959 static HRESULT WINAPI
document_onclick(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
960 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
962 IHTMLDocument3
*doc3
;
963 CHECK_EXPECT(document_onclick
);
964 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
965 doc3
= get_doc3_iface((IUnknown
*)V_DISPATCH(pdp
->rgvarg
));
966 IHTMLDocument3_Release(doc3
);
967 test_event_src(L
"DIV");
968 test_event_obj(L
"click", &no_xy
);
972 EVENT_HANDLER_FUNC_OBJ(document_onclick
);
974 static HRESULT WINAPI
div_onclick(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
975 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
977 CHECK_EXPECT(div_onclick
);
978 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
979 test_event_src(L
"DIV");
980 test_event_obj(L
"click", &no_xy
);
984 EVENT_HANDLER_FUNC_OBJ(div_onclick
);
986 static HRESULT WINAPI
div_onclick_attached(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
987 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
989 CHECK_EXPECT(div_onclick_attached
);
991 test_attached_event_args(id
, wFlags
, pdp
, pvarRes
, pei
);
992 test_event_src(L
"DIV");
996 EVENT_HANDLER_FUNC_OBJ(div_onclick_attached
);
998 static HRESULT WINAPI
doc_onclick_attached(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
999 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1001 CHECK_EXPECT(doc_onclick_attached
);
1003 test_attached_event_args(id
, wFlags
, pdp
, pvarRes
, pei
);
1004 test_event_src(L
"DIV");
1008 EVENT_HANDLER_FUNC_OBJ(doc_onclick_attached
);
1010 static HRESULT WINAPI
body_onclick(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1011 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1013 CHECK_EXPECT(body_onclick
);
1014 /* Native IE returns undocumented DIID in IE9+ mode */
1015 test_event_args(document_mode
< 9 ? &DIID_DispHTMLBody
: NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1016 test_event_src(L
"DIV");
1020 EVENT_HANDLER_FUNC_OBJ(body_onclick
);
1022 static HRESULT WINAPI
div_onclick_capture(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1023 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1025 CHECK_EXPECT(div_onclick_capture
);
1027 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1028 test_event_src(L
"DIV");
1032 EVENT_HANDLER_FUNC_OBJ(div_onclick_capture
);
1034 static HRESULT WINAPI
div_onclick_bubble(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1035 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1037 CHECK_EXPECT(div_onclick_bubble
);
1039 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1040 test_event_src(L
"DIV");
1044 EVENT_HANDLER_FUNC_OBJ(div_onclick_bubble
);
1046 static HRESULT WINAPI
img_onload(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1047 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1049 CHECK_EXPECT(img_onload
);
1050 test_event_args(&DIID_DispHTMLImg
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1051 test_event_src(L
"IMG");
1055 EVENT_HANDLER_FUNC_OBJ(img_onload
);
1057 static HRESULT WINAPI
link_onload(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1058 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1060 CHECK_EXPECT(link_onload
);
1061 test_event_args(&DIID_DispHTMLLinkElement
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1062 test_event_src(L
"LINK");
1066 EVENT_HANDLER_FUNC_OBJ(link_onload
);
1068 static HRESULT WINAPI
unattached_img_onload(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1069 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1071 IHTMLElement
*event_src
;
1073 CHECK_EXPECT(img_onload
);
1075 test_event_args(&DIID_DispHTMLImg
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1076 event_src
= get_event_src();
1078 ok(!event_src
, "event_src != NULL\n");
1080 IHTMLElement_Release(event_src
);
1084 EVENT_HANDLER_FUNC_OBJ(unattached_img_onload
);
1086 static HRESULT WINAPI
img_onerror(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1087 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1089 CHECK_EXPECT(img_onerror
);
1090 test_event_args(&DIID_DispHTMLImg
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1091 test_event_src(L
"IMG");
1095 EVENT_HANDLER_FUNC_OBJ(img_onerror
);
1097 static HRESULT WINAPI
input_onfocus(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1098 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1100 CHECK_EXPECT(input_onfocus
);
1101 test_event_args(&DIID_DispHTMLInputElement
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1102 test_event_src(L
"INPUT");
1106 EVENT_HANDLER_FUNC_OBJ(input_onfocus
);
1108 static HRESULT WINAPI
div_onfocusin(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1109 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1111 CHECK_EXPECT(div_onfocusin
);
1112 test_event_args(NULL
/* FIXME: &DIID_DispHTMLDivElement */, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1113 test_event_src(L
"INPUT");
1117 EVENT_HANDLER_FUNC_OBJ(div_onfocusin
);
1119 static HRESULT WINAPI
div_onfocusout(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1120 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1122 CHECK_EXPECT(div_onfocusout
);
1123 test_event_args(NULL
/* FIXME: &DIID_DispHTMLDivElement */, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1124 test_event_src(L
"INPUT");
1128 EVENT_HANDLER_FUNC_OBJ(div_onfocusout
);
1130 static HRESULT WINAPI
input_onblur(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1131 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1133 CHECK_EXPECT(input_onblur
);
1134 test_event_args(&DIID_DispHTMLInputElement
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1135 test_event_src(L
"INPUT");
1139 EVENT_HANDLER_FUNC_OBJ(input_onblur
);
1141 static HRESULT WINAPI
form_onsubmit(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1142 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1144 CHECK_EXPECT(form_onsubmit
);
1145 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1146 test_event_src(L
"FORM");
1148 V_VT(pvarRes
) = VT_BOOL
;
1149 V_BOOL(pvarRes
) = VARIANT_FALSE
;
1153 EVENT_HANDLER_FUNC_OBJ(form_onsubmit
);
1155 static HRESULT WINAPI
form_onclick(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1156 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1158 CHECK_EXPECT(form_onclick
);
1159 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1164 EVENT_HANDLER_FUNC_OBJ(form_onclick
);
1166 static HRESULT WINAPI
submit_onclick(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1167 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1169 CHECK_EXPECT(submit_onclick
);
1170 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1171 test_event_src(L
"INPUT");
1173 V_VT(pvarRes
) = VT_BOOL
;
1174 V_BOOL(pvarRes
) = VARIANT_FALSE
;
1178 EVENT_HANDLER_FUNC_OBJ(submit_onclick
);
1180 static HRESULT WINAPI
iframe_onload(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1181 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1183 CHECK_EXPECT(iframe_onload
);
1184 test_event_args(&DIID_DispHTMLIFrame
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1185 test_event_src(L
"IFRAME");
1189 EVENT_HANDLER_FUNC_OBJ(iframe_onload
);
1191 static HRESULT WINAPI
submit_onclick_attached(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1192 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1194 CHECK_EXPECT(submit_onclick_attached
);
1195 test_attached_event_args(id
, wFlags
, pdp
, pvarRes
, pei
);
1196 test_event_src(L
"INPUT");
1198 V_VT(pvarRes
) = VT_BOOL
;
1199 V_BOOL(pvarRes
) = VARIANT_FALSE
;
1203 EVENT_HANDLER_FUNC_OBJ(submit_onclick_attached
);
1205 static HRESULT WINAPI
submit_onclick_attached_check_cancel(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1206 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1208 IHTMLEventObj
*event
;
1211 CHECK_EXPECT(submit_onclick_attached_check_cancel
);
1212 test_attached_event_args(id
, wFlags
, pdp
, pvarRes
, pei
);
1213 test_event_src(L
"INPUT");
1216 hres
= IHTMLWindow2_get_event(window
, &event
);
1217 ok(hres
== S_OK
, "get_event failed: %08x\n", hres
);
1218 ok(event
!= NULL
, "event == NULL\n");
1220 test_event_cancelbubble(event
, VARIANT_TRUE
);
1224 EVENT_HANDLER_FUNC_OBJ(submit_onclick_attached_check_cancel
);
1226 static VARIANT onclick_retval
, onclick_event_retval
;
1228 static HRESULT WINAPI
submit_onclick_setret(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1229 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1231 IHTMLEventObj
*event
;
1235 CHECK_EXPECT(submit_onclick_setret
);
1236 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1237 test_event_src(L
"INPUT");
1240 hres
= IHTMLWindow2_get_event(window
, &event
);
1241 ok(hres
== S_OK
, "get_event failed: %08x\n", hres
);
1242 ok(event
!= NULL
, "event == NULL\n");
1244 V_VT(&v
) = VT_ERROR
;
1245 hres
= IHTMLEventObj_get_returnValue(event
, &v
);
1246 ok(hres
== S_OK
, "get_returnValue failed: %08x\n", hres
);
1247 if(document_mode
< 9) {
1248 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(returnValue) = %d\n", V_VT(&v
));
1250 ok(V_VT(&v
) == VT_BOOL
, "V_VT(returnValue) = %d\n", V_VT(&v
));
1251 ok(V_BOOL(&v
) == VARIANT_TRUE
, "V_BOOL(returnValue) = %x\n", V_BOOL(&v
));
1254 hres
= IHTMLEventObj_put_returnValue(event
, onclick_event_retval
);
1255 ok(hres
== S_OK
, "put_returnValue failed: %08x\n", hres
);
1257 V_VT(&v
) = VT_ERROR
;
1258 hres
= IHTMLEventObj_get_returnValue(event
, &v
);
1259 ok(hres
== S_OK
, "get_returnValue failed: %08x\n", hres
);
1260 ok(VarCmp(&v
, &onclick_event_retval
, 0, 0) == VARCMP_EQ
, "unexpected returnValue\n");
1262 IHTMLEventObj_Release(event
);
1263 *pvarRes
= onclick_retval
;
1267 EVENT_HANDLER_FUNC_OBJ(submit_onclick_setret
);
1269 static HRESULT WINAPI
submit_onclick_cancel(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1270 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1272 IHTMLEventObj
*event
;
1275 CHECK_EXPECT(submit_onclick_cancel
);
1276 test_event_args(NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1277 test_event_src(L
"INPUT");
1280 hres
= IHTMLWindow2_get_event(window
, &event
);
1281 ok(hres
== S_OK
, "get_event failed: %08x\n", hres
);
1282 ok(event
!= NULL
, "event == NULL\n");
1284 test_event_cancelbubble(event
, VARIANT_FALSE
);
1286 hres
= IHTMLEventObj_put_cancelBubble(event
, VARIANT_TRUE
);
1287 ok(hres
== S_OK
, "put_returnValue failed: %08x\n", hres
);
1289 test_event_cancelbubble(event
, VARIANT_TRUE
);
1290 IHTMLEventObj_Release(event
);
1294 EVENT_HANDLER_FUNC_OBJ(submit_onclick_cancel
);
1296 static HRESULT WINAPI
iframedoc_onreadystatechange(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1297 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1299 IHTMLEventObj
*event
= NULL
;
1302 CHECK_EXPECT2(iframedoc_onreadystatechange
);
1303 test_event_args(document_mode
< 9 ? &DIID_DispHTMLDocument
: NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1305 event
= (void*)0xdeadbeef;
1306 hres
= IHTMLWindow2_get_event(window
, &event
);
1307 ok(hres
== S_OK
, "get_event failed: %08x\n", hres
);
1308 ok(!event
, "event = %p\n", event
);
1313 EVENT_HANDLER_FUNC_OBJ(iframedoc_onreadystatechange
);
1315 static HRESULT WINAPI
iframe_onreadystatechange(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1316 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1318 IHTMLWindow2
*iframe_window
;
1319 IHTMLDocument2
*iframe_doc
;
1320 IHTMLFrameBase2
*iframe
;
1321 IHTMLElement2
*elem2
;
1327 test_event_args(document_mode
< 9 ? &DIID_DispHTMLIFrame
: NULL
, id
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1328 test_event_src(L
"IFRAME");
1330 elem
= get_event_src();
1331 elem2
= get_elem2_iface((IUnknown
*)elem
);
1332 IHTMLElement_Release(elem
);
1334 V_VT(&v
) = VT_EMPTY
;
1335 hres
= IHTMLElement2_get_readyState(elem2
, &v
);
1336 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
1337 ok(V_VT(&v
) == VT_BSTR
, "V_VT(readyState) = %d\n", V_VT(&v
));
1339 hres
= IHTMLElement2_QueryInterface(elem2
, &IID_IHTMLFrameBase2
, (void**)&iframe
);
1340 IHTMLElement2_Release(elem2
);
1341 ok(hres
== S_OK
, "Could not get IHTMLFrameBase2 iface: %08x\n", hres
);
1344 hres
= IHTMLFrameBase2_get_readyState(iframe
, &str
);
1345 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
1346 ok(str
!= NULL
, "readyState == NULL\n");
1347 ok(!lstrcmpW(str
, V_BSTR(&v
)), "ready states differ\n");
1350 hres
= IHTMLFrameBase2_get_contentWindow(iframe
, &iframe_window
);
1351 ok(hres
== S_OK
, "get_contentDocument failed: %08x\n", hres
);
1353 hres
= IHTMLWindow2_get_document(iframe_window
, &iframe_doc
);
1354 IHTMLWindow2_Release(iframe_window
);
1355 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1357 hres
= IHTMLDocument2_get_readyState(iframe_doc
, &str2
);
1358 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
1359 ok(!lstrcmpW(str
, str2
), "unexpected document readyState %s\n", wine_dbgstr_w(str2
));
1360 SysFreeString(str2
);
1362 if(!lstrcmpW(str
, L
"loading")) {
1363 CHECK_EXPECT(iframe_onreadystatechange_loading
);
1365 V_VT(&v
) = VT_DISPATCH
;
1366 V_DISPATCH(&v
) = (IDispatch
*)&iframedoc_onreadystatechange_obj
;
1367 hres
= IHTMLDocument2_put_onreadystatechange(iframe_doc
, v
);
1368 ok(hres
== S_OK
, "put_onreadystatechange: %08x\n", hres
);
1369 }else if(!lstrcmpW(str
, L
"interactive"))
1370 CHECK_EXPECT(iframe_onreadystatechange_interactive
);
1371 else if(!lstrcmpW(str
, L
"complete"))
1372 CHECK_EXPECT(iframe_onreadystatechange_complete
);
1374 ok(0, "unexpected state %s\n", wine_dbgstr_w(str
));
1377 IHTMLDocument2_Release(iframe_doc
);
1378 IHTMLFrameBase2_Release(iframe
);
1382 EVENT_HANDLER_FUNC_OBJ(iframe_onreadystatechange
);
1384 static HRESULT WINAPI
nocall(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1385 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1387 ok(0, "unexpected call\n");
1391 EVENT_HANDLER_FUNC_OBJ(nocall
);
1393 #define CONNECTION_POINT_OBJ(cpname, diid) \
1394 static HRESULT WINAPI cpname ## _QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) \
1397 if(IsEqualGUID(riid, &IID_IUnknown) \
1398 || IsEqualGUID(riid, &IID_IDispatch) \
1399 || IsEqualGUID(riid, &diid)) \
1402 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); \
1403 return E_NOINTERFACE; \
1407 static IDispatchExVtbl cpname ## Vtbl = { \
1408 cpname ## _QueryInterface, \
1409 DispatchEx_AddRef, \
1410 DispatchEx_Release, \
1411 DispatchEx_GetTypeInfoCount, \
1412 DispatchEx_GetTypeInfo, \
1413 DispatchEx_GetIDsOfNames, \
1415 DispatchEx_GetDispID, \
1416 DispatchEx_InvokeEx, \
1417 DispatchEx_DeleteMemberByName, \
1418 DispatchEx_DeleteMemberByDispID, \
1419 DispatchEx_GetMemberProperties, \
1420 DispatchEx_GetMemberName, \
1421 DispatchEx_GetNextDispID, \
1422 DispatchEx_GetNameSpaceParent \
1424 static IDispatchEx cpname ## _obj = { &cpname ## Vtbl }
1426 #define test_cp_args(a,b,c,d,e,f,g) _test_cp_args(__LINE__,a,b,c,d,e,f,g)
1427 static void _test_cp_args(unsigned line
, REFIID riid
, WORD flags
, DISPPARAMS
*dp
, VARIANT
*vres
, EXCEPINFO
*ei
, UINT
*argerr
, BOOL use_events2
)
1429 ok_(__FILE__
,line
)(IsEqualGUID(&IID_NULL
, riid
), "riid = %s\n", wine_dbgstr_guid(riid
));
1430 ok_(__FILE__
,line
)(flags
== DISPATCH_METHOD
, "flags = %x\n", flags
);
1431 ok_(__FILE__
,line
)(dp
!= NULL
, "dp == NULL\n");
1434 IHTMLEventObj
*event
;
1436 ok_(__FILE__
,line
)(dp
->cArgs
== 1, "dp->cArgs = %d\n", dp
->cArgs
);
1437 ok_(__FILE__
,line
)(dp
->rgvarg
!= NULL
, "dp->rgvarg = %p\n", dp
->rgvarg
);
1438 ok_(__FILE__
,line
)(V_VT(&dp
->rgvarg
[0]) == VT_DISPATCH
, "vt = %d\n", V_VT(&dp
->rgvarg
[0]));
1439 hr
= IDispatch_QueryInterface(V_DISPATCH(&dp
->rgvarg
[0]), &IID_IHTMLEventObj
, (void **)&event
);
1440 ok_(__FILE__
,line
)(hr
== S_OK
, "Could not get IHTMLEventObj iface: %08x\n", hr
);
1441 IHTMLEventObj_Release(event
);
1445 ok_(__FILE__
,line
)(!dp
->cArgs
, "dp->cArgs = %d\n", dp
->cArgs
);
1446 ok_(__FILE__
,line
)(!dp
->rgvarg
, "dp->rgvarg = %p\n", dp
->rgvarg
);
1448 ok_(__FILE__
,line
)(!dp
->cNamedArgs
, "dp->cNamedArgs = %d\n", dp
->cNamedArgs
);
1449 ok_(__FILE__
,line
)(!dp
->rgdispidNamedArgs
, "dp->rgdispidNamedArgs = %p\n", dp
->rgdispidNamedArgs
);
1450 ok_(__FILE__
,line
)(vres
!= NULL
, "vres == NULL\n");
1451 ok_(__FILE__
,line
)(V_VT(vres
) == VT_EMPTY
, "V_VT(vres) = %d\n", V_VT(vres
));
1452 ok_(__FILE__
,line
)(ei
!= NULL
, "ei == NULL\n");
1453 ok_(__FILE__
,line
)(argerr
!= NULL
, "argerr == NULL\n");
1456 #define test_cp_eventarg(a,b,c,d,e,f) _test_cp_eventarg(__LINE__,a,b,c,d,e,f)
1457 static void _test_cp_eventarg(unsigned line
, REFIID riid
, WORD flags
, DISPPARAMS
*dp
, VARIANT
*vres
, EXCEPINFO
*ei
, UINT
*argerr
)
1459 IHTMLEventObj
*event
;
1461 ok_(__FILE__
,line
)(IsEqualGUID(&IID_NULL
, riid
), "riid = %s\n", wine_dbgstr_guid(riid
));
1462 ok_(__FILE__
,line
)(flags
== DISPATCH_METHOD
, "flags = %x\n", flags
);
1463 ok_(__FILE__
,line
)(dp
!= NULL
, "dp == NULL\n");
1464 ok_(__FILE__
,line
)(dp
->cArgs
== 1, "dp->cArgs = %d\n", dp
->cArgs
);
1465 ok_(__FILE__
,line
)(dp
->rgvarg
!= NULL
, "dp->rgvarg = %p\n", dp
->rgvarg
);
1466 ok_(__FILE__
,line
)(!dp
->cNamedArgs
, "dp->cNamedArgs = %d\n", dp
->cNamedArgs
);
1467 ok_(__FILE__
,line
)(!dp
->rgdispidNamedArgs
, "dp->rgdispidNamedArgs = %p\n", dp
->rgdispidNamedArgs
);
1468 ok_(__FILE__
,line
)(vres
!= NULL
, "vres == NULL\n");
1469 ok_(__FILE__
,line
)(V_VT(vres
) == VT_EMPTY
, "V_VT(vres) = %d\n", V_VT(vres
));
1470 ok_(__FILE__
,line
)(ei
!= NULL
, "ei == NULL\n");
1471 ok_(__FILE__
,line
)(argerr
!= NULL
, "argerr == NULL\n");
1473 ok(V_VT(dp
->rgvarg
) == VT_DISPATCH
, "V_VT(dp->rgvarg) = %d\n", V_VT(dp
->rgvarg
));
1474 ok(V_DISPATCH(dp
->rgvarg
) != NULL
, "V_DISPATCH(dp->rgvarg) = %p\n", V_DISPATCH(dp
->rgvarg
));
1476 event
= _get_event_obj(line
);
1478 ok(!iface_cmp((IUnknown
*)event
, (IUnknown
*)V_DISPATCH(dp
->rgvarg
)), "event != arg0\n");
1479 IHTMLEventObj_Release(event
);
1482 static HRESULT WINAPI
doccp(IDispatchEx
*iface
, DISPID dispIdMember
,
1483 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1484 VARIANT
*pVarResult
, EXCEPINFO
*pei
, UINT
*puArgErr
)
1486 switch(dispIdMember
) {
1487 case DISPID_HTMLDOCUMENTEVENTS_ONCLICK
:
1488 CHECK_EXPECT(doccp_onclick
);
1489 test_cp_args(riid
, wFlags
, pdp
, pVarResult
, pei
, puArgErr
, FALSE
);
1492 ok(0, "unexpected call %d\n", dispIdMember
);
1499 CONNECTION_POINT_OBJ(doccp
, DIID_HTMLDocumentEvents
);
1501 static HRESULT WINAPI
doccp2(IDispatchEx
*iface
, DISPID dispIdMember
,
1502 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1503 VARIANT
*pVarResult
, EXCEPINFO
*pei
, UINT
*puArgErr
)
1505 switch(dispIdMember
) {
1506 case DISPID_HTMLDOCUMENTEVENTS_ONCLICK
:
1507 CHECK_EXPECT(doccp2_onclick
);
1508 test_cp_args(riid
, wFlags
, pdp
, pVarResult
, pei
, puArgErr
, TRUE
);
1511 ok(0, "unexpected call %d\n", dispIdMember
);
1518 CONNECTION_POINT_OBJ(doccp2
, DIID_HTMLDocumentEvents2
);
1520 static HRESULT WINAPI
doccp_onclick_cancel(IDispatchEx
*iface
, DISPID dispIdMember
,
1521 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
, VARIANT
*pVarResult
, EXCEPINFO
*pei
, UINT
*puArgErr
)
1523 switch(dispIdMember
) {
1524 case DISPID_HTMLDOCUMENTEVENTS_ONCLICK
:
1525 CHECK_EXPECT(doccp_onclick_cancel
);
1526 test_cp_args(riid
, wFlags
, pdp
, pVarResult
, pei
, puArgErr
, FALSE
);
1527 V_VT(pVarResult
) = VT_BOOL
;
1528 V_BOOL(pVarResult
) = VARIANT_FALSE
;
1531 ok(0, "unexpected call %d\n", dispIdMember
);
1538 CONNECTION_POINT_OBJ(doccp_onclick_cancel
, DIID_HTMLDocumentEvents
);
1540 static HRESULT WINAPI
elem2_cp(IDispatchEx
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
1541 WORD wFlags
, DISPPARAMS
*pdp
, VARIANT
*pVarResult
, EXCEPINFO
*pei
, UINT
*puArgErr
)
1543 switch(dispIdMember
) {
1544 case DISPID_HTMLDOCUMENTEVENTS_ONCLICK
:
1545 CHECK_EXPECT(elem2_cp_onclick
);
1546 test_cp_eventarg(riid
, wFlags
, pdp
, pVarResult
, pei
, puArgErr
);
1549 ok(0, "unexpected call %d\n", dispIdMember
);
1556 CONNECTION_POINT_OBJ(elem2_cp
, DIID_HTMLElementEvents2
);
1558 static HRESULT WINAPI
timeoutFunc_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1559 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1560 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1562 CHECK_EXPECT(timeout
);
1564 ok(dispIdMember
== DISPID_VALUE
, "dispIdMember = %d\n", dispIdMember
);
1565 ok(IsEqualGUID(&IID_NULL
, riid
), "riid = %s\n", wine_dbgstr_guid(riid
));
1566 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %x\n", wFlags
);
1567 ok(!lcid
, "lcid = %x\n", lcid
);
1568 ok(pDispParams
!= NULL
, "pDispParams == NULL\n");
1569 ok(!pDispParams
->cArgs
, "pdp->cArgs = %d\n", pDispParams
->cArgs
);
1570 ok(!pDispParams
->cNamedArgs
, "pdp->cNamedArgs = %d\n", pDispParams
->cNamedArgs
);
1571 ok(!pDispParams
->rgdispidNamedArgs
, "pdp->rgdispidNamedArgs = %p\n", pDispParams
->rgdispidNamedArgs
);
1572 ok(!pDispParams
->rgvarg
, "rgvarg = %p\n", pDispParams
->rgvarg
);
1573 ok(pVarResult
!= NULL
, "pVarResult = NULL\n");
1574 ok(pExcepInfo
!= NULL
, "pExcepInfo = NULL\n");
1575 ok(!puArgErr
, "puArgErr = %p\n", puArgErr
);
1576 ok(V_VT(pVarResult
) == VT_EMPTY
, "V_VT(pVarResult) = %d\n", V_VT(pVarResult
));
1581 static const IDispatchExVtbl timeoutFuncVtbl
= {
1582 DispatchEx_QueryInterface
,
1585 DispatchEx_GetTypeInfoCount
,
1586 DispatchEx_GetTypeInfo
,
1587 DispatchEx_GetIDsOfNames
,
1589 DispatchEx_GetDispID
,
1590 DispatchEx_InvokeEx
,
1591 DispatchEx_DeleteMemberByName
,
1592 DispatchEx_DeleteMemberByDispID
,
1593 DispatchEx_GetMemberProperties
,
1594 DispatchEx_GetMemberName
,
1595 DispatchEx_GetNextDispID
,
1596 DispatchEx_GetNameSpaceParent
1599 static IDispatchEx timeoutFunc
= { &timeoutFuncVtbl
};
1601 static HRESULT WINAPI
timeoutFunc2_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1602 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1603 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1605 ok(0, "unexpected call\n");
1609 static const IDispatchExVtbl timeoutFunc2Vtbl
= {
1610 DispatchEx_QueryInterface
,
1613 DispatchEx_GetTypeInfoCount
,
1614 DispatchEx_GetTypeInfo
,
1615 DispatchEx_GetIDsOfNames
,
1616 timeoutFunc2_Invoke
,
1617 DispatchEx_GetDispID
,
1618 DispatchEx_InvokeEx
,
1619 DispatchEx_DeleteMemberByName
,
1620 DispatchEx_DeleteMemberByDispID
,
1621 DispatchEx_GetMemberProperties
,
1622 DispatchEx_GetMemberName
,
1623 DispatchEx_GetNextDispID
,
1624 DispatchEx_GetNameSpaceParent
1627 static IDispatchEx timeoutFunc2
= { &timeoutFunc2Vtbl
};
1629 static HRESULT WINAPI
div_onclick_disp_Invoke(IDispatchEx
*iface
, DISPID id
,
1630 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1631 VARIANT
*pvarRes
, EXCEPINFO
*pei
, UINT
*puArgErr
)
1633 CHECK_EXPECT(div_onclick_disp
);
1635 test_attached_event_args(id
, wFlags
, pdp
, pvarRes
, pei
);
1637 ok(IsEqualGUID(&IID_NULL
, riid
), "riid = %s\n", wine_dbgstr_guid(riid
));
1638 ok(!puArgErr
, "puArgErr = %p\n", puArgErr
);
1643 static const IDispatchExVtbl div_onclick_dispVtbl
= {
1644 Dispatch_QueryInterface
,
1647 DispatchEx_GetTypeInfoCount
,
1648 DispatchEx_GetTypeInfo
,
1649 DispatchEx_GetIDsOfNames
,
1650 div_onclick_disp_Invoke
,
1653 static IDispatchEx div_onclick_disp
= { &div_onclick_dispVtbl
};
1655 static void pump_msgs(BOOL
*b
)
1660 while(!*b
&& GetMessageW(&msg
, NULL
, 0, 0)) {
1661 TranslateMessage(&msg
);
1662 DispatchMessageW(&msg
);
1665 while(PeekMessageW(&msg
, NULL
, 0, 0, PM_REMOVE
)) {
1666 TranslateMessage(&msg
);
1667 DispatchMessageW(&msg
);
1672 static IConnectionPoint
*get_cp(IUnknown
*unk
, REFIID riid
)
1674 IConnectionPointContainer
*cp_container
;
1675 IConnectionPoint
*cp
;
1678 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
1679 ok(hres
== S_OK
, "Could not get IConnectionPointContainer: %08x\n", hres
);
1681 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, riid
, &cp
);
1682 IConnectionPointContainer_Release(cp_container
);
1683 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
1688 static DWORD
register_cp(IUnknown
*unk
, REFIID riid
, IUnknown
*sink
)
1690 IConnectionPoint
*cp
;
1694 cp
= get_cp(unk
, riid
);
1695 hres
= IConnectionPoint_Advise(cp
, sink
, &cookie
);
1696 IConnectionPoint_Release(cp
);
1697 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
1702 static void unregister_cp(IUnknown
*unk
, REFIID riid
, DWORD cookie
)
1704 IConnectionPoint
*cp
;
1707 cp
= get_cp(unk
, riid
);
1708 hres
= IConnectionPoint_Unadvise(cp
, cookie
);
1709 IConnectionPoint_Release(cp
);
1710 ok(hres
== S_OK
, "Unadvise failed: %08x\n", hres
);
1713 static HRESULT WINAPI
EventDispatch_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppv
)
1715 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IDispatch
, riid
)) {
1720 ok(0, "Unexpected call\n");
1721 return E_NOINTERFACE
;
1724 static DWORD WINAPI
EventDispatch_AddRef(IDispatch
*iface
)
1729 static DWORD WINAPI
EventDispatch_Release(IDispatch
*iface
)
1734 static HRESULT WINAPI
EventDispatch_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1736 ok(0, "Unexpected call\n");
1740 static HRESULT WINAPI
EventDispatch_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1742 ok(0, "Unexpected call\n");
1746 static HRESULT WINAPI
EventDispatch_GetIDsOfNames(IDispatch
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
1747 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1749 ok(0, "Unexpected call\n");
1753 static HRESULT WINAPI
EventDispatch_Invoke(IDispatch
*iface
, DISPID dispIdMember
, REFIID riid
,
1754 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
1755 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1757 ok(IsEqualGUID(&IID_NULL
, riid
), "riid = %s\n", wine_dbgstr_guid(riid
));
1758 ok(pDispParams
!= NULL
, "pDispParams == NULL\n");
1759 ok(pExcepInfo
!= NULL
, "pExcepInfo == NULL\n");
1760 ok(puArgErr
!= NULL
, "puArgErr == NULL\n");
1761 ok(V_VT(pVarResult
) == 0, "V_VT(pVarResult) = %d\n", V_VT(pVarResult
));
1762 ok(wFlags
== DISPATCH_METHOD
, "wFlags = %d\n", wFlags
);
1764 switch(dispIdMember
) {
1765 case DISPID_HTMLDOCUMENTEVENTS_ONCLICK
:
1766 CHECK_EXPECT2(invoke_onclick
);
1768 case DISPID_HTMLDOCUMENTEVENTS2_ONPROPERTYCHANGE
:
1769 case DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE
:
1780 ok(0, "Unexpected call: %d\n", dispIdMember
);
1786 static const IDispatchVtbl EventDispatchVtbl
= {
1787 EventDispatch_QueryInterface
,
1788 EventDispatch_AddRef
,
1789 EventDispatch_Release
,
1790 EventDispatch_GetTypeInfoCount
,
1791 EventDispatch_GetTypeInfo
,
1792 EventDispatch_GetIDsOfNames
,
1793 EventDispatch_Invoke
1796 static IDispatch EventDispatch
= { &EventDispatchVtbl
};
1798 static void set_body_html(IHTMLDocument2
*doc
, const WCHAR
*html
)
1800 IHTMLElement
*body
= doc_get_body(doc
);
1801 set_elem_innerhtml(body
, html
);
1802 IHTMLElement_Release(body
);
1805 static void test_onclick(IHTMLDocument2
*doc
)
1807 DWORD events_cp_cookie
, events2_cp_cookie
, elem2_cp_cookie
;
1808 IHTMLElement
*div
, *body
;
1812 trace("onclick tests in document mode %d\n", document_mode
);
1814 set_body_html(doc
, L
"<div id=\"clickdiv\""
1815 " style=\"text-align: center; background: red; font-size: 32\">"
1819 register_cp((IUnknown
*)doc
, &IID_IDispatch
, (IUnknown
*)&EventDispatch
);
1821 div
= get_elem_id(doc
, L
"clickdiv");
1823 elem_attach_event((IUnknown
*)div
, L
"abcde", (IDispatch
*)&nocall_obj
);
1824 elem_attach_event((IUnknown
*)div
, L
"onclick", (IDispatch
*)&div_onclick_attached_obj
);
1826 V_VT(&v
) = VT_EMPTY
;
1827 hres
= IHTMLElement_get_onclick(div
, &v
);
1828 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
1829 ok(V_VT(&v
) == VT_NULL
, "V_VT(onclick) = %d\n", V_VT(&v
));
1831 V_VT(&v
) = VT_EMPTY
;
1832 hres
= IHTMLElement_put_onclick(div
, v
);
1833 ok(hres
== (document_mode
< 9 ? E_NOTIMPL
: S_OK
), "put_onclick failed: %08x\n", hres
);
1835 V_VT(&v
) = VT_EMPTY
;
1836 hres
= IHTMLElement_get_onclick(div
, &v
);
1837 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
1838 ok(V_VT(&v
) == VT_NULL
, "V_VT(onclick) = %d\n", V_VT(&v
));
1841 V_BSTR(&v
) = SysAllocString(L
"function();");
1842 hres
= IHTMLElement_put_onclick(div
, v
);
1843 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
1844 SysFreeString(V_BSTR(&v
));
1846 V_VT(&v
) = VT_EMPTY
;
1847 hres
= IHTMLElement_get_onclick(div
, &v
);
1848 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
1849 if(document_mode
< 9) {
1850 ok(V_VT(&v
) == VT_BSTR
, "V_VT(onclick) = %d\n", V_VT(&v
));
1851 ok(!lstrcmpW(V_BSTR(&v
), L
"function();"), "V_BSTR(onclick) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
1854 ok(V_VT(&v
) == VT_NULL
, "V_VT(onclick) = %d\n", V_VT(&v
));
1858 V_VT(&v
) = VT_DISPATCH
;
1859 V_DISPATCH(&v
) = (IDispatch
*)&div_onclick_obj
;
1860 hres
= IHTMLElement_put_onclick(div
, v
);
1861 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
1864 hres
= IHTMLElement_put_ondblclick(div
, v
);
1865 ok(hres
== S_OK
, "put_ondblclick failed: %08x\n", hres
);
1867 V_VT(&v
) = VT_EMPTY
;
1868 hres
= IHTMLElement_get_onclick(div
, &v
);
1869 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
1870 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onclick) = %d\n", V_VT(&v
));
1871 ok(V_DISPATCH(&v
) == (IDispatch
*)&div_onclick_obj
, "V_DISPATCH(onclick) != onclickFunc\n");
1874 V_VT(&v
) = VT_EMPTY
;
1875 hres
= IHTMLDocument2_get_onclick(doc
, &v
);
1876 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
1877 ok(V_VT(&v
) == VT_NULL
, "V_VT(onclick) = %d\n", V_VT(&v
));
1879 V_VT(&v
) = VT_DISPATCH
;
1880 V_DISPATCH(&v
) = (IDispatch
*)&document_onclick_obj
;
1881 hres
= IHTMLDocument2_put_onclick(doc
, v
);
1882 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
1884 V_VT(&v
) = VT_EMPTY
;
1885 hres
= IHTMLDocument2_get_onclick(doc
, &v
);
1886 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
1887 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onclick) = %d\n", V_VT(&v
));
1888 ok(V_DISPATCH(&v
) == (IDispatch
*)&document_onclick_obj
, "V_DISPATCH(onclick) != onclickFunc\n");
1891 if(document_mode
>= 9) {
1892 add_event_listener((IUnknown
*)div
, L
"click", (IDispatch
*)&div_onclick_capture_obj
, VARIANT_TRUE
);
1893 add_event_listener((IUnknown
*)div
, L
"click", (IDispatch
*)&div_onclick_bubble_obj
, VARIANT_FALSE
);
1896 body
= doc_get_body(doc
);
1898 V_VT(&v
) = VT_DISPATCH
;
1899 V_DISPATCH(&v
) = (IDispatch
*)&body_onclick_obj
;
1900 hres
= IHTMLElement_put_onclick(body
, v
);
1901 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
1903 if(winetest_interactive
&& document_mode
< 9) {
1904 SET_EXPECT(div_onclick
);
1905 SET_EXPECT(div_onclick_attached
);
1906 SET_EXPECT(body_onclick
);
1907 SET_EXPECT(document_onclick
);
1908 SET_EXPECT(invoke_onclick
);
1909 pump_msgs(&called_document_onclick
);
1910 CHECK_CALLED(div_onclick
);
1911 CHECK_CALLED(div_onclick_attached
);
1912 CHECK_CALLED(body_onclick
);
1913 CHECK_CALLED(document_onclick
);
1914 CHECK_CALLED(invoke_onclick
);
1917 SET_EXPECT(div_onclick
);
1918 SET_EXPECT(div_onclick_attached
);
1919 if(document_mode
>= 9) {
1920 SET_EXPECT(div_onclick_capture
);
1921 SET_EXPECT(div_onclick_bubble
);
1923 SET_EXPECT(body_onclick
);
1924 SET_EXPECT(document_onclick
);
1925 SET_EXPECT(invoke_onclick
);
1927 hres
= IHTMLElement_click(div
);
1928 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
1930 CHECK_CALLED(div_onclick
);
1931 CHECK_CALLED(div_onclick_attached
);
1932 if(document_mode
>= 9) {
1933 CHECK_CALLED(div_onclick_capture
);
1934 CHECK_CALLED(div_onclick_bubble
);
1936 CHECK_CALLED(body_onclick
);
1937 CHECK_CALLED(document_onclick
);
1938 CHECK_CALLED(invoke_onclick
);
1940 SET_EXPECT(div_onclick
);
1941 SET_EXPECT(div_onclick_attached
);
1942 SET_EXPECT(body_onclick
);
1943 SET_EXPECT(document_onclick
);
1944 SET_EXPECT(invoke_onclick
);
1946 V_VT(&v
) = VT_EMPTY
;
1947 elem_fire_event((IUnknown
*)div
, L
"onclick", &v
);
1949 CHECK_CALLED(div_onclick
);
1950 CHECK_CALLED(div_onclick_attached
);
1951 CHECK_CALLED(body_onclick
);
1952 CHECK_CALLED(document_onclick
);
1953 CHECK_CALLED(invoke_onclick
);
1955 events_cp_cookie
= register_cp((IUnknown
*)doc
, &DIID_HTMLDocumentEvents
, (IUnknown
*)&doccp_obj
);
1956 events2_cp_cookie
= register_cp((IUnknown
*)doc
, &DIID_HTMLDocumentEvents2
, (IUnknown
*)&doccp2_obj
);
1957 elem_attach_event((IUnknown
*)div
, L
"onclick", (IDispatch
*)&div_onclick_disp
);
1958 doc_attach_event(doc
, L
"onclick", (IDispatch
*)&doc_onclick_attached_obj
);
1960 SET_EXPECT(div_onclick
);
1961 SET_EXPECT(div_onclick_disp
);
1962 SET_EXPECT(div_onclick_attached
);
1963 if(document_mode
>= 9) {
1964 SET_EXPECT(div_onclick_capture
);
1965 SET_EXPECT(div_onclick_bubble
);
1967 SET_EXPECT(body_onclick
);
1968 SET_EXPECT(document_onclick
);
1969 SET_EXPECT(doc_onclick_attached
);
1970 SET_EXPECT(doccp_onclick
);
1971 SET_EXPECT(doccp2_onclick
);
1972 SET_EXPECT(invoke_onclick
);
1974 hres
= IHTMLElement_click(div
);
1975 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
1977 CHECK_CALLED(div_onclick
);
1978 CHECK_CALLED(div_onclick_disp
);
1979 CHECK_CALLED(div_onclick_attached
);
1980 if(document_mode
>= 9) {
1981 CHECK_CALLED(div_onclick_capture
);
1982 CHECK_CALLED(div_onclick_bubble
);
1984 CHECK_CALLED(body_onclick
);
1985 CHECK_CALLED(document_onclick
);
1986 CHECK_CALLED(doc_onclick_attached
);
1987 CHECK_CALLED(doccp_onclick
);
1988 CHECK_CALLED(doccp2_onclick
);
1989 CHECK_CALLED(invoke_onclick
);
1991 elem2_cp_cookie
= register_cp((IUnknown
*)div
, &DIID_HTMLElementEvents2
, (IUnknown
*)&elem2_cp_obj
);
1993 SET_EXPECT(div_onclick
);
1994 SET_EXPECT(div_onclick_disp
);
1995 SET_EXPECT(div_onclick_attached
);
1996 if(document_mode
>= 9) {
1997 SET_EXPECT(div_onclick_capture
);
1998 SET_EXPECT(div_onclick_bubble
);
2000 SET_EXPECT(elem2_cp_onclick
);
2001 SET_EXPECT(body_onclick
);
2002 SET_EXPECT(document_onclick
);
2003 SET_EXPECT(doc_onclick_attached
);
2004 SET_EXPECT(doccp_onclick
);
2005 SET_EXPECT(doccp2_onclick
);
2006 SET_EXPECT(invoke_onclick
);
2008 trace("click >>>\n");
2009 hres
= IHTMLElement_click(div
);
2010 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2011 trace("click <<<\n");
2013 CHECK_CALLED(div_onclick
);
2014 CHECK_CALLED(div_onclick_disp
);
2015 CHECK_CALLED(div_onclick_attached
);
2016 if(document_mode
>= 9) {
2017 CHECK_CALLED(div_onclick_capture
);
2018 CHECK_CALLED(div_onclick_bubble
);
2020 CHECK_CALLED(elem2_cp_onclick
);
2021 CHECK_CALLED(body_onclick
);
2022 CHECK_CALLED(document_onclick
);
2023 CHECK_CALLED(doc_onclick_attached
);
2024 CHECK_CALLED(doccp_onclick
);
2025 CHECK_CALLED(doccp2_onclick
);
2026 CHECK_CALLED(invoke_onclick
);
2028 unregister_cp((IUnknown
*)div
, &DIID_HTMLElementEvents2
, elem2_cp_cookie
);
2029 unregister_cp((IUnknown
*)doc
, &DIID_HTMLDocumentEvents
, events_cp_cookie
);
2030 unregister_cp((IUnknown
*)doc
, &DIID_HTMLDocumentEvents2
, events2_cp_cookie
);
2033 hres
= IHTMLElement_put_onclick(div
, v
);
2034 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
2036 hres
= IHTMLElement_get_onclick(div
, &v
);
2037 ok(hres
== S_OK
, "get_onclick failed: %08x\n", hres
);
2038 ok(V_VT(&v
) == VT_NULL
, "get_onclick returned vt %d\n", V_VT(&v
));
2040 elem_detach_event((IUnknown
*)div
, L
"onclick", (IDispatch
*)&div_onclick_disp
);
2041 elem_detach_event((IUnknown
*)div
, L
"onclick", (IDispatch
*)&div_onclick_disp
);
2042 elem_detach_event((IUnknown
*)div
, L
"test", (IDispatch
*)&div_onclick_disp
);
2043 doc_detach_event(doc
, L
"onclick", (IDispatch
*)&doc_onclick_attached_obj
);
2045 if(document_mode
>= 9) {
2046 remove_event_listener((IUnknown
*)div
, L
"click", (IDispatch
*)&div_onclick_capture_obj
, VARIANT_TRUE
);
2047 remove_event_listener((IUnknown
*)div
, L
"click", (IDispatch
*)&div_onclick_bubble_obj
, VARIANT_FALSE
);
2050 SET_EXPECT(div_onclick_attached
);
2051 SET_EXPECT(body_onclick
);
2052 SET_EXPECT(document_onclick
);
2053 SET_EXPECT(invoke_onclick
);
2055 hres
= IHTMLElement_click(div
);
2056 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2058 CHECK_CALLED(div_onclick_attached
);
2059 CHECK_CALLED(body_onclick
);
2060 CHECK_CALLED(document_onclick
);
2061 CHECK_CALLED(invoke_onclick
);
2063 IHTMLElement_Release(div
);
2064 IHTMLElement_Release(body
);
2067 static void test_onreadystatechange(IHTMLDocument2
*doc
)
2069 IHTMLFrameBase
*iframe
;
2070 IHTMLElement2
*elem2
;
2076 elem
= get_elem_id(doc
, L
"iframe");
2077 elem2
= get_elem2_iface((IUnknown
*)elem
);
2078 IHTMLElement_Release(elem
);
2080 V_VT(&v
) = VT_EMPTY
;
2081 hres
= IHTMLElement2_get_onreadystatechange(elem2
, &v
);
2082 ok(hres
== S_OK
, "get_onreadystatechange failed: %08x\n", hres
);
2083 ok(V_VT(&v
) == VT_NULL
, "V_VT(onreadystatechange) = %d\n", V_VT(&v
));
2085 V_VT(&v
) = VT_DISPATCH
;
2086 V_DISPATCH(&v
) = (IDispatch
*)&iframe_onreadystatechange_obj
;
2087 hres
= IHTMLElement2_put_onreadystatechange(elem2
, v
);
2088 ok(hres
== S_OK
, "put_onreadystatechange failed: %08x\n", hres
);
2090 V_VT(&v
) = VT_EMPTY
;
2091 hres
= IHTMLElement2_get_onreadystatechange(elem2
, &v
);
2092 ok(hres
== S_OK
, "get_onreadystatechange failed: %08x\n", hres
);
2093 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onreadystatechange) = %d\n", V_VT(&v
));
2094 ok(V_DISPATCH(&v
) == (IDispatch
*)&iframe_onreadystatechange_obj
, "unexpected onreadystatechange value\n");
2096 hres
= IHTMLElement2_QueryInterface(elem2
, &IID_IHTMLFrameBase
, (void**)&iframe
);
2097 IHTMLElement2_Release(elem2
);
2098 ok(hres
== S_OK
, "Could not get IHTMLFrameBase iface: %08x\n", hres
);
2100 hres
= IHTMLFrameBase_put_src(iframe
, (str
= SysAllocString(L
"about:blank")));
2102 ok(hres
== S_OK
, "put_src failed: %08x\n", hres
);
2104 SET_EXPECT(iframe_onreadystatechange_loading
);
2105 SET_EXPECT(iframedoc_onreadystatechange
);
2106 SET_EXPECT(iframe_onreadystatechange_interactive
);
2107 SET_EXPECT(iframe_onreadystatechange_complete
);
2108 pump_msgs(&called_iframe_onreadystatechange_complete
);
2109 CHECK_CALLED(iframe_onreadystatechange_loading
);
2110 CHECK_CALLED(iframedoc_onreadystatechange
);
2111 CHECK_CALLED(iframe_onreadystatechange_interactive
);
2112 CHECK_CALLED(iframe_onreadystatechange_complete
);
2114 IHTMLFrameBase_Release(iframe
);
2117 static void test_imgload(IHTMLDocument2
*doc
)
2119 IHTMLImgElement
*img
;
2125 elem
= get_elem_id(doc
, L
"imgid");
2126 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLImgElement
, (void**)&img
);
2127 IHTMLElement_Release(elem
);
2128 ok(hres
== S_OK
, "Could not get IHTMLImgElement iface: %08x\n", hres
);
2130 V_VT(&v
) = VT_EMPTY
;
2131 hres
= IHTMLImgElement_get_onload(img
, &v
);
2132 ok(hres
== S_OK
, "get_onload failed: %08x\n", hres
);
2133 ok(V_VT(&v
) == VT_NULL
, "V_VT(onload) = %d\n", V_VT(&v
));
2135 V_VT(&v
) = VT_DISPATCH
;
2136 V_DISPATCH(&v
) = (IDispatch
*)&img_onload_obj
;
2137 hres
= IHTMLImgElement_put_onload(img
, v
);
2138 ok(hres
== S_OK
, "put_onload failed: %08x\n", hres
);
2140 V_VT(&v
) = VT_EMPTY
;
2141 hres
= IHTMLImgElement_get_onload(img
, &v
);
2142 ok(hres
== S_OK
, "get_onload failed: %08x\n", hres
);
2143 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onload) = %d\n", V_VT(&v
));
2144 ok(V_DISPATCH(&v
) == (IDispatch
*)&img_onload_obj
, "V_DISPATCH(onload) != onloadkFunc\n");
2147 V_VT(&v
) = VT_DISPATCH
;
2148 V_DISPATCH(&v
) = (IDispatch
*)&img_onerror_obj
;
2149 hres
= IHTMLImgElement_put_onerror(img
, v
);
2150 ok(hres
== S_OK
, "put_onerror failed: %08x\n", hres
);
2152 V_VT(&v
) = VT_EMPTY
;
2153 hres
= IHTMLImgElement_get_onerror(img
, &v
);
2154 ok(hres
== S_OK
, "get_onerror failed: %08x\n", hres
);
2155 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onerror) = %d\n", V_VT(&v
));
2156 ok(V_DISPATCH(&v
) == (IDispatch
*)&img_onerror_obj
, "V_DISPATCH(onerror) != onerrorFunc\n");
2159 str
= SysAllocString(L
"http://test.winehq.org/tests/winehq_snapshot/index_files/winehq_logo_text.png");
2160 hres
= IHTMLImgElement_put_src(img
, str
);
2161 ok(hres
== S_OK
, "put_src failed: %08x\n", hres
);
2164 SET_EXPECT(img_onload
);
2165 pump_msgs(&called_img_onload
);
2166 CHECK_CALLED(img_onload
);
2168 SET_EXPECT(img_onerror
);
2170 str
= SysAllocString(L
"about:blank");
2171 hres
= IHTMLImgElement_put_src(img
, str
);
2172 ok(hres
== S_OK
, "put_src failed: %08x\n", hres
);
2175 pump_msgs(&called_img_onerror
); /* FIXME: should not be needed */
2177 CHECK_CALLED(img_onerror
);
2179 IHTMLImgElement_Release(img
);
2181 /* test onload on unattached image */
2182 hres
= IHTMLDocument2_createElement(doc
, (str
= SysAllocString(L
"img")), &elem
);
2184 ok(hres
== S_OK
, "createElement(img) failed: %08x\n", hres
);
2186 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLImgElement
, (void**)&img
);
2187 IHTMLElement_Release(elem
);
2188 ok(hres
== S_OK
, "Could not get IHTMLImgElement iface: %08x\n", hres
);
2190 V_VT(&v
) = VT_EMPTY
;
2191 hres
= IHTMLImgElement_get_onload(img
, &v
);
2192 ok(hres
== S_OK
, "get_onload failed: %08x\n", hres
);
2193 ok(V_VT(&v
) == VT_NULL
, "V_VT(onload) = %d\n", V_VT(&v
));
2195 V_VT(&v
) = VT_DISPATCH
;
2196 V_DISPATCH(&v
) = (IDispatch
*)&unattached_img_onload_obj
;
2197 hres
= IHTMLImgElement_put_onload(img
, v
);
2198 ok(hres
== S_OK
, "put_onload failed: %08x\n", hres
);
2200 V_VT(&v
) = VT_EMPTY
;
2201 hres
= IHTMLImgElement_get_onload(img
, &v
);
2202 ok(hres
== S_OK
, "get_onload failed: %08x\n", hres
);
2203 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onload) = %d\n", V_VT(&v
));
2204 ok(V_DISPATCH(&v
) == (IDispatch
*)&unattached_img_onload_obj
, "incorrect V_DISPATCH(onload)\n");
2207 str
= SysAllocString(L
"http://test.winehq.org/tests/winehq_snapshot/index_files/winehq_logo_text.png?v=1");
2208 hres
= IHTMLImgElement_put_src(img
, str
);
2209 ok(hres
== S_OK
, "put_src failed: %08x\n", hres
);
2212 SET_EXPECT(img_onload
);
2213 pump_msgs(&called_img_onload
);
2214 CHECK_CALLED(img_onload
);
2216 IHTMLImgElement_Release(img
);
2219 static void test_link_load(IHTMLDocument2
*doc
)
2221 IHTMLLinkElement
*link
;
2227 elem
= get_elem_id(doc
, L
"linkid");
2228 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLLinkElement
, (void**)&link
);
2229 IHTMLElement_Release(elem
);
2230 ok(hres
== S_OK
, "Could not get IHTMLLinkElement iface: %08x\n", hres
);
2232 V_VT(&v
) = VT_EMPTY
;
2233 hres
= IHTMLLinkElement_get_onload(link
, &v
);
2234 ok(hres
== S_OK
, "get_onload failed: %08x\n", hres
);
2235 ok(V_VT(&v
) == VT_NULL
, "V_VT(onload) = %d\n", V_VT(&v
));
2237 V_VT(&v
) = VT_DISPATCH
;
2238 V_DISPATCH(&v
) = (IDispatch
*)&link_onload_obj
;
2239 hres
= IHTMLLinkElement_put_onload(link
, v
);
2240 ok(hres
== S_OK
, "put_onload failed: %08x\n", hres
);
2242 V_VT(&v
) = VT_EMPTY
;
2243 hres
= IHTMLLinkElement_get_onload(link
, &v
);
2244 ok(hres
== S_OK
, "get_onload failed: %08x\n", hres
);
2245 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onload) = %d\n", V_VT(&v
));
2246 ok(V_DISPATCH(&v
) == (IDispatch
*)&link_onload_obj
, "V_DISPATCH(onload) != onloadkFunc\n");
2249 str
= SysAllocString(L
"http://test.winehq.org/tests/winehq_snapshot/index_files/styles.css");
2250 hres
= IHTMLLinkElement_put_href(link
, str
);
2251 ok(hres
== S_OK
, "put_src failed: %08x\n", hres
);
2254 SET_EXPECT(link_onload
);
2255 pump_msgs(&called_link_onload
);
2256 CHECK_CALLED(link_onload
);
2258 IHTMLLinkElement_Release(link
);
2261 static void test_focus(IHTMLDocument2
*doc
)
2263 IHTMLElement2
*elem2
;
2269 elem
= get_elem_id(doc
, L
"inputid");
2270 elem2
= get_elem2_iface((IUnknown
*)elem
);
2271 IHTMLElement_Release(elem
);
2273 elem
= get_elem_id(doc
, L
"divid");
2274 div
= get_elem4_iface((IUnknown
*)elem
);
2275 IHTMLElement_Release(elem
);
2277 V_VT(&v
) = VT_EMPTY
;
2278 hres
= IHTMLElement2_get_onfocus(elem2
, &v
);
2279 ok(hres
== S_OK
, "get_onfocus failed: %08x\n", hres
);
2280 ok(V_VT(&v
) == VT_NULL
, "V_VT(onfocus) = %d\n", V_VT(&v
));
2282 V_VT(&v
) = VT_DISPATCH
;
2283 V_DISPATCH(&v
) = (IDispatch
*)&input_onfocus_obj
;
2284 hres
= IHTMLElement2_put_onfocus(elem2
, v
);
2285 ok(hres
== S_OK
, "put_onfocus failed: %08x\n", hres
);
2287 V_VT(&v
) = VT_EMPTY
;
2288 hres
= IHTMLElement2_get_onfocus(elem2
, &v
);
2289 ok(hres
== S_OK
, "get_onfocus failed: %08x\n", hres
);
2290 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onfocus) = %d\n", V_VT(&v
));
2291 ok(V_DISPATCH(&v
) == (IDispatch
*)&input_onfocus_obj
, "V_DISPATCH(onfocus) != onfocusFunc\n");
2294 V_VT(&v
) = VT_DISPATCH
;
2295 V_DISPATCH(&v
) = (IDispatch
*)&div_onfocusin_obj
;
2296 hres
= IHTMLElement4_put_onfocusin(div
, v
);
2297 ok(hres
== S_OK
, "put_onfocusin failed: %08x\n", hres
);
2299 V_VT(&v
) = VT_EMPTY
;
2300 hres
= IHTMLElement4_get_onfocusin(div
, &v
);
2301 ok(hres
== S_OK
, "get_onfocusin failed: %08x\n", hres
);
2302 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onfocusin) = %d\n", V_VT(&v
));
2303 ok(V_DISPATCH(&v
) == (IDispatch
*)&div_onfocusin_obj
, "V_DISPATCH(onfocus) != onfocusFunc\n");
2306 V_VT(&v
) = VT_EMPTY
;
2307 hres
= IHTMLElement2_get_onfocus(elem2
, &v
);
2308 ok(hres
== S_OK
, "get_onfocus failed: %08x\n", hres
);
2309 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(onfocus) = %d\n", V_VT(&v
));
2310 ok(V_DISPATCH(&v
) == (IDispatch
*)&input_onfocus_obj
, "V_DISPATCH(onfocus) != onfocusFunc\n");
2313 if(!winetest_interactive
)
2314 ShowWindow(container_hwnd
, SW_SHOW
);
2317 ok(!IsChild(container_hwnd
, GetFocus()), "focus belongs to document window\n");
2319 hres
= IHTMLWindow2_focus(window
);
2320 ok(hres
== S_OK
, "focus failed: %08x\n", hres
);
2322 ok(IsChild(container_hwnd
, GetFocus()), "focus does not belong to document window\n");
2325 SET_EXPECT(div_onfocusin
);
2326 SET_EXPECT(input_onfocus
);
2327 hres
= IHTMLElement2_focus(elem2
);
2328 ok(hres
== S_OK
, "focus failed: %08x\n", hres
);
2330 CHECK_CALLED(div_onfocusin
);
2331 CHECK_CALLED(input_onfocus
);
2333 SET_EXPECT(div_onfocusin
);
2334 V_VT(&v
) = VT_EMPTY
;
2335 elem_fire_event((IUnknown
*)elem2
, L
"onfocusin", &v
);
2336 CHECK_CALLED(div_onfocusin
);
2338 V_VT(&v
) = VT_DISPATCH
;
2339 V_DISPATCH(&v
) = (IDispatch
*)&input_onblur_obj
;
2340 hres
= IHTMLElement2_put_onblur(elem2
, v
);
2341 ok(hres
== S_OK
, "put_onblur failed: %08x\n", hres
);
2343 V_VT(&v
) = VT_DISPATCH
;
2344 V_DISPATCH(&v
) = (IDispatch
*)&div_onfocusout_obj
;
2345 hres
= IHTMLElement4_put_onfocusout(div
, v
);
2346 ok(hres
== S_OK
, "put_onfocusout failed: %08x\n", hres
);
2348 SET_EXPECT(div_onfocusout
);
2349 SET_EXPECT(input_onblur
);
2350 hres
= IHTMLElement2_blur(elem2
);
2352 CHECK_CALLED(input_onblur
);
2353 CHECK_CALLED(div_onfocusout
);
2354 ok(hres
== S_OK
, "blur failed: %08x\n", hres
);
2356 if(!winetest_interactive
)
2357 ShowWindow(container_hwnd
, SW_HIDE
);
2359 IHTMLElement2_Release(elem2
);
2360 IHTMLElement4_Release(div
);
2363 static void test_submit(IHTMLDocument2
*doc
)
2365 IHTMLElement
*elem
, *submit
;
2366 IHTMLFormElement
*form
;
2372 L
"<form id=\"formid\" method=\"post\" action=\"about:blank\">"
2373 "<input type=\"text\" value=\"test\" name=\"i\"/>"
2374 "<input type=\"submit\" id=\"submitid\" />"
2377 elem
= get_elem_id(doc
, L
"formid");
2379 V_VT(&v
) = VT_DISPATCH
;
2380 V_DISPATCH(&v
) = (IDispatch
*)&form_onclick_obj
;
2381 hres
= IHTMLElement_put_onclick(elem
, v
);
2382 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
2384 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFormElement
, (void**)&form
);
2385 IHTMLElement_Release(elem
);
2386 ok(hres
== S_OK
, "Could not get IHTMLFormElement iface: %08x\n", hres
);
2388 V_VT(&v
) = VT_DISPATCH
;
2389 V_DISPATCH(&v
) = (IDispatch
*)&form_onsubmit_obj
;
2390 hres
= IHTMLFormElement_put_onsubmit(form
, v
);
2391 ok(hres
== S_OK
, "put_onsubmit failed: %08x\n", hres
);
2393 IHTMLFormElement_Release(form
);
2395 submit
= get_elem_id(doc
, L
"submitid");
2397 SET_EXPECT(form_onclick
);
2398 SET_EXPECT(form_onsubmit
);
2399 hres
= IHTMLElement_click(submit
);
2400 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2401 CHECK_CALLED(form_onclick
);
2402 CHECK_CALLED(form_onsubmit
);
2404 V_VT(&v
) = VT_DISPATCH
;
2405 V_DISPATCH(&v
) = (IDispatch
*)&submit_onclick_obj
;
2406 hres
= IHTMLElement_put_onclick(submit
, v
);
2407 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
2409 SET_EXPECT(form_onclick
);
2410 SET_EXPECT(submit_onclick
);
2411 hres
= IHTMLElement_click(submit
);
2412 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2413 CHECK_CALLED(form_onclick
);
2414 CHECK_CALLED(submit_onclick
);
2416 elem_attach_event((IUnknown
*)submit
, L
"onclick", (IDispatch
*)&submit_onclick_attached_obj
);
2418 SET_EXPECT(form_onclick
);
2419 SET_EXPECT(submit_onclick
);
2420 SET_EXPECT(submit_onclick_attached
);
2421 hres
= IHTMLElement_click(submit
);
2422 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2423 CHECK_CALLED(form_onclick
);
2424 CHECK_CALLED(submit_onclick
);
2425 CHECK_CALLED(submit_onclick_attached
);
2428 hres
= IHTMLElement_put_onclick(submit
, v
);
2429 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
2431 SET_EXPECT(form_onclick
);
2432 SET_EXPECT(submit_onclick_attached
);
2433 hres
= IHTMLElement_click(submit
);
2434 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2435 CHECK_CALLED(form_onclick
);
2436 CHECK_CALLED(submit_onclick_attached
);
2438 elem_detach_event((IUnknown
*)submit
, L
"onclick", (IDispatch
*)&submit_onclick_attached_obj
);
2440 cp_cookie
= register_cp((IUnknown
*)doc
, &DIID_HTMLDocumentEvents
, (IUnknown
*)&doccp_onclick_cancel_obj
);
2442 SET_EXPECT(form_onclick
);
2443 SET_EXPECT(doccp_onclick_cancel
);
2444 hres
= IHTMLElement_click(submit
);
2445 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2446 CHECK_CALLED(form_onclick
);
2447 CHECK_CALLED(doccp_onclick_cancel
);
2449 unregister_cp((IUnknown
*)doc
, &DIID_HTMLDocumentEvents
, cp_cookie
);
2451 V_VT(&v
) = VT_DISPATCH
;
2452 V_DISPATCH(&v
) = (IDispatch
*)&submit_onclick_setret_obj
;
2453 hres
= IHTMLElement_put_onclick(submit
, v
);
2454 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
2456 V_VT(&onclick_retval
) = VT_BOOL
;
2457 V_BOOL(&onclick_retval
) = VARIANT_TRUE
;
2458 V_VT(&onclick_event_retval
) = VT_BOOL
;
2459 V_BOOL(&onclick_event_retval
) = VARIANT_TRUE
;
2461 SET_EXPECT(submit_onclick_setret
);
2462 SET_EXPECT(form_onclick
);
2463 SET_EXPECT(form_onsubmit
);
2464 hres
= IHTMLElement_click(submit
);
2465 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2466 CHECK_CALLED(submit_onclick_setret
);
2467 CHECK_CALLED(form_onclick
);
2468 CHECK_CALLED(form_onsubmit
);
2470 V_VT(&onclick_event_retval
) = VT_BOOL
;
2471 V_BOOL(&onclick_event_retval
) = VARIANT_FALSE
;
2473 SET_EXPECT(submit_onclick_setret
);
2474 SET_EXPECT(form_onclick
);
2475 hres
= IHTMLElement_click(submit
);
2476 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2477 CHECK_CALLED(submit_onclick_setret
);
2478 CHECK_CALLED(form_onclick
);
2480 V_VT(&onclick_retval
) = VT_BOOL
;
2481 V_BOOL(&onclick_retval
) = VARIANT_FALSE
;
2482 V_VT(&onclick_event_retval
) = VT_BOOL
;
2483 V_BOOL(&onclick_event_retval
) = VARIANT_TRUE
;
2485 SET_EXPECT(submit_onclick_setret
);
2486 SET_EXPECT(form_onclick
);
2487 hres
= IHTMLElement_click(submit
);
2488 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2489 CHECK_CALLED(submit_onclick_setret
);
2490 CHECK_CALLED(form_onclick
);
2492 V_VT(&onclick_event_retval
) = VT_BOOL
;
2493 V_BOOL(&onclick_event_retval
) = VARIANT_FALSE
;
2495 SET_EXPECT(submit_onclick_setret
);
2496 SET_EXPECT(form_onclick
);
2497 hres
= IHTMLElement_click(submit
);
2498 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2499 CHECK_CALLED(submit_onclick_setret
);
2500 CHECK_CALLED(form_onclick
);
2502 elem_attach_event((IUnknown
*)submit
, L
"onclick", (IDispatch
*)&submit_onclick_attached_obj
);
2503 elem_attach_event((IUnknown
*)submit
, L
"onclick", (IDispatch
*)&submit_onclick_attached_check_cancel_obj
);
2505 V_VT(&v
) = VT_DISPATCH
;
2506 V_DISPATCH(&v
) = (IDispatch
*)&submit_onclick_cancel_obj
;
2507 hres
= IHTMLElement_put_onclick(submit
, v
);
2508 ok(hres
== S_OK
, "put_onclick failed: %08x\n", hres
);
2510 SET_EXPECT(submit_onclick_cancel
);
2511 SET_EXPECT(submit_onclick_attached_check_cancel
);
2512 SET_EXPECT(submit_onclick_attached
);
2513 hres
= IHTMLElement_click(submit
);
2514 ok(hres
== S_OK
, "click failed: %08x\n", hres
);
2515 CHECK_CALLED(submit_onclick_cancel
);
2516 CHECK_CALLED(submit_onclick_attached_check_cancel
);
2517 CHECK_CALLED(submit_onclick_attached
);
2519 if(1)pump_msgs(NULL
);
2521 IHTMLElement_Release(submit
);
2524 static void test_timeout(IHTMLDocument2
*doc
)
2531 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow3
, (void**)&win3
);
2532 ok(hres
== S_OK
, "Could not get IHTMLWindow3 iface: %08x\n", hres
);
2534 V_VT(&expr
) = VT_DISPATCH
;
2535 V_DISPATCH(&expr
) = (IDispatch
*)&timeoutFunc2
;
2536 V_VT(&var
) = VT_EMPTY
;
2538 hres
= IHTMLWindow3_setInterval(win3
, &expr
, 1, &var
, &id
);
2539 ok(hres
== S_OK
, "setInterval failed: %08x\n", hres
);
2542 hres
= IHTMLWindow2_clearTimeout(window
, id
);
2543 ok(hres
== S_OK
, "clearTimeout failer: %08x\n", hres
);
2545 V_VT(&expr
) = VT_DISPATCH
;
2546 V_DISPATCH(&expr
) = (IDispatch
*)&timeoutFunc
;
2547 V_VT(&var
) = VT_EMPTY
;
2549 hres
= IHTMLWindow3_setTimeout(win3
, &expr
, 0, &var
, &id
);
2550 ok(hres
== S_OK
, "setTimeout failed: %08x\n", hres
);
2553 SET_EXPECT(timeout
);
2554 pump_msgs(&called_timeout
);
2555 CHECK_CALLED(timeout
);
2557 V_VT(&expr
) = VT_DISPATCH
;
2558 V_DISPATCH(&expr
) = (IDispatch
*)&timeoutFunc
;
2559 V_VT(&var
) = VT_EMPTY
;
2561 hres
= IHTMLWindow3_setTimeout(win3
, &expr
, 0, &var
, &id
);
2562 ok(hres
== S_OK
, "setTimeout failed: %08x\n", hres
);
2565 hres
= IHTMLWindow2_clearTimeout(window
, id
);
2566 ok(hres
== S_OK
, "clearTimeout failed: %08x\n", hres
);
2568 V_VT(&expr
) = VT_DISPATCH
;
2569 V_DISPATCH(&expr
) = (IDispatch
*)&timeoutFunc
;
2570 V_VT(&var
) = VT_EMPTY
;
2572 hres
= IHTMLWindow3_setInterval(win3
, &expr
, 1, &var
, &id
);
2573 ok(hres
== S_OK
, "setInterval failed: %08x\n", hres
);
2576 SET_EXPECT(timeout
);
2577 pump_msgs(&called_timeout
);
2578 CHECK_CALLED(timeout
);
2580 SET_EXPECT(timeout
);
2581 pump_msgs(&called_timeout
);
2582 CHECK_CALLED(timeout
);
2584 hres
= IHTMLWindow2_clearInterval(window
, id
);
2585 ok(hres
== S_OK
, "clearTimeout failer: %08x\n", hres
);
2587 IHTMLWindow3_Release(win3
);
2590 static IHTMLWindow2
*get_iframe_window(IHTMLIFrameElement
*iframe
)
2592 IHTMLWindow2
*window
;
2593 IHTMLFrameBase2
*base
;
2596 hres
= IHTMLIFrameElement_QueryInterface(iframe
, &IID_IHTMLFrameBase2
, (void**)&base
);
2597 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLFrameBase2) failed: %08x\n", hres
);
2599 hres
= IHTMLFrameBase2_get_contentWindow(base
, &window
);
2600 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
2601 ok(window
!= NULL
, "window == NULL\n");
2603 IHTMLFrameBase2_Release(base
);
2607 static IHTMLDocument2
*get_iframe_doc(IHTMLIFrameElement
*iframe
)
2609 IHTMLDocument2
*result
= NULL
;
2610 IHTMLWindow2
*window
;
2613 window
= get_iframe_window(iframe
);
2615 hres
= IHTMLWindow2_get_document(window
, &result
);
2616 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2617 ok(result
!= NULL
, "result == NULL\n");
2619 IHTMLWindow2_Release(window
);
2623 static void test_iframe_connections(IHTMLDocument2
*doc
)
2625 IHTMLIFrameElement
*iframe
;
2626 IHTMLDocument2
*iframes_doc
;
2628 IConnectionPoint
*cp
;
2629 IHTMLElement
*element
;
2633 trace("iframe tests...\n");
2635 element
= get_elem_id(doc
, L
"ifr");
2636 iframe
= get_iframe_iface((IUnknown
*)element
);
2637 IHTMLElement_Release(element
);
2639 iframes_doc
= get_iframe_doc(iframe
);
2640 IHTMLIFrameElement_Release(iframe
);
2642 cookie
= register_cp((IUnknown
*)iframes_doc
, &IID_IDispatch
, (IUnknown
*)&div_onclick_disp
);
2644 cp
= get_cp((IUnknown
*)doc
, &IID_IDispatch
);
2645 hres
= IConnectionPoint_Unadvise(cp
, cookie
);
2646 IConnectionPoint_Release(cp
);
2647 ok(hres
== CONNECT_E_NOCONNECTION
, "Unadvise returned %08x, expected CONNECT_E_NOCONNECTION\n", hres
);
2649 unregister_cp((IUnknown
*)iframes_doc
, &IID_IDispatch
, cookie
);
2652 IHTMLFrameBase2
*frame_base2
;
2655 hres
= IHTMLIFrameElement_QueryInterface(iframe
, &IID_IHTMLFrameBase2
, (void**)&frame_base2
);
2656 ok(hres
== S_OK
, "Could not get IHTMLFrameBase2 iface: %08x\n", hres
);
2658 V_VT(&v
) = VT_DISPATCH
;
2659 V_DISPATCH(&v
) = (IDispatch
*)&iframe_onload_obj
;
2660 hres
= IHTMLFrameBase2_put_onload(frame_base2
, v
);
2661 ok(hres
== S_OK
, "put_onload failed: %08x\n", hres
);
2663 IHTMLFrameBase2_Release(frame_base2
);
2665 str
= SysAllocString(L
"about:blank");
2666 hres
= IHTMLDocument2_put_URL(iframes_doc
, str
);
2667 ok(hres
== S_OK
, "put_URL failed: %08x\n", hres
);
2670 SET_EXPECT(iframe_onload
);
2671 pump_msgs(&called_iframe_onload
);
2672 CHECK_CALLED(iframe_onload
);
2674 str
= SysAllocString(L
"about:test");
2675 hres
= IHTMLDocument2_put_URL(iframes_doc
, str
);
2676 ok(hres
== S_OK
, "put_URL failed: %08x\n", hres
);
2679 SET_EXPECT(iframe_onload
);
2680 pump_msgs(&called_iframe_onload
);
2681 CHECK_CALLED(iframe_onload
);
2683 win_skip("Skipping iframe onload tests on IE older than 9.\n");
2686 IHTMLDocument2_Release(iframes_doc
);
2689 static void test_create_event(IHTMLDocument2
*doc
)
2691 IDOMKeyboardEvent
*keyboard_event
;
2692 IDOMCustomEvent
*custom_event
;
2693 IDOMMouseEvent
*mouse_event
;
2694 IDocumentEvent
*doc_event
;
2695 IEventTarget
*event_target
;
2696 IDOMUIEvent
*ui_event
;
2704 trace("createEvent tests...\n");
2706 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentEvent
, (void**)&doc_event
);
2707 ok(hres
== S_OK
, "Could not get IDocumentEvent iface: %08x\n", hres
);
2709 str
= SysAllocString(L
"Event");
2710 hres
= IDocumentEvent_createEvent(doc_event
, str
, &event
);
2712 ok(hres
== S_OK
, "createEvent failed: %08x\n", hres
);
2715 hres
= IDOMEvent_get_eventPhase(event
, &phase
);
2716 ok(hres
== S_OK
, "get_eventPhase failed: %08x\n", hres
);
2717 ok(!phase
, "phase = %u\n", phase
);
2719 hres
= IDOMEvent_preventDefault(event
);
2720 ok(hres
== S_OK
, "preventDefault failed: %08x\n", hres
);
2722 hres
= IDOMEvent_stopPropagation(event
);
2723 ok(hres
== S_OK
, "stopPropagation failed: %08x\n", hres
);
2725 str
= (void*)0xdeadbeef;
2726 hres
= IDOMEvent_get_type(event
, &str
);
2727 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
2728 ok(!str
, "type = %s\n", wine_dbgstr_w(str
));
2731 hres
= IDOMEvent_get_bubbles(event
, &b
);
2732 ok(hres
== S_OK
, "get_bubbles failed: %08x\n", hres
);
2733 ok(!b
, "bubbles = %x\n", b
);
2736 hres
= IDOMEvent_get_cancelable(event
, &b
);
2737 ok(hres
== S_OK
, "get_cancelable failed: %08x\n", hres
);
2738 ok(!b
, "cancelable = %x\n", b
);
2740 elem
= doc_get_body(doc
);
2741 hres
= IHTMLElement_QueryInterface(elem
, &IID_IEventTarget
, (void**)&event_target
);
2742 IHTMLElement_Release(elem
);
2744 hres
= IEventTarget_dispatchEvent(event_target
, NULL
, &b
);
2745 ok(hres
== E_INVALIDARG
, "dispatchEvent failed: %08x\n", hres
);
2747 IEventTarget_Release(event_target
);
2749 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMUIEvent
, (void**)&ui_event
);
2750 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IDOMUIEvent returned %08x\n", hres
);
2751 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMMouseEvent
, (void**)&mouse_event
);
2752 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IDOMMouseEvent returned %08x\n", hres
);
2754 IDOMEvent_Release(event
);
2756 str
= SysAllocString(L
"MouseEvent");
2757 hres
= IDocumentEvent_createEvent(doc_event
, str
, &event
);
2759 ok(hres
== S_OK
, "createEvent failed: %08x\n", hres
);
2761 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMUIEvent
, (void**)&ui_event
);
2762 ok(hres
== S_OK
, "QueryInterface(IID_IDOMUIEvent returned %08x\n", hres
);
2763 IDOMUIEvent_Release(ui_event
);
2764 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMMouseEvent
, (void**)&mouse_event
);
2765 ok(hres
== S_OK
, "QueryInterface(IID_IDOMMouseEvent returned %08x\n", hres
);
2766 IDOMMouseEvent_Release(mouse_event
);
2768 IDOMEvent_Release(event
);
2770 str
= SysAllocString(L
"UIEvent");
2771 hres
= IDocumentEvent_createEvent(doc_event
, str
, &event
);
2773 ok(hres
== S_OK
, "createEvent failed: %08x\n", hres
);
2775 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMUIEvent
, (void**)&ui_event
);
2776 ok(hres
== S_OK
, "QueryInterface(IID_IDOMUIEvent returned %08x\n", hres
);
2777 IDOMUIEvent_Release(ui_event
);
2778 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMMouseEvent
, (void**)&mouse_event
);
2779 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IDOMMouseEvent returned %08x\n", hres
);
2781 IDOMEvent_Release(event
);
2783 str
= SysAllocString(L
"KeyboardEvent");
2784 hres
= IDocumentEvent_createEvent(doc_event
, str
, &event
);
2786 ok(hres
== S_OK
, "createEvent failed: %08x\n", hres
);
2788 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMUIEvent
, (void**)&ui_event
);
2789 ok(hres
== S_OK
, "QueryInterface(IID_IDOMUIEvent returned %08x\n", hres
);
2790 IDOMUIEvent_Release(ui_event
);
2791 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMKeyboardEvent
, (void**)&keyboard_event
);
2792 ok(hres
== S_OK
, "QueryInterface(IID_IDOMKeyboardEvent returned %08x\n", hres
);
2793 IDOMKeyboardEvent_Release(keyboard_event
);
2795 IDOMEvent_Release(event
);
2797 str
= SysAllocString(L
"CustomEvent");
2798 hres
= IDocumentEvent_createEvent(doc_event
, str
, &event
);
2800 ok(hres
== S_OK
, "createEvent failed: %08x\n", hres
);
2802 hres
= IDOMEvent_QueryInterface(event
, &IID_IDOMCustomEvent
, (void**)&custom_event
);
2803 ok(hres
== S_OK
, "QueryInterface(IID_IDOMCustomEvent returned %08x\n", hres
);
2804 IDOMCustomEvent_Release(custom_event
);
2806 IDOMEvent_Release(event
);
2808 IDocumentEvent_Release(doc_event
);
2811 static HRESULT
QueryInterface(REFIID
,void**);
2813 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
2815 return E_NOINTERFACE
;
2818 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
2823 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
2828 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
2833 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
2838 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
2843 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
2844 LPCBORDERWIDTHS pborderwidths
)
2849 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
2850 LPCBORDERWIDTHS pborderwidths
)
2855 static HRESULT WINAPI
InPlaceUIWindow_SetActiveObject(IOleInPlaceFrame
*iface
,
2856 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
2861 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
2862 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
2867 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
2868 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
2873 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
2874 HOLEMENU holemenu
, HWND hwndActiveObject
)
2876 ok(0, "unexpected call\n");
2880 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
2882 ok(0, "unexpected call\n");
2886 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
2891 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
2896 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
2898 ok(0, "unexpected call\n");
2902 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
2903 InPlaceFrame_QueryInterface
,
2904 InPlaceFrame_AddRef
,
2905 InPlaceFrame_Release
,
2906 InPlaceFrame_GetWindow
,
2907 InPlaceFrame_ContextSensitiveHelp
,
2908 InPlaceFrame_GetBorder
,
2909 InPlaceFrame_RequestBorderSpace
,
2910 InPlaceFrame_SetBorderSpace
,
2911 InPlaceFrame_SetActiveObject
,
2912 InPlaceFrame_InsertMenus
,
2913 InPlaceFrame_SetMenu
,
2914 InPlaceFrame_RemoveMenus
,
2915 InPlaceFrame_SetStatusText
,
2916 InPlaceFrame_EnableModeless
,
2917 InPlaceFrame_TranslateAccelerator
2920 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
2922 static const IOleInPlaceFrameVtbl InPlaceUIWindowVtbl
= {
2923 InPlaceFrame_QueryInterface
,
2924 InPlaceFrame_AddRef
,
2925 InPlaceFrame_Release
,
2926 InPlaceFrame_GetWindow
,
2927 InPlaceFrame_ContextSensitiveHelp
,
2928 InPlaceFrame_GetBorder
,
2929 InPlaceFrame_RequestBorderSpace
,
2930 InPlaceFrame_SetBorderSpace
,
2931 InPlaceUIWindow_SetActiveObject
,
2934 static IOleInPlaceFrame InPlaceUIWindow
= { &InPlaceUIWindowVtbl
};
2936 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
2938 return QueryInterface(riid
, ppv
);
2941 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
2946 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
2951 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
2953 *phwnd
= container_hwnd
;
2957 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
2959 ok(0, "unexpected call\n");
2963 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
2968 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
2973 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
2978 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
2979 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
2980 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
2982 static const RECT rect
= {0,0,300,300};
2984 *ppFrame
= &InPlaceFrame
;
2985 *ppDoc
= (IOleInPlaceUIWindow
*)&InPlaceUIWindow
;
2986 *lprcPosRect
= rect
;
2987 *lprcClipRect
= rect
;
2989 ok(lpFrameInfo
->cb
== sizeof(*lpFrameInfo
), "lpFrameInfo->cb = %u, expected %u\n", lpFrameInfo
->cb
, (unsigned)sizeof(*lpFrameInfo
));
2990 lpFrameInfo
->fMDIApp
= FALSE
;
2991 lpFrameInfo
->hwndFrame
= container_hwnd
;
2992 lpFrameInfo
->haccel
= NULL
;
2993 lpFrameInfo
->cAccelEntries
= 0;
2998 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
3003 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
3008 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
3013 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
3018 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
3023 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
3028 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
3029 InPlaceSite_QueryInterface
,
3031 InPlaceSite_Release
,
3032 InPlaceSite_GetWindow
,
3033 InPlaceSite_ContextSensitiveHelp
,
3034 InPlaceSite_CanInPlaceActivate
,
3035 InPlaceSite_OnInPlaceActivate
,
3036 InPlaceSite_OnUIActivate
,
3037 InPlaceSite_GetWindowContext
,
3039 InPlaceSite_OnUIDeactivate
,
3040 InPlaceSite_OnInPlaceDeactivate
,
3041 InPlaceSite_DiscardUndoState
,
3042 InPlaceSite_DeactivateAndUndo
,
3043 InPlaceSite_OnPosRectChange
,
3046 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
3048 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
3050 return QueryInterface(riid
, ppv
);
3053 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
3058 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
3063 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
3065 ok(0, "unexpected call\n");
3069 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
3072 ok(0, "unexpected call\n");
3076 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
3081 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
3083 ok(0, "unexpected call\n");
3087 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
3089 ok(0, "unexpected call\n");
3093 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
3095 ok(0, "unexpected call\n");
3099 static const IOleClientSiteVtbl ClientSiteVtbl
= {
3100 ClientSite_QueryInterface
,
3103 ClientSite_SaveObject
,
3104 ClientSite_GetMoniker
,
3105 ClientSite_GetContainer
,
3106 ClientSite_ShowObject
,
3107 ClientSite_OnShowWindow
,
3108 ClientSite_RequestNewObjectLayout
3111 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
3113 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
3115 return QueryInterface(riid
, ppv
);
3118 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
3123 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
3128 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
3130 RECT rect
= {0,0,300,300};
3131 IOleDocument
*document
;
3134 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
3135 ok(hres
== S_OK
, "could not get IOleDocument: %08x\n", hres
);
3137 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
3138 IOleDocument_Release(document
);
3139 ok(hres
== S_OK
, "CreateView failed: %08x\n", hres
);
3141 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
3142 ok(hres
== S_OK
, "SetInPlaceSite failed: %08x\n", hres
);
3144 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
3145 ok(hres
== S_OK
, "UIActivate failed: %08x\n", hres
);
3147 hres
= IOleDocumentView_SetRect(view
, &rect
);
3148 ok(hres
== S_OK
, "SetRect failed: %08x\n", hres
);
3150 hres
= IOleDocumentView_Show(view
, TRUE
);
3151 ok(hres
== S_OK
, "Show failed: %08x\n", hres
);
3156 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
3157 DocumentSite_QueryInterface
,
3158 DocumentSite_AddRef
,
3159 DocumentSite_Release
,
3160 DocumentSite_ActivateMe
3163 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
3165 static HRESULT
QueryInterface(REFIID riid
, void **ppv
)
3169 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
3171 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
3172 *ppv
= &DocumentSite
;
3173 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
3174 *ppv
= &InPlaceSite
;
3176 return *ppv
? S_OK
: E_NOINTERFACE
;
3179 static IHTMLDocument2
*notif_doc
;
3180 static BOOL doc_complete
;
3182 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
3183 REFIID riid
, void**ppv
)
3185 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
3190 ok(0, "unexpected call\n");
3191 return E_NOINTERFACE
;
3194 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
3199 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
3204 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
3206 if(dispID
== DISPID_READYSTATE
){
3210 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
3211 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
3213 if(!lstrcmpW(state
, L
"complete"))
3214 doc_complete
= TRUE
;
3216 SysFreeString(state
);
3222 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
3224 ok(0, "unexpected call\n");
3228 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
3229 PropertyNotifySink_QueryInterface
,
3230 PropertyNotifySink_AddRef
,
3231 PropertyNotifySink_Release
,
3232 PropertyNotifySink_OnChanged
,
3233 PropertyNotifySink_OnRequestEdit
3236 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
3238 static void doc_load_string(IHTMLDocument2
*doc
, const char *str
)
3240 IPersistStreamInit
*init
;
3248 doc_complete
= FALSE
;
3250 mem
= GlobalAlloc(0, len
);
3251 memcpy(mem
, str
, len
);
3252 hres
= CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
3253 ok(hres
== S_OK
, "Failed to create a stream, hr %#x.\n", hres
);
3255 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
3256 ok(hres
== S_OK
, "Failed to get IPersistStreamInit, hr %#x.\n", hres
);
3258 IPersistStreamInit_Load(init
, stream
);
3259 IPersistStreamInit_Release(init
);
3260 IStream_Release(stream
);
3263 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
3265 IConnectionPointContainer
*container
;
3266 IConnectionPoint
*cp
;
3270 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
3271 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
3273 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
3274 IConnectionPointContainer_Release(container
);
3275 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
3277 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
3278 IConnectionPoint_Release(cp
);
3279 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
3282 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
3288 IOleDocumentView_Show(view
, FALSE
);
3289 IOleDocumentView_CloseView(view
, 0);
3290 IOleDocumentView_SetInPlaceSite(view
, NULL
);
3291 IOleDocumentView_Release(view
);
3295 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
3296 ok(hres
== S_OK
, "Could not et IOleObject: %08x\n", hres
);
3298 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
3299 ok(hres
== S_OK
, "SetClientSite failed: %08x\n", hres
);
3302 IHlinkTarget
*hlink
;
3304 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
3305 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08x\n", hres
);
3307 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
3308 ok(hres
== S_OK
, "Navgate failed: %08x\n", hres
);
3310 IHlinkTarget_Release(hlink
);
3313 IOleObject_Release(oleobj
);
3315 static IHTMLDocument2
*create_document(void)
3317 IHTMLDocument2
*doc
;
3320 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
3321 &IID_IHTMLDocument2
, (void**)&doc
);
3322 #if !defined(__i386__) && !defined(__x86_64__)
3325 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
3326 return SUCCEEDED(hres
) ? doc
: NULL
;
3330 typedef void (*testfunc_t
)(IHTMLDocument2
*);
3332 static void run_test(const char *str
, testfunc_t test
)
3334 IHTMLDocument2
*doc
;
3335 IHTMLElement
*body
= NULL
;
3339 doc
= create_document();
3342 set_client_site(doc
, TRUE
);
3343 doc_load_string(doc
, str
);
3344 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
3346 while(!doc_complete
&& GetMessageA(&msg
, NULL
, 0, 0)) {
3347 TranslateMessage(&msg
);
3348 DispatchMessageA(&msg
);
3351 hres
= IHTMLDocument2_get_body(doc
, &body
);
3352 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3355 IHTMLDocument6
*doc6
;
3357 IHTMLElement_Release(body
);
3359 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument6
, (void**)&doc6
);
3360 if(SUCCEEDED(hres
)) {
3362 hres
= IHTMLDocument6_get_documentMode(doc6
, &v
);
3363 ok(hres
== S_OK
, "get_documentMode failed: %08x\n", hres
);
3364 ok(V_VT(&v
) == VT_R4
, "V_VT(documentMode) = %u\n", V_VT(&v
));
3365 document_mode
= V_R4(&v
);
3366 IHTMLDocument6_Release(doc6
);
3371 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3372 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3373 ok(window
!= NULL
, "window == NULL\n");
3377 IHTMLWindow2_Release(window
);
3380 skip("Could not get document body. Assuming no Gecko installed.\n");
3383 set_client_site(doc
, FALSE
);
3384 IHTMLDocument2_Release(doc
);
3387 static LRESULT WINAPI
wnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3389 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
3392 static HWND
create_container_window(void)
3394 static const CHAR szHTMLDocumentTest
[] = "HTMLDocumentTest";
3395 static WNDCLASSEXA wndclass
= {
3396 sizeof(WNDCLASSEXA
),
3399 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
3404 RegisterClassExA(&wndclass
);
3405 return CreateWindowA(szHTMLDocumentTest
, szHTMLDocumentTest
,
3406 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, CW_USEDEFAULT
,
3407 300, 300, NULL
, NULL
, NULL
, NULL
);
3410 static void test_empty_document(void)
3413 IHTMLWindow2
*window
;
3414 IHTMLDocument2
*windows_doc
, *doc
;
3415 IConnectionPoint
*cp
;
3418 doc
= create_document();
3422 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
3423 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
3425 hres
= IHTMLWindow2_get_document(window
, &windows_doc
);
3426 IHTMLWindow2_Release(window
);
3427 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
3429 cookie
= register_cp((IUnknown
*)windows_doc
, &IID_IDispatch
, (IUnknown
*)&div_onclick_disp
);
3431 cp
= get_cp((IUnknown
*)doc
, &IID_IDispatch
);
3432 hres
= IConnectionPoint_Unadvise(cp
, cookie
);
3433 IConnectionPoint_Release(cp
);
3434 ok(hres
== S_OK
, "Unadvise failed: %08x\n", hres
);
3436 IHTMLDocument2_Release(windows_doc
);
3437 IHTMLDocument2_Release(doc
);
3440 static BOOL
check_ie(void)
3442 IHTMLDocument2
*doc
;
3443 IHTMLDocument5
*doc5
;
3444 IHTMLDocument7
*doc7
;
3447 doc
= create_document();
3451 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument7
, (void**)&doc7
);
3452 if(SUCCEEDED(hres
)) {
3454 IHTMLDocument7_Release(doc7
);
3457 trace("is_ie9plus %x\n", is_ie9plus
);
3459 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
3461 IHTMLDocument5_Release(doc5
);
3463 IHTMLDocument2_Release(doc
);
3464 return SUCCEEDED(hres
);
3472 container_hwnd
= create_container_window();
3474 if(winetest_interactive
)
3475 ShowWindow(container_hwnd
, SW_SHOW
);
3477 run_test(empty_doc_str
, test_timeout
);
3478 run_test(empty_doc_str
, test_onclick
);
3479 run_test(empty_doc_ie9_str
, test_onclick
);
3480 run_test(readystate_doc_str
, test_onreadystatechange
);
3481 run_test(readystate_doc_ie9_str
, test_onreadystatechange
);
3482 run_test(img_doc_str
, test_imgload
);
3483 run_test(link_doc_str
, test_link_load
);
3484 run_test(input_doc_str
, test_focus
);
3485 run_test(empty_doc_str
, test_submit
);
3486 run_test(empty_doc_ie9_str
, test_submit
);
3487 run_test(iframe_doc_str
, test_iframe_connections
);
3489 run_test(empty_doc_ie9_str
, test_create_event
);
3491 test_empty_document();
3493 DestroyWindow(container_hwnd
);
3495 #if !defined(__i386__) && !defined(__x86_64__)
3498 win_skip("Too old IE\n");