2 * Copyright 2007-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
35 #include "wine/test.h"
36 #include "mshtml_test.h"
42 static INT (WINAPI
*pLCIDToLocaleName
)(LCID
,LPWSTR
,INT
,DWORD
);
43 static LANGID (WINAPI
*pGetUserDefaultUILanguage
)(void);
45 static BOOL is_ie9plus
;
50 } compat_mode
= COMPAT_NONE
;
52 static const char doc_blank
[] =
55 static const char doc_blank_ie9
[] =
59 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
65 static const char doc_str1
[] = "<html><body>test</body></html>";
66 static const char elem_test_str
[] =
67 "<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
68 "<meta id=\"metaid\" name=\"meta name\" http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
69 "<link id=\"linkid\"></head>"
70 "<body onload=\"Testing()\">text test<!-- a comment -->"
71 "<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
72 "<label for=\"in\" id=\"labelid\">Label:</label>"
73 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
74 "<button id=\"btnid\" type=\"submit\"></button>"
75 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
76 "<textarea id=\"X\">text text</textarea>"
77 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td></tr></tbody></table>"
78 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
79 "<test /><object id=\"objid\" name=\"objname\" vspace=100></object><embed />"
80 "<img id=\"imgid\" name=\"WineImg\"/>"
81 "<area id=\"area\" href=\"http://test\">"
82 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
83 "<form id=\"frm\"></form>"
84 "<div id=\"attr\" attr1=\"attr1\" attr2 attr3=\"attr3\"></div>"
86 static const char elem_test2_str
[] =
87 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
88 "<link id=\"linkid\" rel=\"stylesheet\" href=\"about:blank\" type=\"text/css\"></head>"
89 "<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
92 static const char indent_test_str
[] =
93 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
94 static const char cond_comment_str
[] =
95 "<html><head><title>test</title></head><body>"
96 "<!--[if gte IE 4]> <br> <![endif]-->"
98 static const char frameset_str
[] =
99 "<html><head><title>frameset test</title></head><frameset rows=\"25, 25, *\">"
100 "<frame src=\"about:blank\" name=\"nm1\" id=\"fr1\"><frame src=\"about:blank\" name=\"nm2\" id=\"fr2\">"
101 "<frame src=\"about:blank\" id=\"fr3\">"
102 "</frameset></html>";
103 static const char emptydiv_str
[] =
104 "<html><head><title>emptydiv test</title></head>"
105 "<body><div id=\"divid\"></div></body></html>";
106 static const char noscript_str
[] =
107 "<html><head><title>noscript test</title><noscript><style>.body { margin-right: 0px; }</style></noscript></head>"
108 "<body><noscript><div>test</div></noscript></body></html>";
109 static const char doctype_str
[] =
113 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" />"
114 " <title>emptydiv test</title>"
116 "<body><div id=\"divid\"></div></body></html>";
118 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
119 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
120 static WCHAR wordW
[] = {'w','o','r','d',0};
163 static const IID
* const none_iids
[] = {
168 static const IID
* const doc_node_iids
[] = {
177 &IID_IDocumentSelector
,
179 &IID_IDisplayServices
,
180 &IID_IConnectionPointContainer
,
181 &IID_IInternetHostSecurityManager
,
182 &IID_IMarkupContainer
,
183 &IID_IMarkupServices
,
186 &IID_IProvideClassInfo
,
190 static const IID
* const doc_obj_iids
[] = {
197 &IID_IDocumentSelector
,
199 &IID_IDisplayServices
,
200 &IID_IConnectionPointContainer
,
202 &IID_IMarkupContainer
,
203 &IID_IMarkupServices
,
206 &IID_IProvideClassInfo
,
207 &IID_ITargetContainer
,
211 #define ELEM_IFACES \
213 &IID_IHTMLDOMNode2, \
215 &IID_IHTMLElement2, \
216 &IID_IHTMLElement3, \
217 &IID_IHTMLElement4, \
218 &IID_IHTMLUniqueName, \
221 static const IID
* const elem_iids
[] = {
223 &IID_IConnectionPointContainer
,
227 static const IID
* const body_iids
[] = {
229 &IID_IHTMLTextContainer
,
230 &IID_IHTMLBodyElement
,
231 &IID_IConnectionPointContainer
,
235 static const IID
* const anchor_iids
[] = {
237 &IID_IHTMLAnchorElement
,
238 &IID_IConnectionPointContainer
,
242 static const IID
* const input_iids
[] = {
244 &IID_IHTMLInputElement
,
245 &IID_IHTMLInputTextElement
,
246 &IID_IConnectionPointContainer
,
250 static const IID
*const button_iids
[] = {
252 &IID_IHTMLButtonElement
,
253 &IID_IConnectionPointContainer
,
257 static const IID
*const area_iids
[] = {
259 &IID_IHTMLAreaElement
,
260 &IID_IConnectionPointContainer
,
264 static const IID
* const label_iids
[] = {
266 &IID_IHTMLLabelElement
,
267 &IID_IConnectionPointContainer
,
271 static const IID
* const select_iids
[] = {
273 &IID_IHTMLSelectElement
,
274 &IID_IConnectionPointContainer
,
278 static const IID
* const textarea_iids
[] = {
280 &IID_IHTMLTextAreaElement
,
281 &IID_IConnectionPointContainer
,
285 static const IID
* const option_iids
[] = {
287 &IID_IHTMLOptionElement
,
288 &IID_IConnectionPointContainer
,
292 static const IID
* const table_iids
[] = {
297 &IID_IConnectionPointContainer
,
301 static const IID
* const script_iids
[] = {
303 &IID_IHTMLScriptElement
,
304 &IID_IConnectionPointContainer
,
308 static const IID
* const text_iids
[] = {
311 &IID_IHTMLDOMTextNode
,
312 &IID_IHTMLDOMTextNode2
,
316 static const IID
* const attr_iids
[] = {
317 &IID_IHTMLDOMAttribute
,
318 &IID_IHTMLDOMAttribute2
,
323 static const IID
* const location_iids
[] = {
329 static const IID
* const window_iids
[] = {
334 &IID_IServiceProvider
,
338 static const IID
* const comment_iids
[] = {
340 &IID_IHTMLCommentElement
,
341 &IID_IConnectionPointContainer
,
345 static const IID
* const img_iids
[] = {
347 &IID_IHTMLImgElement
,
348 &IID_IConnectionPointContainer
,
352 static const IID
* const tr_iids
[] = {
355 &IID_IConnectionPointContainer
,
359 static const IID
* const td_iids
[] = {
362 &IID_IConnectionPointContainer
,
366 static const IID
* const frame_iids
[] = {
369 &IID_IHTMLFrameBase2
,
370 &IID_IConnectionPointContainer
,
374 static const IID
* const html_iids
[] = {
376 &IID_IHTMLHtmlElement
,
377 &IID_IConnectionPointContainer
,
381 static const IID
* const head_iids
[] = {
383 &IID_IHTMLHeadElement
,
384 &DIID_DispHTMLHeadElement
,
385 &IID_IConnectionPointContainer
,
389 static const IID
* const title_iids
[] = {
391 &IID_IHTMLTitleElement
,
392 &IID_IConnectionPointContainer
,
396 static const IID
* const meta_iids
[] = {
398 &IID_IHTMLMetaElement
,
399 &IID_IConnectionPointContainer
,
403 static const IID
* const link_iids
[] = {
405 &IID_IHTMLLinkElement
,
406 &IID_IConnectionPointContainer
,
410 static const IID
* const object_iids
[] = {
412 &IID_IHTMLObjectElement
,
413 &IID_IHTMLObjectElement2
,
414 /* FIXME: No IConnectionPointContainer */
418 static const IID
* const embed_iids
[] = {
420 &IID_IHTMLEmbedElement
,
421 /* FIXME: No IConnectionPointContainer */
425 static const IID
* const iframe_iids
[] = {
428 &IID_IHTMLFrameBase2
,
429 &IID_IHTMLIFrameElement
,
430 &IID_IHTMLIFrameElement2
,
431 &IID_IConnectionPointContainer
,
435 static const IID
* const form_iids
[] = {
437 &IID_IHTMLFormElement
,
438 &IID_IConnectionPointContainer
,
439 &DIID_DispHTMLFormElement
,
443 static const IID
* const styleelem_iids
[] = {
445 &IID_IHTMLStyleElement
,
446 &IID_IConnectionPointContainer
,
450 static const IID
* const generic_iids
[] = {
452 &IID_IHTMLGenericElement
,
453 &IID_IConnectionPointContainer
,
457 static const IID
* const svg_iids
[] = {
464 static const IID
* const circle_iids
[] = {
467 &IID_ISVGCircleElement
,
471 static const IID
* const tspan_iids
[] = {
474 &IID_ISVGTextContentElement
,
475 &IID_ISVGTSpanElement
,
479 static const IID
* const style_iids
[] = {
490 static const IID
* const cstyle_iids
[] = {
494 &IID_IHTMLCurrentStyle
,
495 &IID_IHTMLCurrentStyle2
,
496 &IID_IHTMLCurrentStyle3
,
500 static const IID
* const computed_style_iids
[] = {
504 &IID_IHTMLCSSStyleDeclaration
,
508 static const IID
* const img_factory_iids
[] = {
512 &IID_IHTMLImageElementFactory
,
516 static const IID
* const selection_iids
[] = {
520 &IID_IHTMLSelectionObject
,
521 &IID_IHTMLSelectionObject2
,
532 static const elem_type_info_t elem_type_infos
[] = {
533 {L
"", none_iids
, NULL
},
534 {L
"HTML", html_iids
, &DIID_DispHTMLHtmlElement
, &CLSID_HTMLHtmlElement
},
535 {L
"HEAD", head_iids
, &DIID_DispHTMLHeadElement
, &CLSID_HTMLHeadElement
},
536 {L
"TITLE", title_iids
, &DIID_DispHTMLTitleElement
, &CLSID_HTMLTitleElement
},
537 {L
"BODY", body_iids
, &DIID_DispHTMLBody
, &CLSID_HTMLBody
},
538 {L
"A", anchor_iids
, &DIID_DispHTMLAnchorElement
, &CLSID_HTMLAnchorElement
},
539 {L
"INPUT", input_iids
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
},
540 {L
"SELECT", select_iids
, &DIID_DispHTMLSelectElement
, &CLSID_HTMLSelectElement
},
541 {L
"TEXTAREA", textarea_iids
, &DIID_DispHTMLTextAreaElement
, &CLSID_HTMLTextAreaElement
},
542 {L
"OPTION", option_iids
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
},
543 {L
"STYLE", styleelem_iids
, &DIID_DispHTMLStyleElement
, &CLSID_HTMLStyleElement
},
544 {L
"BLOCKQUOTE",elem_iids
, NULL
},
545 {L
"P", elem_iids
, NULL
},
546 {L
"BR", elem_iids
, NULL
},
547 {L
"TABLE", table_iids
, &DIID_DispHTMLTable
, &CLSID_HTMLTable
},
548 {L
"TBODY", elem_iids
, NULL
},
549 {L
"SCRIPT", script_iids
, &DIID_DispHTMLScriptElement
, &CLSID_HTMLScriptElement
},
550 {L
"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
, &CLSID_HTMLUnknownElement
},
551 {L
"TEST", generic_iids
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
},
552 {L
"!", comment_iids
, &DIID_DispHTMLCommentElement
, &CLSID_HTMLCommentElement
},
553 {L
"IMG", img_iids
, &DIID_DispHTMLImg
, &CLSID_HTMLImg
},
554 {L
"TR", tr_iids
, &DIID_DispHTMLTableRow
, &CLSID_HTMLTableRow
},
555 {L
"TD", td_iids
, &DIID_DispHTMLTableCell
, &CLSID_HTMLTableCell
},
556 {L
"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
, &CLSID_HTMLIFrame
},
557 {L
"FORM", form_iids
, &DIID_DispHTMLFormElement
, &CLSID_HTMLFormElement
},
558 {L
"FRAME", frame_iids
, &DIID_DispHTMLFrameElement
, &CLSID_HTMLFrameElement
},
559 {L
"OBJECT", object_iids
, &DIID_DispHTMLObjectElement
, &CLSID_HTMLObjectElement
},
560 {L
"EMBED", embed_iids
, &DIID_DispHTMLEmbed
, &CLSID_HTMLEmbed
},
561 {L
"DIV", elem_iids
, NULL
},
562 {L
"META", meta_iids
, &DIID_DispHTMLMetaElement
, &CLSID_HTMLMetaElement
},
563 {L
"NOSCRIPT", elem_iids
, /* &DIID_DispHTMLNoShowElement */},
564 {L
"LINK", link_iids
, &DIID_DispHTMLLinkElement
, &CLSID_HTMLLinkElement
},
565 {L
"LABEL", label_iids
, &DIID_DispHTMLLabelElement
, &CLSID_HTMLLabelElement
},
566 {L
"BUTTON", button_iids
, &DIID_DispHTMLButtonElement
, &CLSID_HTMLButtonElement
},
567 {L
"AREA", area_iids
, &DIID_DispHTMLAreaElement
, &CLSID_HTMLAreaElement
},
568 {L
"svg", svg_iids
, NULL
},
569 {L
"circle", circle_iids
, NULL
},
570 {L
"tspan", tspan_iids
, NULL
}
573 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
575 IUnknown
*unk1
, *unk2
;
580 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
581 IUnknown_Release(unk1
);
582 IUnknown_QueryInterface(iface2
, &IID_IUnknown
, (void**)&unk2
);
583 IUnknown_Release(unk2
);
588 static IHTMLDocument2
*create_document(void)
591 IHTMLDocument5
*doc5
;
594 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
595 &IID_IHTMLDocument2
, (void**)&doc
);
596 ok(hres
== S_OK
, "CoCreateInstance failed: %08lx\n", hres
);
600 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
602 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
603 IHTMLDocument2_Release(doc
);
607 IHTMLDocument5_Release(doc5
);
611 #define get_dispex_iface(u) _get_dispex_iface(__LINE__,u)
612 static IDispatchEx
*_get_dispex_iface(unsigned line
, IUnknown
*unk
)
617 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
618 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatchEx: %08lx\n", hres
);
622 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
623 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
625 const IID
* const *piid
;
629 for(piid
= iids
; *piid
; piid
++) {
630 hres
= IUnknown_QueryInterface(iface
, *piid
, (void**)&unk
);
631 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08lx\n", wine_dbgstr_guid(*piid
), hres
);
633 IUnknown_Release(unk
);
637 #define test_no_iface(a,b) _test_no_iface(__LINE__,a,b)
638 static void _test_no_iface(unsigned line
, IUnknown
*iface
, REFIID iid
)
643 unk
= (void*)0xdeadbeef;
644 hres
= IUnknown_QueryInterface(iface
, iid
, (void**)&unk
);
645 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "hres = %08lx, expected E_NOINTERFACE\n", hres
);
646 ok_(__FILE__
,line
)(!unk
, "unk = %p\n", unk
);
649 #define test_get_dispid(u,id) _test_get_dispid(__LINE__,u,id)
650 static BOOL
_test_get_dispid(unsigned line
, IUnknown
*unk
, IID
*iid
)
652 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
659 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
660 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08lx\n", hres
);
661 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
663 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
664 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08lx\n", hres
);
666 if(SUCCEEDED(hres
)) {
669 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
670 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08lx\n", hres
);
672 *iid
= type_attr
->guid
;
676 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
677 ITypeInfo_Release(typeinfo
);
680 IDispatchEx_Release(dispex
);
684 #define test_disp_value(u) _test_disp_value(__LINE__,u,v)
685 static void _test_disp_value(unsigned line
, IUnknown
*unk
, const WCHAR
*val
)
687 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
688 DISPPARAMS dp
= {NULL
,NULL
,0,0};
693 hres
= IDispatchEx_InvokeEx(dispex
, DISPID_VALUE
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
694 IDispatchEx_Release(dispex
);
695 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx(DISPID_VALUE) returned: %08lx\n", hres
);
697 ok_(__FILE__
,line
)(V_VT(&var
) == VT_BSTR
, "V_VT(value) = %d\n", V_VT(&var
));
698 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&var
), val
), "value = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&var
)), wine_dbgstr_w(val
));
702 #define test_class_info(a,b) _test_class_info(__LINE__,a,b)
703 static void _test_class_info(unsigned line
, IUnknown
*unk
, const CLSID
*clsid
)
705 IProvideMultipleClassInfo
*multiple_classinfo
;
706 IProvideClassInfo2
*classinfo
;
712 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo2
, (void**)&classinfo
);
713 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08lx\n", hres
);
717 hres
= IProvideClassInfo2_GetClassInfo(classinfo
, &typeinfo
);
718 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get ITypeInfo interface: %08lx\n", hres
);
721 IProvideClassInfo2_Release(classinfo
);
725 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
726 ok_(__FILE__
,line
)(hres
== S_OK
, "GetTypeAttr failed: %08lx\n", hres
);
729 ok_(__FILE__
,line
)(IsEqualGUID(&type_attr
->guid
, clsid
),
730 "unexpected guid %s\n", wine_dbgstr_guid(&type_attr
->guid
));
731 ok_(__FILE__
,line
)(type_attr
->typekind
== TKIND_COCLASS
,
732 "unexpected typekind %d\n", type_attr
->typekind
);
733 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
736 ITypeInfo_Release(typeinfo
);
737 IProvideClassInfo2_Release(classinfo
);
739 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideMultipleClassInfo
, (void**)&multiple_classinfo
);
740 if(IsEqualGUID(clsid
, &CLSID_HTMLXMLHttpRequest
)) {
741 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Could not get IProvideClassInfo2 interface: %08lx\n", hres
);
743 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IProvideClassInfo2 interface: %08lx\n", hres
);
745 hres
= IProvideMultipleClassInfo_GetMultiTypeInfoCount(multiple_classinfo
, &count
);
746 ok_(__FILE__
,line
)(hres
== S_OK
, "GetMultiTypeInfoCount failed: %08lx\n", hres
);
747 ok_(__FILE__
,line
)(count
> 0, "count = %lu\n", count
);
749 IProvideMultipleClassInfo_Release(multiple_classinfo
);
753 #define test_disp2(a,b,c,d,e) _test_disp2(__LINE__,a,b,c,d,e)
754 static void _test_disp2(unsigned line
, IUnknown
*unk
, const IID
*diid
, const IID
*diid2
, const CLSID
*clsid
, const WCHAR
*val
)
760 if(_test_get_dispid(line
, unk
, &iid
) && compat_mode
< COMPAT_IE9
)
761 ok_(__FILE__
,line
) (IsEqualGUID(&iid
, diid
) || broken(diid2
&& IsEqualGUID(&iid
, diid2
)),
762 "unexpected guid %s\n", wine_dbgstr_guid(&iid
));
764 if(!IsEqualGUID(diid
, &DIID_DispHTMLWindow2
) && !IsEqualGUID(diid
, &DIID_DispHTMLLocation
)) {
765 u
= (void*)0xdeadbeef;
766 hres
= IUnknown_QueryInterface(unk
, &IID_IMarshal
, (void**)&u
);
767 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IMarshal iface\n");
768 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
771 u
= (void*)0xdeadbeef;
772 hres
= IUnknown_QueryInterface(unk
, &IID_IManagedObject
, (void**)&u
);
773 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IManagedObject iface\n");
774 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
776 if(val
&& compat_mode
< COMPAT_IE9
) /* FIXME: Enable those tests in IE9+ mode */
777 _test_disp_value(line
, unk
, val
);
780 _test_class_info(line
, unk
, clsid
);
782 u
= (void*)0xdeadbeef;
783 hres
= IUnknown_QueryInterface(unk
, &IID_IProvideClassInfo
, (void**)&u
);
784 ok_(__FILE__
,line
)(hres
== E_NOINTERFACE
, "Got IProvideClassInfo iface\n");
785 ok_(__FILE__
,line
)(!u
, "u = %p\n", u
);
789 #define test_disp(a,b,c,d) _test_disp(__LINE__,a,b,c,d)
790 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
, const CLSID
*clsid
, const WCHAR
*val
)
792 return _test_disp2(line
, unk
, diid
, NULL
, clsid
, val
);
795 #define set_dispex_value(a,b,c) _set_dispex_value(__LINE__,a,b,c)
796 static void _set_dispex_value(unsigned line
, IUnknown
*unk
, const WCHAR
*name
, VARIANT
*val
)
798 IDispatchEx
*dispex
= _get_dispex_iface(line
, unk
);
799 DISPPARAMS dp
= {val
, NULL
, 1, 0};
805 str
= SysAllocString(name
);
806 hres
= IDispatchEx_GetDispID(dispex
, str
, fdexNameEnsure
|fdexNameCaseInsensitive
, &id
);
808 ok_(__FILE__
,line
)(hres
== S_OK
, "GetDispID failed: %08lx\n", hres
);
810 memset(&ei
, 0, sizeof(ei
));
811 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYPUT
, &dp
, NULL
, &ei
, NULL
);
812 ok_(__FILE__
,line
)(hres
== S_OK
, "InvokeEx failed: %08lx\n", hres
);
813 IDispatchEx_Release(dispex
);
816 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
817 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
822 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
823 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement: %08lx\n", hres
);
827 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
828 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
833 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
834 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement2: %08lx\n", hres
);
838 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
839 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
844 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
845 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement3: %08lx\n", hres
);
849 #define get_elem4_iface(u) _get_elem4_iface(__LINE__,u)
850 static IHTMLElement4
*_get_elem4_iface(unsigned line
, IUnknown
*unk
)
855 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement4
, (void**)&elem
);
856 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElement4: %08lx\n", hres
);
860 #define get_doc3_iface(u) _get_doc3_iface(__LINE__,u)
861 static IHTMLDocument3
*_get_doc3_iface(unsigned line
, IHTMLDocument2
*doc
)
863 IHTMLDocument3
*doc3
;
866 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
867 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08lx\n", hres
);
872 #define get_node_iface(u) _get_node_iface(__LINE__,u)
873 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
878 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
879 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode: %08lx\n", hres
);
883 #define get_node2_iface(u) _get_node2_iface(__LINE__,u)
884 static IHTMLDOMNode2
*_get_node2_iface(unsigned line
, IUnknown
*unk
)
889 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode2
, (void**)&node
);
890 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMNode2: %08lx\n", hres
);
894 #define get_htmldoc5_iface(u) _get_htmldoc5_iface(__LINE__,u)
895 static IHTMLDocument5
*_get_htmldoc5_iface(unsigned line
, IUnknown
*unk
)
900 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDocument5
, (void**)&doc
);
901 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument5: %08lx\n", hres
);
905 #define get_img_iface(u) _get_img_iface(__LINE__,u)
906 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
908 IHTMLImgElement
*img
;
911 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08lx\n", hres
);
916 #define get_anchor_iface(u) _get_anchor_iface(__LINE__,u)
917 static IHTMLAnchorElement
*_get_anchor_iface(unsigned line
, IUnknown
*unk
)
919 IHTMLAnchorElement
*anchor
;
922 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAnchorElement
, (void**)&anchor
);
923 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAnchorElement: %08lx\n", hres
);
927 #define get_area_iface(u) _get_area_iface(__LINE__,u)
928 static IHTMLAreaElement
*_get_area_iface(unsigned line
, IUnknown
*unk
)
930 IHTMLAreaElement
*area
;
933 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLAreaElement
, (void**)&area
);
934 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLAreaElement: %08lx\n", hres
);
938 #define get_textarea_iface(u) _get_textarea_iface(__LINE__,u)
939 static IHTMLTextAreaElement
*_get_textarea_iface(unsigned line
, IUnknown
*unk
)
941 IHTMLTextAreaElement
*textarea
;
944 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextAreaElement
, (void**)&textarea
);
945 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextAreaElement: %08lx\n", hres
);
949 #define get_select_iface(u) _get_select_iface(__LINE__,u)
950 static IHTMLSelectElement
*_get_select_iface(unsigned line
, IUnknown
*unk
)
952 IHTMLSelectElement
*select
;
955 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLSelectElement
, (void**)&select
);
956 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLSelectElement: %08lx\n", hres
);
960 #define get_option_iface(u) _get_option_iface(__LINE__,u)
961 static IHTMLOptionElement
*_get_option_iface(unsigned line
, IUnknown
*unk
)
963 IHTMLOptionElement
*option
;
966 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLOptionElement
, (void**)&option
);
967 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLOptionElement: %08lx\n", hres
);
971 #define get_form_iface(u) _get_form_iface(__LINE__,u)
972 static IHTMLFormElement
*_get_form_iface(unsigned line
, IUnknown
*unk
)
974 IHTMLFormElement
*form
;
977 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFormElement
, (void**)&form
);
978 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLFormElement: %08lx\n", hres
);
982 #define get_text_iface(u) _get_text_iface(__LINE__,u)
983 static IHTMLDOMTextNode
*_get_text_iface(unsigned line
, IUnknown
*unk
)
985 IHTMLDOMTextNode
*text
;
988 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode
, (void**)&text
);
989 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode: %08lx\n", hres
);
993 #define get_text2_iface(u) _get_text2_iface(__LINE__,u)
994 static IHTMLDOMTextNode2
*_get_text2_iface(unsigned line
, IUnknown
*unk
)
996 IHTMLDOMTextNode2
*text2
;
999 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMTextNode2
, (void**)&text2
);
1000 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMTextNode2: %08lx\n", hres
);
1004 #define get_comment_iface(u) _get_comment_iface(__LINE__,u)
1005 static IHTMLCommentElement
*_get_comment_iface(unsigned line
, IUnknown
*unk
)
1007 IHTMLCommentElement
*comment
;
1010 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLCommentElement
, (void**)&comment
);
1011 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLCommentElement: %08lx\n", hres
);
1015 #define get_object_iface(u) _get_object_iface(__LINE__,u)
1016 static IHTMLObjectElement
*_get_object_iface(unsigned line
, IUnknown
*unk
)
1018 IHTMLObjectElement
*obj
;
1021 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLObjectElement
, (void**)&obj
);
1022 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLObjectElement: %08lx\n", hres
);
1026 #define get_style_iface(u) _get_style_iface(__LINE__,u)
1027 static IHTMLStyleElement
*_get_style_iface(unsigned line
, IUnknown
*unk
)
1029 IHTMLStyleElement
*obj
;
1032 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLStyleElement
, (void**)&obj
);
1033 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLStyleElement: %08lx\n", hres
);
1037 #define get_metaelem_iface(u) _get_metaelem_iface(__LINE__,u)
1038 static IHTMLMetaElement
*_get_metaelem_iface(unsigned line
, IUnknown
*unk
)
1040 IHTMLMetaElement
*ret
;
1043 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLMetaElement
, (void**)&ret
);
1044 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLMetaElement: %08lx\n", hres
);
1048 #define get_link_iface(u) _get_link_iface(__LINE__,u)
1049 static IHTMLLinkElement
*_get_link_iface(unsigned line
, IUnknown
*unk
)
1051 IHTMLLinkElement
*ret
;
1054 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLinkElement
, (void**)&ret
);
1055 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLinkElement: %08lx\n", hres
);
1059 #define get_iframe2_iface(u) _get_iframe2_iface(__LINE__,u)
1060 static IHTMLIFrameElement2
*_get_iframe2_iface(unsigned line
, IUnknown
*unk
)
1062 IHTMLIFrameElement2
*ret
;
1065 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLIFrameElement2
, (void**)&ret
);
1066 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLIFrameElement: %08lx\n", hres
);
1070 #define get_button_iface(u) _get_button_iface(__LINE__,u)
1071 static IHTMLButtonElement
*_get_button_iface(unsigned line
, IUnknown
*unk
)
1073 IHTMLButtonElement
*ret
;
1076 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLButtonElement
, (void**)&ret
);
1077 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLButtonElement: %08lx\n", hres
);
1081 #define get_label_iface(u) _get_label_iface(__LINE__,u)
1082 static IHTMLLabelElement
*_get_label_iface(unsigned line
, IUnknown
*unk
)
1084 IHTMLLabelElement
*ret
;
1087 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLLabelElement
, (void**)&ret
);
1088 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLLabelElement: %08lx\n", hres
);
1092 #define get_attr2_iface(u) _get_attr2_iface(__LINE__,u)
1093 static IHTMLDOMAttribute2
*_get_attr2_iface(unsigned line
, IUnknown
*unk
)
1095 IHTMLDOMAttribute2
*ret
;
1098 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMAttribute2
, (void**)&ret
);
1099 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMAttribute2: %08lx\n", hres
);
1103 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
1104 static void _test_node_name(unsigned line
, IUnknown
*unk
, const WCHAR
*exname
)
1106 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1107 IHTMLElement6
*elem
;
1111 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
1112 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08lx\n", hres
);
1113 ok_(__FILE__
, line
) (!lstrcmpW(name
, exname
), "got name: %s, expected %s\n", wine_dbgstr_w(name
), wine_dbgstr_w(exname
));
1114 SysFreeString(name
);
1116 hres
= IHTMLDOMNode_QueryInterface(node
, &IID_IHTMLElement6
, (void**)&elem
);
1117 if(SUCCEEDED(hres
)) {
1118 hres
= IHTMLElement6_get_nodeName(elem
, &name
);
1119 ok_(__FILE__
, line
) (hres
== S_OK
, "(elem) get_nodeName failed: %08lx\n", hres
);
1120 ok_(__FILE__
, line
) (!lstrcmpW(name
, exname
), "(elem) got name: %s, expected %s\n",
1121 wine_dbgstr_w(name
), wine_dbgstr_w(exname
));
1122 SysFreeString(name
);
1123 IHTMLElement6_Release(elem
);
1126 IHTMLDOMNode_Release(node
);
1129 #define get_owner_doc(u) _get_owner_doc(__LINE__,u)
1130 static IHTMLDocument2
*_get_owner_doc(unsigned line
, IUnknown
*unk
)
1132 IHTMLDOMNode2
*node
= _get_node2_iface(line
, unk
);
1133 IDispatch
*disp
= (void*)0xdeadbeef;
1134 IHTMLDocument2
*doc
= NULL
;
1137 hres
= IHTMLDOMNode2_get_ownerDocument(node
, &disp
);
1138 IHTMLDOMNode2_Release(node
);
1139 ok_(__FILE__
,line
)(hres
== S_OK
, "get_ownerDocument failed: %08lx\n", hres
);
1142 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
1143 IDispatch_Release(disp
);
1144 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08lx\n", hres
);
1150 #define get_doc_window(d) _get_doc_window(__LINE__,d)
1151 static IHTMLWindow2
*_get_doc_window(unsigned line
, IHTMLDocument2
*doc
)
1153 IHTMLWindow2
*window
;
1157 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1158 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
1159 ok_(__FILE__
,line
)(window
!= NULL
, "window == NULL\n");
1164 #define clone_node(n,d) _clone_node(__LINE__,n,d)
1165 static IHTMLDOMNode
*_clone_node(unsigned line
, IUnknown
*unk
, VARIANT_BOOL deep
)
1167 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1168 IHTMLDOMNode
*ret
= NULL
;
1171 hres
= IHTMLDOMNode_cloneNode(node
, deep
, &ret
);
1172 IHTMLDOMNode_Release(node
);
1173 ok_(__FILE__
,line
)(hres
== S_OK
, "cloneNode failed: %08lx\n", hres
);
1174 ok_(__FILE__
,line
)(ret
!= NULL
, "ret == NULL\n");
1180 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
1181 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const WCHAR
*extag
)
1183 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1184 IHTMLElement6
*elem6
;
1188 hres
= IHTMLElement_get_tagName(elem
, &tag
);
1189 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08lx\n", hres
);
1190 ok_(__FILE__
, line
) (!lstrcmpW(tag
, extag
), "got tag: %s, expected %s\n", wine_dbgstr_w(tag
), wine_dbgstr_w(extag
));
1193 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLElement6
, (void**)&elem6
);
1194 if(SUCCEEDED(hres
)) {
1195 hres
= IHTMLElement6_get_tagName(elem6
, &tag
);
1196 ok_(__FILE__
, line
)(hres
== S_OK
, "(elem6) get_tagName failed: %08lx\n", hres
);
1197 ok_(__FILE__
, line
)(!lstrcmpW(tag
, extag
), "(elem6) got tag: %s, expected %s\n",
1198 wine_dbgstr_w(tag
), wine_dbgstr_w(extag
));
1200 IHTMLElement6_Release(elem6
);
1203 IHTMLElement_Release(elem
);
1206 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
1207 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
1209 const WCHAR
*expected_value
= L
"[object]";
1211 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
1212 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
1214 if(elem_type_infos
[type
].dispiid
&& type
!= ET_A
) {
1216 expected_value
= NULL
;
1217 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
, elem_type_infos
[type
].clsid
, expected_value
);
1221 #define get_node_type(n) _get_node_type(__LINE__,n)
1222 static LONG
_get_node_type(unsigned line
, IUnknown
*unk
)
1224 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1228 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
1229 ok(hres
== S_OK
, "get_nodeType failed: %08lx\n", hres
);
1231 IHTMLDOMNode_Release(node
);
1236 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
1237 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
1239 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1240 IHTMLDOMChildrenCollection
*col
= NULL
;
1244 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
1245 IHTMLDOMNode_Release(node
);
1246 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08lx\n", hres
);
1250 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
1251 IDispatch_Release(disp
);
1252 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08lx\n", hres
);
1257 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
1258 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, LONG idx
)
1260 IHTMLDOMNode
*node
= NULL
;
1264 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
1265 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
1267 node
= _get_node_iface(line
, (IUnknown
*)disp
);
1268 IDispatch_Release(disp
);
1273 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
1274 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, const WCHAR
*name
, const WCHAR
*exval
)
1280 VariantInit(&value
);
1282 tmp
= SysAllocString(name
);
1283 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
1285 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1288 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
1289 ok_(__FILE__
,line
) (!lstrcmpW(V_BSTR(&value
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&value
)));
1291 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
1294 VariantClear(&value
);
1297 #define test_elem_offset(a,b) _test_elem_offset(__LINE__,a,b)
1298 static void _test_elem_offset(unsigned line
, IUnknown
*unk
, const WCHAR
*parent_tag
)
1300 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1301 IHTMLElement
*off_parent
;
1305 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
1306 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08lx\n", hres
);
1308 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
1309 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08lx\n", hres
);
1311 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
1312 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08lx\n", hres
);
1314 hres
= IHTMLElement_get_offsetLeft(elem
, &l
);
1315 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetLeft failed: %08lx\n", hres
);
1317 hres
= IHTMLElement_get_offsetParent(elem
, &off_parent
);
1318 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetParent failed: %08lx\n", hres
);
1319 IHTMLElement_Release(elem
);
1322 _test_elem_tag(line
, (IUnknown
*)off_parent
, parent_tag
);
1323 IHTMLElement_Release(off_parent
);
1325 ok_(__FILE__
,line
) (parent_tag
== NULL
, "Offset parent is NULL. %s expected\n", wine_dbgstr_w(parent_tag
));
1329 #define test_elem_source_index(a,b) _test_elem_source_index(__LINE__,a,b)
1330 static void _test_elem_source_index(unsigned line
, IHTMLElement
*elem
, int index
)
1332 LONG l
= 0xdeadbeef;
1335 hres
= IHTMLElement_get_sourceIndex(elem
, &l
);
1336 ok_(__FILE__
,line
)(hres
== S_OK
, "get_sourceIndex failed: %08lx\n", hres
);
1337 ok_(__FILE__
,line
)(l
== index
, "sourceIndex = %ld, expected %d\n", l
, index
);
1340 #define get_doc_node(d) _get_doc_node(__LINE__,d)
1341 static IHTMLDocument2
*_get_doc_node(unsigned line
, IHTMLDocument2
*doc
)
1343 IHTMLWindow2
*window
;
1344 IHTMLDocument2
*ret
;
1347 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
1348 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
1350 hres
= IHTMLWindow2_get_document(window
, &ret
);
1351 ok_(__FILE__
,line
)(hres
== S_OK
, "get_document failed: %08lx\n", hres
);
1352 ok_(__FILE__
,line
)(ret
!= NULL
, "document = NULL\n");
1353 IHTMLWindow2_Release(window
);
1358 #define test_window_name(d,e) _test_window_name(__LINE__,d,e)
1359 static void _test_window_name(unsigned line
, IHTMLWindow2
*window
, const WCHAR
*exname
)
1364 hres
= IHTMLWindow2_get_name(window
, &name
);
1365 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
1367 ok_(__FILE__
,line
)(!lstrcmpW(name
, exname
), "name = %s\n", wine_dbgstr_w(name
));
1369 ok_(__FILE__
,line
)(!name
, "name = %s\n", wine_dbgstr_w(name
));
1370 SysFreeString(name
);
1373 #define set_window_name(w,n) _set_window_name(__LINE__,w,n)
1374 static void _set_window_name(unsigned line
, IHTMLWindow2
*window
, const WCHAR
*name
)
1379 str
= SysAllocString(name
);
1380 hres
= IHTMLWindow2_put_name(window
, str
);
1382 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08lx\n", hres
);
1384 _test_window_name(line
, window
, name
);
1387 #define test_window_status(d) _test_window_status(__LINE__,d)
1388 static void _test_window_status(unsigned line
, IHTMLWindow2
*window
)
1393 status
= (void*)0xdeadbeef;
1394 hres
= IHTMLWindow2_get_status(window
, &status
);
1395 ok_(__FILE__
,line
)(hres
== S_OK
, "get_status failed: %08lx\n", hres
);
1396 ok_(__FILE__
,line
)(!status
, "status = %s\n", wine_dbgstr_w(status
));
1397 SysFreeString(status
);
1400 #define set_window_status(w,n) _set_window_status(__LINE__,w,n)
1401 static void _set_window_status(unsigned line
, IHTMLWindow2
*window
, const WCHAR
*status
)
1406 str
= SysAllocString(status
);
1407 hres
= IHTMLWindow2_put_status(window
, str
);
1409 ok_(__FILE__
,line
)(hres
== S_OK
, "put_status failed: %08lx\n", hres
);
1412 #define test_window_length(w,l) _test_window_length(__LINE__,w,l)
1413 static void _test_window_length(unsigned line
, IHTMLWindow2
*window
, LONG exlen
)
1418 hres
= IHTMLWindow2_get_length(window
, &length
);
1419 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
1420 ok_(__FILE__
,line
)(length
== exlen
, "length = %ld, expected %ld\n", length
, exlen
);
1423 #define get_frame_content_window(e) _get_frame_content_window(__LINE__,e)
1424 static IHTMLWindow2
*_get_frame_content_window(unsigned line
, IUnknown
*elem
)
1426 IHTMLFrameBase2
*base2
;
1427 IHTMLWindow2
*window
;
1430 hres
= IUnknown_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
1431 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08lx\n", hres
);
1434 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &window
);
1435 IHTMLFrameBase2_Release(base2
);
1436 ok(hres
== S_OK
, "get_contentWindow failed: %08lx\n", hres
);
1437 ok(window
!= NULL
, "contentWindow = NULL\n");
1442 static void test_get_set_attr(IHTMLDocument2
*doc
)
1445 IHTMLDocument3
*doc3
;
1450 /* grab an element to test with */
1451 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1452 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08lx\n", hres
);
1454 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1455 IHTMLDocument3_Release(doc3
);
1456 ok(hres
== S_OK
, "get_documentElement failed: %08lx\n", hres
);
1458 /* get a non-present attribute */
1459 bstr
= SysAllocString(L
"notAnAttribute");
1460 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1461 ok(hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1462 ok(V_VT(&val
) == VT_NULL
, "variant type should have been VT_NULL (0x%x), was: 0x%x\n", VT_NULL
, V_VT(&val
));
1464 SysFreeString(bstr
);
1466 /* get a present attribute */
1467 bstr
= SysAllocString(L
"scrollHeight");
1468 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1469 ok(hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1470 ok(V_VT(&val
) == VT_I4
, "variant type should have been VT_I4 (0x%x), was: 0x%x\n", VT_I4
, V_VT(&val
));
1472 SysFreeString(bstr
);
1474 /* create a new BSTR attribute */
1475 bstr
= SysAllocString(L
"newAttribute");
1477 V_VT(&val
) = VT_BSTR
;
1478 V_BSTR(&val
) = SysAllocString(L
"the value");
1479 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1480 ok(hres
== S_OK
, "setAttribute failed: %08lx\n", hres
);
1483 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1484 ok(hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1485 ok(V_VT(&val
) == VT_BSTR
, "variant type should have been VT_BSTR (0x%x), was: 0x%x\n", VT_BSTR
, V_VT(&val
));
1486 ok(lstrcmpW(V_BSTR(&val
), L
"the value") == 0, "variant value should have been L\"the value\", was %s\n", wine_dbgstr_w(V_BSTR(&val
)));
1489 /* overwrite the attribute with a BOOL */
1490 V_VT(&val
) = VT_BOOL
;
1491 V_BOOL(&val
) = VARIANT_TRUE
;
1492 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1493 ok(hres
== S_OK
, "setAttribute failed: %08lx\n", hres
);
1496 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1497 ok(hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1498 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1499 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1502 SysFreeString(bstr
);
1504 /* case-insensitive */
1505 bstr
= SysAllocString(L
"newattribute");
1506 hres
= IHTMLElement_getAttribute(elem
, bstr
, 0, &val
);
1507 ok(hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1508 ok(V_VT(&val
) == VT_BOOL
, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL
, V_VT(&val
));
1509 ok(V_BOOL(&val
) == VARIANT_TRUE
, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE
, V_BOOL(&val
));
1512 /* overwrite the attribute with null */
1513 V_VT(&val
) = VT_NULL
;
1514 hres
= IHTMLElement_setAttribute(elem
, bstr
, val
, 0);
1515 ok(hres
== S_OK
, "setAttribute failed: %08lx\n", hres
);
1517 hres
= IHTMLElement_getAttribute(elem
, bstr
, 2, &val
);
1518 ok(hres
== S_OK
, "getAttribute failed: %08lx\n", hres
);
1519 ok(V_VT(&val
) == VT_BSTR
, "V_VT(val) = %u, expected VT_BSTR\n", V_VT(&val
));
1520 ok(!lstrcmpW(V_BSTR(&val
), L
"null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val
)));
1523 SysFreeString(bstr
);
1524 IHTMLElement_Release(elem
);
1527 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
1528 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
1531 IHTMLDocument3
*doc3
;
1534 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1535 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08lx\n", hres
);
1536 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
1537 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08lx\n", hres
);
1538 IHTMLDocument3_Release(doc3
);
1543 #define test_anchor_href(a,h) _test_anchor_href(__LINE__,a,h)
1544 static void _test_anchor_href(unsigned line
, IUnknown
*unk
, const WCHAR
*exhref
)
1546 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1550 hres
= IHTMLAnchorElement_get_href(anchor
, &str
);
1551 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
1552 ok_(__FILE__
,line
)(!lstrcmpW(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exhref
));
1553 IHTMLAnchorElement_Release(anchor
);
1556 _test_disp_value(line
, unk
, exhref
);
1559 #define test_anchor_put_href(a,h) _test_anchor_put_href(__LINE__,a,h)
1560 static void _test_anchor_put_href(unsigned line
, IUnknown
*unk
, const WCHAR
*exhref
)
1562 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1566 str
= SysAllocString(exhref
);
1567 hres
= IHTMLAnchorElement_put_href(anchor
, str
);
1568 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
1569 IHTMLAnchorElement_Release(anchor
);
1572 _test_disp_value(line
, unk
, exhref
);
1575 #define test_anchor_rel(a,h) _test_anchor_rel(__LINE__,a,h)
1576 static void _test_anchor_rel(unsigned line
, IUnknown
*unk
, const WCHAR
*exrel
)
1578 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1582 hres
= IHTMLAnchorElement_get_rel(anchor
, &str
);
1583 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08lx\n", hres
);
1585 ok_(__FILE__
,line
)(!lstrcmpW(str
, exrel
), "rel = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exrel
));
1587 ok_(__FILE__
,line
)(!str
, "rel = %s, expected NULL\n", wine_dbgstr_w(str
));
1588 IHTMLAnchorElement_Release(anchor
);
1592 #define test_anchor_put_rel(a,h) _test_anchor_put_rel(__LINE__,a,h)
1593 static void _test_anchor_put_rel(unsigned line
, IUnknown
*unk
, const WCHAR
*exrel
)
1595 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1599 str
= SysAllocString(exrel
);
1600 hres
= IHTMLAnchorElement_put_rel(anchor
, str
);
1601 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08lx\n", hres
);
1602 IHTMLAnchorElement_Release(anchor
);
1606 #define test_anchor_get_target(a,h) _test_anchor_get_target(__LINE__,a,h)
1607 static void _test_anchor_get_target(unsigned line
, IUnknown
*unk
, const WCHAR
*target
)
1609 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1613 hres
= IHTMLAnchorElement_get_target(anchor
, &str
);
1614 ok_(__FILE__
,line
)(hres
== S_OK
, "get_target failed: %08lx\n", hres
);
1616 ok_(__FILE__
,line
)(!lstrcmpW(str
, target
), "target = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(target
));
1618 ok_(__FILE__
,line
)(str
== NULL
, "target = %s, expected NULL\n", wine_dbgstr_w(str
));
1619 IHTMLAnchorElement_Release(anchor
);
1623 #define test_anchor_put_target(a,h) _test_anchor_put_target(__LINE__,a,h)
1624 static void _test_anchor_put_target(unsigned line
, IUnknown
*unk
, const WCHAR
*target
)
1626 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1630 str
= target
? SysAllocString(target
) : NULL
;
1631 hres
= IHTMLAnchorElement_put_target(anchor
, str
);
1632 ok_(__FILE__
,line
)(hres
== S_OK
, "put_target failed: %08lx\n", hres
);
1633 IHTMLAnchorElement_Release(anchor
);
1637 #define test_anchor_name(a,h) _test_anchor_name(__LINE__,a,h)
1638 static void _test_anchor_name(unsigned line
, IUnknown
*unk
, const WCHAR
*name
)
1640 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1644 hres
= IHTMLAnchorElement_get_name(anchor
, &str
);
1645 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
1647 ok_(__FILE__
,line
)(!lstrcmpW(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(name
));
1649 ok_(__FILE__
,line
)(str
== NULL
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
1650 IHTMLAnchorElement_Release(anchor
);
1654 #define test_anchor_put_name(a,h) _test_anchor_put_name(__LINE__,a,h)
1655 static void _test_anchor_put_name(unsigned line
, IUnknown
*unk
, const WCHAR
*name
)
1657 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1661 str
= name
? SysAllocString(name
) : NULL
;
1662 hres
= IHTMLAnchorElement_put_name(anchor
, str
);
1663 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08lx\n", hres
);
1664 IHTMLAnchorElement_Release(anchor
);
1667 _test_anchor_name(line
, unk
, name
);
1670 #define test_anchor_hostname(a,h) _test_anchor_hostname(__LINE__,a,h)
1671 static void _test_anchor_hostname(unsigned line
, IUnknown
*unk
, const WCHAR
*hostname
)
1673 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1677 hres
= IHTMLAnchorElement_get_hostname(anchor
, &str
);
1678 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
1680 ok_(__FILE__
,line
)(!lstrcmpW(str
, hostname
), "hostname = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(hostname
));
1682 ok_(__FILE__
,line
)(str
== NULL
, "hostname = %s, expected NULL\n", wine_dbgstr_w(str
));
1683 IHTMLAnchorElement_Release(anchor
);
1687 #define test_anchor_port(a,p) _test_anchor_port(__LINE__,a,p)
1688 static void _test_anchor_port(unsigned line
, IUnknown
*unk
, const WCHAR
*port
)
1690 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1694 hres
= IHTMLAnchorElement_get_port(anchor
, &str
);
1695 ok_(__FILE__
,line
)(hres
== S_OK
, "get_port failed: %08lx\n", hres
);
1697 ok_(__FILE__
,line
)(!lstrcmpW(str
, port
), "port = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(port
));
1699 ok_(__FILE__
,line
)(str
== NULL
, "port = %s, expected NULL\n", wine_dbgstr_w(str
));
1700 IHTMLAnchorElement_Release(anchor
);
1704 #define test_anchor_search(a,h,n) _test_anchor_search(__LINE__,a,h,n)
1705 static void _test_anchor_search(unsigned line
, IUnknown
*elem
, const WCHAR
*search
, BOOL allowbroken
)
1707 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, elem
);
1711 hres
= IHTMLAnchorElement_get_search(anchor
, &str
);
1712 ok_(__FILE__
,line
)(hres
== S_OK
, "get_search failed: %08lx\n", hres
);
1713 if ( ! str
&& allowbroken
)
1714 win_skip("skip ie6 incorrect behavior\n");
1716 ok_(__FILE__
,line
)(!lstrcmpW(str
, search
), "search = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(search
));
1718 ok_(__FILE__
,line
)(!str
, "search = %s, expected NULL\n", wine_dbgstr_w(str
));
1719 IHTMLAnchorElement_Release(anchor
);
1723 #define test_anchor_put_search(a,h) _test_anchor_put_search(__LINE__,a,h)
1724 static void _test_anchor_put_search(unsigned line
, IUnknown
*unk
, const WCHAR
*search
)
1726 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, unk
);
1730 str
= search
? SysAllocString(search
) : NULL
;
1731 hres
= IHTMLAnchorElement_put_search(anchor
, str
);
1732 ok_(__FILE__
,line
)(hres
== S_OK
, "put_search failed: %08lx\n", hres
);
1733 IHTMLAnchorElement_Release(anchor
);
1737 #define test_anchor_hash(a,h) _test_anchor_hash(__LINE__,a,h)
1738 static void _test_anchor_hash(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exhash
)
1740 IHTMLAnchorElement
*anchor
= _get_anchor_iface(line
, (IUnknown
*)elem
);
1744 hres
= IHTMLAnchorElement_get_hash(anchor
, &str
);
1745 ok_(__FILE__
,line
)(hres
== S_OK
, "get_hash failed: %08lx\n", hres
);
1747 ok_(__FILE__
,line
)(!lstrcmpW(str
, exhash
), "hash = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exhash
));
1749 ok_(__FILE__
,line
)(!str
, "hash = %s, expected NULL\n", wine_dbgstr_w(str
));
1750 IHTMLAnchorElement_Release(anchor
);
1754 #define test_area_href(a,h) _test_area_href(__LINE__,a,h)
1755 static void _test_area_href(unsigned line
, IUnknown
*unk
, const WCHAR
*exhref
)
1757 IHTMLAreaElement
*area
= _get_area_iface(line
, unk
);
1761 hres
= IHTMLAreaElement_get_href(area
, &str
);
1762 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
1763 ok_(__FILE__
,line
)(!lstrcmpW(str
, exhref
), "href = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exhref
));
1764 IHTMLAreaElement_Release(area
);
1767 _test_disp_value(line
, unk
, exhref
);
1770 #define test_area_put_href(a,h) _test_area_put_href(__LINE__,a,h)
1771 static void _test_area_put_href(unsigned line
, IUnknown
*unk
, const WCHAR
*exhref
)
1773 IHTMLAreaElement
*area
= _get_area_iface(line
, unk
);
1777 str
= SysAllocString(exhref
);
1778 hres
= IHTMLAreaElement_put_href(area
, str
);
1779 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
1780 IHTMLAreaElement_Release(area
);
1783 _test_disp_value(line
, unk
, exhref
);
1786 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
1787 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const WCHAR
*text
)
1792 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
1793 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08lx\n", hres
);
1794 ok_(__FILE__
,line
) (!lstrcmpW(bstr
, text
), "text=%s\n", wine_dbgstr_w(bstr
));
1795 SysFreeString(bstr
);
1798 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
1799 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const WCHAR
*text
)
1804 bstr
= SysAllocString(text
);
1805 hres
= IHTMLOptionElement_put_text(option
, bstr
);
1806 SysFreeString(bstr
);
1807 ok(hres
== S_OK
, "put_text failed: %08lx\n", hres
);
1809 _test_option_text(line
, option
, text
);
1812 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
1813 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const WCHAR
*value
)
1818 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
1819 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08lx\n", hres
);
1820 ok_(__FILE__
,line
) (!lstrcmpW(bstr
, value
), "value=%s\n", wine_dbgstr_w(bstr
));
1821 SysFreeString(bstr
);
1824 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
1825 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const WCHAR
*value
)
1830 bstr
= SysAllocString(value
);
1831 hres
= IHTMLOptionElement_put_value(option
, bstr
);
1832 SysFreeString(bstr
);
1833 ok(hres
== S_OK
, "put_value failed: %08lx\n", hres
);
1835 _test_option_value(line
, option
, value
);
1838 #define test_option_selected(o,s) _test_option_selected(__LINE__,o,s)
1839 static void _test_option_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1841 VARIANT_BOOL b
= 0x100;
1844 hres
= IHTMLOptionElement_get_selected(option
, &b
);
1845 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selected failed: %08lx\n", hres
);
1846 ok_(__FILE__
,line
)(b
== ex
, "selected = %x, expected %x\n", b
, ex
);
1849 #define test_option_put_selected(o,s) _test_option_put_selected(__LINE__,o,s)
1850 static void _test_option_put_selected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1854 hres
= IHTMLOptionElement_put_selected(option
, b
);
1855 ok_(__FILE__
,line
)(hres
== S_OK
, "put_selected failed: %08lx\n", hres
);
1856 _test_option_selected(line
, option
, b
);
1859 #define test_option_get_index(o,s) _test_option_get_index(__LINE__,o,s)
1860 static void _test_option_get_index(unsigned line
, IHTMLOptionElement
*option
, LONG exval
)
1865 hres
= IHTMLOptionElement_get_index(option
, NULL
);
1866 ok_(__FILE__
,line
)(hres
== E_INVALIDARG
, "Expect E_INVALIDARG, got %08lx\n", hres
);
1869 hres
= IHTMLOptionElement_get_index(option
, &val
);
1870 ok_(__FILE__
,line
)(hres
== S_OK
, "get_index failed: %08lx\n", hres
);
1871 ok_(__FILE__
,line
)(val
== exval
|| broken(val
== 12345678), /* Win2k doesn't touch it*/
1872 "value = %ld, expected = %ld\n", val
, exval
);
1875 #define test_option_put_defaultSelected(o,d) _test_option_put_defaultSelected(__LINE__,o,d)
1876 static void _test_option_put_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL b
)
1880 hres
= IHTMLOptionElement_put_defaultSelected(option
, b
);
1881 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultSelected %08lx\n", hres
);
1884 #define test_option_defaultSelected(o,e) _test_option_defaultSelected(__LINE__,o,e)
1885 static void _test_option_defaultSelected(unsigned line
, IHTMLOptionElement
*option
, VARIANT_BOOL ex
)
1890 hres
= IHTMLOptionElement_get_defaultSelected(option
, NULL
);
1891 ok_(__FILE__
,line
)(hres
== E_POINTER
, "Expect E_POINTER, got %08lx\n", hres
);
1894 hres
= IHTMLOptionElement_get_defaultSelected(option
, &b
);
1895 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultSelected failed: %08lx\n", hres
);
1896 ok_(__FILE__
,line
)(b
== ex
, "b = %x, expected = %x\n", b
, ex
);
1899 static void test_option_defaultSelected_property(IHTMLOptionElement
*option
)
1901 test_option_defaultSelected(option
, VARIANT_FALSE
);
1902 test_option_selected(option
, VARIANT_FALSE
);
1904 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1905 test_option_defaultSelected(option
, VARIANT_FALSE
);
1906 test_option_selected(option
, VARIANT_FALSE
);
1908 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1909 test_option_defaultSelected(option
, VARIANT_TRUE
);
1910 test_option_selected(option
, VARIANT_FALSE
);
1912 test_option_put_defaultSelected(option
, 0x100); /* Invalid value */
1913 test_option_defaultSelected(option
, VARIANT_FALSE
);
1914 test_option_selected(option
, VARIANT_FALSE
);
1916 test_option_put_selected(option
, VARIANT_TRUE
);
1917 test_option_selected(option
, VARIANT_TRUE
);
1918 test_option_defaultSelected(option
, VARIANT_FALSE
);
1920 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1921 test_option_defaultSelected(option
, VARIANT_TRUE
);
1922 test_option_selected(option
, VARIANT_TRUE
);
1924 /* Restore defaultSelected */
1925 test_option_put_defaultSelected(option
, VARIANT_TRUE
);
1926 test_option_put_selected(option
, VARIANT_FALSE
);
1929 #define test_textarea_value(t,v) _test_textarea_value(__LINE__,t,v)
1930 static void _test_textarea_value(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
1932 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1933 BSTR value
= (void*)0xdeadbeef;
1936 hres
= IHTMLTextAreaElement_get_value(textarea
, &value
);
1937 IHTMLTextAreaElement_Release(textarea
);
1938 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08lx\n", hres
);
1940 ok_(__FILE__
,line
)(!lstrcmpW(value
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(value
), wine_dbgstr_w(exval
));
1942 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1943 SysFreeString(value
);
1946 #define test_textarea_put_value(t,v) _test_textarea_put_value(__LINE__,t,v)
1947 static void _test_textarea_put_value(unsigned line
, IUnknown
*unk
, const WCHAR
*value
)
1949 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1950 BSTR tmp
= SysAllocString(value
);
1953 hres
= IHTMLTextAreaElement_put_value(textarea
, tmp
);
1954 IHTMLTextAreaElement_Release(textarea
);
1955 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08lx\n", hres
);
1958 _test_textarea_value(line
, unk
, value
);
1961 #define test_textarea_defaultvalue(t,v) _test_textarea_defaultvalue(__LINE__,t,v)
1962 static void _test_textarea_defaultvalue(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
1964 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1965 BSTR value
= (void*)0xdeadbeef;
1968 hres
= IHTMLTextAreaElement_get_defaultValue(textarea
, &value
);
1969 IHTMLTextAreaElement_Release(textarea
);
1970 ok_(__FILE__
,line
)(hres
== S_OK
, "get_defaultValue failed: %08lx\n", hres
);
1972 ok_(__FILE__
,line
)(!lstrcmpW(value
, exval
), "defaultValue = %s, expected %s\n", wine_dbgstr_w(value
), wine_dbgstr_w(exval
));
1974 ok_(__FILE__
,line
)(!value
, "value = %p\n", value
);
1975 SysFreeString(value
);
1978 #define test_textarea_put_defaultvalue(t,v) _test_textarea_put_defaultvalue(__LINE__,t,v)
1979 static void _test_textarea_put_defaultvalue(unsigned line
, IUnknown
*unk
, const WCHAR
*value
)
1981 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1982 BSTR tmp
= SysAllocString(value
);
1985 hres
= IHTMLTextAreaElement_put_defaultValue(textarea
, tmp
);
1986 IHTMLTextAreaElement_Release(textarea
);
1987 ok_(__FILE__
,line
)(hres
== S_OK
, "put_defaultValue failed: %08lx\n", hres
);
1990 _test_textarea_defaultvalue(line
, unk
, value
);
1993 #define test_textarea_readonly(t,v) _test_textarea_readonly(__LINE__,t,v)
1994 static void _test_textarea_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL ex
)
1996 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
1997 VARIANT_BOOL b
= 0x100;
2000 hres
= IHTMLTextAreaElement_get_readOnly(textarea
, &b
);
2001 IHTMLTextAreaElement_Release(textarea
);
2002 ok_(__FILE__
,line
)(hres
== S_OK
, "get_readOnly failed: %08lx\n", hres
);
2003 ok_(__FILE__
,line
)(b
== ex
, "readOnly = %x, expected %x\n", b
, ex
);
2006 #define test_textarea_put_readonly(t,v) _test_textarea_put_readonly(__LINE__,t,v)
2007 static void _test_textarea_put_readonly(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
2009 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
2012 hres
= IHTMLTextAreaElement_put_readOnly(textarea
, b
);
2013 IHTMLTextAreaElement_Release(textarea
);
2014 ok_(__FILE__
,line
)(hres
== S_OK
, "put_readOnly failed: %08lx\n", hres
);
2016 _test_textarea_readonly(line
, unk
, b
);
2019 #define test_textarea_type(t) _test_textarea_type(__LINE__,t)
2020 static void _test_textarea_type(unsigned line
, IUnknown
*unk
)
2022 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
2023 BSTR type
= (void*)0xdeadbeef;
2026 hres
= IHTMLTextAreaElement_get_type(textarea
, &type
);
2027 IHTMLTextAreaElement_Release(textarea
);
2028 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
2029 ok_(__FILE__
,line
)(!lstrcmpW(type
, L
"textarea"), "type = %s, expected textarea\n", wine_dbgstr_w(type
));
2030 SysFreeString(type
);
2033 #define get_textarea_form(t) _get_textarea_form(__LINE__,t)
2034 static IHTMLFormElement
*_get_textarea_form(unsigned line
, IUnknown
*unk
)
2036 IHTMLTextAreaElement
*textarea
= _get_textarea_iface(line
, unk
);
2037 IHTMLFormElement
*form
;
2040 hres
= IHTMLTextAreaElement_get_form(textarea
, &form
);
2041 IHTMLTextAreaElement_Release(textarea
);
2042 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
2047 #define test_comment_text(c,t) _test_comment_text(__LINE__,c,t)
2048 static void _test_comment_text(unsigned line
, IUnknown
*unk
, const WCHAR
*extext
)
2050 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
2055 hres
= IHTMLCommentElement_get_text(comment
, &text
);
2056 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08lx\n", hres
);
2057 if((p
= wcsstr(extext
, L
"-->")) && SysStringLen(text
) == p
- extext
) /* Some IEs drop comment ending */
2058 ok_(__FILE__
,line
)(!wcsncmp(text
, extext
, p
- extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), wine_dbgstr_w(extext
));
2060 ok_(__FILE__
,line
)(!lstrcmpW(text
, extext
), "text = \"%s\", expected \"%s\"\n", wine_dbgstr_w(text
), wine_dbgstr_w(extext
));
2062 IHTMLCommentElement_Release(comment
);
2063 SysFreeString(text
);
2066 #define create_attr(a,b) _create_attr(__LINE__,a,b)
2067 static IHTMLDOMAttribute
*_create_attr(unsigned line
, IUnknown
*unk
, const char *name
)
2069 IHTMLDocument5
*doc
= _get_htmldoc5_iface(line
, unk
);
2070 BSTR str
= SysAllocString(L
"Test");
2071 IHTMLDOMAttribute
*attr
;
2074 hres
= IHTMLDocument5_createAttribute(doc
, str
, &attr
);
2075 ok_(__FILE__
,line
)(hres
== S_OK
, "createAttribute failed: %08lx\n", hres
);
2077 IHTMLDocument5_Release(doc
);
2082 #define test_attr_specified(a,b) _test_attr_specified(__LINE__,a,b)
2083 static void _test_attr_specified(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2085 VARIANT_BOOL specified
;
2088 hres
= IHTMLDOMAttribute_get_specified(attr
, &specified
);
2089 ok_(__FILE__
,line
)(hres
== S_OK
, "get_specified failed: %08lx\n", hres
);
2090 ok_(__FILE__
,line
)(specified
== expected
, "specified = %x, expected %x\n", specified
, expected
);
2093 #define test_attr_expando(a,b) _test_attr_expando(__LINE__,a,b)
2094 static void _test_attr_expando(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT_BOOL expected
)
2096 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2097 VARIANT_BOOL expando
;
2100 hres
= IHTMLDOMAttribute2_get_expando(attr2
, &expando
);
2101 ok_(__FILE__
,line
)(hres
== S_OK
, "get_expando failed: %08lx\n", hres
);
2102 ok_(__FILE__
,line
)(expando
== expected
, "expando = %x, expected %x\n", expando
, expected
);
2104 IHTMLDOMAttribute2_Release(attr2
);
2107 #define test_attr_value(a,b) _test_attr_value(__LINE__,a,b)
2108 static void _test_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const WCHAR
*exval
)
2110 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
2114 hres
= IHTMLDOMAttribute2_get_value(attr2
, &val
);
2115 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08lx\n", hres
);
2117 ok_(__FILE__
,line
)(!lstrcmpW(val
, exval
), "value = %s, expected %s\n", wine_dbgstr_w(val
), wine_dbgstr_w(exval
));
2119 ok_(__FILE__
,line
)(!val
, "value = %s, expected NULL\n", wine_dbgstr_w(val
));
2121 IHTMLDOMAttribute2_Release(attr2
);
2125 #define test_comment_attrs(c) _test_comment_attrs(__LINE__,c)
2126 static void _test_comment_attrs(unsigned line
, IUnknown
*unk
)
2128 IHTMLCommentElement
*comment
= _get_comment_iface(__LINE__
,unk
);
2129 IHTMLElement
*elem
= _get_elem_iface(__LINE__
,unk
);
2130 IHTMLElement4
*elem4
= _get_elem4_iface(__LINE__
,unk
);
2131 IHTMLDOMAttribute
*attr
;
2132 BSTR name
= SysAllocString(L
"test");
2136 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2137 ok(hres
== S_OK
, "getAttributeNode failed: %08lx\n", hres
);
2138 ok(attr
== NULL
, "attr != NULL\n");
2142 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
2143 ok(hres
== S_OK
, "setAttribute failed: %08lx\n", hres
);
2145 hres
= IHTMLElement4_getAttributeNode(elem4
, name
, &attr
);
2146 ok(hres
== S_OK
, "getAttributeNode failed: %08lx\n", hres
);
2147 ok(attr
!= NULL
, "attr == NULL\n");
2149 test_attr_expando(attr
, VARIANT_TRUE
);
2151 IHTMLDOMAttribute_Release(attr
);
2152 IHTMLCommentElement_Release(comment
);
2153 IHTMLElement_Release(elem
);
2154 IHTMLElement4_Release(elem4
);
2155 SysFreeString(name
);
2158 #define test_object_vspace(u,s) _test_object_vspace(__LINE__,u,s)
2159 static void _test_object_vspace(unsigned line
, IUnknown
*unk
, LONG exl
)
2161 IHTMLObjectElement
*object
= _get_object_iface(line
, unk
);
2166 hres
= IHTMLObjectElement_get_vspace(object
, &l
);
2167 ok_(__FILE__
,line
)(hres
== S_OK
, "get_vspace failed: %08lx\n", hres
);
2168 ok_(__FILE__
,line
)(l
== exl
, "vspace=%ld, expected %ld\n", l
, exl
);
2169 IHTMLObjectElement_Release(object
);
2172 #define test_object_name(a,b) _test_object_name(__LINE__,a,b)
2173 static void _test_object_name(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exname
)
2175 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2179 str
= (void*)0xdeadbeef;
2180 hres
= IHTMLObjectElement_get_name(object
, &str
);
2181 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
2183 ok_(__FILE__
,line
)(!lstrcmpW(str
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exname
));
2185 ok_(__FILE__
,line
)(!str
, "name=%s, expected NULL\n", wine_dbgstr_w(str
));
2187 IHTMLObjectElement_Release(object
);
2190 #define set_object_name(a,b) _set_object_name(__LINE__,a,b)
2191 static void _set_object_name(unsigned line
, IHTMLElement
*elem
, const WCHAR
*name
)
2193 IHTMLObjectElement
*object
= _get_object_iface(line
, (IUnknown
*)elem
);
2197 str
= SysAllocString(name
);
2198 hres
= IHTMLObjectElement_put_name(object
, str
);
2199 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08lx\n", hres
);
2201 IHTMLObjectElement_Release(object
);
2203 _test_object_name(line
, elem
, name
);
2206 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
2207 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
2208 const WCHAR
*txt
, const WCHAR
*val
)
2210 VARIANT text
, value
, empty
, option_var
, args
[2];
2211 DISPPARAMS dp
= { args
, NULL
, 2, 0 };
2212 IHTMLOptionElementFactory
*factory
;
2213 IHTMLOptionElement
*option
;
2214 IHTMLWindow2
*window
;
2218 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2219 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08lx\n", hres
);
2221 hres
= IHTMLWindow2_get_Option(window
, &factory
);
2222 IHTMLWindow2_Release(window
);
2223 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08lx\n", hres
);
2225 test_disp((IUnknown
*)factory
, &IID_IHTMLOptionElementFactory
, NULL
, L
"[object]");
2227 V_VT(&text
) = VT_BSTR
;
2228 V_BSTR(&text
) = SysAllocString(txt
);
2229 V_VT(&value
) = VT_BSTR
;
2230 V_BSTR(&value
) = SysAllocString(val
);
2231 V_VT(&empty
) = VT_EMPTY
;
2233 hres
= IHTMLOptionElementFactory_QueryInterface(factory
, &IID_IDispatch
, (void**)&disp
);
2234 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IDispatch: %08lx\n", hres
);
2238 hres
= IDispatch_Invoke(disp
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_CONSTRUCT
, &dp
, &option_var
, NULL
, NULL
);
2239 IDispatch_Release(disp
);
2240 ok_(__FILE__
,line
)(hres
== S_OK
, "Invoke(DISPID_VALUE) returned: %08lx\n", hres
);
2241 ok_(__FILE__
,line
)(V_VT(&option_var
) == VT_DISPATCH
, "VT(option_var) = %d\n", V_VT(&option_var
));
2242 hres
= IDispatch_QueryInterface(V_DISPATCH(&option_var
), &IID_IHTMLOptionElement
, (void**)&option
);
2243 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLOptionElement: %08lx\n", hres
);
2244 VariantClear(&option_var
);
2246 _test_option_text(line
, option
, txt
);
2247 _test_option_value(line
, option
, val
);
2248 _test_option_selected(line
, option
, VARIANT_FALSE
);
2249 IHTMLOptionElement_Release(option
);
2251 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
2252 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08lx\n", hres
);
2254 IHTMLOptionElementFactory_Release(factory
);
2255 VariantClear(&text
);
2256 VariantClear(&value
);
2258 _test_option_text(line
, option
, txt
);
2259 _test_option_value(line
, option
, val
);
2260 _test_option_selected(line
, option
, VARIANT_FALSE
);
2265 #define test_img_width(o,w) _test_img_width(__LINE__,o,w)
2266 static void _test_img_width(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2271 hres
= IHTMLImgElement_get_width(img
, &found
);
2272 ok_(__FILE__
,line
) (hres
== S_OK
, "get_width failed: %08lx\n", hres
);
2273 ok_(__FILE__
,line
) (found
== exp
, "width=%ld\n", found
);
2276 #define test_img_put_width(o,w) _test_img_put_width(__LINE__,o,w)
2277 static void _test_img_put_width(unsigned line
, IHTMLImgElement
*img
, const LONG width
)
2281 hres
= IHTMLImgElement_put_width(img
, width
);
2282 ok(hres
== S_OK
, "put_width failed: %08lx\n", hres
);
2284 _test_img_width(line
, img
, width
);
2287 #define test_img_height(o,h) _test_img_height(__LINE__,o,h)
2288 static void _test_img_height(unsigned line
, IHTMLImgElement
*img
, const LONG exp
)
2293 hres
= IHTMLImgElement_get_height(img
, &found
);
2294 ok_(__FILE__
,line
) (hres
== S_OK
, "get_height failed: %08lx\n", hres
);
2295 ok_(__FILE__
,line
) (found
== exp
, "height=%ld\n", found
);
2298 #define test_img_put_height(o,w) _test_img_put_height(__LINE__,o,w)
2299 static void _test_img_put_height(unsigned line
, IHTMLImgElement
*img
, const LONG height
)
2303 hres
= IHTMLImgElement_put_height(img
, height
);
2304 ok(hres
== S_OK
, "put_height failed: %08lx\n", hres
);
2306 _test_img_height(line
, img
, height
);
2309 #define create_img_elem(d,t,v) _create_img_elem(__LINE__,d,t,v)
2310 static IHTMLImgElement
*_create_img_elem(unsigned line
, IHTMLDocument2
*doc
,
2311 LONG wdth
, LONG hght
)
2313 IHTMLImageElementFactory
*factory
;
2314 IHTMLImgElement
*img
;
2315 IHTMLWindow2
*window
;
2316 VARIANT width
, height
;
2320 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2321 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08lx\n", hres
);
2323 hres
= IHTMLWindow2_get_Image(window
, &factory
);
2324 IHTMLWindow2_Release(window
);
2325 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Image failed: %08lx\n", hres
);
2327 test_ifaces((IUnknown
*)factory
, img_factory_iids
);
2328 test_disp((IUnknown
*)factory
, &IID_IHTMLImageElementFactory
, NULL
, L
"[object]");
2331 wsprintfW(buf
, L
"%d", wdth
);
2332 V_VT(&width
) = VT_BSTR
;
2333 V_BSTR(&width
) = SysAllocString(buf
);
2335 V_VT(&width
) = VT_EMPTY
;
2340 wsprintfW(buf
, L
"%d", hght
);
2341 V_VT(&height
) = VT_BSTR
;
2342 V_BSTR(&height
) = SysAllocString(buf
);
2344 V_VT(&height
) = VT_EMPTY
;
2348 hres
= IHTMLImageElementFactory_create(factory
, width
, height
, &img
);
2349 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08lx\n", hres
);
2351 IHTMLImageElementFactory_Release(factory
);
2352 VariantClear(&width
);
2353 VariantClear(&height
);
2355 if(SUCCEEDED(hres
)) {
2356 _test_img_width(line
, img
, wdth
);
2357 _test_img_height(line
, img
, hght
);
2364 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
2365 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, LONG length
)
2367 LONG len
= 0xdeadbeef;
2370 hres
= IHTMLSelectElement_get_length(select
, &len
);
2371 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08lx\n", hres
);
2372 ok_(__FILE__
,line
) (len
== length
, "len=%ld, expected %ld\n", len
, length
);
2375 #define test_select_put_length(s,l) _test_select_put_length(__LINE__,s,l)
2376 static void _test_select_put_length(unsigned line
, IUnknown
*unk
, LONG length
)
2378 IHTMLSelectElement
*select
= _get_select_iface(line
, unk
);
2381 hres
= IHTMLSelectElement_put_length(select
, length
);
2382 ok_(__FILE__
,line
) (hres
== S_OK
, "put_length failed: %08lx\n", hres
);
2383 _test_select_length(line
, select
, length
);
2384 IHTMLSelectElement_Release(select
);
2387 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
2388 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2390 LONG idx
= 0xdeadbeef;
2393 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
2394 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08lx\n", hres
);
2395 ok_(__FILE__
,line
) (idx
== index
, "idx=%ld, expected %ld\n", idx
, index
);
2398 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
2399 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, LONG index
)
2403 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
2404 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08lx\n", hres
);
2405 _test_select_selidx(line
, select
, index
);
2408 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
2409 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const WCHAR
*exval
)
2414 hres
= IHTMLSelectElement_get_value(select
, &val
);
2415 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08lx\n", hres
);
2417 ok_(__FILE__
,line
) (!lstrcmpW(val
, exval
), "unexpected value %s\n", wine_dbgstr_w(val
));
2419 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", wine_dbgstr_w(val
));
2423 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
2424 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const WCHAR
*val
)
2429 bstr
= SysAllocString(val
);
2430 hres
= IHTMLSelectElement_put_value(select
, bstr
);
2431 SysFreeString(bstr
);
2432 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08lx\n", hres
);
2435 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
2436 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const WCHAR
*extype
)
2441 hres
= IHTMLSelectElement_get_type(select
, &type
);
2442 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08lx\n", hres
);
2443 ok_(__FILE__
,line
) (!lstrcmpW(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), wine_dbgstr_w(extype
));
2444 SysFreeString(type
);
2447 #define test_select_multiple(s,t) _test_select_multiple(__LINE__,s,t)
2448 static void _test_select_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exmultiple
)
2450 VARIANT_BOOL b
= 100;
2453 hres
= IHTMLSelectElement_get_multiple(select
, &b
);
2454 ok_(__FILE__
,line
) (hres
== S_OK
, "get_multiple failed: %08lx\n", hres
);
2455 ok_(__FILE__
,line
) (b
== exmultiple
, "multiple=%x, expected %x\n", b
, exmultiple
);
2458 #define test_select_set_multiple(s,v) _test_select_set_multiple(__LINE__,s,v)
2459 static void _test_select_set_multiple(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL val
)
2463 hres
= IHTMLSelectElement_put_multiple(select
, val
);
2464 ok_(__FILE__
,line
) (hres
== S_OK
, "put_multiple failed: %08lx\n", hres
);
2466 _test_select_multiple(line
, select
, val
);
2469 #define test_select_size(s,v) _test_select_size(__LINE__,s,v)
2470 static void _test_select_size(unsigned line
, IHTMLSelectElement
*select
, LONG exval
)
2475 hres
= IHTMLSelectElement_get_size(select
, NULL
);
2476 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "got %08lx, expected E_INVALIDARG\n", hres
);
2479 hres
= IHTMLSelectElement_get_size(select
, &val
);
2480 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08lx\n", hres
);
2481 ok_(__FILE__
,line
) (val
== exval
, "size = %ld, expected %ld\n", val
, exval
);
2484 #define test_select_set_size(s,v,e) _test_select_set_size(__LINE__,s,v,e)
2485 static void _test_select_set_size(unsigned line
, IHTMLSelectElement
*select
, LONG val
, HRESULT exhres
)
2489 hres
= IHTMLSelectElement_put_size(select
, val
);
2490 ok_(__FILE__
,line
) (hres
== exhres
, "put_size(%ld) got %08lx, expect %08lx\n", val
, hres
, exhres
);
2493 #define test_select_name(s,v) _test_select_name(__LINE__,s,v)
2494 static void _test_select_name(unsigned line
, IHTMLSelectElement
*select
, const WCHAR
*extext
)
2500 hres
= IHTMLSelectElement_get_name(select
, &text
);
2501 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08lx\n", hres
);
2503 ok_(__FILE__
,line
) (text
!= NULL
, "text == NULL\n");
2504 ok_(__FILE__
,line
) (!lstrcmpW(text
, extext
), "name = %s, expected %s\n",
2505 wine_dbgstr_w(text
), wine_dbgstr_w(extext
));
2506 SysFreeString(text
);
2508 ok_(__FILE__
,line
) (text
== NULL
, "text(%p) = %s\n", text
, wine_dbgstr_w(text
));
2511 #define test_select_set_name(s,v) _test_select_set_name(__LINE__,s,v)
2512 static void _test_select_set_name(unsigned line
, IHTMLSelectElement
*select
, const WCHAR
*text
)
2517 bstr
= SysAllocString(text
);
2519 hres
= IHTMLSelectElement_put_name(select
, bstr
);
2520 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name(%s) failed: %08lx\n", wine_dbgstr_w(bstr
), hres
);
2521 SysFreeString(bstr
);
2524 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
2525 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const WCHAR
*extext
)
2530 hres
= IHTMLTxtRange_get_text(range
, &text
);
2531 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08lx\n", hres
);
2534 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
2535 ok_(__FILE__
, line
) (!lstrcmpW(text
, extext
), "text=%s, expected %s\n", wine_dbgstr_w(text
), wine_dbgstr_w(extext
));
2537 ok_(__FILE__
, line
) (text
== NULL
, "text=%s, expected NULL\n", wine_dbgstr_w(text
));
2540 SysFreeString(text
);
2544 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
2545 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
2549 hres
= IHTMLTxtRange_collapse(range
, b
);
2550 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08lx\n", hres
);
2551 _test_range_text(line
, range
, NULL
);
2554 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
2555 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
2556 VARIANT_BOOL exb
, const WCHAR
*extext
)
2558 VARIANT_BOOL b
= 0xe0e0;
2561 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
2562 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08lx\n", hres
);
2563 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
2564 _test_range_text(line
, range
, extext
);
2567 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
2568 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2570 LONG c
= 0xdeadbeef;
2573 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
2574 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08lx\n", hres
);
2575 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
2576 _test_range_text(line
, range
, NULL
);
2579 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
2580 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
2581 LPWSTR unit
, LONG cnt
, LONG excnt
)
2583 LONG c
= 0xdeadbeef;
2586 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
2587 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08lx\n", hres
);
2588 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
2591 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
2592 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, LONG cnt
, LONG excnt
)
2594 LONG c
= 0xdeadbeef;
2597 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
2598 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08lx\n", hres
);
2599 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
2602 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
2603 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const WCHAR
*text
)
2606 BSTR bstr
= SysAllocString(text
);
2608 hres
= IHTMLTxtRange_put_text(range
, bstr
);
2609 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08lx\n", hres
);
2610 SysFreeString(bstr
);
2611 _test_range_text(line
, range
, NULL
);
2614 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
2615 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2621 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
2622 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08lx\n", hres
);
2623 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2626 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
2627 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
2633 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
2634 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08lx\n", hres
);
2635 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
2638 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
2639 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08lx\n", hres
);
2640 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
2643 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
2644 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
2648 #define test_range_paste_html(a,b) _test_range_paste_html(__LINE__,a,b)
2649 static void _test_range_paste_html(unsigned line
, IHTMLTxtRange
*range
, const WCHAR
*html
)
2651 BSTR str
= SysAllocString(html
);
2654 hres
= IHTMLTxtRange_pasteHTML(range
, str
);
2655 ok_(__FILE__
,line
)(hres
== S_OK
, "pasteHTML failed: %08lx\n", hres
);
2659 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
2660 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
2665 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
2666 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08lx\n", hres
);
2668 _test_elem_type(line
, (IUnknown
*)elem
, type
);
2670 IHTMLElement_Release(elem
);
2673 #define get_elem_col_item_idx(a,b) _get_elem_col_item_idx(__LINE__,a,b)
2674 static IHTMLElement
*_get_elem_col_item_idx(unsigned line
, IHTMLElementCollection
*col
, int i
)
2676 VARIANT name
, index
;
2681 V_VT(&index
) = VT_EMPTY
;
2682 V_VT(&name
) = VT_I4
;
2684 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2685 ok_(__FILE__
,line
)(hres
== S_OK
, "item failed: %08lx\n", hres
);
2686 ok_(__FILE__
,line
)(disp
!= NULL
, "disp == NULL\n");
2688 elem
= _get_elem_iface(line
, (IUnknown
*)disp
);
2689 IDispatch_Release(disp
);
2693 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
2694 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
2695 const elem_type_t
*elem_types
, LONG exlen
)
2697 IHTMLElementCollection
*col
;
2698 IEnumVARIANT
*enum_var
;
2703 VARIANT name
, index
, v
, vs
[5];
2704 IDispatch
*disp
, *disp2
;
2707 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
2708 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08lx\n", hres
);
2710 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
, NULL
, L
"[object]");
2712 hres
= IHTMLElementCollection_get_length(col
, &len
);
2713 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08lx\n", hres
);
2714 ok_(__FILE__
,line
) (len
== exlen
, "len=%ld, expected %ld\n", len
, exlen
);
2719 V_VT(&index
) = VT_EMPTY
;
2721 hres
= IHTMLElementCollection_get__newEnum(col
, &enum_unk
);
2722 ok_(__FILE__
,line
)(hres
== S_OK
, "_newEnum failed: %08lx\n", hres
);
2724 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
2725 IUnknown_Release(enum_unk
);
2726 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
2728 for(i
=0; i
<len
; i
++) {
2729 V_VT(&name
) = VT_I4
;
2731 disp
= (void*)0xdeadbeef;
2732 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2733 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%ld) failed: %08lx\n", i
, hres
);
2734 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
2735 if(FAILED(hres
) || !disp
)
2738 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
2741 V_VT(&name
) = VT_UINT
;
2743 disp2
= (void*)0xdeadbeef;
2744 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp2
);
2745 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%ld) failed: %08lx\n", i
, hres
);
2746 ok_(__FILE__
,line
) (iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
2748 IDispatch_Release(disp2
);
2752 V_VT(&v
) = VT_ERROR
;
2753 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
2754 ok_(__FILE__
,line
)(hres
== S_OK
, "Next failed: %08lx\n", hres
);
2756 ok_(__FILE__
,line
)(fetched
== 1, "fetched = %ld\n", fetched
);
2757 ok_(__FILE__
,line
)(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
2758 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)disp
, (IUnknown
*)V_DISPATCH(&v
)), "disp != V_DISPATCH(v)\n");
2759 IDispatch_Release(V_DISPATCH(&v
));
2761 IDispatch_Release(disp
);
2764 fetched
= 0xdeadbeef;
2766 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
2767 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next returned %08lx, expected S_FALSE\n", hres
);
2768 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %ld\n", fetched
);
2769 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2771 hres
= IEnumVARIANT_Reset(enum_var
);
2772 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08lx\n", hres
);
2774 fetched
= 0xdeadbeef;
2776 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
2777 ok_(__FILE__
,line
)(hres
== S_OK
, "Next returned %08lx, expected S_FALSE\n", hres
);
2778 ok_(__FILE__
,line
)(fetched
== 0, "fetched = %ld\n", fetched
);
2779 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
2781 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
2782 ok_(__FILE__
,line
)(hres
== S_OK
, "Skip failed: %08lx\n", hres
);
2784 memset(vs
, 0, sizeof(vs
));
2786 hres
= IEnumVARIANT_Next(enum_var
, ARRAY_SIZE(vs
), vs
, &fetched
);
2787 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Next failed: %08lx\n", hres
);
2788 ok_(__FILE__
,line
)(fetched
== (len
> 2 ? 2 : len
), "fetched = %ld\n", fetched
);
2790 ok_(__FILE__
,line
)(V_VT(vs
) == VT_DISPATCH
&& V_DISPATCH(vs
), "V_VT(vs[0]) = %d\n", V_VT(vs
));
2791 IDispatch_Release(V_DISPATCH(vs
));
2794 ok_(__FILE__
,line
)(V_VT(vs
+1) == VT_DISPATCH
&& V_DISPATCH(vs
+1), "V_VT(vs[1]) = %d\n", V_VT(vs
+1));
2795 IDispatch_Release(V_DISPATCH(vs
+1));
2798 hres
= IEnumVARIANT_Reset(enum_var
);
2799 ok_(__FILE__
,line
)(hres
== S_OK
, "Reset failed: %08lx\n", hres
);
2801 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
2802 ok_(__FILE__
,line
)(hres
== S_FALSE
, "Skip failed: %08lx\n", hres
);
2804 IEnumVARIANT_Release(enum_var
);
2806 V_VT(&name
) = VT_I4
;
2808 disp
= (void*)0xdeadbeef;
2809 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2810 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08lx\n", hres
);
2811 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2813 V_VT(&name
) = VT_UI4
;
2815 disp
= (void*)0xdeadbeef;
2816 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2817 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08lx\n", hres
);
2818 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2820 V_VT(&name
) = VT_INT
;
2822 disp
= (void*)0xdeadbeef;
2823 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2824 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08lx\n", hres
);
2825 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2827 V_VT(&name
) = VT_UINT
;
2829 disp
= (void*)0xdeadbeef;
2830 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2831 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08lx\n", hres
);
2832 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2834 V_VT(&name
) = VT_I4
;
2836 disp
= (void*)0xdeadbeef;
2837 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
2838 if(compat_mode
< COMPAT_IE9
)
2839 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
2841 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08lx\n", hres
);
2842 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
2844 IHTMLElementCollection_Release(col
);
2847 #define test_elem_all(c,t,l) _test_elem_all(__LINE__,c,t,l)
2848 static void _test_elem_all(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
, LONG exlen
)
2850 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
2854 hres
= IHTMLElement_get_all(elem
, &disp
);
2855 IHTMLElement_Release(elem
);
2856 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
2858 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, exlen
);
2859 IDispatch_Release(disp
);
2862 #define test_doc_all(a,b,c) _test_doc_all(__LINE__,a,b,c)
2863 static void _test_doc_all(unsigned line
, IHTMLDocument2
*doc
, const elem_type_t
*elem_types
, LONG exlen
)
2865 IHTMLElementCollection
*col
;
2868 hres
= IHTMLDocument2_get_all(doc
, &col
);
2869 ok_(__FILE__
,line
)(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
2871 _test_elem_collection(line
, (IUnknown
*)col
, elem_types
, exlen
);
2872 IHTMLElementCollection_Release(col
);
2875 #define test_children_collection_length(a,b) _test_children_collection_length(__LINE__,a,b)
2876 static LONG
_test_children_collection_length(unsigned line
, IHTMLDOMChildrenCollection
*collection
, LONG exlen
)
2881 hres
= IHTMLDOMChildrenCollection_get_length(collection
, &length
);
2882 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
2884 ok_(__FILE__
,line
)(length
== exlen
, "length = %ld, expected %ld\n", length
, exlen
);
2889 #define test_elem_getelembytag(a,b,c,d) _test_elem_getelembytag(__LINE__,a,b,c,d)
2890 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, LONG exlen
, IHTMLElement
**ret
)
2892 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
2893 IHTMLElementCollection
*col
= NULL
;
2894 elem_type_t
*types
= NULL
;
2899 tmp
= SysAllocString(elem_type_infos
[type
].tag
);
2900 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
2902 IHTMLElement2_Release(elem
);
2903 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08lx\n", hres
);
2904 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2907 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2908 for(i
=0; i
<exlen
; i
++)
2912 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2914 HeapFree(GetProcessHeap(), 0, types
);
2917 *ret
= get_elem_col_item_idx(col
, 0);
2918 IHTMLElementCollection_Release(col
);
2921 #define test_doc_getelembytag(a,b,c,d) _test_doc_getelembytag(__LINE__,a,b,c,d)
2922 static void _test_doc_getelembytag(unsigned line
, IHTMLDocument2
*unk
, const char *tag
, elem_type_t type
, LONG exlen
)
2924 IHTMLDocument3
*doc
= _get_doc3_iface(line
, unk
);
2925 IHTMLElementCollection
*col
= NULL
;
2926 elem_type_t
*types
= NULL
;
2931 tmp
= SysAllocString(elem_type_infos
[type
].tag
);
2932 hres
= IHTMLDocument3_getElementsByTagName(doc
, tmp
, &col
);
2934 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08lx\n", hres
);
2935 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
2938 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
2939 for(i
=0; i
<exlen
; i
++)
2943 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
2945 HeapFree(GetProcessHeap(), 0, types
);
2946 IHTMLElementCollection_Release(col
);
2947 IHTMLDocument3_Release(doc
);
2950 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
2951 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const WCHAR
*extext
)
2956 hres
= IHTMLElement_get_innerText(elem
, &text
);
2957 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08lx\n", hres
);
2959 ok_(__FILE__
,line
) (!lstrcmpW(text
, extext
), "get_innerText returned %s expected %s\n",
2960 wine_dbgstr_w(text
), wine_dbgstr_w(extext
));
2962 ok_(__FILE__
,line
) (!text
, "get_innerText returned %s expected NULL\n", wine_dbgstr_w(text
));
2963 SysFreeString(text
);
2966 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
2967 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const WCHAR
*text
)
2969 IHTMLDOMChildrenCollection
*col
;
2973 str
= SysAllocString(text
);
2974 hres
= IHTMLElement_put_innerText(elem
, str
);
2975 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08lx\n", hres
);
2978 _test_elem_innertext(line
, elem
, text
);
2981 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
2982 ok(col
!= NULL
, "col == NULL\n");
2987 _test_children_collection_length(line
, col
, 1);
2989 node
= _get_child_item(line
, col
, 0);
2990 ok(node
!= NULL
, "node == NULL\n");
2992 type
= _get_node_type(line
, (IUnknown
*)node
);
2993 ok(type
== 3, "type=%ld\n", type
);
2994 IHTMLDOMNode_Release(node
);
2997 IHTMLDOMChildrenCollection_Release(col
);
3002 #define test_elem_outertext(e,t) _test_elem_outertext(__LINE__,e,t)
3003 static void _test_elem_outertext(unsigned line
, IHTMLElement
*elem
, const WCHAR
*extext
)
3008 hres
= IHTMLElement_get_outerText(elem
, &text
);
3009 ok_(__FILE__
,line
) (hres
== S_OK
, "get_outerText failed: %08lx\n", hres
);
3011 ok_(__FILE__
,line
) (!lstrcmpW(text
, extext
), "get_outerText returned %s expected %s\n",
3012 wine_dbgstr_w(text
), wine_dbgstr_w(extext
));
3014 ok_(__FILE__
,line
) (!text
, "get_outerText returned %s expected NULL\n", wine_dbgstr_w(text
));
3015 SysFreeString(text
);
3018 #define test_elem_set_outertext(e,t) _test_elem_set_outertext(__LINE__,e,t)
3019 static void _test_elem_set_outertext(unsigned line
, IHTMLElement
*elem
, const WCHAR
*text
)
3021 BSTR str
= SysAllocString(text
);
3024 hres
= IHTMLElement_put_outerText(elem
, str
);
3025 ok_(__FILE__
,line
) (hres
== S_OK
, "put_outerText failed: %08lx\n", hres
);
3029 #define test_elem_set_outertext_fail(a) _test_elem_set_outertext_fail(__LINE__,a)
3030 static void _test_elem_set_outertext_fail(unsigned line
, IHTMLElement
*elem
)
3032 BSTR str
= SysAllocString(L
"test");
3035 hres
= IHTMLElement_put_outerText(elem
, str
);
3036 ok_(__FILE__
,line
) (hres
== 0x800a0258, "put_outerText failed: %08lx\n", hres
);
3040 #define test_elem_innerhtml(e,t) _test_elem_innerhtml(__LINE__,e,t)
3041 static void _test_elem_innerhtml(unsigned line
, IUnknown
*unk
, const WCHAR
*inner_html
)
3043 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3047 hres
= IHTMLElement_get_innerHTML(elem
, &html
);
3048 ok_(__FILE__
,line
)(hres
== S_OK
, "get_innerHTML failed: %08lx\n", hres
);
3050 ok_(__FILE__
,line
)(!lstrcmpW(html
, inner_html
), "unexpected innerHTML: %s\n", wine_dbgstr_w(html
));
3052 ok_(__FILE__
,line
)(!html
, "innerHTML = %s\n", wine_dbgstr_w(html
));
3054 IHTMLElement_Release(elem
);
3055 SysFreeString(html
);
3058 #define test_elem_set_innerhtml(e,t) _test_elem_set_innerhtml(__LINE__,e,t)
3059 static void _test_elem_set_innerhtml(unsigned line
, IUnknown
*unk
, const WCHAR
*inner_html
)
3061 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3065 html
= SysAllocString(inner_html
);
3066 hres
= IHTMLElement_put_innerHTML(elem
, html
);
3067 ok_(__FILE__
,line
)(hres
== S_OK
, "put_innerHTML failed: %08lx\n", hres
);
3069 IHTMLElement_Release(elem
);
3070 SysFreeString(html
);
3073 #define test_elem_set_outerhtml(e,t) _test_elem_set_outerhtml(__LINE__,e,t)
3074 static void _test_elem_set_outerhtml(unsigned line
, IUnknown
*unk
, const WCHAR
*outer_html
)
3076 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3080 html
= SysAllocString(outer_html
);
3081 hres
= IHTMLElement_put_outerHTML(elem
, html
);
3082 ok_(__FILE__
,line
)(hres
== S_OK
, "put_outerHTML failed: %08lx\n", hres
);
3084 IHTMLElement_Release(elem
);
3085 SysFreeString(html
);
3088 #define test_elem_outerhtml(e,t) _test_elem_outerhtml(__LINE__,e,t)
3089 static void _test_elem_outerhtml(unsigned line
, IUnknown
*unk
, const WCHAR
*outer_html
)
3091 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3096 hres
= IHTMLElement_get_outerHTML(elem
, &html
);
3097 ok_(__FILE__
,line
)(hres
== S_OK
, "get_outerHTML failed: %08lx\n", hres
);
3098 if((p
= wcsstr(outer_html
, L
"-->")) && !p
[3] && SysStringLen(html
) == p
- outer_html
) /* Some IEs drop comment ending */
3099 ok_(__FILE__
,line
)(!wcsncmp(html
, outer_html
, p
- outer_html
), "text = \"%s\", expected \"%s\"\n",
3100 wine_dbgstr_w(html
), wine_dbgstr_w(outer_html
));
3102 ok_(__FILE__
,line
)(!lstrcmpW(html
, outer_html
), "outerHTML = %s, expected %s\n", wine_dbgstr_w(html
), wine_dbgstr_w(outer_html
));
3104 IHTMLElement_Release(elem
);
3105 SysFreeString(html
);
3108 #define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
3109 static void _test_elem_contains(unsigned line
, IHTMLElement
*elem
, IHTMLElement
*elem2
, VARIANT_BOOL exval
)
3115 hres
= IHTMLElement_contains(elem
, elem2
, &b
);
3116 ok_(__FILE__
,line
)(hres
== S_OK
, "contains failed: %08lx\n", hres
);
3117 ok_(__FILE__
,line
)(b
== exval
, "contains returned %x, expected %x\n", b
, exval
);
3120 #define test_elem_istextedit(a,b) _test_elem_istextedit(__LINE__,a,b)
3121 static void _test_elem_istextedit(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exval
)
3127 hres
= IHTMLElement_get_isTextEdit(elem
, &b
);
3128 ok_(__FILE__
,line
)(hres
== S_OK
, "isTextEdit failed: %08lx\n", hres
);
3129 ok_(__FILE__
,line
)(b
== exval
, "isTextEdit = %x\n", b
);
3132 #define get_first_child(n) _get_first_child(__LINE__,n)
3133 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
3135 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3136 IHTMLDOMNode
*child
= NULL
;
3139 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
3140 IHTMLDOMNode_Release(node
);
3141 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08lx\n", hres
);
3146 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
3147 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3149 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3150 VARIANT_BOOL b
= 0xdead;
3153 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
3154 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08lx\n", hres
);
3155 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
3157 IHTMLDOMNode_Release(node
);
3160 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
3161 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
3163 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3164 IHTMLDOMNode
*parent
;
3167 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
3168 IHTMLDOMNode_Release(node
);
3169 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08lx\n", hres
);
3174 #define node_get_next(u) _node_get_next(__LINE__,u)
3175 static IHTMLDOMNode
*_node_get_next(unsigned line
, IUnknown
*unk
)
3177 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3181 hres
= IHTMLDOMNode_get_nextSibling(node
, &next
);
3182 IHTMLDOMNode_Release(node
);
3183 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nextSiblibg failed: %08lx\n", hres
);
3188 #define node_get_prev(u) _node_get_prev(__LINE__,u)
3189 static IHTMLDOMNode
*_node_get_prev(unsigned line
, IUnknown
*unk
)
3191 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
3195 hres
= IHTMLDOMNode_get_previousSibling(node
, &prev
);
3196 IHTMLDOMNode_Release(node
);
3197 ok_(__FILE__
,line
) (hres
== S_OK
, "get_previousSibling failed: %08lx\n", hres
);
3202 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
3203 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
3205 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3206 IHTMLElement
*parent
;
3209 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
3210 IHTMLElement_Release(elem
);
3211 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08lx\n", hres
);
3216 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
3217 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
3219 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3220 VARIANT_BOOL disabled
= 100;
3224 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
3225 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
3226 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3227 IHTMLElement3_Release(elem3
);
3230 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
3231 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
3233 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
3237 hres
= IHTMLElement3_put_disabled(elem3
, b
);
3238 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
3240 IHTMLElement3_Release(elem3
);
3241 _test_elem3_get_disabled(line
, unk
, b
);
3244 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
3245 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
3247 VARIANT_BOOL disabled
= 100;
3250 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
3251 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
3252 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
3254 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
3257 static void test_select_remove(IHTMLSelectElement
*select
)
3261 hres
= IHTMLSelectElement_remove(select
, 3);
3262 ok(hres
== S_OK
, "remove failed: %08lx, expected S_OK\n", hres
);
3263 test_select_length(select
, 2);
3265 hres
= IHTMLSelectElement_remove(select
, -1);
3266 ok(hres
== E_INVALIDARG
, "remove failed: %08lx, expected E_INVALIDARG\n", hres
);
3267 test_select_length(select
, 2);
3269 hres
= IHTMLSelectElement_remove(select
, 0);
3270 ok(hres
== S_OK
, "remove failed:%08lx\n", hres
);
3271 test_select_length(select
, 1);
3274 #define test_text_length(u,l) _test_text_length(__LINE__,u,l)
3275 static void _test_text_length(unsigned line
, IUnknown
*unk
, LONG l
)
3277 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3281 hres
= IHTMLDOMTextNode_get_length(text
, &length
);
3282 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
3283 ok_(__FILE__
,line
)(length
== l
, "length = %ld, expected %ld\n", length
, l
);
3284 IHTMLDOMTextNode_Release(text
);
3287 #define test_text_data(a,b) _test_text_data(__LINE__,a,b)
3288 static void _test_text_data(unsigned line
, IUnknown
*unk
, const WCHAR
*exdata
)
3290 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3294 hres
= IHTMLDOMTextNode_get_data(text
, &str
);
3295 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08lx\n", hres
);
3296 ok_(__FILE__
,line
)(!lstrcmpW(str
, exdata
), "data = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exdata
));
3297 IHTMLDOMTextNode_Release(text
);
3301 #define set_text_data(a,b) _set_text_data(__LINE__,a,b)
3302 static void _set_text_data(unsigned line
, IUnknown
*unk
, const WCHAR
*data
)
3304 IHTMLDOMTextNode
*text
= _get_text_iface(line
, unk
);
3305 BSTR str
= SysAllocString(data
);
3308 hres
= IHTMLDOMTextNode_put_data(text
, str
);
3309 ok_(__FILE__
,line
)(hres
== S_OK
, "get_data failed: %08lx\n", hres
);
3310 IHTMLDOMTextNode_Release(text
);
3314 #define text_append_data(a,b) _text_append_data(__LINE__,a,b)
3315 static void _text_append_data(unsigned line
, IUnknown
*unk
, const WCHAR
*data
)
3317 IHTMLDOMTextNode2
*text
= _get_text2_iface(line
, unk
);
3318 BSTR str
= SysAllocString(data
);
3321 hres
= IHTMLDOMTextNode2_appendData(text
, str
);
3322 ok_(__FILE__
,line
)(hres
== S_OK
, "appendData failed: %08lx\n", hres
);
3323 IHTMLDOMTextNode2_Release(text
);
3327 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
3328 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
3332 hres
= IHTMLSelectElement_put_disabled(select
, b
);
3333 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
3335 _test_select_get_disabled(line
, select
, b
);
3338 #define test_elem_dir(u,n) _test_elem_dir(__LINE__,u,n)
3339 static void _test_elem_dir(unsigned line
, IUnknown
*unk
, const WCHAR
*exdir
)
3341 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3345 hres
= IHTMLElement2_get_dir(elem
, &dir
);
3346 IHTMLElement2_Release(elem
);
3347 ok_(__FILE__
, line
) (hres
== S_OK
, "get_dir failed: %08lx\n", hres
);
3349 ok_(__FILE__
, line
) (!lstrcmpW(dir
, exdir
), "got dir: %s, expected %s\n", wine_dbgstr_w(dir
), wine_dbgstr_w(exdir
));
3351 ok_(__FILE__
, line
) (!dir
, "got dir: %s, expected NULL\n", wine_dbgstr_w(dir
));
3356 #define set_elem_dir(u,n) _set_elem_dir(__LINE__,u,n)
3357 static void _set_elem_dir(unsigned line
, IUnknown
*unk
, const WCHAR
*d
)
3359 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3360 BSTR dir
= SysAllocString(d
);
3363 hres
= IHTMLElement2_put_dir(elem
, dir
);
3364 IHTMLElement2_Release(elem
);
3365 ok_(__FILE__
, line
) (hres
== S_OK
, "put_dir failed: %08lx\n", hres
);
3368 _test_elem_dir(line
, unk
, d
);
3371 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
3372 static LONG
_elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
3374 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3375 IHTMLTextContainer
*txtcont
;
3376 LONG l
= -1, l2
= -1;
3379 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
3380 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08lx\n", hres
);
3381 IHTMLElement2_Release(elem
);
3383 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3384 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08lx\n", hres
);
3386 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
3387 IHTMLTextContainer_Release(txtcont
);
3388 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %ld\n", l2
);
3389 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %ld, expected %ld\n", l2
, l
);
3394 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
3395 static LONG
_elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
3397 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3398 IHTMLTextContainer
*txtcont
;
3399 LONG l
= -1, l2
= -1;
3402 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
3403 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08lx\n", hres
);
3404 IHTMLElement2_Release(elem
);
3406 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3407 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08lx\n", hres
);
3409 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
3410 IHTMLTextContainer_Release(txtcont
);
3411 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %ld\n", l2
);
3412 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %ld, expected %ld\n", l2
, l
);
3417 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
3418 static LONG
_elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
3420 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3421 IHTMLTextContainer
*txtcont
;
3422 LONG l
= -1, l2
= -1;
3425 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
3426 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08lx\n", hres
);
3427 IHTMLElement2_Release(elem
);
3429 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3430 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08lx\n", hres
);
3432 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
3433 IHTMLTextContainer_Release(txtcont
);
3434 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %ld\n", l2
);
3435 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %ld, expected %ld\n", l2
, l
);
3440 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
3441 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
3443 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
3444 IHTMLTextContainer
*txtcont
;
3445 LONG l
= -1, l2
= -1;
3448 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
3449 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08lx\n", hres
);
3451 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
3452 ok(hres
== S_OK
, "get_scrollTop failed: %08lx\n", hres
);
3453 IHTMLElement2_Release(elem
);
3455 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
3456 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08lx\n", hres
);
3458 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
3459 IHTMLTextContainer_Release(txtcont
);
3460 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %ld\n", l2
);
3461 ok(l
== l2
, "unexpected left %ld, expected %ld\n", l2
, l
);
3464 #define test_img_src(a,b,c) _test_img_src(__LINE__,a,b,c)
3465 static void _test_img_src(unsigned line
, IUnknown
*unk
, const WCHAR
*exsrc
, const WCHAR
*broken_src
)
3467 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3471 hres
= IHTMLImgElement_get_src(img
, &src
);
3472 IHTMLImgElement_Release(img
);
3473 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08lx\n", hres
);
3474 ok_(__FILE__
,line
) (!lstrcmpW(src
, exsrc
) || (broken_src
&& broken(!lstrcmpW(src
, broken_src
))),
3475 "get_src returned %s expected %s\n", wine_dbgstr_w(src
), wine_dbgstr_w(exsrc
));
3479 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
3480 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const WCHAR
*src
)
3482 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3486 tmp
= SysAllocString(src
);
3487 hres
= IHTMLImgElement_put_src(img
, tmp
);
3488 IHTMLImgElement_Release(img
);
3490 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08lx\n", hres
);
3493 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
3494 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const WCHAR
*exalt
)
3496 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3500 hres
= IHTMLImgElement_get_alt(img
, &alt
);
3501 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08lx\n", hres
);
3503 ok_(__FILE__
,line
) (!lstrcmpW(alt
, exalt
), "unexpected alt %s\n", wine_dbgstr_w(alt
));
3505 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
3506 IHTMLImgElement_Release(img
);
3510 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
3511 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const WCHAR
*alt
)
3513 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3517 tmp
= SysAllocString(alt
);
3518 hres
= IHTMLImgElement_put_alt(img
, tmp
);
3519 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08lx\n", hres
);
3520 IHTMLImgElement_Release(img
);
3523 _test_img_alt(line
, unk
, alt
);
3526 #define test_img_align(u,a) _test_img_align(__LINE__,u,a)
3527 static void _test_img_align(unsigned line
, IUnknown
*unk
, const WCHAR
*align
)
3529 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3533 tmp
= SysAllocString(align
);
3534 hres
= IHTMLImgElement_put_align(img
, tmp
);
3535 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08lx\n", hres
);
3538 hres
= IHTMLImgElement_get_align(img
, &tmp
);
3539 ok_(__FILE__
,line
) (hres
== S_OK
, "put_align failed: %08lx\n", hres
);
3540 ok_(__FILE__
,line
) (!lstrcmpW(tmp
, align
), "Expect %s, got %s\n", wine_dbgstr_w(align
), wine_dbgstr_w(tmp
));
3541 IHTMLImgElement_Release(img
);
3545 #define test_img_name(u, c) _test_img_name(__LINE__,u, c)
3546 static void _test_img_name(unsigned line
, IUnknown
*unk
, const WCHAR
*pValue
)
3548 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3552 hres
= IHTMLImgElement_get_name(img
, &sName
);
3553 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Name failed: %08lx\n", hres
);
3554 ok_(__FILE__
,line
) (!lstrcmpW (sName
, pValue
), "expected %s got %s\n", wine_dbgstr_w(pValue
), wine_dbgstr_w(sName
));
3555 IHTMLImgElement_Release(img
);
3556 SysFreeString(sName
);
3559 #define test_img_complete(a,b) _test_img_complete(__LINE__,a,b)
3560 static void _test_img_complete(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
3562 IHTMLImgElement
*img
= _get_img_iface(line
, (IUnknown
*)elem
);
3563 VARIANT_BOOL b
= 100;
3566 hres
= IHTMLImgElement_get_complete(img
, &b
);
3567 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08lx\n", hres
);
3568 ok_(__FILE__
,line
) (b
== exb
, "complete = %x, expected %x\n", b
, exb
);
3569 IHTMLImgElement_Release(img
);
3572 #define test_img_isMap(u, c) _test_img_isMap(__LINE__,u, c)
3573 static void _test_img_isMap(unsigned line
, IUnknown
*unk
, VARIANT_BOOL v
)
3575 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
3576 VARIANT_BOOL b
= 100;
3579 hres
= IHTMLImgElement_put_isMap(img
, v
);
3580 ok_(__FILE__
,line
) (hres
== S_OK
, "put_isMap failed: %08lx\n", hres
);
3582 hres
= IHTMLImgElement_get_isMap(img
, &b
);
3583 ok_(__FILE__
,line
) (hres
== S_OK
, "get_isMap failed: %08lx\n", hres
);
3584 ok_(__FILE__
,line
) (b
== v
, "isMap = %x, expected %x\n", b
, v
);
3586 hres
= IHTMLImgElement_get_isMap(img
, NULL
);
3587 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "ret = %08lx, expected E_INVALIDARG\n", hres
);
3588 IHTMLImgElement_Release(img
);
3591 static void test_dynamic_properties(IHTMLElement
*elem
)
3593 static const WCHAR attr1W
[] = {'a','t','t','r','1',0};
3594 IDispatchEx
*dispex
;
3595 BSTR name
, attr1
= SysAllocString(attr1W
);
3599 DISPID id
= DISPID_STARTENUM
;
3602 hres
= IHTMLElement_QueryInterface(elem
, &IID_IDispatchEx
, (void**)&dispex
);
3603 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
3605 hres
= IHTMLElement_removeAttribute(elem
, attr1
, 0, &succ
);
3606 ok(hres
== S_OK
, "removeAttribute failed: %08lx\n", hres
);
3607 ok(succ
, "removeAttribute set succ to FALSE\n");
3610 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumAll
, id
, &id
);
3611 ok(hres
==S_OK
|| hres
==S_FALSE
, "GetNextDispID failed: %08lx\n", hres
);
3615 hres
= IDispatchEx_GetMemberName(dispex
, id
, &name
);
3616 ok(hres
== S_OK
, "GetMemberName failed: %08lx\n", hres
);
3618 if(!lstrcmpW(name
, L
"attr1"))
3619 ok(0, "attr1 should be removed\n");
3620 else if(!lstrcmpW(name
, L
"attr2") || !lstrcmpW(name
, L
"attr3"))
3622 SysFreeString(name
);
3624 ok(checked_no
== 2, "checked_no=%d, expected 2\n", checked_no
);
3625 IDispatchEx_Release(dispex
);
3627 V_VT(&val
) = VT_BSTR
;
3628 V_BSTR(&val
) = attr1
;
3629 hres
= IHTMLElement_setAttribute(elem
, attr1
, val
, 0);
3630 ok(hres
== S_OK
, "setAttribute failed: %08lx\n", hres
);
3631 SysFreeString(attr1
);
3634 #define test_attr_node_name(a,b) _test_attr_node_name(__LINE__,a,b)
3635 static void _test_attr_node_name(unsigned line
, IHTMLDOMAttribute
*attr
, const WCHAR
*exname
)
3637 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3641 hres
= IHTMLDOMAttribute_get_nodeName(attr
, &str
);
3642 ok_(__FILE__
,line
)(hres
== S_OK
, "get_nodeName failed: %08lx\n", hres
);
3643 ok_(__FILE__
,line
)(!lstrcmpW(str
, exname
), "node name is %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exname
));
3646 hres
= IHTMLDOMAttribute2_get_name(attr2
, &str
);
3647 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
3648 ok_(__FILE__
,line
)(!lstrcmpW(str
, exname
), "name is %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exname
));
3651 IHTMLDOMAttribute2_Release(attr2
);
3654 #define test_attr_parent(a) _test_attr_parent(__LINE__,a)
3655 static void _test_attr_parent(unsigned line
, IHTMLDOMAttribute
*attr
)
3657 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
3658 IHTMLDOMNode
*parent
= (void*)0xdeadbeef;
3661 hres
= IHTMLDOMAttribute2_get_parentNode(attr2
, &parent
);
3662 ok_(__FILE__
,line
)(hres
== S_OK
, "get_parentNode failed: %08lx\n", hres
);
3663 ok_(__FILE__
,line
)(!parent
, "parent != NULL\n");
3664 IHTMLDOMAttribute2_Release(attr2
);
3667 static LONG
test_attr_collection_attr(IDispatch
*attr
, LONG i
)
3669 IHTMLDOMAttribute
*dom_attr
;
3675 hres
= IDispatch_QueryInterface(attr
, &IID_IHTMLDOMAttribute
, (void**)&dom_attr
);
3676 ok(hres
== S_OK
, "%ld) QueryInterface failed: %08lx\n", i
, hres
);
3678 hres
= IHTMLDOMAttribute_get_nodeName(dom_attr
, &name
);
3679 ok(hres
== S_OK
, "%ld) get_nodeName failed: %08lx\n", i
, hres
);
3681 if(!lstrcmpW(name
, L
"id")) {
3682 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3683 ok(hres
== S_OK
, "%ld) get_nodeValue failed: %08lx\n", i
, hres
);
3684 ok(V_VT(&val
) == VT_BSTR
, "id: V_VT(&val) = %d\n", V_VT(&val
));
3685 ok(!lstrcmpW(V_BSTR(&val
), L
"attr"), "id: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3686 test_attr_expando(dom_attr
, VARIANT_FALSE
);
3687 test_attr_value(dom_attr
, L
"attr");
3688 } else if(!lstrcmpW(name
, L
"attr1")) {
3689 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3690 ok(hres
== S_OK
, "%ld) get_nodeValue failed: %08lx\n", i
, hres
);
3691 ok(V_VT(&val
) == VT_BSTR
, "attr1: V_VT(&val) = %d\n", V_VT(&val
));
3692 ok(!lstrcmpW(V_BSTR(&val
), L
"attr1"), "attr1: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3693 test_attr_expando(dom_attr
, VARIANT_TRUE
);
3694 test_attr_value(dom_attr
, L
"attr1");
3695 } else if(!lstrcmpW(name
, L
"attr2")) {
3696 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3697 ok(hres
== S_OK
, "%ld) get_nodeValue failed: %08lx\n", i
, hres
);
3698 ok(V_VT(&val
) == VT_BSTR
, "attr2: V_VT(&val) = %d\n", V_VT(&val
));
3699 ok(!V_BSTR(&val
), "attr2: V_BSTR(&val) != NULL\n");
3700 test_attr_value(dom_attr
, L
"");
3701 } else if(!lstrcmpW(name
, L
"attr3")) {
3702 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3703 ok(hres
== S_OK
, "%ld) get_nodeValue failed: %08lx\n", i
, hres
);
3704 ok(V_VT(&val
) == VT_BSTR
, "attr3: V_VT(&val) = %d\n", V_VT(&val
));
3705 ok(!lstrcmpW(V_BSTR(&val
), L
"attr3"), "attr3: V_BSTR(&val) = %s\n", wine_dbgstr_w(V_BSTR(&val
)));
3706 test_attr_value(dom_attr
, L
"attr3");
3707 } else if(!lstrcmpW(name
, L
"test")) {
3708 hres
= IHTMLDOMAttribute_get_nodeValue(dom_attr
, &val
);
3709 ok(hres
== S_OK
, "%ld) get_nodeValue failed: %08lx\n", i
, hres
);
3710 ok(V_VT(&val
) == VT_I4
, "test: V_VT(&val) = %d\n", V_VT(&val
));
3711 ok(V_I4(&val
) == 1, "test: V_I4(&val) = %ld\n", V_I4(&val
));
3712 test_attr_value(dom_attr
, L
"1");
3716 IHTMLDOMAttribute_Release(dom_attr
);
3717 SysFreeString(name
);
3722 static void test_attr_collection_disp(IDispatch
*disp
)
3724 IDispatchEx
*dispex
;
3725 IHTMLDOMAttribute
*attr
;
3726 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3733 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3734 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
3736 bstr
= SysAllocString(L
"0");
3737 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3738 ok(hres
== S_OK
, "GetDispID failed: %08lx\n", hres
);
3739 SysFreeString(bstr
);
3742 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3743 ok(hres
== S_OK
, "InvokeEx failed: %08lx\n", hres
);
3744 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3745 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3748 bstr
= SysAllocString(L
"attr1");
3749 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3750 ok(hres
== S_OK
, "GetDispID failed: %08lx\n", hres
);
3751 SysFreeString(bstr
);
3754 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3755 ok(hres
== S_OK
, "InvokeEx failed: %08lx\n", hres
);
3756 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3757 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3758 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLDOMAttribute
, (void**)&attr
);
3759 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
3761 test_attr_node_name(attr
, L
"attr1");
3763 IHTMLDOMAttribute_Release(attr
);
3766 IDispatchEx_Release(dispex
);
3769 static void test_attr_collection(IHTMLElement
*elem
)
3771 static const WCHAR testW
[] = {'t','e','s','t',0};
3774 IDispatch
*disp
, *attr
;
3775 IHTMLAttributeCollection
*attr_col
;
3776 BSTR name
= SysAllocString(testW
);
3777 IEnumVARIANT
*enum_var
;
3780 LONG i
, len
, checked
;
3784 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
3785 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
3787 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
3788 ok(hres
== S_OK
, "get_attributes failed: %08lx\n", hres
);
3790 hres
= IHTMLDOMNode_get_attributes(node
, &attr
);
3791 ok(hres
== S_OK
, "get_attributes failed: %08lx\n", hres
);
3792 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)attr
), "disp != attr\n");
3793 IDispatch_Release(attr
);
3794 IHTMLDOMNode_Release(node
);
3796 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLAttributeCollection
, (void**)&attr_col
);
3797 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
3799 hres
= IHTMLAttributeCollection_get_length(attr_col
, &i
);
3800 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
3804 hres
= IHTMLElement_setAttribute(elem
, name
, val
, 0);
3805 ok(hres
== S_OK
, "setAttribute failed: %08lx\n", hres
);
3806 SysFreeString(name
);
3808 hres
= IHTMLAttributeCollection_get_length(attr_col
, &len
);
3809 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
3810 ok(len
== i
+1, "get_length returned %ld, expected %ld\n", len
, i
+1);
3812 hres
= IHTMLAttributeCollection_get__newEnum(attr_col
, &enum_unk
);
3813 ok(hres
== S_OK
, "_newEnum failed: %08lx\n", hres
);
3815 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
3816 IUnknown_Release(enum_unk
);
3817 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
3820 for(i
=0; i
<len
; i
++) {
3823 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3824 ok(hres
== S_OK
, "%ld) item failed: %08lx\n", i
, hres
);
3826 checked
+= test_attr_collection_attr(attr
, i
);
3827 IDispatch_Release(attr
);
3829 ok(checked
==5, "invalid number of specified attributes (%ld)\n", checked
);
3832 for(i
=0; i
<len
; i
++) {
3834 V_VT(&val
) = VT_ERROR
;
3835 hres
= IEnumVARIANT_Next(enum_var
, 1, &val
, &fetched
);
3836 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
3837 ok(fetched
== 1, "fetched = %lu\n", fetched
);
3838 ok(V_VT(&val
) == VT_DISPATCH
, "V_VT(val) = %d\n", V_VT(&val
));
3839 ok(V_DISPATCH(&val
) != NULL
, "V_DISPATCH(&val) == NULL\n");
3841 checked
+= test_attr_collection_attr(V_DISPATCH(&val
), i
);
3842 IDispatch_Release(V_DISPATCH(&val
));
3844 ok(checked
==5, "invalid number of specified attributes (%ld)\n", checked
);
3847 V_VT(&val
) = VT_ERROR
;
3848 hres
= IEnumVARIANT_Next(enum_var
, 1, &val
, &fetched
);
3849 ok(hres
== S_FALSE
, "Next failed: %08lx\n", hres
);
3850 ok(fetched
== 0, "fetched = %lu\n", fetched
);
3851 IEnumVARIANT_Release(enum_var
);
3854 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3855 ok(hres
== E_INVALIDARG
, "item failed: %08lx\n", hres
);
3857 V_VT(&id
) = VT_BSTR
;
3858 V_BSTR(&id
) = SysAllocString(L
"nonexisting");
3859 hres
= IHTMLAttributeCollection_item(attr_col
, &id
, &attr
);
3860 ok(hres
== E_INVALIDARG
, "item failed: %08lx\n", hres
);
3863 test_attr_collection_disp(disp
);
3865 IDispatch_Release(disp
);
3866 IHTMLAttributeCollection_Release(attr_col
);
3869 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
3870 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const WCHAR
*exid
)
3872 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3873 BSTR id
= (void*)0xdeadbeef;
3876 hres
= IHTMLElement_get_id(elem
, &id
);
3877 IHTMLElement_Release(elem
);
3878 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08lx\n", hres
);
3881 ok_(__FILE__
,line
) (!lstrcmpW(id
, exid
), "unexpected id %s\n", wine_dbgstr_w(id
));
3883 ok_(__FILE__
,line
) (!id
, "id=%s\n", wine_dbgstr_w(id
));
3888 #define test_elem_language(e,i) _test_elem_language(__LINE__,e,i)
3889 static void _test_elem_language(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exlang
)
3891 BSTR lang
= (void*)0xdeadbeef;
3894 hres
= IHTMLElement_get_language(elem
, &lang
);
3895 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08lx\n", hres
);
3898 ok_(__FILE__
,line
) (!lstrcmpW(lang
, exlang
), "unexpected language %s\n", wine_dbgstr_w(lang
));
3900 ok_(__FILE__
,line
) (!lang
, "language=%s\n", wine_dbgstr_w(lang
));
3902 SysFreeString(lang
);
3905 #define set_elem_language(e,i) _set_elem_language(__LINE__,e,i)
3906 static void _set_elem_language(unsigned line
, IHTMLElement
*elem
, const WCHAR
*lang
)
3908 BSTR str
= SysAllocString(lang
);
3911 hres
= IHTMLElement_put_language(elem
, str
);
3912 ok_(__FILE__
,line
) (hres
== S_OK
, "get_language failed: %08lx\n", hres
);
3915 _test_elem_language(line
, elem
, lang
);
3918 #define test_elem_lang(e,i) _test_elem_lang(__LINE__,e,i)
3919 static void _test_elem_lang(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exlang
)
3921 BSTR lang
= (void*)0xdeadbeef;
3924 hres
= IHTMLElement_get_lang(elem
, &lang
);
3925 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08lx\n", hres
);
3928 ok_(__FILE__
,line
) (!lstrcmpW(lang
, exlang
), "unexpected lang %s\n", wine_dbgstr_w(lang
));
3930 ok_(__FILE__
,line
) (!lang
, "lang=%s\n", wine_dbgstr_w(lang
));
3932 SysFreeString(lang
);
3935 #define set_elem_lang(e,i) _set_elem_lang(__LINE__,e,i)
3936 static void _set_elem_lang(unsigned line
, IHTMLElement
*elem
, const WCHAR
*lang
)
3938 BSTR str
= SysAllocString(lang
);
3941 hres
= IHTMLElement_put_lang(elem
, str
);
3942 ok_(__FILE__
,line
) (hres
== S_OK
, "get_lang failed: %08lx\n", hres
);
3945 _test_elem_lang(line
, elem
, lang
);
3948 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
3949 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const WCHAR
*new_id
)
3951 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
3952 BSTR tmp
= SysAllocString(new_id
);
3955 hres
= IHTMLElement_put_id(elem
, tmp
);
3956 IHTMLElement_Release(elem
);
3958 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08lx\n", hres
);
3960 _test_elem_id(line
, unk
, new_id
);
3963 static void test_contenteditable(IUnknown
*unk
)
3965 IHTMLElement3
*elem3
= get_elem3_iface(unk
);
3967 BSTR str
, strDefault
;
3970 hres
= IHTMLElement3_get_contentEditable(elem3
, &strDefault
);
3971 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08lx\n", hres
);
3973 str
= SysAllocString(L
"true");
3974 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3975 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08lx\n", wine_dbgstr_w(str
), hres
);
3977 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3978 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08lx\n", hres
);
3979 ok(!lstrcmpW(str
, L
"true"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "true");
3981 hres
= IHTMLElement3_get_isContentEditable(elem3
, &vbool
);
3982 ok(hres
== S_OK
, "get_isContentEditable failed: 0x%08lx\n", hres
);
3983 ok(vbool
== VARIANT_TRUE
, "Got %d, expected VARIANT_TRUE\n", vbool
);
3985 str
= SysAllocString(L
"inherit");
3986 hres
= IHTMLElement3_put_contentEditable(elem3
, str
);
3987 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08lx\n", wine_dbgstr_w(str
), hres
);
3989 hres
= IHTMLElement3_get_contentEditable(elem3
, &str
);
3990 ok(hres
== S_OK
, "get_contentEditable failed: 0x%08lx\n", hres
);
3991 ok(!lstrcmpW(str
, L
"inherit"), "Got %s, expected %s\n", wine_dbgstr_w(str
), "inherit");
3993 hres
= IHTMLElement3_get_isContentEditable(elem3
, &vbool
);
3994 ok(hres
== S_OK
, "get_isContentEditable failed: 0x%08lx\n", hres
);
3995 ok(vbool
== VARIANT_FALSE
, "Got %d, expected VARIANT_FALSE\n", vbool
);
3997 /* Restore origin contentEditable */
3998 hres
= IHTMLElement3_put_contentEditable(elem3
, strDefault
);
3999 ok(hres
== S_OK
, "put_contentEditable(%s) failed: 0x%08lx\n", wine_dbgstr_w(strDefault
), hres
);
4000 SysFreeString(strDefault
);
4002 IHTMLElement3_Release(elem3
);
4005 #define test_input_type(i,t) _test_input_type(__LINE__,i,t)
4006 static void _test_input_type(unsigned line
, IHTMLInputElement
*input
, const WCHAR
*extype
)
4012 hres
= IHTMLInputElement_get_type(input
, &type
);
4013 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08lx\n", hres
);
4014 ok_(__FILE__
,line
) (!lstrcmpW(type
, extype
), "type=%s, expected %s\n", wine_dbgstr_w(type
), wine_dbgstr_w(extype
));
4015 SysFreeString(type
);
4017 hres
= IHTMLInputElement_get_complete(input
, &b
);
4018 ok_(__FILE__
,line
) (hres
== S_OK
, "get_complete failed: %08lx\n", hres
);
4019 ok(b
== VARIANT_FALSE
, "complete = %x\n", b
);
4022 #define test_input_name(u, c) _test_input_name(__LINE__,u, c)
4023 static void _test_input_name(unsigned line
, IHTMLInputElement
*input
, const WCHAR
*exname
)
4025 BSTR name
= (BSTR
)0xdeadbeef;
4028 hres
= IHTMLInputElement_get_name(input
, &name
);
4029 ok_(__FILE__
,line
) (hres
== S_OK
, "get_name failed: %08lx\n", hres
);
4031 ok_(__FILE__
,line
) (!lstrcmpW(name
, exname
), "name=%s, expected %s\n", wine_dbgstr_w(name
), wine_dbgstr_w(exname
));
4033 ok_(__FILE__
,line
) (!name
, "name=%p, expected NULL\n", name
);
4034 SysFreeString(name
);
4037 #define test_input_set_name(u, c) _test_input_set_name(__LINE__,u, c)
4038 static void _test_input_set_name(unsigned line
, IHTMLInputElement
*input
, const WCHAR
*name
)
4040 BSTR tmp
= SysAllocString(name
);
4043 hres
= IHTMLInputElement_put_name(input
, tmp
);
4044 ok_(__FILE__
,line
) (hres
== S_OK
, "put_name failed: %08lx\n", hres
);
4047 _test_input_name(line
, input
, name
);
4050 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
4051 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
4053 VARIANT_BOOL disabled
= 100;
4056 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
4057 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
4058 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
4060 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
4063 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
4064 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
4068 hres
= IHTMLInputElement_put_disabled(input
, b
);
4069 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
4071 _test_input_get_disabled(line
, input
, b
);
4074 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
4075 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
4077 VARIANT_BOOL checked
= 100;
4080 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
4081 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08lx\n", hres
);
4082 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
4085 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
4086 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
4090 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
4091 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08lx\n", hres
);
4093 _test_input_get_defaultchecked(line
, input
, b
);
4096 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
4097 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
4099 VARIANT_BOOL checked
= 100;
4102 hres
= IHTMLInputElement_get_checked(input
, &checked
);
4103 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08lx\n", hres
);
4104 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
4107 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
4108 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
4112 hres
= IHTMLInputElement_put_checked(input
, b
);
4113 ok_(__FILE__
,line
) (hres
== S_OK
, "put_checked failed: %08lx\n", hres
);
4115 _test_input_get_checked(line
, input
, b
);
4118 #define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
4119 static void _test_input_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG exl
)
4121 LONG maxlength
= 0xdeadbeef;
4124 hres
= IHTMLInputElement_get_maxLength(input
, &maxlength
);
4125 ok_(__FILE__
,line
) (hres
== S_OK
, "get_maxLength failed: %08lx\n", hres
);
4126 ok_(__FILE__
,line
) (maxlength
== exl
, "maxLength=%lx, expected %ld\n", maxlength
, exl
);
4129 #define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
4130 static void _test_input_set_maxlength(unsigned line
, IHTMLInputElement
*input
, LONG l
)
4134 hres
= IHTMLInputElement_put_maxLength(input
, l
);
4135 ok_(__FILE__
,line
) (hres
== S_OK
, "put_maxLength failed: %08lx\n", hres
);
4137 _test_input_maxlength(line
, input
, l
);
4140 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
4141 static void _test_input_value(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
4143 IHTMLInputElement
*input
;
4147 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4148 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08lx\n", hres
);
4152 hres
= IHTMLInputElement_get_value(input
, &bstr
);
4153 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08lx\n", hres
);
4155 ok_(__FILE__
,line
) (!lstrcmpW(bstr
, exval
), "value=%s\n", wine_dbgstr_w(bstr
));
4157 ok_(__FILE__
,line
) (!bstr
, "exval != NULL\n");
4158 SysFreeString(bstr
);
4159 IHTMLInputElement_Release(input
);
4162 #define test_input_get_form(o, t) _test_input_get_form(__LINE__, o, t)
4163 static void _test_input_get_form(unsigned line
, IUnknown
*unk
, const WCHAR
*id
)
4165 IHTMLInputElement
*input
;
4166 IHTMLFormElement
*form
;
4170 ok_(__FILE__
,line
) (unk
!= NULL
, "unk is NULL!\n");
4171 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4172 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08lx\n", hres
);
4173 ok_(__FILE__
,line
) (input
!= NULL
, "input == NULL\n");
4174 if(FAILED(hres
) || input
== NULL
)
4177 hres
= IHTMLInputElement_get_form(input
, &form
);
4178 ok_(__FILE__
, line
) (hres
== S_OK
, "get_form failed: %08lx\n", hres
);
4179 ok_(__FILE__
, line
) (form
!= NULL
, "form == NULL\n");
4180 if(FAILED(hres
) || form
== NULL
){
4181 IHTMLInputElement_Release(input
);
4185 hres
= IHTMLFormElement_QueryInterface(form
, &IID_IHTMLElement
, (void **)&elem
);
4186 ok_(__FILE__
, line
) (hres
== S_OK
, "QueryInterface(IID_IHTMLElement) failed: %08lx\n", hres
);
4187 ok_(__FILE__
, line
) (elem
!= NULL
, "elem == NULL\n");
4188 if(FAILED(hres
) || elem
== NULL
){
4189 IHTMLInputElement_Release(input
);
4190 IHTMLFormElement_Release(form
);
4194 _test_elem_id(line
, (IUnknown
*)elem
, id
);
4196 IHTMLInputElement_Release(input
);
4197 IHTMLFormElement_Release(form
);
4198 IHTMLElement_Release(elem
);
4201 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
4202 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const WCHAR
*val
)
4204 IHTMLInputElement
*input
;
4208 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4209 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08lx\n", hres
);
4213 bstr
= SysAllocString(val
);
4214 hres
= IHTMLInputElement_put_value(input
, bstr
);
4215 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08lx\n", hres
);
4216 SysFreeString(bstr
);
4217 IHTMLInputElement_Release(input
);
4219 _test_input_value(line
, unk
, val
);
4222 #define test_input_defaultValue(o,t) _test_input_defaultValue(__LINE__,o,t)
4223 static void _test_input_defaultValue(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
4225 IHTMLInputElement
*input
;
4229 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4230 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08lx\n", hres
);
4234 hres
= IHTMLInputElement_get_defaultValue(input
, &str
);
4235 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08lx\n", hres
);
4237 ok_(__FILE__
,line
) (!lstrcmpW(str
, exval
), "defaultValue=%s\n", wine_dbgstr_w(str
));
4239 ok_(__FILE__
,line
) (!str
, "exval != NULL\n");
4241 IHTMLInputElement_Release(input
);
4244 #define test_input_put_defaultValue(o,v) _test_input_put_defaultValue(__LINE__,o,v)
4245 static void _test_input_put_defaultValue(unsigned line
, IUnknown
*unk
, const WCHAR
*val
)
4247 IHTMLInputElement
*input
;
4251 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
4252 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08lx\n", hres
);
4256 str
= SysAllocString(val
);
4257 hres
= IHTMLInputElement_put_defaultValue(input
, str
);
4258 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultValue failed: %08lx\n", hres
);
4260 IHTMLInputElement_Release(input
);
4262 _test_input_defaultValue(line
, unk
, val
);
4265 #define test_input_src(i,s) _test_input_src(__LINE__,i,s)
4266 static void _test_input_src(unsigned line
, IHTMLInputElement
*input
, const WCHAR
*exsrc
)
4271 hres
= IHTMLInputElement_get_src(input
, &src
);
4272 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08lx\n", hres
);
4274 ok_(__FILE__
,line
) (!lstrcmpW(src
, exsrc
), "get_src returned %s expected %s\n", wine_dbgstr_w(src
), wine_dbgstr_w(exsrc
));
4276 ok_(__FILE__
,line
) (!src
, "get_src returned %s expected NULL\n", wine_dbgstr_w(src
));
4280 #define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s)
4281 static void _test_input_set_src(unsigned line
, IHTMLInputElement
*input
, const WCHAR
*src
)
4286 tmp
= SysAllocString(src
);
4287 hres
= IHTMLInputElement_put_src(input
, tmp
);
4289 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08lx\n", hres
);
4291 _test_input_src(line
, input
, src
);
4294 #define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r)
4295 static void _test_input_set_size(unsigned line
, IHTMLInputElement
*input
, LONG size
, HRESULT exret
)
4299 hres
= IHTMLInputElement_put_size(input
, size
);
4300 ok_(__FILE__
,line
) (hres
== exret
, "Expect ret = %08lx, got: %08lx\n", exret
, hres
);
4303 #define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s)
4304 static void _test_input_get_size(unsigned line
, IHTMLInputElement
*input
, LONG exsize
)
4309 hres
= IHTMLInputElement_get_size(input
, &size
);
4310 ok_(__FILE__
,line
) (hres
== S_OK
, "get_size failed: %08lx\n", hres
);
4311 ok_(__FILE__
,line
) (size
== exsize
, "Expect %ld, got %ld\n", exsize
, size
);
4313 hres
= IHTMLInputElement_get_size(input
, NULL
);
4314 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "Expect ret E_INVALIDARG, got: %08lx\n", hres
);
4317 #define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b)
4318 static void _test_input_readOnly(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL v
)
4321 VARIANT_BOOL b
= 100;
4323 hres
= IHTMLInputElement_put_readOnly(input
, v
);
4324 ok_(__FILE__
,line
)(hres
== S_OK
, "put readOnly failed: %08lx\n", hres
);
4326 hres
= IHTMLInputElement_get_readOnly(input
, &b
);
4327 ok_(__FILE__
,line
)(hres
== S_OK
, "get readOnly failed: %08lx\n", hres
);
4328 ok_(__FILE__
,line
)(v
== b
, "Expect %x, got %x\n", v
, b
);
4331 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
4332 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const WCHAR
*exclass
)
4334 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4335 BSTR
class = (void*)0xdeadbeef;
4338 hres
= IHTMLElement_get_className(elem
, &class);
4339 IHTMLElement_Release(elem
);
4340 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08lx\n", hres
);
4342 ok_(__FILE__
,line
) (!lstrcmpW(class, exclass
), "unexpected className %s\n", wine_dbgstr_w(class));
4344 ok_(__FILE__
,line
) (!class, "class != NULL\n");
4345 SysFreeString(class);
4348 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
4349 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
4351 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4355 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
4356 IHTMLElement2_Release(elem2
);
4357 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08lx\n", hres
);
4358 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
4361 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
4362 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
4364 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
4367 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
4368 IHTMLElement2_Release(elem2
);
4369 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08lx\n", hres
);
4371 _test_elem_tabindex(line
, unk
, index
);
4374 #define test_style_media(s,m) _test_style_media(__LINE__,s,m)
4375 static void _test_style_media(unsigned line
, IUnknown
*unk
, const WCHAR
*exmedia
)
4377 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4381 hres
= IHTMLStyleElement_get_media(style
, &media
);
4382 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08lx\n", hres
);
4384 ok_(__FILE__
,line
)(!lstrcmpW(media
, exmedia
), "media = %s, expected %s\n", wine_dbgstr_w(media
), wine_dbgstr_w(exmedia
));
4386 ok_(__FILE__
,line
)(!media
, "media = %s, expected NULL\n", wine_dbgstr_w(media
));
4388 IHTMLStyleElement_Release(style
);
4389 SysFreeString(media
);
4392 #define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
4393 static void _test_style_put_media(unsigned line
, IUnknown
*unk
, const WCHAR
*media
)
4395 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4399 str
= SysAllocString(media
);
4400 hres
= IHTMLStyleElement_put_media(style
, str
);
4401 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08lx\n", hres
);
4402 IHTMLStyleElement_Release(style
);
4405 _test_style_media(line
, unk
, media
);
4408 #define test_style_type(s,m) _test_style_type(__LINE__,s,m)
4409 static void _test_style_type(unsigned line
, IUnknown
*unk
, const WCHAR
*extype
)
4411 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4415 hres
= IHTMLStyleElement_get_type(style
, &type
);
4416 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
4418 ok_(__FILE__
,line
)(!lstrcmpW(type
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(type
), wine_dbgstr_w(extype
));
4420 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
4422 IHTMLStyleElement_Release(style
);
4423 SysFreeString(type
);
4426 #define test_style_put_type(s,m) _test_style_put_type(__LINE__,s,m)
4427 static void _test_style_put_type(unsigned line
, IUnknown
*unk
, const WCHAR
*type
)
4429 IHTMLStyleElement
*style
= _get_style_iface(line
, unk
);
4433 str
= SysAllocString(type
);
4434 hres
= IHTMLStyleElement_put_type(style
, str
);
4435 ok_(__FILE__
,line
)(hres
== S_OK
, "put_type failed: %08lx\n", hres
);
4436 IHTMLStyleElement_Release(style
);
4439 _test_style_type(line
, unk
, type
);
4442 #define test_elem_filters(u) _test_elem_filters(__LINE__,u)
4443 static void _test_elem_filters(unsigned line
, IUnknown
*unk
)
4445 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4447 IHTMLFiltersCollection
*filters
;
4449 hres
= IHTMLElement_get_filters(elem
, &filters
);
4450 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== REGDB_E_CLASSNOTREG
) /* NT4 */,
4451 "get_filters failed: %08lx\n", hres
);
4455 IDispatchEx
*dispex
;
4457 hres
= IHTMLFiltersCollection_get_length(filters
, &len
);
4458 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08lx\n", hres
);
4459 ok_(__FILE__
,line
) (len
== 0, "expect 0 got %ld\n", len
);
4461 hres
= IHTMLFiltersCollection_QueryInterface(filters
, &IID_IDispatchEx
, (void**)&dispex
);
4462 ok_(__FILE__
,line
) (hres
== S_OK
|| broken(hres
== E_NOINTERFACE
),
4463 "Could not get IDispatchEx interface: %08lx\n", hres
);
4464 if(SUCCEEDED(hres
)) {
4465 test_disp((IUnknown
*)filters
, &IID_IHTMLFiltersCollection
, NULL
, L
"[object]");
4466 IDispatchEx_Release(dispex
);
4469 IHTMLFiltersCollection_Release(filters
);
4472 IHTMLElement_Release(elem
);
4475 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
4476 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const WCHAR
*class)
4478 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4482 tmp
= class ? SysAllocString(class) : NULL
;
4483 hres
= IHTMLElement_put_className(elem
, tmp
);
4484 IHTMLElement_Release(elem
);
4485 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08lx\n", hres
);
4488 _test_elem_class(line
, unk
, class);
4491 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
4492 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const WCHAR
*extitle
)
4494 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4498 hres
= IHTMLElement_get_title(elem
, &title
);
4499 IHTMLElement_Release(elem
);
4500 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08lx\n", hres
);
4502 ok_(__FILE__
,line
) (!lstrcmpW(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
4504 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", wine_dbgstr_w(title
));
4506 SysFreeString(title
);
4509 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
4510 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const WCHAR
*title
)
4512 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
4516 tmp
= SysAllocString(title
);
4517 hres
= IHTMLElement_put_title(elem
, tmp
);
4518 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08lx\n", hres
);
4520 IHTMLElement_Release(elem
);
4524 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
4525 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
4527 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4531 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
4532 IHTMLDOMNode_Release(node
);
4533 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08lx, expected VT_BSTR\n", hres
);
4536 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
4537 ok_(__FILE__
,line
) (!lstrcmpW(V_BSTR(&var
), exval
), "unexpected value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4539 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
4545 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
4546 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const WCHAR
*val
)
4548 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
4552 V_VT(&var
) = VT_BSTR
;
4553 V_BSTR(&var
) = SysAllocString(val
);
4555 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
4556 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08lx, expected VT_BSTR\n", hres
);
4557 IHTMLDOMNode_Release(node
);
4561 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
4562 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
4564 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4568 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
4569 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08lx\n", hres
);
4570 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
4571 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08lx\n", hres
);
4573 IHTMLElement2_Release(elem
);
4576 #define test_elem_client_rect(u) _test_elem_client_rect(__LINE__,u)
4577 static void _test_elem_client_rect(unsigned line
, IUnknown
*unk
)
4579 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
4583 hres
= IHTMLElement2_get_clientLeft(elem
, &l
);
4584 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientLeft failed: %08lx\n", hres
);
4585 ok_(__FILE__
,line
) (!l
, "clientLeft = %ld\n", l
);
4587 hres
= IHTMLElement2_get_clientTop(elem
, &l
);
4588 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientTop failed: %08lx\n", hres
);
4589 ok_(__FILE__
,line
) (!l
, "clientTop = %ld\n", l
);
4591 IHTMLElement2_Release(elem
);
4594 #define test_form_length(e,l) _test_form_length(__LINE__,e,l)
4595 static void _test_form_length(unsigned line
, IUnknown
*unk
, LONG exlen
)
4597 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4598 LONG len
= 0xdeadbeef;
4601 hres
= IHTMLFormElement_get_length(form
, &len
);
4602 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
4603 ok_(__FILE__
,line
)(len
== exlen
, "length=%ld, expected %ld\n", len
, exlen
);
4605 IHTMLFormElement_Release(form
);
4608 #define test_form_action(f,a) _test_form_action(__LINE__,f,a)
4609 static void _test_form_action(unsigned line
, IUnknown
*unk
, const WCHAR
*ex
)
4611 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4612 BSTR action
= (void*)0xdeadbeef;
4615 hres
= IHTMLFormElement_get_action(form
, &action
);
4616 ok_(__FILE__
,line
)(hres
== S_OK
, "get_action failed: %08lx\n", hres
);
4618 ok_(__FILE__
,line
)(!lstrcmpW(action
, ex
), "action=%s, expected %s\n", wine_dbgstr_w(action
), wine_dbgstr_w(ex
));
4620 ok_(__FILE__
,line
)(!action
, "action=%p\n", action
);
4622 SysFreeString(action
);
4623 IHTMLFormElement_Release(form
);
4626 #define test_form_put_action(f,a) _test_form_put_action(__LINE__,f,a)
4627 static void _test_form_put_action(unsigned line
, IUnknown
*unk
, const WCHAR
*action
)
4629 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4630 BSTR tmp
= SysAllocString(action
);
4633 hres
= IHTMLFormElement_put_action(form
, tmp
);
4634 ok_(__FILE__
,line
)(hres
== S_OK
, "put_action failed: %08lx\n", hres
);
4636 IHTMLFormElement_Release(form
);
4638 _test_form_action(line
, unk
, action
);
4641 #define test_form_method(f,a) _test_form_method(__LINE__,f,a)
4642 static void _test_form_method(unsigned line
, IUnknown
*unk
, const WCHAR
*ex
)
4644 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4645 BSTR method
= (void*)0xdeadbeef;
4648 hres
= IHTMLFormElement_get_method(form
, &method
);
4649 ok_(__FILE__
,line
)(hres
== S_OK
, "get_method failed: %08lx\n", hres
);
4651 ok_(__FILE__
,line
)(!lstrcmpW(method
, ex
), "method=%s, expected %s\n", wine_dbgstr_w(method
), wine_dbgstr_w(ex
));
4653 ok_(__FILE__
,line
)(!method
, "method=%p\n", method
);
4655 SysFreeString(method
);
4656 IHTMLFormElement_Release(form
);
4659 #define test_form_put_method(f,r,a) _test_form_put_method(__LINE__,f,r,a)
4660 static void _test_form_put_method(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const WCHAR
*method
)
4662 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4663 BSTR tmp
= SysAllocString(method
);
4666 hres
= IHTMLFormElement_put_method(form
, tmp
);
4667 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_method returned: %08lx, expected %08lx\n", hres
, exp_hres
);
4669 IHTMLFormElement_Release(form
);
4671 if(exp_hres
== S_OK
)
4672 _test_form_method(line
, unk
, method
);
4675 #define test_form_name(f,a) _test_form_name(__LINE__,f,a)
4676 static void _test_form_name(unsigned line
, IUnknown
*unk
, const WCHAR
*ex
)
4678 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4679 BSTR name
= (void*)0xdeadbeef;
4682 hres
= IHTMLFormElement_get_name(form
, &name
);
4683 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
4685 ok_(__FILE__
,line
)(!lstrcmpW(name
, ex
), "name=%s, expected %s\n", wine_dbgstr_w(name
), wine_dbgstr_w(ex
));
4687 ok_(__FILE__
,line
)(!name
, "name=%p\n", name
);
4689 SysFreeString(name
);
4690 IHTMLFormElement_Release(form
);
4693 #define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a)
4694 static void _test_form_put_name(unsigned line
, IUnknown
*unk
, const WCHAR
*name
)
4696 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4697 BSTR tmp
= SysAllocString(name
);
4700 hres
= IHTMLFormElement_put_name(form
, tmp
);
4701 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08lx\n", hres
);
4703 IHTMLFormElement_Release(form
);
4705 _test_form_name(line
, unk
, name
);
4708 #define test_form_encoding(f,a) _test_form_encoding(__LINE__,f,a)
4709 static void _test_form_encoding(unsigned line
, IUnknown
*unk
, const WCHAR
*ex
)
4711 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4712 BSTR encoding
= (void*)0xdeadbeef;
4715 hres
= IHTMLFormElement_get_encoding(form
, &encoding
);
4716 ok_(__FILE__
,line
)(hres
== S_OK
, "get_encoding failed: %08lx\n", hres
);
4718 ok_(__FILE__
,line
)(!lstrcmpW(encoding
, ex
), "encoding=%s, expected %s\n", wine_dbgstr_w(encoding
), wine_dbgstr_w(ex
));
4720 ok_(__FILE__
,line
)(!encoding
, "encoding=%p\n", encoding
);
4722 SysFreeString(encoding
);
4723 IHTMLFormElement_Release(form
);
4726 #define test_form_put_encoding(f,r,a) _test_form_put_encoding(__LINE__,f,r,a)
4727 static void _test_form_put_encoding(unsigned line
, IUnknown
*unk
, HRESULT exp_hres
, const WCHAR
*encoding
)
4729 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4730 BSTR tmp
= SysAllocString(encoding
);
4733 hres
= IHTMLFormElement_put_encoding(form
, tmp
);
4734 ok_(__FILE__
,line
)(hres
== exp_hres
, "put_encoding returned: %08lx, expected %08lx\n", hres
, exp_hres
);
4736 IHTMLFormElement_Release(form
);
4738 if(exp_hres
== S_OK
)
4739 _test_form_encoding(line
, unk
, encoding
);
4742 #define test_form_elements(a,b,c) _test_form_elements(__LINE__,a,b,c)
4743 static void _test_form_elements(unsigned line
, IUnknown
*unk
, const elem_type_t
*elem_types
,
4744 LONG elem_types_cnt
)
4746 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4751 hres
= IHTMLFormElement_get_elements(form
, &disp
);
4752 ok_(__FILE__
,line
)(hres
== S_OK
, "get_elements failed: %08lx\n", hres
);
4753 ok_(__FILE__
,line
)(disp
!= NULL
, "disp = NULL\n");
4754 if(compat_mode
< COMPAT_IE9
)
4755 ok_(__FILE__
,line
)(iface_cmp((IUnknown
*)form
, (IUnknown
*)disp
), "disp != form\n");
4757 _test_elem_collection(line
, (IUnknown
*)disp
, elem_types
, elem_types_cnt
);
4759 IDispatch_Release(disp
);
4760 IHTMLFormElement_Release(form
);
4763 #define test_form_reset(a) _test_form_reset(__LINE__,a)
4764 static void _test_form_reset(unsigned line
, IUnknown
*unk
)
4766 IHTMLFormElement
*form
= _get_form_iface(line
, unk
);
4769 hres
= IHTMLFormElement_reset(form
);
4770 ok_(__FILE__
,line
)(hres
== S_OK
, "reset failed: %08lx\n", hres
);
4772 IHTMLFormElement_Release(form
);
4775 static void test_form_target(IUnknown
*unk
)
4777 IHTMLFormElement
*form
= get_form_iface(unk
);
4781 str
= SysAllocString(L
"_blank");
4782 hres
= IHTMLFormElement_put_target(form
, str
);
4783 ok(hres
== S_OK
, "put_target failed: %08lx\n", hres
);
4786 hres
= IHTMLFormElement_get_target(form
, &str
);
4787 ok(hres
== S_OK
, "get_target failed: %08lx\n", hres
);
4788 ok(!lstrcmpW(str
, L
"_blank"), "got %s\n", wine_dbgstr_w(str
));
4791 IHTMLFormElement_Release(form
);
4794 static void test_select_form(IUnknown
*uselect
, IUnknown
*uform
)
4796 IHTMLSelectElement
*select
= get_select_iface(uselect
);
4797 IHTMLFormElement
*form
;
4800 hres
= IHTMLSelectElement_get_form(select
, NULL
);
4801 ok(hres
== E_POINTER
, "got %08lx\n, expected E_POINTER\n", hres
);
4803 hres
= IHTMLSelectElement_get_form(select
, &form
);
4804 ok(hres
== S_OK
, "get_form failed: %08lx\n", hres
);
4805 ok(form
!= NULL
, "form == NULL\n");
4807 test_form_length((IUnknown
*)form
, 2);
4808 test_form_elements((IUnknown
*)form
, NULL
, 0);
4809 test_form_name((IUnknown
*)form
, L
"form_name");
4811 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
4813 IHTMLSelectElement_Release(select
);
4814 IHTMLFormElement_Release(form
);
4817 static void test_select_form_notfound(IHTMLSelectElement
*select
)
4819 IHTMLFormElement
*form
;
4822 form
= (IHTMLFormElement
*)0xdeadbeef;
4823 hres
= IHTMLSelectElement_get_form(select
, &form
);
4824 ok(hres
== S_OK
, "get_form failed: %08lx\n", hres
);
4825 ok(form
== NULL
, "got %p\n", form
);
4828 #define test_meta_name(a,b) _test_meta_name(__LINE__,a,b)
4829 static void _test_meta_name(unsigned line
, IUnknown
*unk
, const WCHAR
*exname
)
4831 IHTMLMetaElement
*meta
;
4835 meta
= _get_metaelem_iface(line
, unk
);
4836 hres
= IHTMLMetaElement_get_name(meta
, &name
);
4837 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
4838 ok_(__FILE__
,line
)(!lstrcmpW(name
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(name
), wine_dbgstr_w(exname
));
4839 SysFreeString(name
);
4840 IHTMLMetaElement_Release(meta
);
4843 #define test_meta_content(a,b) _test_meta_content(__LINE__,a,b)
4844 static void _test_meta_content(unsigned line
, IUnknown
*unk
, const WCHAR
*excontent
)
4846 IHTMLMetaElement
*meta
;
4847 BSTR content
= NULL
;
4850 meta
= _get_metaelem_iface(line
, unk
);
4851 hres
= IHTMLMetaElement_get_content(meta
, &content
);
4852 ok_(__FILE__
,line
)(hres
== S_OK
, "get_content failed: %08lx\n", hres
);
4853 ok_(__FILE__
,line
)(!lstrcmpW(content
, excontent
), "content = %s, expected %s\n", wine_dbgstr_w(content
), wine_dbgstr_w(excontent
));
4854 SysFreeString(content
);
4855 IHTMLMetaElement_Release(meta
);
4858 #define test_meta_httpequiv(a,b) _test_meta_httpequiv(__LINE__,a,b)
4859 static void _test_meta_httpequiv(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
4861 IHTMLMetaElement
*meta
;
4865 meta
= _get_metaelem_iface(line
, unk
);
4866 hres
= IHTMLMetaElement_get_httpEquiv(meta
, &val
);
4867 ok_(__FILE__
,line
)(hres
== S_OK
, "get_httpEquiv failed: %08lx\n", hres
);
4868 ok_(__FILE__
,line
)(!lstrcmpW(val
, exval
), "httpEquiv = %s, expected %s\n", wine_dbgstr_w(val
), wine_dbgstr_w(exval
));
4870 IHTMLMetaElement_Release(meta
);
4873 #define test_meta_charset(a,b) _test_meta_charset(__LINE__,a,b)
4874 static void _test_meta_charset(unsigned line
, IUnknown
*unk
, const WCHAR
*exval
)
4876 IHTMLMetaElement
*meta
;
4880 meta
= _get_metaelem_iface(line
, unk
);
4881 hres
= IHTMLMetaElement_get_charset(meta
, &val
);
4882 ok_(__FILE__
,line
)(hres
== S_OK
, "get_charset failed: %08lx\n", hres
);
4884 ok_(__FILE__
,line
)(!lstrcmpW(val
, exval
), "charset = %s, expected %s\n", wine_dbgstr_w(val
), wine_dbgstr_w(exval
));
4886 ok_(__FILE__
,line
)(!val
, "charset = %s, expected NULL\n", wine_dbgstr_w(val
));
4888 IHTMLMetaElement_Release(meta
);
4891 #define set_meta_charset(a,b) _set_meta_charset(__LINE__,a,b)
4892 static void _set_meta_charset(unsigned line
, IUnknown
*unk
, const WCHAR
*v
)
4894 BSTR val
= SysAllocString(v
);
4895 IHTMLMetaElement
*meta
;
4898 meta
= _get_metaelem_iface(line
, unk
);
4899 hres
= IHTMLMetaElement_put_charset(meta
, val
);
4900 ok_(__FILE__
,line
)(hres
== S_OK
, "put_charset failed: %08lx\n", hres
);
4902 IHTMLMetaElement_Release(meta
);
4904 _test_meta_charset(line
, unk
, v
);
4907 #define test_link_media(a,b) _test_link_media(__LINE__,a,b)
4908 static void _test_link_media(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exval
)
4910 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4914 str
= SysAllocString(exval
);
4915 hres
= IHTMLLinkElement_put_media(link
, str
);
4916 ok_(__FILE__
,line
)(hres
== S_OK
, "put_media failed: %08lx\n", hres
);
4919 hres
= IHTMLLinkElement_get_media(link
, &str
);
4920 ok_(__FILE__
,line
)(hres
== S_OK
, "get_media failed: %08lx\n", hres
);
4921 ok_(__FILE__
,line
)(!lstrcmpW(str
, exval
), "got %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exval
));
4923 IHTMLLinkElement_Release(link
);
4926 #define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
4927 static void _test_link_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4929 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4930 VARIANT_BOOL b
= 10;
4933 hres
= IHTMLLinkElement_get_disabled(link
, &b
);
4934 ok_(__FILE__
,line
)(hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
4935 ok_(__FILE__
,line
)(b
== v
, "disabled = %x, expected %x\n", b
, v
);
4937 IHTMLLinkElement_Release(link
);
4940 #define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
4941 static void _link_put_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL v
)
4943 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4946 hres
= IHTMLLinkElement_put_disabled(link
, v
);
4947 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08lx\n", hres
);
4948 IHTMLLinkElement_Release(link
);
4949 _test_link_disabled(line
, elem
, v
);
4952 #define test_link_rel(a,b) _test_link_rel(__LINE__,a,b)
4953 static void _test_link_rel(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
4955 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4959 hres
= IHTMLLinkElement_get_rel(link
, &rel
);
4960 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rel failed: %08lx\n", hres
);
4962 ok_(__FILE__
,line
)(!lstrcmpW(rel
, v
), "rel = %s\n", wine_dbgstr_w(rel
));
4964 ok_(__FILE__
,line
)(!rel
, "rel = %s, expected NULL\n", wine_dbgstr_w(rel
));
4967 IHTMLLinkElement_Release(link
);
4970 #define link_put_rel(a,b) _link_put_rel(__LINE__,a,b)
4971 static void _link_put_rel(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
4973 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4974 BSTR str
= SysAllocString(v
);
4977 hres
= IHTMLLinkElement_put_rel(link
, str
);
4978 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08lx\n", hres
);
4980 IHTMLLinkElement_Release(link
);
4981 _test_link_rel(line
, elem
, v
);
4984 #define test_link_rev(a,b) _test_link_rev(__LINE__,a,b)
4985 static void _test_link_rev(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
4987 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
4991 hres
= IHTMLLinkElement_get_rev(link
, &rev
);
4992 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rev failed: %08lx\n", hres
);
4994 ok_(__FILE__
,line
)(!lstrcmpW(rev
, v
), "rev = %s\n", wine_dbgstr_w(rev
));
4996 ok_(__FILE__
,line
)(!rev
, "rev = %s, expected NULL\n", wine_dbgstr_w(rev
));
4999 IHTMLLinkElement_Release(link
);
5002 #define link_put_rev(a,b) _link_put_rev(__LINE__,a,b)
5003 static void _link_put_rev(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
5005 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
5006 BSTR str
= SysAllocString(v
);
5009 hres
= IHTMLLinkElement_put_rev(link
, str
);
5010 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08lx\n", hres
);
5012 IHTMLLinkElement_Release(link
);
5013 _test_link_rev(line
, elem
, v
);
5016 #define test_link_type(a,b) _test_link_type(__LINE__,a,b)
5017 static void _test_link_type(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
5019 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
5023 hres
= IHTMLLinkElement_get_type(link
, &type
);
5024 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
5026 ok_(__FILE__
,line
)(!lstrcmpW(type
, v
), "type = %s, expected %s\n", wine_dbgstr_w(type
), wine_dbgstr_w(v
));
5028 ok_(__FILE__
,line
)(!type
, "type = %s, expected NULL\n", wine_dbgstr_w(type
));
5029 SysFreeString(type
);
5031 IHTMLLinkElement_Release(link
);
5034 #define test_script_text(a,b) _test_script_text(__LINE__,a,b)
5035 static void _test_script_text(unsigned line
, IHTMLScriptElement
*script
, const WCHAR
*extext
)
5040 str
= (void*)0xdeadbeef;
5041 hres
= IHTMLScriptElement_get_text(script
, &str
);
5042 ok_(__FILE__
,line
)(hres
== S_OK
, "get_text failed: %08lx\n", hres
);
5043 ok(!lstrcmpW(str
, extext
), "text = %s, expected \"%s\"\n", wine_dbgstr_w(str
), wine_dbgstr_w(extext
));
5047 #define link_put_type(a,b) _link_put_type(__LINE__,a,b)
5048 static void _link_put_type(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
5050 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
5051 BSTR str
= SysAllocString(v
);
5054 hres
= IHTMLLinkElement_put_type(link
, str
);
5055 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08lx\n", hres
);
5057 IHTMLLinkElement_Release(link
);
5058 _test_link_type(line
, elem
, v
);
5061 #define test_link_href(a,b) _test_link_href(__LINE__,a,b)
5062 static void _test_link_href(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
5064 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
5068 hres
= IHTMLLinkElement_get_href(link
, &href
);
5069 ok_(__FILE__
,line
)(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
5071 ok_(__FILE__
,line
)(!lstrcmpW(href
, v
), "href = %s, expected %s\n", wine_dbgstr_w(href
), wine_dbgstr_w(v
));
5073 ok_(__FILE__
,line
)(!href
, "href = %s, expected NULL\n", wine_dbgstr_w(href
));
5074 SysFreeString(href
);
5076 IHTMLLinkElement_Release(link
);
5079 #define link_put_href(a,b) _link_put_href(__LINE__,a,b)
5080 static void _link_put_href(unsigned line
, IHTMLElement
*elem
, const WCHAR
*v
)
5082 IHTMLLinkElement
*link
= _get_link_iface(line
, (IUnknown
*)elem
);
5083 BSTR str
= SysAllocString(v
);
5086 hres
= IHTMLLinkElement_put_href(link
, str
);
5087 ok_(__FILE__
,line
)(hres
== S_OK
, "put_disabled failed: %08lx\n", hres
);
5089 IHTMLLinkElement_Release(link
);
5090 _test_link_href(line
, elem
, v
);
5093 #define get_elem_doc(e) _get_elem_doc(__LINE__,e)
5094 static IHTMLDocument2
*_get_elem_doc(unsigned line
, IUnknown
*unk
)
5096 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
5097 IHTMLDocument2
*doc
;
5102 hres
= IHTMLElement_get_document(elem
, &disp
);
5103 ok(hres
== S_OK
, "get_document failed: %08lx\n", hres
);
5104 ok(disp
!= NULL
, "disp == NULL\n");
5105 IHTMLElement_Release(elem
);
5107 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDocument2
, (void**)&doc
);
5108 IDispatch_Release(disp
);
5109 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08lx\n", hres
);
5114 #define get_elem_attr_node(a,b,c) _get_elem_attr_node(__LINE__,a,b,c)
5115 static IHTMLDOMAttribute
*_get_elem_attr_node(unsigned line
, IUnknown
*unk
, const WCHAR
*attr_name
, BOOL expect_success
)
5117 IHTMLElement4
*elem
= _get_elem4_iface(line
, unk
);
5118 BSTR str
= SysAllocString(attr_name
);
5119 IHTMLDOMAttribute
*attr
;
5122 attr
= (void*)0xdeadbeef;
5123 hres
= IHTMLElement4_getAttributeNode(elem
, str
, &attr
);
5124 ok_(__FILE__
,line
)(hres
== S_OK
, "getAttributeNode failed: %08lx\n", hres
);
5126 ok_(__FILE__
,line
)(attr
!= NULL
, "attr = NULL\n");
5128 ok_(__FILE__
,line
)(!attr
, "attr = %p\n", attr
);
5130 IHTMLElement4_Release(elem
);
5135 #define get_attr_node_value(a,b,c) _get_attr_node_value(__LINE__,a,b,c)
5136 static void _get_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT
*v
, VARTYPE vt
)
5141 hres
= IHTMLDOMAttribute_get_nodeValue(attr
, v
);
5142 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08lx\n", hres
);
5143 ok_(__FILE__
,line
) (V_VT(v
) == vt
, "vt=%d, expected %d\n", V_VT(v
), vt
);
5146 #define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
5147 static void _put_attr_node_value(unsigned line
, IHTMLDOMAttribute
*attr
, VARIANT v
)
5151 hres
= IHTMLDOMAttribute_put_nodeValue(attr
, v
);
5152 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08lx\n", hres
);
5155 #define put_attr_value(a,b) _put_attr_value(__LINE__,a,b)
5156 static void _put_attr_value(unsigned line
, IHTMLDOMAttribute
*attr
, const WCHAR
*value
)
5158 IHTMLDOMAttribute2
*attr2
= _get_attr2_iface(line
, (IUnknown
*)attr
);
5159 BSTR str
= SysAllocString(value
);
5162 hres
= IHTMLDOMAttribute2_put_value(attr2
, str
);
5163 ok_(__FILE__
,line
) (hres
== S_OK
, "put_nodeValue failed: %08lx\n", hres
);
5165 IHTMLDOMAttribute2_Release(attr2
);
5169 #define get_window_doc(e) _get_window_doc(__LINE__,e)
5170 static IHTMLDocument2
*_get_window_doc(unsigned line
, IHTMLWindow2
*window
)
5172 IHTMLDocument2
*doc
;
5176 hres
= IHTMLWindow2_get_document(window
, &doc
);
5177 ok(hres
== S_OK
, "get_document failed: %08lx\n", hres
);
5178 ok(doc
!= NULL
, "disp == NULL\n");
5183 #define doc_get_body(d) _doc_get_body(__LINE__,d)
5184 static IHTMLElement
*_doc_get_body(unsigned line
, IHTMLDocument2
*doc
)
5189 hres
= IHTMLDocument2_get_body(doc
, &elem
);
5190 ok_(__FILE__
,line
)(hres
== S_OK
, "get_body failed: %08lx\n", hres
);
5191 ok_(__FILE__
,line
)(elem
!= NULL
, "body == NULL\n");
5196 static void set_body_html(IHTMLDocument2
*doc
, const WCHAR
*html
)
5199 body
= doc_get_body(doc
);
5200 test_elem_set_innerhtml((IUnknown
*)body
, html
);
5201 IHTMLElement_Release(body
);
5204 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
5205 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*tag
)
5207 IHTMLElement
*elem
= NULL
;
5211 tmp
= SysAllocString(tag
);
5212 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
5213 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08lx\n", hres
);
5214 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
5220 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
5221 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*text
)
5223 IHTMLDocument3
*doc3
;
5224 IHTMLDOMNode
*node
= NULL
;
5228 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5229 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08lx\n", hres
);
5231 tmp
= SysAllocString(text
);
5232 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
5233 IHTMLDocument3_Release(doc3
);
5235 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08lx\n", hres
);
5236 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
5241 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
5242 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
5244 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5245 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
5246 IHTMLDOMNode
*new_child
= NULL
;
5249 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
5250 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08lx\n", hres
);
5251 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5252 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5254 IHTMLDOMNode_Release(node
);
5255 IHTMLDOMNode_Release(child
);
5260 #define test_node_append_child_discard(n,c) _test_node_append_child_discard(__LINE__,n,c)
5261 static void _test_node_append_child_discard(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
5263 IHTMLDOMNode
*node
= _test_node_append_child(line
, node_unk
, child_unk
);
5264 IHTMLDOMNode_Release(node
);
5267 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
5268 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
5270 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
5271 IHTMLDOMNode
*new_child
= NULL
;
5274 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
5275 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08lx\n", hres
);
5276 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
5277 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
5279 IHTMLDOMNode_Release(node
);
5284 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
5285 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
5287 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
5288 IHTMLDOMNode
*new_node
= NULL
;
5291 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
5292 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08lx\n", hres
);
5293 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
5294 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
5296 IHTMLDOMNode_Release(node
);
5297 IHTMLDOMNode_Release(new_node
);
5300 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
5301 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*extitle
)
5306 hres
= IHTMLDocument2_get_title(doc
, &title
);
5307 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08lx\n", hres
);
5308 ok_(__FILE__
,line
) (!lstrcmpW(title
, extitle
), "unexpected title %s\n", wine_dbgstr_w(title
));
5309 SysFreeString(title
);
5312 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
5313 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*title
)
5318 tmp
= SysAllocString(title
);
5319 hres
= IHTMLDocument2_put_title(doc
, tmp
);
5320 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08lx\n", hres
);
5324 static void test_doc_GetIDsOfNames(IHTMLDocument2
*doc
)
5330 bstr
[0] = SysAllocString(L
"createStyleSheet");
5331 bstr
[1] = SysAllocString(L
"bstrHref");
5332 bstr
[2] = SysAllocString(L
"lIndex");
5334 dispids
[1] = 0xdead;
5335 dispids
[2] = 0xbeef;
5336 hres
= IHTMLDocument2_GetIDsOfNames(doc
, &IID_NULL
, bstr
, 3, 0, dispids
);
5337 ok(hres
== S_OK
, "GetIDsOfNames failed: %08lx\n", hres
);
5338 ok(dispids
[0] == DISPID_IHTMLDOCUMENT2_CREATESTYLESHEET
, "createStyleSheet dispid = %ld\n", dispids
[0]);
5339 ok(dispids
[1] == 0xdead, "bstrHref dispid = %ld\n", dispids
[1]);
5340 ok(dispids
[2] == 0xbeef, "lIndex dispid = %ld\n", dispids
[2]);
5341 SysFreeString(bstr
[2]);
5342 SysFreeString(bstr
[1]);
5343 SysFreeString(bstr
[0]);
5346 static void test_window_GetIDsOfNames(IHTMLWindow2
*window
)
5352 bstr
[0] = SysAllocString(L
"showHelp");
5353 bstr
[1] = SysAllocString(L
"helpURL");
5354 bstr
[2] = SysAllocString(L
"helpArg");
5356 dispids
[1] = 0xdead;
5357 dispids
[2] = 0xbeef;
5358 hres
= IHTMLWindow2_GetIDsOfNames(window
, &IID_NULL
, bstr
, 3, 0, dispids
);
5359 ok(hres
== S_OK
, "GetIDsOfNames failed: %08lx\n", hres
);
5360 ok(dispids
[0] == DISPID_IHTMLWINDOW2_SHOWHELP
, "showHelp dispid = %ld\n", dispids
[0]);
5361 ok(dispids
[1] == 0xdead, "helpURL dispid = %ld\n", dispids
[1]);
5362 ok(dispids
[2] == 0xbeef, "helpArg dispid = %ld\n", dispids
[2]);
5363 SysFreeString(bstr
[2]);
5364 SysFreeString(bstr
[1]);
5365 SysFreeString(bstr
[0]);
5368 static void test_elem_GetIDsOfNames(IHTMLElement
*elem
)
5374 /* IE9+ use something like js proxies even on native and have different dispids */
5375 if(compat_mode
>= COMPAT_IE9
)
5378 bstr
[0] = SysAllocString(L
"insertAdjacentText");
5379 bstr
[1] = SysAllocString(L
"where");
5380 bstr
[2] = SysAllocString(L
"text");
5382 dispids
[1] = 0xdead;
5383 dispids
[2] = 0xbeef;
5384 hres
= IHTMLElement_GetIDsOfNames(elem
, &IID_NULL
, bstr
, 3, 0, dispids
);
5385 ok(hres
== S_OK
, "GetIDsOfNames failed: %08lx\n", hres
);
5386 ok(dispids
[0] == DISPID_IHTMLELEMENT_INSERTADJACENTTEXT
, "insertAdjacentText dispid = %ld\n", dispids
[0]);
5387 ok(dispids
[1] == 0xdead, "where dispid = %ld\n", dispids
[1]);
5388 ok(dispids
[2] == 0xbeef, "text dispid = %ld\n", dispids
[2]);
5389 SysFreeString(bstr
[2]);
5390 SysFreeString(bstr
[1]);
5391 SysFreeString(bstr
[0]);
5394 static void test_attr_GetIDsOfNames(IHTMLDOMAttribute
*attr
)
5400 bstr
[0] = SysAllocString(L
"insertBefore");
5401 bstr
[1] = SysAllocString(L
"newChild");
5402 bstr
[2] = SysAllocString(L
"refChild");
5404 dispids
[1] = 0xdead;
5405 dispids
[2] = 0xbeef;
5406 hres
= IHTMLDOMAttribute_GetIDsOfNames(attr
, &IID_NULL
, bstr
, 3, 0, dispids
);
5407 ok(hres
== S_OK
, "GetIDsOfNames failed: %08lx\n", hres
);
5408 ok(dispids
[0] == DISPID_IHTMLDOMATTRIBUTE2_INSERTBEFORE
, "insertBefore dispid = %ld\n", dispids
[0]);
5409 ok(dispids
[1] == 0xdead, "newChild dispid = %ld\n", dispids
[1]);
5410 ok(dispids
[2] == 0xbeef, "refChild dispid = %ld\n", dispids
[2]);
5411 SysFreeString(bstr
[2]);
5412 SysFreeString(bstr
[1]);
5413 SysFreeString(bstr
[0]);
5416 static void test_elem_bounding_client_rect(IUnknown
*unk
)
5418 IHTMLRectCollection
*rects
;
5419 IHTMLRect
*rect
, *rect2
;
5420 IEnumVARIANT
*enum_var
;
5421 IHTMLElement2
*elem2
;
5428 elem2
= get_elem2_iface(unk
);
5429 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect
);
5430 ok(hres
== S_OK
, "getBoundingClientRect failed: %08lx\n", hres
);
5431 hres
= IHTMLElement2_getBoundingClientRect(elem2
, &rect2
);
5432 ok(hres
== S_OK
, "getBoundingClientRect failed: %08lx\n", hres
);
5433 ok(rect
!= NULL
, "rect == NULL\n");
5434 ok(rect
!= rect2
, "rect == rect2\n");
5435 IHTMLRect_Release(rect2
);
5437 test_disp((IUnknown
*)rect
, &IID_IHTMLRect
, NULL
, L
"[object]");
5440 hres
= IHTMLRect_get_top(rect
, &l
);
5441 ok(hres
== S_OK
, "get_top failed: %08lx\n", hres
);
5442 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5445 hres
= IHTMLRect_get_left(rect
, &l
);
5446 ok(hres
== S_OK
, "get_left failed: %08lx\n", hres
);
5447 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5450 hres
= IHTMLRect_get_bottom(rect
, &l
);
5451 ok(hres
== S_OK
, "get_bottom failed: %08lx\n", hres
);
5452 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5455 hres
= IHTMLRect_get_right(rect
, &l
);
5456 ok(hres
== S_OK
, "get_right failed: %08lx\n", hres
);
5457 ok(l
!= 0xdeadbeef, "l = 0xdeadbeef\n");
5459 IHTMLRect_Release(rect
);
5461 hres
= IHTMLElement2_getClientRects(elem2
, &rects
);
5462 ok(hres
== S_OK
, "getClientRects failed: %08lx\n", hres
);
5464 test_disp((IUnknown
*)rects
, &IID_IHTMLRectCollection
, NULL
, L
"[object]");
5466 hres
= IHTMLRectCollection_get_length(rects
, &l
);
5467 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
5468 ok(l
== 1, "length = %lu\n", l
);
5470 V_VT(&index
) = VT_I4
;
5472 V_VT(&v
) = VT_ERROR
;
5473 hres
= IHTMLRectCollection_item(rects
, &index
, &v
);
5474 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5475 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
5476 test_disp((IUnknown
*)V_DISPATCH(&v
), &IID_IHTMLRect
, NULL
, L
"[object]");
5479 hres
= IHTMLRectCollection_get__newEnum(rects
, &enum_unk
);
5480 ok(hres
== S_OK
, "_newEnum failed: %08lx\n", hres
);
5482 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
5483 IUnknown_Release(enum_unk
);
5484 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
5487 V_VT(&v
) = VT_ERROR
;
5488 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5489 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
5490 ok(fetched
== 1, "fetched = %lu\n", fetched
);
5491 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
5492 ok(V_DISPATCH(&v
) != NULL
, "V_DISPATCH(&v) == NULL\n");
5493 test_disp((IUnknown
*)V_DISPATCH(&v
), &IID_IHTMLRect
, NULL
, L
"[object]");
5497 V_VT(&v
) = VT_ERROR
;
5498 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5499 ok(hres
== S_FALSE
, "Next failed: %08lx\n", hres
);
5500 ok(fetched
== 0, "fetched = %lu\n", fetched
);
5501 IEnumVARIANT_Release(enum_var
);
5503 IHTMLRectCollection_Release(rects
);
5504 IHTMLElement2_Release(elem2
);
5507 static void test_elem_col_item(IHTMLElementCollection
*col
, const WCHAR
*n
,
5508 const elem_type_t
*elem_types
, LONG len
)
5511 VARIANT name
, index
;
5515 V_VT(&index
) = VT_EMPTY
;
5516 V_VT(&name
) = VT_BSTR
;
5517 V_BSTR(&name
) = SysAllocString(n
);
5519 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5520 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5522 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
5523 IDispatch_Release(disp
);
5525 V_VT(&index
) = VT_I4
;
5527 for(i
=0; i
<len
; i
++) {
5529 disp
= (void*)0xdeadbeef;
5530 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5531 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5532 ok(disp
!= NULL
, "disp == NULL\n");
5533 if(FAILED(hres
) || !disp
)
5536 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
5538 IDispatch_Release(disp
);
5542 disp
= (void*)0xdeadbeef;
5543 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5544 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5545 ok(disp
== NULL
, "disp != NULL\n");
5548 disp
= (void*)0xdeadbeef;
5549 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5550 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
5551 ok(disp
== NULL
, "disp != NULL\n");
5553 SysFreeString(V_BSTR(&name
));
5556 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, const WCHAR
*id
, BOOL expect_success
)
5558 IHTMLElementCollection
*col
;
5560 IDispatch
*disp
= (void*)0xdeadbeef;
5561 VARIANT name
, index
;
5564 hres
= IHTMLDocument2_get_all(doc
, &col
);
5565 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
5566 ok(col
!= NULL
, "col == NULL\n");
5567 if(FAILED(hres
) || !col
)
5570 V_VT(&index
) = VT_EMPTY
;
5571 V_VT(&name
) = VT_BSTR
;
5572 V_BSTR(&name
) = SysAllocString(id
);
5574 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
5575 IHTMLElementCollection_Release(col
);
5576 SysFreeString(V_BSTR(&name
));
5577 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5578 if(!expect_success
) {
5579 ok(disp
== NULL
, "disp != NULL\n");
5583 ok(disp
!= NULL
, "disp == NULL\n");
5587 elem
= get_elem_iface((IUnknown
*)disp
);
5588 IDispatch_Release(disp
);
5590 test_elem_GetIDsOfNames(elem
);
5594 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, const WCHAR
*id
)
5596 IHTMLDocument3
*doc3
;
5601 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
5602 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08lx\n", hres
);
5604 tmp
= SysAllocString(id
);
5605 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
5607 ok(hres
== S_OK
, "getElementById(%s) failed: %08lx\n", wine_dbgstr_w(id
), hres
);
5609 IHTMLDocument3_Release(doc3
);
5612 test_elem_GetIDsOfNames(elem
);
5616 static void test_select_elem(IHTMLSelectElement
*select
)
5618 IDispatch
*disp
, *disp2
;
5619 VARIANT name
, index
, v
;
5620 IEnumVARIANT
*enum_var
;
5625 test_select_type(select
, L
"select-one");
5626 test_select_length(select
, 2);
5627 test_select_selidx(select
, 0);
5628 test_select_put_selidx(select
, 1);
5630 test_select_set_value(select
, L
"val1");
5631 test_select_value(select
, L
"val1");
5633 test_select_size(select
, 0);
5634 test_select_set_size(select
, 1, S_OK
);
5635 test_select_size(select
, 1);
5637 test_select_set_size(select
, -1, CTL_E_INVALIDPROPERTYVALUE
);
5638 test_select_size(select
, 1);
5639 test_select_set_size(select
, 3, S_OK
);
5640 test_select_size(select
, 3);
5642 test_select_name(select
, NULL
);
5643 test_select_set_name(select
, L
"select-name");
5644 test_select_name(select
, L
"select-name");
5645 test_select_form_notfound(select
);
5647 test_select_get_disabled(select
, VARIANT_FALSE
);
5648 test_select_set_disabled(select
, VARIANT_TRUE
);
5649 test_select_set_disabled(select
, VARIANT_FALSE
);
5652 hres
= IHTMLSelectElement_get_options(select
, &disp
);
5653 ok(hres
== S_OK
, "get_options failed: %08lx\n", hres
);
5654 ok(disp
!= NULL
, "options == NULL\n");
5655 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)select
), "disp != select\n");
5656 IDispatch_Release(disp
);
5658 V_VT(&index
) = VT_EMPTY
;
5659 V_VT(&name
) = VT_I4
;
5661 disp
= (void*)0xdeadbeef;
5662 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5663 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
5664 ok(!disp
, "disp = %p\n", disp
);
5667 disp
= (void*)0xdeadbeef;
5668 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5669 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5670 ok(!disp
, "disp = %p\n", disp
);
5673 hres
= IHTMLSelectElement_item(select
, name
, index
, NULL
);
5674 ok(hres
== E_POINTER
|| broken(hres
== E_INVALIDARG
), "item failed: %08lx, expected E_POINTER\n", hres
);
5677 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp
);
5678 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5679 ok(disp
!= NULL
, "disp = NULL\n");
5680 test_disp((IUnknown
*)disp
, &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5682 V_VT(&index
) = VT_I4
;
5685 hres
= IHTMLSelectElement_item(select
, name
, index
, &disp2
);
5686 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5687 ok(disp2
!= NULL
, "disp = NULL\n");
5688 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5689 IDispatch_Release(disp2
);
5690 IDispatch_Release(disp
);
5692 hres
= IHTMLSelectElement_get__newEnum(select
, &enum_unk
);
5693 ok(hres
== S_OK
, "_newEnum failed: %08lx\n", hres
);
5695 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
5696 IUnknown_Release(enum_unk
);
5697 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
5700 V_VT(&v
) = VT_ERROR
;
5701 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5702 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
5703 ok(fetched
== 1, "fetched = %lu\n", fetched
);
5704 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
5705 ok(V_DISPATCH(&v
) != NULL
, "V_DISPATCH(&v) == NULL\n");
5706 test_disp((IUnknown
*)V_DISPATCH(&v
), &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5710 V_VT(&v
) = VT_ERROR
;
5711 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5712 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
5713 ok(fetched
== 1, "fetched = %lu\n", fetched
);
5714 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
5715 ok(V_DISPATCH(&v
) != NULL
, "V_DISPATCH(&v) == NULL\n");
5716 test_disp((IUnknown
*)V_DISPATCH(&v
), &DIID_DispHTMLOptionElement
, &CLSID_HTMLOptionElement
, NULL
);
5720 V_VT(&v
) = VT_ERROR
;
5721 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5722 ok(hres
== S_FALSE
, "Next failed: %08lx\n", hres
);
5723 ok(fetched
== 0, "fetched = %lu\n", fetched
);
5724 IEnumVARIANT_Release(enum_var
);
5726 test_select_multiple(select
, VARIANT_FALSE
);
5727 test_select_set_multiple(select
, VARIANT_TRUE
);
5728 test_select_remove(select
);
5731 static void test_form_item(IHTMLElement
*elem
)
5733 IHTMLFormElement
*form
= get_form_iface((IUnknown
*)elem
);
5734 IDispatch
*disp
, *disp2
;
5735 IEnumVARIANT
*enum_var
;
5736 VARIANT name
, index
, v
;
5741 V_VT(&index
) = VT_EMPTY
;
5742 V_VT(&name
) = VT_I4
;
5744 disp
= (void*)0xdeadbeef;
5745 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5746 if(compat_mode
< COMPAT_IE9
)
5747 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
5749 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5750 ok(!disp
, "disp = %p\n", disp
);
5753 disp
= (void*)0xdeadbeef;
5754 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5755 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5756 ok(!disp
, "disp = %p\n", disp
);
5759 hres
= IHTMLFormElement_item(form
, name
, index
, NULL
);
5760 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
5763 hres
= IHTMLFormElement_item(form
, name
, index
, &disp
);
5764 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5765 ok(disp
!= NULL
, "disp = NULL\n");
5766 test_disp((IUnknown
*)disp
, &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
, NULL
);
5768 V_VT(&index
) = VT_I4
;
5771 hres
= IHTMLFormElement_item(form
, name
, index
, &disp2
);
5772 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
5773 ok(disp2
!= NULL
, "disp = NULL\n");
5774 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)disp2
), "disp != disp2\n");
5775 IDispatch_Release(disp2
);
5776 IDispatch_Release(disp
);
5778 hres
= IHTMLFormElement_get__newEnum(form
, &enum_unk
);
5779 ok(hres
== S_OK
, "_newEnum failed: %08lx\n", hres
);
5781 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
5782 IUnknown_Release(enum_unk
);
5783 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
5786 V_VT(&v
) = VT_ERROR
;
5787 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5788 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
5789 ok(fetched
== 1, "fetched = %lu\n", fetched
);
5790 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
5791 ok(V_DISPATCH(&v
) != NULL
, "V_DISPATCH(&v) == NULL\n");
5792 test_disp((IUnknown
*)V_DISPATCH(&v
), &DIID_DispHTMLTextAreaElement
, &CLSID_HTMLTextAreaElement
, NULL
);
5796 V_VT(&v
) = VT_ERROR
;
5797 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5798 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
5799 ok(fetched
== 1, "fetched = %lu\n", fetched
);
5800 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(v) = %d\n", V_VT(&v
));
5801 ok(V_DISPATCH(&v
) != NULL
, "V_DISPATCH(&v) == NULL\n");
5802 test_disp((IUnknown
*)V_DISPATCH(&v
), &DIID_DispHTMLInputElement
, &CLSID_HTMLInputElement
, NULL
);
5806 V_VT(&v
) = VT_ERROR
;
5807 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
5808 ok(hres
== S_FALSE
, "Next failed: %08lx\n", hres
);
5809 ok(fetched
== 0, "fetched = %lu\n", fetched
);
5810 IEnumVARIANT_Release(enum_var
);
5812 IHTMLFormElement_Release(form
);
5815 static void test_create_option_elem(IHTMLDocument2
*doc
)
5817 IHTMLOptionElement
*option
;
5819 option
= create_option_elem(doc
, L
"test text", L
"test value");
5821 test_option_put_text(option
, L
"new text");
5822 test_option_put_value(option
, L
"new value");
5823 test_option_get_index(option
, 0);
5824 test_option_defaultSelected_property(option
);
5825 test_option_put_selected(option
, VARIANT_TRUE
);
5826 test_option_put_selected(option
, VARIANT_FALSE
);
5828 IHTMLOptionElement_Release(option
);
5831 static void test_option_form(IUnknown
*uoption
, IUnknown
*uform
)
5833 IHTMLOptionElement
*option
= get_option_iface(uoption
);
5834 IHTMLFormElement
*form
;
5837 hres
= IHTMLOptionElement_get_form(option
, NULL
);
5838 ok(hres
== E_POINTER
, "got %08lx\n, expected E_POINTER\n", hres
);
5840 hres
= IHTMLOptionElement_get_form(option
, &form
);
5841 ok(hres
== S_OK
, "get_form failed: %08lx\n", hres
);
5842 ok(form
!= NULL
, "form == NULL\n");
5844 ok(iface_cmp(uform
, (IUnknown
*)form
), "Expected %p, got %p\n", uform
, form
);
5846 IHTMLOptionElement_Release(option
);
5847 IHTMLFormElement_Release(form
);
5850 static void test_create_img_elem(IHTMLDocument2
*doc
)
5852 IHTMLImgElement
*img
;
5854 img
= create_img_elem(doc
, 10, 15);
5857 test_img_put_width(img
, 5);
5858 test_img_put_height(img
, 20);
5860 IHTMLImgElement_Release(img
);
5864 img
= create_img_elem(doc
, -1, -1);
5867 test_img_put_width(img
, 5);
5868 test_img_put_height(img
, 20);
5870 IHTMLImgElement_Release(img
);
5874 #define test_doc_selection_type(a,b) _test_doc_selection_type(__LINE__,a,b)
5875 static void _test_doc_selection_type(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*type
)
5877 IHTMLSelectionObject2
*selection2
;
5878 IHTMLSelectionObject
*selection
;
5882 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
5883 ok_(__FILE__
,line
)(hres
== S_OK
, "get_selection failed: %08lx\n", hres
);
5885 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
5886 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
5887 ok_(__FILE__
,line
)(!lstrcmpW(str
, type
), "type = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(type
));
5890 hres
= IHTMLSelectionObject_QueryInterface(selection
, &IID_IHTMLSelectionObject2
, (void**)&selection2
);
5891 ok_(__FILE__
,line
)(hres
== S_OK
, "Could not get IHTMLSelectionObject2 iface: %08lx\n", hres
);
5893 IHTMLSelectionObject_Release(selection
);
5895 hres
= IHTMLSelectionObject2_get_typeDetail(selection2
, &str
);
5896 ok_(__FILE__
,line
)(hres
== S_OK
, "get_typeDetail failed: %08lx\n", hres
);
5897 ok_(__FILE__
,line
)(!lstrcmpW(str
, L
"undefined"), "typeDetail = %s\n", wine_dbgstr_w(str
));
5900 IHTMLSelectionObject2_Release(selection2
);
5903 #define insert_adjacent_elem(a,b,c) _insert_adjacent_elem(__LINE__,a,b,c)
5904 static void _insert_adjacent_elem(unsigned line
, IHTMLElement
*parent
, const WCHAR
*where
, IHTMLElement
*elem
)
5906 IHTMLElement2
*elem2
= _get_elem2_iface(line
, (IUnknown
*)parent
);
5907 IHTMLElement
*ret_elem
= NULL
;
5908 BSTR str
= SysAllocString(where
);
5911 hres
= IHTMLElement2_insertAdjacentElement(elem2
, str
, elem
, &ret_elem
);
5912 IHTMLElement2_Release(elem2
);
5914 ok_(__FILE__
,line
)(hres
== S_OK
, "insertAdjacentElement failed: %08lx\n", hres
);
5915 ok_(__FILE__
,line
)(ret_elem
== elem
, "ret_elem != elem\n");
5916 IHTMLElement_Release(ret_elem
);
5919 static void test_insert_adjacent_elems(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
5921 IHTMLElement
*elem
, *elem2
;
5923 static const elem_type_t br_br
[] = {ET_BR
, ET_BR
};
5924 static const elem_type_t br_div_br
[] = {ET_BR
, ET_DIV
, ET_BR
};
5926 elem
= test_create_elem(doc
, L
"BR");
5927 elem2
= test_elem_get_parent((IUnknown
*)elem
);
5928 ok(!elem2
, "get_parentElement returned %p\n", elem2
);
5929 insert_adjacent_elem(parent
, L
"BeforeEnd", elem
);
5930 IHTMLElement_Release(elem
);
5932 test_elem_all((IUnknown
*)parent
, br_br
, 1);
5934 elem
= test_create_elem(doc
, L
"BR");
5935 insert_adjacent_elem(parent
, L
"beforeend", elem
);
5937 test_elem_all((IUnknown
*)parent
, br_br
, 2);
5939 elem2
= test_create_elem(doc
, L
"DIV");
5940 insert_adjacent_elem(elem
, L
"beforebegin", elem2
);
5941 IHTMLElement_Release(elem2
);
5942 IHTMLElement_Release(elem
);
5944 test_elem_all((IUnknown
*)parent
, br_div_br
, 3);
5947 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
5949 IHTMLBodyElement
*body
;
5950 IHTMLTxtRange
*range
;
5954 elem
= doc_get_body(doc
);
5955 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
5956 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
5957 IHTMLElement_Release(elem
);
5959 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
5960 IHTMLBodyElement_Release(body
);
5961 ok(hres
== S_OK
, "createTextRange failed: %08lx\n", hres
);
5966 #define range_duplicate(a) _range_duplicate(__LINE__,a)
5967 static IHTMLTxtRange
*_range_duplicate(unsigned line
, IHTMLTxtRange
*range
)
5972 hres
= IHTMLTxtRange_duplicate(range
, &ret
);
5973 ok_(__FILE__
,line
)(hres
== S_OK
, "duplicate failed: %08lx\n", hres
);
5978 #define test_range_set_end_point(a,b,c,d) _test_range_set_end_point(__LINE__,a,b,c,d)
5979 static void _test_range_set_end_point(unsigned line
, IHTMLTxtRange
*range
, const WCHAR
*how
,
5980 IHTMLTxtRange
*ref_range
, HRESULT exhres
)
5982 BSTR str
= SysAllocString(how
);
5985 hres
= IHTMLTxtRange_setEndPoint(range
, str
, ref_range
);
5986 ok_(__FILE__
,line
)(hres
== exhres
, "setEndPoint failed: %08lx, expected %08lx\n", hres
, exhres
);
5990 static void test_txtrange(IHTMLDocument2
*doc
)
5992 IHTMLTxtRange
*body_range
, *range
, *range2
;
5993 IHTMLSelectionObject
*selection
;
5994 IDispatch
*disp_range
;
5998 set_body_html(doc
, L
"test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br />");
6000 body_range
= test_create_body_range(doc
);
6002 test_disp((IUnknown
*)body_range
, &IID_IHTMLTxtRange
, NULL
, L
"[object]");
6004 test_range_text(body_range
, L
"test abc 123\r\nit's text");
6006 range
= range_duplicate(body_range
);
6007 range2
= range_duplicate(body_range
);
6009 test_range_isequal(range
, range2
, VARIANT_TRUE
);
6011 test_range_text(range
, L
"test abc 123\r\nit's text");
6012 test_range_text(body_range
, L
"test abc 123\r\nit's text");
6014 test_range_collapse(range
, TRUE
);
6015 test_range_isequal(range
, range2
, VARIANT_FALSE
);
6016 test_range_inrange(range
, range2
, VARIANT_FALSE
);
6017 test_range_inrange(range2
, range
, VARIANT_TRUE
);
6018 IHTMLTxtRange_Release(range2
);
6020 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"test ");
6021 test_range_expand(range
, wordW
, VARIANT_FALSE
, L
"test ");
6022 test_range_move(range
, characterW
, 2, 2);
6023 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"test ");
6025 test_range_collapse(range
, FALSE
);
6026 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"abc ");
6028 test_range_collapse(range
, FALSE
);
6029 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"123");
6030 test_range_expand(range
, wordW
, VARIANT_FALSE
, L
"123");
6031 test_range_move(range
, characterW
, 2, 2);
6032 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"123");
6033 test_range_moveend(range
, characterW
, -5, -5);
6034 test_range_text(range
, NULL
);
6035 test_range_moveend(range
, characterW
, 3, 3);
6036 test_range_text(range
, L
"c 1");
6037 test_range_expand(range
, texteditW
, VARIANT_TRUE
, L
"test abc 123\r\nit's text");
6038 test_range_collapse(range
, TRUE
);
6039 test_range_move(range
, characterW
, 4, 4);
6040 test_range_moveend(range
, characterW
, 1, 1);
6041 test_range_text(range
, L
" ");
6042 test_range_move(range
, wordW
, 1, 1);
6043 test_range_moveend(range
, characterW
, 2, 2);
6044 test_range_text(range
, L
"ab");
6046 IHTMLTxtRange_Release(range
);
6048 range
= range_duplicate(body_range
);
6050 test_range_text(range
, L
"test abc 123\r\nit's text");
6051 test_range_move(range
, characterW
, 3, 3);
6052 test_range_moveend(range
, characterW
, 1, 1);
6053 test_range_text(range
, L
"t");
6054 test_range_moveend(range
, characterW
, 3, 3);
6055 test_range_text(range
, L
"t ab");
6056 test_range_moveend(range
, characterW
, -2, -2);
6057 test_range_text(range
, L
"t ");
6058 test_range_move(range
, characterW
, 6, 6);
6059 test_range_moveend(range
, characterW
, 3, 3);
6060 test_range_text(range
, L
"123");
6061 test_range_moveend(range
, characterW
, 2, 2);
6062 test_range_text(range
, L
"123\r\ni");
6064 IHTMLTxtRange_Release(range
);
6066 range
= range_duplicate(body_range
);
6068 test_range_move(range
, wordW
, 1, 1);
6069 test_range_moveend(range
, characterW
, 2, 2);
6070 test_range_text(range
, L
"ab");
6072 test_range_move(range
, characterW
, -2, -2);
6073 test_range_moveend(range
, characterW
, 2, 2);
6074 test_range_text(range
, L
"t ");
6076 test_range_move(range
, wordW
, 3, 3);
6077 test_range_move(range
, wordW
, -2, -2);
6078 test_range_moveend(range
, characterW
, 2, 2);
6079 test_range_text(range
, L
"ab");
6081 test_range_move(range
, characterW
, -6, -5);
6082 test_range_moveend(range
, characterW
, -1, 0);
6083 test_range_moveend(range
, characterW
, -6, 0);
6084 test_range_move(range
, characterW
, 2, 2);
6085 test_range_moveend(range
, characterW
, 2, 2);
6086 test_range_text(range
, L
"st");
6087 test_range_moveend(range
, characterW
, -6, -4);
6088 test_range_moveend(range
, characterW
, 2, 2);
6090 IHTMLTxtRange_Release(range
);
6092 range
= range_duplicate(body_range
);
6094 test_range_move(range
, wordW
, 2, 2);
6095 test_range_moveend(range
, characterW
, 2, 2);
6096 test_range_text(range
, L
"12");
6098 test_range_move(range
, characterW
, 15, 14);
6099 test_range_move(range
, characterW
, -2, -2);
6100 test_range_moveend(range
, characterW
, 3, 2);
6101 test_range_text(range
, L
"t");
6102 test_range_moveend(range
, characterW
, -1, -1);
6103 test_range_text(range
, L
"t");
6104 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"text");
6105 test_range_move(range
, characterW
, -2, -2);
6106 test_range_moveend(range
, characterW
, 2, 2);
6107 test_range_text(range
, L
"s ");
6108 test_range_move(range
, characterW
, 100, 7);
6109 test_range_move(range
, wordW
, 1, 0);
6110 test_range_move(range
, characterW
, -2, -2);
6111 test_range_moveend(range
, characterW
, 3, 2);
6112 test_range_text(range
, L
"t");
6114 IHTMLTxtRange_Release(range
);
6116 range
= range_duplicate(body_range
);
6118 test_range_collapse(range
, TRUE
);
6119 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"test ");
6120 test_range_put_text(range
, L
"word");
6121 test_range_text(body_range
, L
"wordabc 123\r\nit's text");
6122 test_range_text(range
, NULL
);
6123 test_range_moveend(range
, characterW
, 3, 3);
6124 test_range_text(range
, L
"abc");
6125 test_range_movestart(range
, characterW
, -2, -2);
6126 test_range_text(range
, L
"rdabc");
6127 test_range_movestart(range
, characterW
, 3, 3);
6128 test_range_text(range
, L
"bc");
6129 test_range_movestart(range
, characterW
, 4, 4);
6130 test_range_text(range
, NULL
);
6131 test_range_movestart(range
, characterW
, -3, -3);
6132 test_range_text(range
, L
"c 1");
6133 test_range_movestart(range
, characterW
, -7, -6);
6134 test_range_text(range
, L
"wordabc 1");
6135 test_range_movestart(range
, characterW
, 100, 22);
6136 test_range_text(range
, NULL
);
6138 IHTMLTxtRange_Release(range
);
6140 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6141 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08lx\n", hres
);
6143 test_disp((IUnknown
*)selection
, &IID_IHTMLSelectionObject
, NULL
, L
"[object]");
6144 test_ifaces((IUnknown
*)selection
, selection_iids
);
6146 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
6147 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08lx\n", hres
);
6148 IHTMLSelectionObject_Release(selection
);
6150 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
6151 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08lx\n", hres
);
6152 IDispatch_Release(disp_range
);
6154 test_range_text(range
, NULL
);
6155 test_range_moveend(range
, characterW
, 3, 3);
6156 test_range_text(range
, L
"wor");
6157 test_range_parent(range
, ET_BODY
);
6158 test_range_expand(range
, texteditW
, VARIANT_TRUE
, L
"wordabc 123\r\nit's text");
6159 test_range_expand(range
, texteditW
, VARIANT_TRUE
, L
"wordabc 123\r\nit's text");
6160 test_range_move(range
, characterW
, 3, 3);
6161 test_range_expand(range
, wordW
, VARIANT_TRUE
, L
"wordabc ");
6162 test_range_moveend(range
, characterW
, -4, -4);
6163 test_range_put_text(range
, L
"abc def ");
6164 test_range_expand(range
, texteditW
, VARIANT_TRUE
, L
"abc def abc 123\r\nit's text");
6165 test_range_move(range
, wordW
, 1, 1);
6166 test_range_movestart(range
, characterW
, -1, -1);
6167 test_range_text(range
, L
" ");
6168 test_range_move(range
, wordW
, 1, 1);
6169 test_range_moveend(range
, characterW
, 3, 3);
6170 test_range_text(range
, L
"def");
6171 test_range_put_text(range
, L
"xyz");
6172 test_range_moveend(range
, characterW
, 1, 1);
6173 test_range_move(range
, wordW
, 1, 1);
6174 test_range_moveend(range
, characterW
, 2, 2);
6175 test_range_text(range
, L
"ab");
6177 body
= doc_get_body(doc
);
6179 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
6180 ok(hres
== S_OK
, "moveToElementText failed: %08lx\n", hres
);
6182 test_range_text(range
, L
"abc xyz abc 123\r\nit's text");
6183 test_range_parent(range
, ET_BODY
);
6185 test_range_move(range
, wordW
, 1, 1);
6186 test_range_moveend(range
, characterW
, 12, 12);
6187 test_range_text(range
, L
"xyz abc 123");
6189 test_range_collapse(range
, VARIANT_TRUE
);
6190 test_range_paste_html(range
, L
"<br>paste<br>");
6191 test_range_text(range
, NULL
);
6193 test_range_moveend(range
, characterW
, 3, 3);
6194 test_range_text(range
, L
"xyz");
6196 hres
= IHTMLTxtRange_moveToElementText(range
, body
);
6197 ok(hres
== S_OK
, "moveToElementText failed: %08lx\n", hres
);
6199 test_range_text(range
, L
"abc \r\npaste\r\nxyz abc 123\r\nit's text");
6201 test_range_move(range
, wordW
, 2, 2);
6202 test_range_collapse(range
, VARIANT_TRUE
);
6203 test_range_moveend(range
, characterW
, 5, 5);
6204 test_range_text(range
, L
"paste");
6206 range2
= range_duplicate(range
);
6208 test_range_set_end_point(range
, L
"starttostart", body_range
, S_OK
);
6209 test_range_text(range
, L
"abc \r\npaste");
6211 test_range_set_end_point(range
, L
"endtoend", body_range
, S_OK
);
6212 test_range_text(range
, L
"abc \r\npaste\r\nxyz abc 123\r\nit's text");
6214 test_range_set_end_point(range
, L
"starttoend", range2
, S_OK
);
6215 test_range_text(range
, L
"\r\nxyz abc 123\r\nit's text");
6217 test_range_set_end_point(range
, L
"starttostart", body_range
, S_OK
);
6218 test_range_set_end_point(range
, L
"endtostart", range2
, S_OK
);
6219 test_range_text(range
, L
"abc ");
6221 test_range_set_end_point(range
, L
"starttoend", body_range
, S_OK
);
6222 test_range_text(range
, L
"paste\r\nxyz abc 123\r\nit's text");
6224 test_range_set_end_point(range
, L
"EndToStart", body_range
, S_OK
);
6225 test_range_text(range
, L
"abc ");
6227 test_range_set_end_point(range
, L
"xxx", body_range
, E_INVALIDARG
);
6229 hres
= IHTMLTxtRange_select(range
);
6230 ok(hres
== S_OK
, "select failed: %08lx\n", hres
);
6232 test_doc_selection_type(doc
, L
"Text");
6234 IHTMLTxtRange_Release(range
);
6235 IHTMLTxtRange_Release(range2
);
6236 IHTMLTxtRange_Release(body_range
);
6237 IHTMLElement_Release(body
);
6239 set_body_html(doc
, L
"<html><body>abc<hr />123<br /><hr />def</body></html>");
6241 range
= test_create_body_range(doc
);
6243 test_range_text(range
, L
"abc\r\n\r\n123\r\n\r\n\r\ndef");
6244 test_range_move(range
, characterW
, 5, 5);
6245 test_range_moveend(range
, characterW
, 1, 1);
6246 test_range_text(range
, L
"2");
6247 test_range_move(range
, characterW
, -3, -3);
6248 test_range_moveend(range
, characterW
, 3, 3);
6249 test_range_text(range
, L
"c\r\n\r\n1");
6250 test_range_collapse(range
, VARIANT_FALSE
);
6251 test_range_moveend(range
, characterW
, 4, 4);
6252 test_range_text(range
, L
"23");
6253 test_range_moveend(range
, characterW
, 1, 1);
6254 test_range_text(range
, L
"23\r\n\r\n\r\nd");
6255 test_range_moveend(range
, characterW
, -1, -1);
6256 test_range_text(range
, L
"23");
6257 test_range_moveend(range
, characterW
, -1, -1);
6258 test_range_text(range
, L
"23");
6259 test_range_moveend(range
, characterW
, -2, -2);
6260 test_range_text(range
, L
"2");
6262 IHTMLTxtRange_Release(range
);
6265 static void test_markup_services(IHTMLDocument2
*doc
)
6267 IMarkupServices
*markup_services
;
6268 IMarkupPointer
*markup_pointer
;
6269 IMarkupPointer2
*markup_pointer2
;
6272 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IMarkupServices
, (void**)&markup_services
);
6273 ok(hres
== S_OK
, "Could not get IMarkupServices iface: %08lx\n", hres
);
6275 hres
= IMarkupServices_CreateMarkupPointer(markup_services
, &markup_pointer
);
6276 ok(hres
== S_OK
, "CreateMarkupPointer failed: %08lx\n", hres
);
6278 hres
= IMarkupPointer_QueryInterface(markup_pointer
, &IID_IMarkupPointer2
, (void**)&markup_pointer2
);
6279 ok(hres
== S_OK
, "Could not get IMarkupPointer2 iface: %08lx\n", hres
);
6281 IMarkupPointer_Release(markup_pointer
);
6282 IMarkupPointer2_Release(markup_pointer2
);
6283 IMarkupServices_Release(markup_services
);
6286 static void test_range(IHTMLDocument2
*doc
)
6289 IDocumentRange
*doc_range
;
6290 IHTMLDOMRange
*range
;
6293 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentRange
, (void **)&doc_range
);
6294 ok(hres
== S_OK
, "Failed to get IDocumentRange: %08lx\n", hres
);
6298 hres
= IDocumentRange_createRange(doc_range
, &range
);
6299 ok(hres
== S_OK
, "Failed to create range, %08lx\n", hres
);
6301 test_disp((IUnknown
*)range
, &DIID_DispHTMLDOMRange
, NULL
, NULL
);
6303 IHTMLDOMRange_Release(range
);
6305 IDocumentRange_Release(doc_range
);
6309 test_markup_services(doc
);
6312 #define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
6313 static void _test_compatmode(unsigned line
, IHTMLDocument2
*doc2
, const WCHAR
*excompat
)
6315 IHTMLDocument5
*doc
= get_htmldoc5_iface((IUnknown
*)doc2
);
6319 hres
= IHTMLDocument5_get_compatMode(doc
, &str
);
6320 ok_(__FILE__
,line
)(hres
== S_OK
, "get_compatMode failed: %08lx\n", hres
);
6321 ok_(__FILE__
,line
)(!lstrcmpW(str
, excompat
), "compatMode = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(excompat
));
6324 IHTMLDocument5_Release(doc
);
6327 static void test_location(IHTMLDocument2
*doc
)
6329 IHTMLLocation
*location
, *location2
;
6330 IHTMLWindow2
*window
;
6334 hres
= IHTMLDocument2_get_location(doc
, &location
);
6335 ok(hres
== S_OK
, "get_location failed: %08lx\n", hres
);
6337 hres
= IHTMLDocument2_get_location(doc
, &location2
);
6338 ok(hres
== S_OK
, "get_location failed: %08lx\n", hres
);
6340 ok(location
== location2
, "location != location2\n");
6341 IHTMLLocation_Release(location2
);
6343 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6344 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
6346 hres
= IHTMLWindow2_get_location(window
, &location2
);
6347 ok(hres
== S_OK
, "get_location failed: %08lx\n", hres
);
6348 ok(location
== location2
, "location != location2\n");
6349 IHTMLLocation_Release(location2
);
6350 IHTMLWindow2_Release(window
);
6352 test_ifaces((IUnknown
*)location
, location_iids
);
6353 test_disp2((IUnknown
*)location
, &DIID_DispHTMLLocation
, &IID_IHTMLLocation
, NULL
, L
"about:blank");
6355 hres
= IHTMLLocation_get_pathname(location
, &str
);
6356 ok(hres
== S_OK
, "get_pathname failed: %08lx\n", hres
);
6357 ok(!lstrcmpW(str
, L
"blank"), "unexpected pathname %s\n", wine_dbgstr_w(str
));
6360 hres
= IHTMLLocation_get_href(location
, NULL
);
6361 ok(hres
== E_POINTER
, "get_href passed: %08lx\n", hres
);
6363 hres
= IHTMLLocation_get_href(location
, &str
);
6364 ok(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
6365 ok(!lstrcmpW(str
, L
"about:blank"), "unexpected href %s\n", wine_dbgstr_w(str
));
6368 IHTMLLocation_Release(location
);
6371 static void test_plugins_col(IHTMLDocument2
*doc
)
6373 IHTMLPluginsCollection
*col
, *col2
;
6374 IHTMLWindow2
*window
;
6380 window
= get_doc_window(doc
);
6381 hres
= IHTMLWindow2_get_navigator(window
, &nav
);
6382 ok(hres
== S_OK
, "get_navigator failed: %08lx\n", hres
);
6383 IHTMLWindow2_Release(window
);
6385 hres
= IOmNavigator_get_plugins(nav
, &col
);
6386 ok(hres
== S_OK
, "get_plugins failed: %08lx\n", hres
);
6388 hres
= IOmNavigator_get_plugins(nav
, &col2
);
6389 ok(hres
== S_OK
, "get_plugins failed: %08lx\n", hres
);
6390 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
6391 IHTMLPluginsCollection_Release(col2
);
6393 test_disp2((IUnknown
*)col
, &DIID_DispCPlugins
, &IID_IHTMLPluginsCollection
, NULL
, L
"[object]");
6396 hres
= IHTMLPluginsCollection_get_length(col
, &len
);
6397 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
6398 ok(!len
, "length = %ld\n", len
);
6400 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_FALSE
);
6401 ok(hres
== S_OK
, "refresh failed: %08lx\n", hres
);
6403 hres
= IHTMLPluginsCollection_refresh(col
, VARIANT_TRUE
);
6404 ok(hres
== S_OK
, "refresh failed: %08lx\n", hres
);
6406 ref
= IHTMLPluginsCollection_Release(col
);
6407 ok(!ref
, "ref=%ld\n", ref
);
6409 IOmNavigator_Release(nav
);
6412 static void test_mime_types_col(IOmNavigator
*nav
)
6414 IHTMLMimeTypesCollection
*col
, *col2
;
6419 hres
= IOmNavigator_get_mimeTypes(nav
, &col
);
6420 ok(hres
== S_OK
, "get_mimeTypes failed: %08lx\n", hres
);
6422 hres
= IOmNavigator_get_mimeTypes(nav
, &col2
);
6423 ok(hres
== S_OK
, "get_mimeTypes failed: %08lx\n", hres
);
6424 ok(iface_cmp((IUnknown
*)col
, (IUnknown
*)col2
), "col != col2\n");
6425 IHTMLMimeTypesCollection_Release(col2
);
6427 test_disp((IUnknown
*)col
, &IID_IHTMLMimeTypesCollection
, NULL
, L
"[object]");
6429 length
= 0xdeadbeef;
6430 hres
= IHTMLMimeTypesCollection_get_length(col
, &length
);
6431 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
6432 ok(!length
, "length = %ld\n", length
);
6434 ref
= IHTMLMimeTypesCollection_Release(col
);
6435 ok(!ref
, "ref=%ld\n", ref
);
6438 #define test_framebase_name(a,b) _test_framebase_name(__LINE__,a,b)
6439 static void _test_framebase_name(unsigned line
, IHTMLElement
*elem
, const WCHAR
*name
)
6441 BSTR str
= (void*)0xdeadbeef;
6442 IHTMLFrameBase
*fbase
;
6445 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6446 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08lx\n", hres
);
6448 hres
= IHTMLFrameBase_get_name(fbase
, &str
);
6449 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_name failed: 0x%08lx\n", hres
);
6451 ok_(__FILE__
,line
)(!lstrcmpW(str
, name
), "name = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(name
));
6453 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
6456 IHTMLFrameBase_Release(fbase
);
6459 #define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b)
6460 static void _test_framebase_put_name(unsigned line
, IHTMLElement
*elem
, const WCHAR
*name
)
6462 IHTMLFrameBase
*fbase
;
6466 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6467 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08lx\n", hres
);
6469 str
= name
? SysAllocString(name
) : NULL
;
6470 hres
= IHTMLFrameBase_put_name(fbase
, str
);
6471 ok_(__FILE__
,line
)(hres
== S_OK
, "put_name failed: %08lx\n", hres
);
6474 _test_framebase_name(line
, elem
, name
);
6475 IHTMLFrameBase_Release(fbase
);
6478 #define test_framebase_src(a,b) _test_framebase_src(__LINE__,a,b)
6479 static void _test_framebase_src(unsigned line
, IHTMLElement
*elem
, const WCHAR
*src
)
6481 BSTR str
= (void*)0xdeadbeef;
6482 IHTMLFrameBase
*fbase
;
6485 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6486 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08lx\n", hres
);
6488 hres
= IHTMLFrameBase_get_src(fbase
, &str
);
6489 ok_(__FILE__
,line
)(hres
== S_OK
, "IHTMLFrameBase_get_src failed: 0x%08lx\n", hres
);
6491 ok_(__FILE__
,line
)(!lstrcmpW(str
, src
), "src = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(src
));
6493 ok_(__FILE__
,line
)(!str
, "src = %s, expected NULL\n", wine_dbgstr_w(str
));
6496 IHTMLFrameBase_Release(fbase
);
6499 #define test_framebase_marginheight(a,b) _test_framebase_marginheight(__LINE__,a,b)
6500 static void _test_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const WCHAR
*exval
)
6505 hres
= IHTMLFrameBase_get_marginHeight(framebase
, &v
);
6506 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginHeight failed: %08lx\n", hres
);
6507 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginHeight) = %d\n", V_VT(&v
));
6509 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&v
), exval
), "marginHeight = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6511 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginHeight = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6515 #define set_framebase_marginheight(a,b) _set_framebase_marginheight(__LINE__,a,b)
6516 static void _set_framebase_marginheight(unsigned line
, IHTMLFrameBase
*framebase
, const WCHAR
*val
)
6522 V_BSTR(&v
) = SysAllocString(val
);
6523 hres
= IHTMLFrameBase_put_marginHeight(framebase
, v
);
6524 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginHeight failed: %08lx\n", hres
);
6528 #define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b)
6529 static void _test_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const WCHAR
*exval
)
6534 hres
= IHTMLFrameBase_get_marginWidth(framebase
, &v
);
6535 ok_(__FILE__
,line
)(hres
== S_OK
, "get_marginWidth failed: %08lx\n", hres
);
6536 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(marginWidth) = %d\n", V_VT(&v
));
6538 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&v
), exval
), "marginWidth = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
6540 ok_(__FILE__
,line
)(!V_BSTR(&v
), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
6544 #define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b)
6545 static void _set_framebase_marginwidth(unsigned line
, IHTMLFrameBase
*framebase
, const WCHAR
*val
)
6551 V_BSTR(&v
) = SysAllocString(val
);
6552 hres
= IHTMLFrameBase_put_marginWidth(framebase
, v
);
6553 ok_(__FILE__
,line
)(hres
== S_OK
, "put_marginWidth failed: %08lx\n", hres
);
6557 static void test_framebase(IUnknown
*unk
)
6559 IHTMLFrameBase
*fbase
;
6563 /* get/put scrolling */
6564 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLFrameBase
, (void**)&fbase
);
6565 ok(hres
== S_OK
, "Could not get IHTMLFrameBase interface: 0x%08lx\n", hres
);
6567 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6568 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08lx\n", hres
);
6569 ok(!lstrcmpW(str
, L
"auto"), "get_scrolling should have given 'auto', gave: %s\n", wine_dbgstr_w(str
));
6572 str
= SysAllocString(L
"no");
6573 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6574 ok(hres
== S_OK
, "IHTMLFrameBase_put_scrolling failed: 0x%08lx\n", hres
);
6577 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6578 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08lx\n", hres
);
6579 ok(!lstrcmpW(str
, L
"no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6582 str
= SysAllocString(L
"junk");
6583 hres
= IHTMLFrameBase_put_scrolling(fbase
, str
);
6584 ok(hres
== E_INVALIDARG
, "IHTMLFrameBase_put_scrolling should have failed "
6585 "with E_INVALIDARG, instead: 0x%08lx\n", hres
);
6588 hres
= IHTMLFrameBase_get_scrolling(fbase
, &str
);
6589 ok(hres
== S_OK
, "IHTMLFrameBase_get_scrolling failed: 0x%08lx\n", hres
);
6590 ok(!lstrcmpW(str
, L
"no"), "get_scrolling should have given 'no', gave: %s\n", wine_dbgstr_w(str
));
6593 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6594 ok(hres
== S_OK
, "get_frameBorder failed: %08lx\n", hres
);
6595 ok(!str
, "frameBorder = %s\n", wine_dbgstr_w(str
));
6597 str
= SysAllocString(L
"1");
6598 hres
= IHTMLFrameBase_put_frameBorder(fbase
, str
);
6599 ok(hres
== S_OK
, "put_frameBorder failed: %08lx\n", hres
);
6602 hres
= IHTMLFrameBase_get_frameBorder(fbase
, &str
);
6603 ok(hres
== S_OK
, "get_frameBorder failed: %08lx\n", hres
);
6604 ok(!lstrcmpW(str
, L
"1"), "frameBorder = %s, expected \"1\"\n", wine_dbgstr_w(str
));
6607 test_framebase_marginheight(fbase
, NULL
);
6608 set_framebase_marginheight(fbase
, L
"1px");
6609 test_framebase_marginheight(fbase
, L
"1");
6611 test_framebase_marginwidth(fbase
, NULL
);
6612 set_framebase_marginwidth(fbase
, L
"2px");
6613 test_framebase_marginwidth(fbase
, L
"2");
6615 IHTMLFrameBase_Release(fbase
);
6618 #define test_language_string(a,b) _test_language_string(__LINE__,a,b)
6619 static void _test_language_string(unsigned line
, const WCHAR
*lang
, LCID lcid
)
6624 if(pLCIDToLocaleName
) {
6625 res
= pLCIDToLocaleName(lcid
, buf
, ARRAY_SIZE(buf
), 0);
6626 ok_(__FILE__
,line
)(res
, "LCIDToLocaleName failed: %lu\n", GetLastError());
6627 ok_(__FILE__
,line
)(!lstrcmpW(lang
, buf
), "lang = %s, expected %s\n", wine_dbgstr_w(lang
), wine_dbgstr_w(buf
));
6629 win_skip("LCIDToLocaleName not available, unable to test language string\n");
6630 ok_(__FILE__
,line
)(lang
!= NULL
, "lang == NULL\n");
6634 #define test_table_length(t,l) _test_table_length(__LINE__,t,l)
6635 static void _test_table_length(unsigned line
, IHTMLTable
*table
, LONG expect
)
6637 IHTMLElementCollection
*col
;
6641 hres
= IHTMLTable_get_rows(table
, &col
);
6642 ok_(__FILE__
,line
)(hres
== S_OK
, "get_rows failed: %08lx\n", hres
);
6643 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
6644 if (hres
!= S_OK
|| col
== NULL
)
6646 hres
= IHTMLElementCollection_get_length(col
, &len
);
6647 ok_(__FILE__
,line
)(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
6648 ok_(__FILE__
,line
)(len
== expect
, "Expect %ld, got %ld\n", expect
, len
);
6650 IHTMLElementCollection_Release(col
);
6653 static void test_navigator(IHTMLDocument2
*doc
)
6655 IHTMLWindow2
*window
;
6656 IOmNavigator
*navigator
, *navigator2
;
6665 static const WCHAR v40
[] = {'4','.','0'};
6666 static char ua
[] = "1234567890xxxABC";
6668 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
6669 ok(hres
== S_OK
, "parentWidnow failed: %08lx\n", hres
);
6671 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
6672 ok(hres
== S_OK
, "get_navigator failed: %08lx\n", hres
);
6673 ok(navigator
!= NULL
, "navigator == NULL\n");
6674 test_disp2((IUnknown
*)navigator
, &DIID_DispHTMLNavigator
, &IID_IOmNavigator
, NULL
, L
"[object]");
6676 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
6677 ok(hres
== S_OK
, "get_navigator failed: %08lx\n", hres
);
6679 ok(navigator
!= navigator2
, "navigator2 != navigator\n");
6680 IOmNavigator_Release(navigator2
);
6682 hres
= IHTMLWindow2_get_clientInformation(window
, &navigator2
);
6683 ok(hres
== S_OK
, "get_clientInformation failed: %08lx\n", hres
);
6684 ok(iface_cmp((IUnknown
*)navigator
, (IUnknown
*)navigator2
), "navigator2 != navigator\n");
6685 IOmNavigator_Release(navigator2
);
6687 IHTMLWindow2_Release(window
);
6689 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
6690 ok(hres
== S_OK
, "get_appCodeName failed: %08lx\n", hres
);
6691 ok(!lstrcmpW(bstr
, L
"Mozilla"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6692 SysFreeString(bstr
);
6695 hres
= IOmNavigator_get_appName(navigator
, &bstr
);
6696 ok(hres
== S_OK
, "get_appName failed: %08lx\n", hres
);
6697 ok(!lstrcmpW(bstr
, L
"Microsoft Internet Explorer"), "Unexpected appCodeName %s\n", wine_dbgstr_w(bstr
));
6698 SysFreeString(bstr
);
6701 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
6702 ok(hres
== S_OK
, "get_platform failed: %08lx\n", hres
);
6703 ok(!lstrcmpW(bstr
, sizeof(void*) == 8 ? L
"Win64" : L
"Win32")
6704 || (sizeof(void*) == 8 && broken(!lstrcmpW(bstr
, L
"Win32") /* IE6 */)), "unexpected platform %s\n", wine_dbgstr_w(bstr
));
6705 SysFreeString(bstr
);
6708 hres
= IOmNavigator_get_cpuClass(navigator
, &bstr
);
6709 ok(hres
== S_OK
, "get_cpuClass failed: %08lx\n", hres
);
6710 ok(!lstrcmpW(bstr
, sizeof(void*) == 8 ? L
"x64" : L
"x86"), "unexpected cpuClass %s\n", wine_dbgstr_w(bstr
));
6711 SysFreeString(bstr
);
6714 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6715 ok(hres
== S_OK
, "get_appVersion failed: %08lx\n", hres
);
6716 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", wine_dbgstr_w(bstr
));
6717 SysFreeString(bstr
);
6720 hres
= IOmNavigator_get_systemLanguage(navigator
, &bstr
);
6721 ok(hres
== S_OK
, "get_systemLanguage failed: %08lx\n", hres
);
6722 test_language_string(bstr
, LOCALE_SYSTEM_DEFAULT
);
6723 SysFreeString(bstr
);
6725 if (pGetUserDefaultUILanguage
)
6728 hres
= IOmNavigator_get_browserLanguage(navigator
, &bstr
);
6729 ok(hres
== S_OK
, "get_browserLanguage failed: %08lx\n", hres
);
6730 test_language_string(bstr
, pGetUserDefaultUILanguage());
6731 SysFreeString(bstr
);
6734 win_skip("GetUserDefaultUILanguage not available\n");
6737 hres
= IOmNavigator_get_userLanguage(navigator
, &bstr
);
6738 ok(hres
== S_OK
, "get_userLanguage failed: %08lx\n", hres
);
6739 test_language_string(bstr
, LOCALE_USER_DEFAULT
);
6740 SysFreeString(bstr
);
6742 hres
= IOmNavigator_toString(navigator
, NULL
);
6743 ok(hres
== E_INVALIDARG
, "toString failed: %08lx\n", hres
);
6746 hres
= IOmNavigator_toString(navigator
, &bstr
);
6747 ok(hres
== S_OK
, "toString failed: %08lx\n", hres
);
6748 ok(!lstrcmpW(bstr
, L
"[object]"), "toString returned %s\n", wine_dbgstr_w(bstr
));
6749 SysFreeString(bstr
);
6752 hres
= IOmNavigator_get_onLine(navigator
, &b
);
6753 ok(hres
== S_OK
, "get_onLine failed: %08lx\n", hres
);
6754 ok(b
== VARIANT_TRUE
, "onLine = %x\n", b
);
6757 hres
= ObtainUserAgentString(0, bufa
, &size
);
6758 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08lx\n", hres
);
6760 MultiByteToWideChar(CP_ACP
, 0, bufa
, size
, buf
, ARRAY_SIZE(buf
));
6763 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6764 ok(hres
== S_OK
, "get_userAgent failed: %08lx\n", hres
);
6765 ok(!lstrcmpW(bstr
, buf
), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), wine_dbgstr_w(buf
));
6766 SysFreeString(bstr
);
6768 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, ua
, sizeof(ua
), 0);
6769 ok(hres
== S_OK
, "UrlMkSetSessionOption failed: %08lx\n", hres
);
6770 MultiByteToWideChar(CP_ACP
, 0, ua
, -1, buf
, ARRAY_SIZE(buf
));
6772 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
6773 ok(hres
== S_OK
, "get_appVersion failed: %08lx\n", hres
);
6774 ok(!lstrcmpW(bstr
, buf
+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr
), wine_dbgstr_w(buf
+8));
6775 SysFreeString(bstr
);
6777 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
6778 ok(hres
== S_OK
, "get_userAgent failed: %08lx\n", hres
);
6779 ok(!lstrcmpW(bstr
, buf
), "userAgent returned %s, expected %s\n", wine_dbgstr_w(bstr
), wine_dbgstr_w(buf
));
6780 SysFreeString(bstr
);
6782 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, buf
, lstrlenW(buf
), 0);
6783 ok(hres
== S_OK
, "UrlMkSetSessionOption failed: %08lx\n", hres
);
6786 hres
= IOmNavigator_get_appMinorVersion(navigator
, &bstr
);
6787 ok(hres
== S_OK
, "get_appMonorVersion failed: %08lx\n", hres
);
6788 ok(bstr
!= NULL
, "appMinorVersion returned NULL\n");
6789 SysFreeString(bstr
);
6791 test_mime_types_col(navigator
);
6793 ref
= IOmNavigator_Release(navigator
);
6795 ok(!ref
, "navigator should be destroyed here\n");
6798 static void test_screen(IHTMLWindow2
*window
)
6800 IHTMLScreen
*screen
, *screen2
;
6801 IDispatchEx
*dispex
;
6808 hres
= IHTMLWindow2_get_screen(window
, &screen
);
6809 ok(hres
== S_OK
, "get_screen failed: %08lx\n", hres
);
6810 ok(screen
!= NULL
, "screen == NULL\n");
6813 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
6814 ok(hres
== S_OK
, "get_screen failed: %08lx\n", hres
);
6815 ok(screen2
!= NULL
, "screen == NULL\n");
6816 ok(iface_cmp((IUnknown
*)screen2
, (IUnknown
*)screen
), "screen2 != screen\n");
6817 IHTMLScreen_Release(screen2
);
6819 hres
= IHTMLScreen_QueryInterface(screen
, &IID_IDispatchEx
, (void**)&dispex
);
6820 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDispatchEx interface: %08lx\n", hres
);
6821 if(SUCCEEDED(hres
)) {
6822 test_disp((IUnknown
*)screen
, &DIID_DispHTMLScreen
, NULL
, L
"[object]");
6823 IDispatchEx_Release(dispex
);
6826 hdc
= CreateICA("DISPLAY", NULL
, NULL
, NULL
);
6828 exl
= GetDeviceCaps(hdc
, HORZRES
);
6830 hres
= IHTMLScreen_get_width(screen
, &l
);
6831 ok(hres
== S_OK
, "get_width failed: %08lx\n", hres
);
6832 ok(l
== exl
, "width = %ld, expected %ld\n", l
, exl
);
6834 exl
= GetDeviceCaps(hdc
, VERTRES
);
6836 hres
= IHTMLScreen_get_height(screen
, &l
);
6837 ok(hres
== S_OK
, "get_height failed: %08lx\n", hres
);
6838 ok(l
== exl
, "height = %ld, expected %ld\n", l
, exl
);
6840 exl
= GetDeviceCaps(hdc
, BITSPIXEL
);
6842 hres
= IHTMLScreen_get_colorDepth(screen
, &l
);
6843 ok(hres
== S_OK
, "get_height failed: %08lx\n", hres
);
6844 ok(l
== exl
, "height = %ld, expected %ld\n", l
, exl
);
6848 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &work_area
, 0);
6851 hres
= IHTMLScreen_get_availHeight(screen
, &l
);
6852 ok(hres
== S_OK
, "get_availHeight failed: %08lx\n", hres
);
6853 ok(l
== work_area
.bottom
-work_area
.top
, "availHeight = %ld, expected %ld\n", l
, work_area
.bottom
-work_area
.top
);
6856 hres
= IHTMLScreen_get_availWidth(screen
, &l
);
6857 ok(hres
== S_OK
, "get_availWidth failed: %08lx\n", hres
);
6858 ok(l
== work_area
.right
-work_area
.left
, "availWidth = %ld, expected %ld\n", l
, work_area
.right
-work_area
.left
);
6860 IHTMLScreen_Release(screen
);
6863 static void test_default_selection(IHTMLDocument2
*doc
)
6865 IHTMLSelectionObject
*selection
;
6866 IHTMLTxtRange
*range
;
6870 test_doc_selection_type(doc
, L
"None");
6872 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
6873 ok(hres
== S_OK
, "get_selection failed: %08lx\n", hres
);
6875 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
6876 IHTMLSelectionObject_Release(selection
);
6877 ok(hres
== S_OK
, "createRange failed: %08lx\n", hres
);
6879 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
6880 IDispatch_Release(disp
);
6881 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08lx\n", hres
);
6883 test_range_text(range
, NULL
);
6884 IHTMLTxtRange_Release(range
);
6887 static void test_doc_dir(IHTMLDocument2
*doc2
)
6889 IHTMLDocument3
*doc
= get_doc3_iface(doc2
);
6893 dir
= (BSTR
)0xdeadbeef;
6894 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6895 ok(hres
== S_OK
, "get_dir failed: %08lx\n", hres
);
6896 ok(!dir
, "dir = %s\n", wine_dbgstr_w(dir
));
6898 dir
= SysAllocString(L
"rtl");
6899 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6900 ok(hres
== S_OK
, "put_dir failed: %08lx\n", hres
);
6904 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6905 ok(hres
== S_OK
, "get_dir failed: %08lx\n", hres
);
6906 ok(!lstrcmpW(dir
, L
"rtl"), "dir = %s\n", wine_dbgstr_w(dir
));
6909 dir
= SysAllocString(L
"ltr");
6910 hres
= IHTMLDocument3_put_dir(doc
, dir
);
6911 ok(hres
== S_OK
, "put_dir failed: %08lx\n", hres
);
6915 hres
= IHTMLDocument3_get_dir(doc
, &dir
);
6916 ok(hres
== S_OK
, "get_dir failed: %08lx\n", hres
);
6917 ok(!lstrcmpW(dir
, L
"ltr"), "dir = %s\n", wine_dbgstr_w(dir
));
6920 IHTMLDocument3_Release(doc
);
6923 static void test_unique_id(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
6925 IHTMLDocument3
*doc3
= get_doc3_iface(doc
);
6926 IHTMLUniqueName
*unique_name
;
6932 static const WCHAR prefixW
[] = {'m','s','_','_','i','d',0};
6934 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id
);
6935 ok(hres
== S_OK
, "get_uniqueID failed: %08lx\n", hres
);
6936 ok(SysStringLen(id
) >= ARRAY_SIZE(prefixW
), "id %s too short\n", wine_dbgstr_w(id
));
6938 hres
= IHTMLDocument3_get_uniqueID(doc3
, &id2
);
6939 ok(hres
== S_OK
, "get_uniqueID failed: %08lx\n", hres
);
6940 ok(SysStringLen(id2
) >= ARRAY_SIZE(prefixW
), "id %s too short\n", wine_dbgstr_w(id2
));
6942 ok(lstrcmpW(id
, id2
), "same unique ids %s\n", wine_dbgstr_w(id
));
6944 id
[ARRAY_SIZE(prefixW
)-1] = 0;
6945 ok(!lstrcmpW(id
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id
));
6946 id2
[ARRAY_SIZE(prefixW
)-1] = 0;
6947 ok(!lstrcmpW(id2
, prefixW
), "unexpected prefix %s\n", wine_dbgstr_w(id2
));
6952 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLUniqueName
, (void**)&unique_name
);
6953 ok(hres
== S_OK
, "Could not get IHTMLUniqueName iface: %08lx\n", hres
);
6955 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id
);
6956 ok(hres
== S_OK
, "get_uniqueName failed: %08lx\n", hres
);
6958 hres
= IHTMLUniqueName_get_uniqueID(unique_name
, &id2
);
6959 ok(hres
== S_OK
, "get_uniqueName failed: %08lx\n", hres
);
6960 ok(!lstrcmpW(id
, id2
), "unique names differ\n");
6962 hres
= IHTMLUniqueName_get_uniqueNumber(unique_name
, &num
);
6963 ok(hres
== S_OK
, "get_uniqueName failed: %08lx\n", hres
);
6964 ok(num
, "num = 0\n");
6966 swprintf(buf
, ARRAY_SIZE(buf
), L
"ms__id%u", num
);
6967 ok(!lstrcmpW(id
, buf
), "unexpected id %s\n", wine_dbgstr_w(id
));
6972 IHTMLUniqueName_Release(unique_name
);
6973 IHTMLDocument3_Release(doc3
);
6976 static void test_doc_elem(IHTMLDocument2
*doc
)
6978 IHTMLNamespaceCollection
*namespaces
;
6979 IHTMLDocument2
*doc_node
, *owner_doc
;
6980 IHTMLDocument4
*doc4
;
6982 IHTMLDocument3
*doc3
;
6988 test_doc_GetIDsOfNames(doc
);
6990 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
6991 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08lx\n", hres
);
6993 hres
= IHTMLDocument2_toString(doc
, &bstr
);
6994 ok(hres
== S_OK
, "toString failed: %08lx\n", hres
);
6995 ok(!lstrcmpW(bstr
, L
"[object]"),
6996 "toString returned %s, expected [object]\n", wine_dbgstr_w(bstr
));
6997 SysFreeString(bstr
);
6999 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
7000 IHTMLDocument3_Release(doc3
);
7001 ok(hres
== S_OK
, "get_documentElement failed: %08lx\n", hres
);
7003 test_node_name((IUnknown
*)elem
, L
"HTML");
7004 test_elem_tag((IUnknown
*)elem
, L
"HTML");
7005 test_elem_set_outertext_fail(elem
);
7007 doc_node
= get_doc_node(doc
);
7008 owner_doc
= get_owner_doc((IUnknown
*)elem
);
7009 ok(iface_cmp((IUnknown
*)doc_node
, (IUnknown
*)owner_doc
), "doc_node != owner_doc\n");
7010 IHTMLDocument2_Release(owner_doc
);
7011 test_doc_GetIDsOfNames(doc_node
);
7013 owner_doc
= get_owner_doc((IUnknown
*)doc_node
);
7014 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
7015 IHTMLDocument2_Release(doc_node
);
7017 test_elem_client_rect((IUnknown
*)elem
);
7018 test_unique_id(doc
, elem
);
7021 IHTMLElement_Release(elem
);
7023 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument4
, (void**)&doc4
);
7024 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument4) failed: %08lx\n", hres
);
7026 hres
= IHTMLDocument4_get_namespaces(doc4
, &disp
);
7027 ok(hres
== S_OK
, "get_namespaces failed: %08lx\n", hres
);
7029 test_disp((IUnknown
*)disp
, &DIID_DispHTMLNamespaceCollection
, NULL
, L
"[object]");
7031 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLNamespaceCollection
, (void**)&namespaces
);
7032 ok(hres
== S_OK
, "Could not get IHTMLNamespaceCollection iface: %08lx\n", hres
);
7034 hres
= IHTMLNamespaceCollection_get_length(namespaces
, &l
);
7035 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
7036 ok(l
== 0, "length = %ld\n", l
);
7038 IHTMLNamespaceCollection_Release(namespaces
);
7039 IDispatch_Release(disp
);
7040 IHTMLDocument4_Release(doc4
);
7043 static void test_default_body(IHTMLBodyElement
*body
)
7050 bstr
= (void*)0xdeadbeef;
7051 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
7052 ok(hres
== S_OK
, "get_background failed: %08lx\n", hres
);
7053 ok(bstr
== NULL
, "bstr != NULL\n");
7055 l
= elem_get_scroll_height((IUnknown
*)body
);
7056 ok(l
!= -1, "scrollHeight == -1\n");
7057 l
= elem_get_scroll_width((IUnknown
*)body
);
7058 ok(l
!= -1, "scrollWidth == -1\n");
7059 l
= elem_get_scroll_top((IUnknown
*)body
);
7060 ok(!l
, "scrollTop = %ld\n", l
);
7061 elem_get_scroll_left((IUnknown
*)body
);
7063 test_elem_dir((IUnknown
*)body
, NULL
);
7064 set_elem_dir((IUnknown
*)body
, L
"ltr");
7066 /* get_text tests */
7067 hres
= IHTMLBodyElement_get_text(body
, &v
);
7068 ok(hres
== S_OK
, "expect S_OK got 0x%08ld\n", hres
);
7069 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
7070 ok(V_BSTR(&v
) == NULL
, "bstr != NULL\n");
7072 /* get_text - Invalid Text */
7074 V_BSTR(&v
) = SysAllocString(L
"Invalid");
7075 hres
= IHTMLBodyElement_put_text(body
, v
);
7076 ok(hres
== S_OK
, "expect S_OK got 0x%08ld\n", hres
);
7080 hres
= IHTMLBodyElement_get_text(body
, &v
);
7081 ok(hres
== S_OK
, "expect S_OK got 0x%08ld\n", hres
);
7082 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
7083 ok(!lstrcmpW(V_BSTR(&v
), L
"#00a0d0"), "v = %s, expected '#00a0d0'\n", wine_dbgstr_w(V_BSTR(&v
)));
7086 /* get_text - Valid Text */
7088 V_BSTR(&v
) = SysAllocString(L
"#FF0000");
7089 hres
= IHTMLBodyElement_put_text(body
, v
);
7090 ok(hres
== S_OK
, "expect S_OK got 0x%08ld\n", hres
);
7094 hres
= IHTMLBodyElement_get_text(body
, &v
);
7095 ok(hres
== S_OK
, "expect S_OK got 0x%08ld\n", hres
);
7096 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
7097 ok(!lstrcmpW(V_BSTR(&v
), L
"#ff0000"), "v = %s, expected '#ff0000'\n", wine_dbgstr_w(V_BSTR(&v
)));
7101 #define test_body_scroll(a,b) _test_body_scroll(__LINE__,a,b)
7102 static void _test_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const WCHAR
*ex
)
7107 hres
= IHTMLBodyElement_get_scroll(body
, &str
);
7108 ok_(__FILE__
,line
)(hres
== S_OK
, "get_scroll failed: %08lx\n", hres
);
7109 ok_(__FILE__
,line
)(ex
? !lstrcmpW(str
, ex
) : !str
, "scroll = %s\n", wine_dbgstr_w(str
));
7113 #define set_body_scroll(a,b) _set_body_scroll(__LINE__,a,b)
7114 static void _set_body_scroll(unsigned line
, IHTMLBodyElement
*body
, const WCHAR
*val
)
7116 BSTR str
= SysAllocString(val
);
7119 hres
= IHTMLBodyElement_put_scroll(body
, str
);
7120 ok_(__FILE__
,line
)(hres
== S_OK
, "put_scroll failed: %08lx\n", hres
);
7123 _test_body_scroll(line
, body
, val
);
7126 static void test_body_funs(IHTMLBodyElement
*body
, IHTMLDocument2
*doc
)
7128 VARIANT vbg
, vDefaultbg
;
7131 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
7132 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7133 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
7134 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
7136 hres
= IHTMLDocument2_get_bgColor(doc
, &vbg
);
7137 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7138 ok(V_VT(&vbg
) == VT_BSTR
&& V_BSTR(&vbg
) && !wcscmp(V_BSTR(&vbg
), L
"#ffffff"), "bgColor = %s\n", wine_dbgstr_variant(&vbg
));
7140 V_VT(&vbg
) = VT_BSTR
;
7141 V_BSTR(&vbg
) = SysAllocString(L
"red");
7142 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
7143 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
7146 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
7147 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7148 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7149 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7152 hres
= IHTMLDocument2_get_bgColor(doc
, &vbg
);
7153 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7154 ok(V_VT(&vbg
) == VT_BSTR
&& V_BSTR(&vbg
) && !wcscmp(V_BSTR(&vbg
), L
"#ff0000"), "bgColor = %s\n", wine_dbgstr_variant(&vbg
));
7156 hres
= IHTMLDocument2_get_bgColor(doc
, &vbg
);
7157 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7158 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7159 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7162 /* Restore Original */
7163 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
7164 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
7165 VariantClear(&vDefaultbg
);
7167 /* Set via IHTMLDocument2 */
7168 V_VT(&vbg
) = VT_BSTR
;
7169 V_BSTR(&vbg
) = SysAllocString(L
"red");
7170 hres
= IHTMLDocument2_put_bgColor(doc
, vbg
);
7171 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
7174 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
7175 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7176 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7177 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7180 hres
= IHTMLDocument2_get_bgColor(doc
, &vbg
);
7181 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
7182 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
7183 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
7186 /* Restore Original */
7187 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
7188 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
7189 VariantClear(&vDefaultbg
);
7191 test_body_scroll(body
, NULL
);
7192 set_body_scroll(body
, L
"yes");
7193 set_body_scroll(body
, L
"no");
7194 set_body_scroll(body
, L
"auto");
7197 static void test_history(IHTMLWindow2
*window
)
7199 IOmHistory
*history
, *history2
;
7203 hres
= IHTMLWindow2_get_history(window
, &history
);
7204 ok(hres
== S_OK
, "get_history failed: %08lx\n", hres
);
7205 ok(history
!= NULL
, "history = NULL\n");
7207 test_disp2((IUnknown
*)history
, &DIID_DispHTMLHistory
, &IID_IOmHistory
, NULL
, L
"[object]");
7210 hres
= IHTMLWindow2_get_history(window
, &history2
);
7211 ok(hres
== S_OK
, "get_history failed: %08lx\n", hres
);
7212 ok(history2
!= NULL
, "history2 = NULL\n");
7213 ok(iface_cmp((IUnknown
*)history
, (IUnknown
*)history2
), "history != history2\n");
7215 IOmHistory_Release(history2
);
7216 IOmHistory_Release(history
);
7219 static void test_xmlhttprequest(IHTMLWindow5
*window
)
7223 IHTMLXMLHttpRequestFactory
*factory
;
7224 IHTMLXMLHttpRequest
*xml
;
7226 hres
= IHTMLWindow5_get_XMLHttpRequest(window
, &var
);
7227 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08lx\n", hres
);
7228 ok(V_VT(&var
) == VT_DISPATCH
|| broken(V_VT(&var
) == VT_EMPTY
), "expect VT_DISPATCH, got %s\n", debugstr_variant(&var
));
7230 if (V_VT(&var
) == VT_EMPTY
) {
7231 win_skip("Native XMLHTTP support is missing or disabled.\n");
7236 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLXMLHttpRequestFactory
, (void**)&factory
);
7237 ok(hres
== S_OK
, "QueryInterface(&IID_IHTMLXMLHttpRequestFactory) failed: %08lx\n", hres
);
7238 ok(factory
!= NULL
, "factory == NULL\n");
7241 hres
= IHTMLXMLHttpRequestFactory_create(factory
, &xml
);
7242 ok(hres
== S_OK
, "create failed: %08lx\n", hres
);
7243 ok(xml
!= NULL
, "xml == NULL\n");
7245 test_disp((IUnknown
*)xml
, &DIID_DispHTMLXMLHttpRequest
, &CLSID_HTMLXMLHttpRequest
, L
"[object]");
7247 IHTMLXMLHttpRequest_Release(xml
);
7248 IHTMLXMLHttpRequestFactory_Release(factory
);
7252 static void test_read_only_style(IHTMLCSSStyleDeclaration
*style
)
7254 BSTR none
= SysAllocString(L
"none"), display
= SysAllocString(L
"display"), str
;
7258 hres
= IHTMLCSSStyleDeclaration_put_display(style
, none
);
7259 ok(hres
== 0x80700007, "put_display failed: %08lx\n", hres
);
7261 hres
= IHTMLCSSStyleDeclaration_removeProperty(style
, display
, &str
);
7262 ok(hres
== 0x80700007, "removeProperty failed: %08lx\n", hres
);
7266 hres
= IHTMLCSSStyleDeclaration_setProperty(style
, display
, &v
, NULL
);
7267 ok(hres
== 0x80700007, "setProperty returned: %08lx\n", hres
);
7269 SysFreeString(none
);
7270 SysFreeString(display
);
7273 static void test_window(IHTMLDocument2
*doc
)
7275 IHTMLWindow2
*window
, *window2
, *self
, *parent
;
7276 IHTMLWindow5
*window5
;
7277 IHTMLWindow7
*window7
;
7278 IHTMLDocument2
*doc2
= NULL
;
7285 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
7286 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
7287 test_ifaces((IUnknown
*)window
, window_iids
);
7288 hres
= IHTMLWindow2_QueryInterface(window
, &IID_ITravelLogClient
, (void**)&unk
);
7290 IUnknown_Release(unk
);
7292 win_skip("IID_ITravelLogClient not supported\n");
7294 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
, &CLSID_HTMLWindow2
, L
"[object]");
7295 test_window_GetIDsOfNames(window
);
7297 hres
= IHTMLWindow2_get_document(window
, &doc2
);
7298 ok(hres
== S_OK
, "get_document failed: %08lx\n", hres
);
7299 ok(doc2
!= NULL
, "doc2 == NULL\n");
7302 test_ifaces((IUnknown
*)doc2
, doc_node_iids
);
7303 test_disp((IUnknown
*)doc2
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, L
"[object]");
7306 test_ifaces((IUnknown
*)doc
, doc_obj_iids
);
7307 test_disp((IUnknown
*)doc
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, L
"[object]");
7309 unk
= (void*)0xdeadbeef;
7310 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_ICustomDoc
, (void**)&unk
);
7311 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_ICustomDoc) returned: %08lx\n", hres
);
7312 ok(!unk
, "unk = %p\n", unk
);
7314 IHTMLDocument2_Release(doc2
);
7316 hres
= IHTMLWindow2_get_window(window
, &window2
);
7317 ok(hres
== S_OK
, "get_window failed: %08lx\n", hres
);
7318 ok(window2
!= NULL
, "window2 == NULL\n");
7320 hres
= IHTMLWindow2_get_self(window
, &self
);
7321 ok(hres
== S_OK
, "get_self failed: %08lx\n", hres
);
7322 ok(window2
!= NULL
, "self == NULL\n");
7324 ok(self
== window2
, "self != window2\n");
7326 IHTMLWindow2_Release(window2
);
7329 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
7330 ok(hres
== S_OK
, "get_Script failed: %08lx\n", hres
);
7331 ok(disp
== (void*)window
, "disp != window\n");
7332 IDispatch_Release(disp
);
7334 hres
= IHTMLWindow2_toString(window
, NULL
);
7335 ok(hres
== E_INVALIDARG
, "toString failed: %08lx\n", hres
);
7338 hres
= IHTMLWindow2_toString(window
, &str
);
7339 ok(hres
== S_OK
, "toString failed: %08lx\n", hres
);
7340 ok(!lstrcmpW(str
, L
"[object]") ||
7341 !lstrcmpW(str
, L
"[object Window]") /* win7 ie9 */, "toString returned %s\n", wine_dbgstr_w(str
));
7344 V_VT(&v
) = VT_ERROR
;
7345 hres
= IHTMLWindow2_get_opener(window
, &v
);
7346 ok(hres
== S_OK
, "get_opener failed: %08lx\n", hres
);
7347 ok(V_VT(&v
) == VT_EMPTY
, "V_VT(opener) = %d\n", V_VT(&v
));
7350 hres
= IHTMLWindow2_get_parent(window
, &parent
);
7351 ok(hres
== S_OK
, "get_parent failed: %08lx\n", hres
);
7352 ok(parent
!= NULL
, "parent == NULL\n");
7353 ok(parent
== self
, "parent != window\n");
7354 IHTMLWindow2_Release(parent
);
7355 IHTMLWindow2_Release(self
);
7357 test_window_name(window
, NULL
);
7358 set_window_name(window
, L
"test");
7359 test_window_length(window
, 0);
7360 test_screen(window
);
7361 test_window_status(window
);
7362 set_window_status(window
, L
"Test!");
7363 test_history(window
);
7365 hres
= IHTMLWindow2_moveBy(window
, 0, 0);
7366 ok(hres
== S_FALSE
, "moveBy failed: %08lx\n", hres
);
7368 hres
= IHTMLWindow2_resizeBy(window
, 0, 0);
7369 ok(hres
== S_FALSE
, "resizeBy failed: %08lx\n", hres
);
7371 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
7372 if(SUCCEEDED(hres
)) {
7373 ok(window5
!= NULL
, "window5 == NULL\n");
7374 test_xmlhttprequest(window5
);
7375 IHTMLWindow5_Release(window5
);
7377 win_skip("IHTMLWindow5 not supported!\n");
7380 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow7
, (void**)&window7
);
7381 if(SUCCEEDED(hres
)) {
7382 IHTMLCSSStyleDeclaration
*computed_style
;
7383 IHTMLPerformance
*performance
;
7388 ok(window7
!= NULL
, "window7 == NULL\n");
7390 hres
= IHTMLWindow7_get_performance(window7
, &v
);
7391 ok(hres
== S_OK
, "get_performance failed: %08lx\n", hres
);
7392 if(SUCCEEDED(hres
)) {
7393 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(performance) = %u\n", V_VT(&v
));
7395 hres
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IHTMLPerformance
,
7396 (void**)&performance
);
7397 ok(hres
== S_OK
, "Could not get IHTMLPerformance iface: %08lx\n", hres
);
7398 IDispatch_Release(V_DISPATCH(&v
));
7399 IHTMLPerformance_Release(performance
);
7403 hres
= IHTMLWindow7_put_performance(window7
, v
);
7404 ok(hres
== S_OK
, "put_performance failed: %08lx\n", hres
);
7406 V_VT(&v
) = VT_ERROR
;
7407 hres
= IHTMLWindow7_get_performance(window7
, &v
);
7408 ok(hres
== S_OK
, "get_performance failed: %08lx\n", hres
);
7409 ok(V_VT(&v
) == VT_I2
, "V_VT(performance) = %u\n", V_VT(&v
));
7410 ok(V_I2(&v
) == 2, "V_I2(performance) = %d\n", V_I2(&v
));
7413 hres
= IHTMLWindow7_get_pageXOffset(window7
, &offset
);
7414 ok(hres
== S_OK
, "get_pageXOffset failed: %08lx\n", hres
);
7415 ok(!offset
, "Unexpected offset %ld.\n", offset
);
7417 hres
= IHTMLWindow7_get_pageYOffset(window7
, &offset
);
7418 ok(hres
== S_OK
, "get_pageYOffset failed: %08lx\n", hres
);
7419 ok(!offset
, "Unexpected offset %ld.\n", offset
);
7421 hres
= IHTMLDocument2_get_body(doc
, &elem
);
7422 ok(hres
== S_OK
, "get_body failed: %08lx\n", hres
);
7424 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLDOMNode
, (void**)&node
);
7425 ok(hres
== S_OK
, "Could not get IHTMLDOMNode iface: %08lx\n", hres
);
7427 hres
= IHTMLWindow7_getComputedStyle(window7
, node
, NULL
, &computed_style
);
7428 ok(hres
== S_OK
, "getComputedStyle failed: %08lx\n", hres
);
7430 test_disp((IUnknown
*)computed_style
, &DIID_DispHTMLW3CComputedStyle
, NULL
, L
"[object]");
7431 test_ifaces((IUnknown
*)computed_style
, computed_style_iids
);
7433 test_read_only_style(computed_style
);
7435 IHTMLCSSStyleDeclaration_Release(computed_style
);
7437 IHTMLDOMNode_Release(node
);
7438 IHTMLElement_Release(elem
);
7440 IHTMLWindow7_Release(window7
);
7442 win_skip("IHTMLWindow7 not supported\n");
7445 IHTMLWindow2_Release(window
);
7448 static void test_dom_implementation(IHTMLDocument2
*doc
)
7450 IHTMLDocument5
*doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
7451 IHTMLDOMImplementation2
*dom_implementation2
;
7452 IHTMLDOMImplementation
*dom_implementation
;
7458 hres
= IHTMLDocument5_get_implementation(doc5
, &dom_implementation
);
7459 IHTMLDocument5_Release(doc5
);
7460 ok(hres
== S_OK
, "get_implementation failed: %08lx\n", hres
);
7461 ok(dom_implementation
!= NULL
, "dom_implementation == NULL\n");
7463 str
= SysAllocString(L
"test");
7465 V_BSTR(&v
) = SysAllocString(L
"1.0");
7467 hres
= IHTMLDOMImplementation_hasFeature(dom_implementation
, str
, v
, &b
);
7470 ok(hres
== S_OK
, "hasFeature failed: %08lx\n", hres
);
7471 ok(!b
, "hasFeature returned %x\n", b
);
7473 hres
= IHTMLDOMImplementation_QueryInterface(dom_implementation
, &IID_IHTMLDOMImplementation2
,
7474 (void**)&dom_implementation2
);
7475 if(SUCCEEDED(hres
)) {
7476 IHTMLSelectionObject
*selection
;
7477 IHTMLFramesCollection2
*frames
;
7478 IHTMLDocument2
*new_document2
;
7479 IHTMLDocument3
*new_document3
;
7480 IHTMLDocument7
*new_document
;
7481 IHTMLLocation
*location
;
7482 IHTMLWindow2
*window
;
7487 test_disp((IUnknown
*)dom_implementation
, &DIID_DispHTMLDOMImplementation
, NULL
, L
"[object]");
7489 str
= SysAllocString(L
"test");
7490 hres
= IHTMLDOMImplementation2_createHTMLDocument(dom_implementation2
, str
, &new_document
);
7491 ok(hres
== S_OK
, "createHTMLDocument failed: %08lx\n", hres
);
7494 test_disp((IUnknown
*)new_document
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, L
"[object]");
7495 test_ifaces((IUnknown
*)new_document
, doc_node_iids
);
7497 hres
= IHTMLDocument7_get_defaultView(new_document
, &window
);
7498 ok(hres
== S_OK
, "get_defaultView returned: %08lx\n", hres
);
7499 ok(!window
, "window = %p\n", window
);
7501 hres
= IHTMLDocument7_get_parentWindow(new_document
, &window
);
7502 ok(hres
== S_OK
, "get_parentWindow returned: %08lx\n", hres
);
7503 ok(!window
, "window = %p\n", window
);
7505 hres
= IHTMLDocument7_QueryInterface(new_document
, &IID_IHTMLDocument2
, (void**)&new_document2
);
7506 ok(hres
== S_OK
, "Could not get IHTMLDocument2 iface: %08lx\n", hres
);
7508 hres
= IHTMLDocument7_QueryInterface(new_document
, &IID_IHTMLDocument3
, (void**)&new_document3
);
7509 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08lx\n", hres
);
7511 hres
= IHTMLDocument2_get_parentWindow(new_document2
, &window
);
7512 ok(hres
== E_FAIL
, "get_parentWindow returned: %08lx\n", hres
);
7514 hres
= IHTMLDocument2_get_readyState(new_document2
, &str
);
7515 ok(hres
== S_OK
, "get_readyState returned: %08lx\n", hres
);
7516 ok(!lstrcmpW(str
, L
"uninitialized"), "readyState = %s\n", wine_dbgstr_w(str
));
7519 hres
= IHTMLDocument2_get_Script(new_document2
, &disp
);
7520 ok(hres
== E_PENDING
, "get_Script returned: %08lx\n", hres
);
7522 str
= SysAllocString(L
"test=testval");
7523 hres
= IHTMLDocument2_put_cookie(new_document2
, str
);
7524 ok(hres
== S_OK
, "put_cookie returned: %08lx\n", hres
);
7527 hres
= IHTMLDocument2_get_cookie(doc
, &str
);
7528 ok(hres
== S_OK
, "get_cookie returned: %08lx\n", hres
);
7529 ok(str
== NULL
, "cookie = %s\n", wine_dbgstr_w(str
));
7532 hres
= IHTMLDocument3_get_documentElement(new_document3
, &elem
);
7533 ok(hres
== S_OK
, "get_documentElement returned: %08lx\n", hres
);
7534 ok(elem
!= NULL
, "documentElement = NULL\n");
7535 IHTMLElement_Release(elem
);
7537 hres
= IHTMLDocument2_get_frames(new_document2
, &frames
);
7538 ok(hres
== E_NOTIMPL
, "get_frames returned: %08lx\n", hres
);
7540 hres
= IHTMLDocument2_get_location(new_document2
, &location
);
7541 ok(hres
== E_UNEXPECTED
, "get_location returned: %08lx\n", hres
);
7543 hres
= IHTMLDocument2_get_selection(new_document2
, &selection
);
7544 ok(hres
== S_OK
, "get_selection returned: %08lx\n", hres
);
7545 ok(selection
!= NULL
, "selection = NULL\n");
7546 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
7547 ok(hres
== S_OK
, "selection get_type returned: %08lx\n", hres
);
7548 ok(!lstrcmpW(str
, L
"None"), "selection type = %s\n", wine_dbgstr_w(str
));
7549 IHTMLSelectionObject_Release(selection
);
7552 hres
= IHTMLDocument2_get_URL(new_document2
, &str
);
7553 ok(hres
== S_OK
, "get_URL returned: %08lx\n", hres
);
7554 ok(!lstrcmpW(str
, L
"about:blank"), "URL = %s\n", wine_dbgstr_w(str
));
7557 str
= SysAllocString(L
"text/html");
7558 V_VT(&v
) = VT_ERROR
;
7559 disp
= (IDispatch
*)0xdeadbeef;
7560 hres
= IHTMLDocument2_open(new_document2
, str
, v
, v
, v
, &disp
);
7561 ok(hres
== E_FAIL
, "open returned: %08lx\n", hres
);
7562 ok(disp
== NULL
, "disp = %p\n", disp
);
7565 memset(&v
, 0xcc, sizeof(v
));
7566 hres
= IHTMLDocument7_get_onmsthumbnailclick(new_document
, &v
);
7567 ok(hres
== S_OK
, "get_onmsthumbnailclick returned: %08lx\n", hres
);
7568 ok(V_VT(&v
) == VT_NULL
, "got %u\n", V_VT(&v
));
7569 ok((DWORD
)(DWORD_PTR
)V_DISPATCH(&v
) == 0xcccccccc, "got %p\n", V_DISPATCH(&v
));
7571 IHTMLDocument2_Release(new_document2
);
7572 IHTMLDocument3_Release(new_document3
);
7573 IHTMLDocument7_Release(new_document
);
7574 IHTMLDOMImplementation2_Release(dom_implementation2
);
7576 win_skip("Missing IHTMLDOMImplementation implementation\n");
7579 IHTMLDOMImplementation_Release(dom_implementation
);
7582 static void test_xhr(IHTMLDocument2
*doc
)
7584 IHTMLWindow2
*window
;
7585 IDispatchEx
*dispex
;
7590 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
7591 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
7593 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IDispatchEx
, (void**)&dispex
);
7594 ok(hres
== S_OK
, "Could not get IDispatchEx iface: %08lx\n", hres
);
7596 str
= SysAllocString(L
"XMLHttpRequest");
7597 hres
= IDispatchEx_GetDispID(dispex
, str
, 0, &id
);
7598 ok(hres
== S_OK
, "GetDispID failed: %08lx\n", hres
);
7601 IHTMLWindow2_Release(window
);
7602 IDispatchEx_Release(dispex
);
7605 static void test_defaults(IHTMLDocument2
*doc
)
7607 IHTMLStyleSheetsCollection
*stylesheetcol
;
7608 IHTMLCurrentStyle
*cstyle
;
7609 IHTMLBodyElement
*body
;
7610 IHTMLElement2
*elem2
;
7618 IHTMLElementCollection
*collection
;
7620 elem
= doc_get_body(doc
);
7622 hres
= IHTMLDocument2_get_images(doc
, NULL
);
7623 ok(hres
== E_INVALIDARG
, "hres %08lx\n", hres
);
7625 hres
= IHTMLDocument2_get_images(doc
, &collection
);
7626 ok(hres
== S_OK
, "get_images failed: %08lx\n", hres
);
7629 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
7630 IHTMLElementCollection_Release(collection
);
7633 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
7634 ok(hres
== E_INVALIDARG
, "hres %08lx\n", hres
);
7636 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
7637 ok(hres
== S_OK
, "get_applets failed: %08lx\n", hres
);
7640 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
7641 IHTMLElementCollection_Release(collection
);
7644 hres
= IHTMLDocument2_get_links(doc
, NULL
);
7645 ok(hres
== E_INVALIDARG
, "hres %08lx\n", hres
);
7647 hres
= IHTMLDocument2_get_links(doc
, &collection
);
7648 ok(hres
== S_OK
, "get_links failed: %08lx\n", hres
);
7651 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
7652 IHTMLElementCollection_Release(collection
);
7655 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
7656 ok(hres
== E_INVALIDARG
, "hres %08lx\n", hres
);
7658 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
7659 ok(hres
== S_OK
, "get_forms failed: %08lx\n", hres
);
7662 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
7663 IHTMLElementCollection_Release(collection
);
7666 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
7667 ok(hres
== E_INVALIDARG
, "hres %08lx\n", hres
);
7669 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
7670 ok(hres
== S_OK
, "get_anchors failed: %08lx\n", hres
);
7673 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
7674 IHTMLElementCollection_Release(collection
);
7679 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
7680 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08lx\n", hres
);
7681 test_default_body(body
);
7682 test_body_funs(body
, doc
);
7683 IHTMLBodyElement_Release(body
);
7685 test_elem_set_outertext_fail(elem
);
7687 test_elem_istextedit(elem
, VARIANT_TRUE
);
7689 hres
= IHTMLElement_get_style(elem
, &style
);
7690 ok(hres
== S_OK
, "get_style failed: %08lx\n", hres
);
7692 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
, NULL
, L
"[object]");
7693 test_ifaces((IUnknown
*)style
, style_iids
);
7694 IHTMLStyle_Release(style
);
7697 hres
= IHTMLDocument2_get_charset(doc
, &str
);
7698 ok(hres
== S_OK
, "get_charset failed: %08lx\n", hres
);
7699 ok(str
&& *str
, "charset is empty\n"); /* FIXME: better tests */
7703 test_compatmode(doc
, L
"BackCompat");
7705 test_navigator(doc
);
7706 test_plugins_col(doc
);
7708 elem2
= get_elem2_iface((IUnknown
*)elem
);
7709 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
7710 ok(hres
== S_OK
, "get_currentStyle failed: %08lx\n", hres
);
7711 if(SUCCEEDED(hres
)) {
7714 test_disp((IUnknown
*)cstyle
, &DIID_DispHTMLCurrentStyle
, NULL
, L
"[object]");
7715 test_ifaces((IUnknown
*)cstyle
, cstyle_iids
);
7717 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCurrentStyle4
, (void**)&unk
);
7718 if(SUCCEEDED(hres
)) {
7719 IHTMLCSSStyleDeclaration
*css_style
;
7721 hres
= IHTMLCurrentStyle_QueryInterface(cstyle
, &IID_IHTMLCSSStyleDeclaration
, (void**)&css_style
);
7722 if(SUCCEEDED(hres
)) {
7723 test_read_only_style(css_style
);
7724 IHTMLCSSStyleDeclaration_Release(css_style
);
7726 win_skip("IHTMLCSSStyleDeclaration not supported\n");
7729 IUnknown_Release(unk
);
7731 /*IE6 doesn't have interface */
7732 win_skip("IID_IHTMLCurrentStyle4 not supported\n");
7735 IHTMLCurrentStyle_Release(cstyle
);
7737 IHTMLElement2_Release(elem2
);
7739 IHTMLElement_Release(elem
);
7741 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
7742 ok(hres
== S_OK
, "get_styleSheets failed: %08lx\n", hres
);
7745 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
7746 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
7747 ok(l
== 0, "length = %ld\n", l
);
7749 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
7751 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFiltersCollection
, (void**)&body
);
7752 ok(hres
== E_NOINTERFACE
, "got interface IHTMLFiltersCollection\n");
7754 str
= SysAllocString(L
"xxx");
7756 V_VT(&v
) = VT_EMPTY
;
7757 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7758 ok(hres
== OLECMDERR_E_NOTSUPPORTED
|| hres
== E_INVALIDARG
,
7759 "execCommand failed: %08lx, expected OLECMDERR_E_NOTSUPPORTED or E_INVALIDARG\n", hres
);
7762 str
= SysAllocString(L
"respectvisibilityindesign");
7765 V_BOOL(&v
) = VARIANT_TRUE
;
7766 hres
= IHTMLDocument2_execCommand(doc
, str
, FALSE
, v
, &b
);
7767 ok(hres
== S_OK
, "execCommand failed: %08lx, expected DRAGDROP_E_NOTREGISTERED\n", hres
);
7770 test_default_selection(doc
);
7771 test_doc_title(doc
, L
"");
7772 test_dom_implementation(doc
);
7774 str
= (BSTR
)0xdeadbeef;
7775 hres
= IHTMLDocument2_get_cookie(doc
, &str
);
7776 ok(hres
== S_OK
, "get_cookie failed: %08lx\n", hres
);
7777 ok(!str
, "cookie = %s\n", wine_dbgstr_w(str
));
7780 #define test_button_name(a,b) _test_button_name(__LINE__,a,b)
7781 static void _test_button_name(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exname
)
7783 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7787 str
= (void*)0xdeadbeef;
7788 hres
= IHTMLButtonElement_get_name(button
, &str
);
7789 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
7791 ok_(__FILE__
,line
)(!lstrcmpW(str
, exname
), "name = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exname
));
7793 ok_(__FILE__
,line
)(!str
, "name = %s, expected NULL\n", wine_dbgstr_w(str
));
7795 IHTMLButtonElement_Release(button
);
7798 #define set_button_name(a,b) _set_button_name(__LINE__,a,b)
7799 static void _set_button_name(unsigned line
, IHTMLElement
*elem
, const WCHAR
*name
)
7801 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7802 BSTR str
= SysAllocString(name
);
7805 hres
= IHTMLButtonElement_put_name(button
, str
);
7806 ok_(__FILE__
,line
)(hres
== S_OK
, "get_name failed: %08lx\n", hres
);
7808 IHTMLButtonElement_Release(button
);
7810 _test_button_name(line
, elem
, name
);
7813 #define test_button_get_disabled(i,b) _test_button_get_disabled(__LINE__,i,b)
7814 static void _test_button_get_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL exb
)
7816 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7817 VARIANT_BOOL disabled
= 100;
7820 hres
= IHTMLButtonElement_get_disabled(button
, &disabled
);
7821 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08lx\n", hres
);
7822 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
7823 IHTMLButtonElement_Release(button
);
7825 _test_elem3_get_disabled(line
, (IUnknown
*)elem
, exb
);
7828 #define test_button_set_disabled(i,b) _test_button_set_disabled(__LINE__,i,b)
7829 static void _test_button_set_disabled(unsigned line
, IHTMLElement
*elem
, VARIANT_BOOL b
)
7831 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7834 hres
= IHTMLButtonElement_put_disabled(button
, b
);
7835 ok_(__FILE__
,line
) (hres
== S_OK
, "put_disabled failed: %08lx\n", hres
);
7836 IHTMLButtonElement_Release(button
);
7838 _test_button_get_disabled(line
, elem
, b
);
7841 #define test_button_type(a,b) _test_button_type(__LINE__,a,b)
7842 static void _test_button_type(unsigned line
, IHTMLElement
*elem
, const WCHAR
*extype
)
7844 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7848 hres
= IHTMLButtonElement_get_type(button
, &str
);
7849 ok_(__FILE__
,line
)(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
7850 ok_(__FILE__
,line
)(!lstrcmpW(str
, extype
), "type = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(extype
));
7853 IHTMLButtonElement_Release(button
);
7856 #define test_button_value(a,b) _test_button_value(__LINE__,a,b)
7857 static void _test_button_value(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exvalue
)
7859 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7863 hres
= IHTMLButtonElement_get_value(button
, &str
);
7864 ok_(__FILE__
,line
)(hres
== S_OK
, "get_value failed: %08lx\n", hres
);
7866 ok_(__FILE__
,line
)(!lstrcmpW(str
, exvalue
), "value = %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(exvalue
));
7868 ok_(__FILE__
,line
)(!str
, "value = %s, expected NULL\n", wine_dbgstr_w(str
));
7871 IHTMLButtonElement_Release(button
);
7874 #define set_button_value(a,b) _set_button_value(__LINE__,a,b)
7875 static void _set_button_value(unsigned line
, IHTMLElement
*elem
, const WCHAR
*value
)
7877 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7878 BSTR str
= SysAllocString(value
);
7881 hres
= IHTMLButtonElement_put_value(button
, str
);
7882 ok_(__FILE__
,line
)(hres
== S_OK
, "put_value failed: %08lx\n", hres
);
7883 IHTMLButtonElement_Release(button
);
7886 _test_button_value(line
, elem
, value
);
7889 #define get_button_form(a) _get_button_form(__LINE__,a)
7890 static IHTMLFormElement
*_get_button_form(unsigned line
, IHTMLElement
*elem
)
7892 IHTMLButtonElement
*button
= _get_button_iface(line
, (IUnknown
*)elem
);
7893 IHTMLFormElement
*form
;
7896 hres
= IHTMLButtonElement_get_form(button
, &form
);
7897 ok_(__FILE__
,line
)(hres
== S_OK
, "get_form failed: %08lx\n", hres
);
7898 IHTMLButtonElement_Release(button
);
7903 static void test_button_elem(IHTMLElement
*elem
)
7905 IHTMLFormElement
*form
;
7907 test_button_name(elem
, NULL
);
7908 set_button_name(elem
, L
"button name");
7909 test_button_type(elem
, L
"submit");
7910 test_button_value(elem
, NULL
);
7911 set_button_value(elem
, L
"val");
7913 form
= get_button_form(elem
);
7914 ok(!form
, "form != NULL\n");
7916 test_elem_istextedit(elem
, VARIANT_TRUE
);
7919 #define test_tr_possess(e,r,l,i) _test_tr_possess(__LINE__,e,r,l,i)
7920 static void _test_tr_possess(unsigned line
, IHTMLElement
*elem
,
7921 IHTMLTableRow
*row
, LONG len
, const WCHAR
*id
)
7923 IHTMLElementCollection
*col
;
7929 hres
= IHTMLTableRow_get_cells(row
, &col
);
7930 ok_(__FILE__
, line
)(hres
== S_OK
, "get_cells failed: %08lx\n", hres
);
7931 ok_(__FILE__
, line
)(col
!= NULL
, "get_cells returned NULL\n");
7933 hres
= IHTMLElementCollection_get_length(col
, &lval
);
7934 ok_(__FILE__
, line
)(hres
== S_OK
, "get length failed: %08lx\n", hres
);
7935 ok_(__FILE__
, line
)(lval
== len
, "expected len = %ld, got %ld\n", len
, lval
);
7937 V_VT(&var
) = VT_BSTR
;
7938 V_BSTR(&var
) = SysAllocString(id
);
7939 hres
= IHTMLElementCollection_tags(col
, var
, &disp
);
7940 ok_(__FILE__
, line
)(hres
== S_OK
, "search by tags(%s) failed: %08lx\n", wine_dbgstr_w(id
), hres
);
7941 ok_(__FILE__
, line
)(disp
!= NULL
, "disp == NULL\n");
7944 IDispatch_Release(disp
);
7945 IHTMLElementCollection_Release(col
);
7948 static void test_tr_modify(IHTMLElement
*elem
, IHTMLTableRow
*row
)
7952 IHTMLTableCell
*cell
;
7954 hres
= IHTMLTableRow_deleteCell(row
, 0);
7955 ok(hres
== S_OK
, "deleteCell failed: %08lx\n", hres
);
7956 test_tr_possess(elem
, row
, 1, L
"td2");
7958 hres
= IHTMLTableRow_insertCell(row
, 0, &disp
);
7959 ok(hres
== S_OK
, "insertCell failed: %08lx\n", hres
);
7960 ok(disp
!= NULL
, "disp == NULL\n");
7961 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableCell
, (void **)&cell
);
7962 ok(hres
== S_OK
, "Could not get IID_IHTMLTableCell interface: %08lx\n", hres
);
7963 ok(cell
!= NULL
, "cell == NULL\n");
7964 if (SUCCEEDED(hres
))
7965 IHTMLTableCell_Release(cell
);
7966 test_tr_possess(elem
, row
, 2, L
"td2");
7967 IDispatch_Release(disp
);
7970 static void test_tr_elem(IHTMLElement
*elem
)
7972 IHTMLElementCollection
*col
;
7977 VARIANT vbg
, vDefaultbg
;
7979 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
7981 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
7982 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08lx\n", hres
);
7987 hres
= IHTMLTableRow_get_cells(row
, &col
);
7988 ok(hres
== S_OK
, "get_cells failed: %08lx\n", hres
);
7989 ok(col
!= NULL
, "get_cells returned NULL\n");
7991 test_elem_collection((IUnknown
*)col
, cell_types
, ARRAY_SIZE(cell_types
));
7992 IHTMLElementCollection_Release(col
);
7994 bstr
= SysAllocString(L
"left");
7995 hres
= IHTMLTableRow_put_align(row
, bstr
);
7996 ok(hres
== S_OK
, "set_align failed: %08lx\n", hres
);
7997 SysFreeString(bstr
);
8000 hres
= IHTMLTableRow_get_align(row
, &bstr
);
8001 ok(hres
== S_OK
, "get_align failed: %08lx\n", hres
);
8002 ok(bstr
!= NULL
, "get_align returned NULL\n");
8003 ok(!lstrcmpW(bstr
, L
"left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
8004 SysFreeString(bstr
);
8006 bstr
= SysAllocString(L
"top");
8007 hres
= IHTMLTableRow_put_vAlign(row
, bstr
);
8008 ok(hres
== S_OK
, "set_valign failed: %08lx\n", hres
);
8009 SysFreeString(bstr
);
8012 hres
= IHTMLTableRow_get_vAlign(row
, &bstr
);
8013 ok(hres
== S_OK
, "get_valign failed: %08lx\n", hres
);
8014 ok(bstr
!= NULL
, "get_valign returned NULL\n");
8015 ok(!lstrcmpW(bstr
, L
"top"), "get_valign returned %s\n", wine_dbgstr_w(bstr
));
8016 SysFreeString(bstr
);
8019 hres
= IHTMLTableRow_get_rowIndex(row
, &lval
);
8020 ok(hres
== S_OK
, "get_rowIndex failed: %08lx\n", hres
);
8021 ok(lval
== 1, "get_rowIndex returned %ld\n", lval
);
8024 hres
= IHTMLTableRow_get_sectionRowIndex(row
, &lval
);
8025 ok(hres
== S_OK
, "get_sectionRowIndex failed: %08lx\n", hres
);
8026 ok(lval
== 1, "get_sectionRowIndex returned %ld\n", lval
);
8028 hres
= IHTMLTableRow_get_bgColor(row
, &vDefaultbg
);
8029 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8030 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
8031 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
8033 V_VT(&vbg
) = VT_BSTR
;
8034 V_BSTR(&vbg
) = SysAllocString(L
"red");
8035 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
8036 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8039 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
8040 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8041 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
8042 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
8046 V_I4(&vbg
) = 0xff0000;
8047 hres
= IHTMLTableRow_put_bgColor(row
, vbg
);
8048 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8051 hres
= IHTMLTableRow_get_bgColor(row
, &vbg
);
8052 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8053 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
8054 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
8057 /* Restore Original */
8058 hres
= IHTMLTableRow_put_bgColor(row
, vDefaultbg
);
8059 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8060 VariantClear(&vDefaultbg
);
8062 test_tr_modify(elem
, row
);
8064 IHTMLTableRow_Release(row
);
8067 static void test_td_elem(IHTMLDocument2
*doc
, IHTMLElement
*div
)
8069 IHTMLTableCell
*cell
;
8074 VARIANT vbg
, vDefaultbg
, v
;
8076 test_elem_set_innerhtml((IUnknown
*)div
,
8077 L
"<table id=\"tbl\"><tbody>"
8079 " <tr id=\"row2\"><td id=\"td1\">td1 text</td><td id=\"td2\">td2 text</td><td></td></tr>"
8081 "</tbody></table>");
8083 elem
= get_doc_elem_by_id(doc
, L
"td1");
8084 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableCell
, (void**)&cell
);
8085 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08lx\n", hres
);
8086 IHTMLElement_Release(elem
);
8089 hres
= IHTMLTableCell_get_cellIndex(cell
, &lval
);
8090 ok(hres
== S_OK
, "get cellIndex failed: %08lx\n", hres
);
8091 ok(!lval
, "Expected 0, got %ld\n", lval
);
8093 str
= SysAllocString(L
"left");
8094 hres
= IHTMLTableCell_put_align(cell
, str
);
8095 ok(hres
== S_OK
, "put_align failed: %08lx\n", hres
);
8099 hres
= IHTMLTableCell_get_align(cell
, &str
);
8100 ok(hres
== S_OK
, "get_align failed: %08lx\n", hres
);
8101 ok(str
!= NULL
, "str is NULL\n");
8102 if (str
!= NULL
&& hres
== S_OK
) {
8103 ok(!lstrcmpW(str
, L
"left"), "got %s\n", wine_dbgstr_w(str
));
8107 hres
= IHTMLTableCell_get_bgColor(cell
, &vDefaultbg
);
8108 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8109 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
8110 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
8112 V_VT(&vbg
) = VT_BSTR
;
8113 V_BSTR(&vbg
) = SysAllocString(L
"red");
8114 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
8115 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8118 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
8119 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8120 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
8121 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
8125 V_I4(&vbg
) = 0xff0000;
8126 hres
= IHTMLTableCell_put_bgColor(cell
, vbg
);
8127 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8130 hres
= IHTMLTableCell_get_bgColor(cell
, &vbg
);
8131 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8132 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
8133 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
8138 hres
= IHTMLTableCell_put_height(cell
, v
);
8139 ok(hres
== S_OK
, "put_height failed: %08lx\n", hres
);
8141 V_VT(&v
) = VT_EMPTY
;
8142 hres
= IHTMLTableCell_get_height(cell
, &v
);
8143 ok(hres
== S_OK
, "get_height failed: %08lx\n", hres
);
8144 ok(V_VT(&v
) == VT_BSTR
&& !lstrcmpW(V_BSTR(&v
), L
"100"), "height = %s\n", wine_dbgstr_variant(&v
));
8148 V_BSTR(&v
) = SysAllocString(L
"110px");
8149 hres
= IHTMLTableCell_put_height(cell
, v
);
8150 ok(hres
== S_OK
, "put_height failed: %08lx\n", hres
);
8151 SysFreeString(V_BSTR(&v
));
8153 V_VT(&v
) = VT_EMPTY
;
8154 hres
= IHTMLTableCell_get_height(cell
, &v
);
8155 ok(hres
== S_OK
, "get_height failed: %08lx\n", hres
);
8156 ok(V_VT(&v
) == VT_BSTR
&& !lstrcmpW(V_BSTR(&v
), L
"110"), "height = %s\n", wine_dbgstr_variant(&v
));
8161 hres
= IHTMLTableCell_put_width(cell
, v
);
8162 ok(hres
== S_OK
, "put_width failed: %08lx\n", hres
);
8164 V_VT(&v
) = VT_EMPTY
;
8165 hres
= IHTMLTableCell_get_width(cell
, &v
);
8166 ok(hres
== S_OK
, "get_width failed: %08lx\n", hres
);
8167 ok(V_VT(&v
) == VT_BSTR
&& !lstrcmpW(V_BSTR(&v
), L
"200"), "width = %s\n", wine_dbgstr_variant(&v
));
8171 V_BSTR(&v
) = SysAllocString(L
"210px");
8172 hres
= IHTMLTableCell_put_width(cell
, v
);
8173 ok(hres
== S_OK
, "put_width failed: %08lx\n", hres
);
8174 SysFreeString(V_BSTR(&v
));
8176 V_VT(&v
) = VT_EMPTY
;
8177 hres
= IHTMLTableCell_get_width(cell
, &v
);
8178 ok(hres
== S_OK
, "get_width failed: %08lx\n", hres
);
8179 ok(V_VT(&v
) == VT_BSTR
&& !lstrcmpW(V_BSTR(&v
), L
"210"), "width = %s\n", wine_dbgstr_variant(&v
));
8182 /* Restore Original */
8183 hres
= IHTMLTableCell_put_bgColor(cell
, vDefaultbg
);
8184 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8185 VariantClear(&vDefaultbg
);
8187 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
8188 ok(hres
== S_OK
, "get_rowSpan failed: %08lx\n", hres
);
8189 ok(lval
== 1, "rowSpan = %ld\n", lval
);
8191 hres
= IHTMLTableCell_put_rowSpan(cell
, -1);
8192 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08lx\n", hres
);
8194 hres
= IHTMLTableCell_put_rowSpan(cell
, 0);
8195 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08lx\n", hres
);
8197 hres
= IHTMLTableCell_put_rowSpan(cell
, 2);
8198 ok(hres
== S_OK
, "put_rowSpan failed: %08lx\n", hres
);
8200 hres
= IHTMLTableCell_get_rowSpan(cell
, &lval
);
8201 ok(hres
== S_OK
, "get_rowSpan failed: %08lx\n", hres
);
8202 ok(lval
== 2, "rowSpan = %ld\n", lval
);
8204 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
8205 ok(hres
== S_OK
, "get_rowSpan failed: %08lx\n", hres
);
8206 ok(lval
== 1, "rowSpan = %ld\n", lval
);
8208 hres
= IHTMLTableCell_put_colSpan(cell
, -1);
8209 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08lx\n", hres
);
8211 hres
= IHTMLTableCell_put_colSpan(cell
, 0);
8212 ok(hres
== E_INVALIDARG
, "put_rowSpan failed: %08lx\n", hres
);
8214 hres
= IHTMLTableCell_put_colSpan(cell
, 2);
8215 ok(hres
== S_OK
, "put_rowSpan failed: %08lx\n", hres
);
8217 hres
= IHTMLTableCell_get_colSpan(cell
, &lval
);
8218 ok(hres
== S_OK
, "get_rowSpan failed: %08lx\n", hres
);
8219 ok(lval
== 2, "rowSpan = %ld\n", lval
);
8221 IHTMLTableCell_Release(cell
);
8224 static void test_label_elem(IHTMLElement
*elem
)
8226 IHTMLLabelElement
*label
;
8230 label
= get_label_iface((IUnknown
*)elem
);
8233 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
8234 ok(hres
== S_OK
, "get_htmlFor failed: %08lx\n", hres
);
8235 ok(!lstrcmpW(str
, L
"in"), "htmlFor = %s\n", wine_dbgstr_w(str
));
8238 str
= SysAllocString(L
"");
8239 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
8240 ok(hres
== S_OK
, "put_htmlFor failed: %08lx\n", hres
);
8243 str
= (void*)0xdeadbeef;
8244 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
8245 ok(hres
== S_OK
, "get_htmlFor failed: %08lx\n", hres
);
8246 ok(!lstrcmpW(str
, L
""), "htmlFor = %s\n", wine_dbgstr_w(str
));
8249 str
= SysAllocString(L
"abc");
8250 hres
= IHTMLLabelElement_put_htmlFor(label
, str
);
8251 ok(hres
== S_OK
, "put_htmlFor failed: %08lx\n", hres
);
8255 hres
= IHTMLLabelElement_get_htmlFor(label
, &str
);
8256 ok(hres
== S_OK
, "get_htmlFor failed: %08lx\n", hres
);
8257 ok(!lstrcmpW(str
, L
"abc"), "htmlFor = %s\n", wine_dbgstr_w(str
));
8260 IHTMLLabelElement_Release(label
);
8263 #define test_table_cell_spacing(a,b) _test_table_cell_spacing(__LINE__,a,b)
8264 static void _test_table_cell_spacing(unsigned line
, IHTMLTable
*table
, const WCHAR
*exstr
)
8269 V_VT(&v
) = VT_ERROR
;
8270 hres
= IHTMLTable_get_cellSpacing(table
, &v
);
8271 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellSpacing failed: %08lx\n", hres
);
8272 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
8274 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&v
), exstr
), "cellSpacing = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), wine_dbgstr_w(exstr
));
8276 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellSpacing = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
8280 #define test_table_cell_padding(a,b) _test_table_cell_padding(__LINE__,a,b)
8281 static void _test_table_cell_padding(unsigned line
, IHTMLTable
*table
, const WCHAR
*exstr
)
8286 V_VT(&v
) = VT_ERROR
;
8287 hres
= IHTMLTable_get_cellPadding(table
, &v
);
8288 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cellPadding failed: %08lx\n", hres
);
8289 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(v) = %d\n", V_VT(&v
));
8291 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&v
), exstr
), "cellPadding = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v
)), wine_dbgstr_w(exstr
));
8293 ok_(__FILE__
,line
)(!V_BSTR(&v
), "cellPadding = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
8297 static void test_table_modify(IHTMLTable
*table
)
8304 test_table_length(table
, 2);
8306 hres
= IHTMLTable_insertRow(table
, 0, &disp
);
8307 ok(hres
== S_OK
, "insertRow failed: %08lx\n", hres
);
8308 ok(disp
!= NULL
, "disp == NULL\n");
8309 test_table_length(table
, 3);
8310 if (hres
!= S_OK
|| disp
== NULL
)
8313 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTableRow
, (void**)&row
);
8314 IDispatch_Release(disp
);
8316 ok(hres
== S_OK
, "QueryInterface failed: %08lx\n", hres
);
8317 ok(row
!= NULL
, "row == NULL\n");
8320 hres
= IHTMLTableRow_get_rowIndex(row
, &index
);
8321 ok(hres
== S_OK
, "get_rowIndex failed: %08lx\n", hres
);
8322 ok(index
== 0, "index = %ld, expected 0\n", index
);
8324 IHTMLTableRow_Release(row
);
8326 hres
= IHTMLTable_deleteRow(table
, 0);
8327 ok(hres
== S_OK
, "deleteRow failed: %08lx\n", hres
);
8328 test_table_length(table
, 2);
8331 static void test_table_elem(IHTMLElement
*elem
)
8333 IHTMLElementCollection
*col
;
8335 IHTMLTable3
*table3
;
8340 VARIANT vbg
, vDefaultbg
;
8342 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
8343 static const elem_type_t all_types
[] = {ET_TBODY
,ET_TR
,ET_TR
,ET_TD
,ET_TD
};
8344 static const elem_type_t tbodies_types
[] = {ET_TBODY
};
8346 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
8347 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08lx\n", hres
);
8351 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable3
, (void**)&table3
);
8352 ok(hres
== S_OK
, "Could not get IHTMLTable3 iface: %08lx\n", hres
);
8357 hres
= IHTMLTable_get_rows(table
, &col
);
8358 ok(hres
== S_OK
, "get_rows failed: %08lx\n", hres
);
8359 ok(col
!= NULL
, "get_rows returned NULL\n");
8361 test_elem_collection((IUnknown
*)col
, row_types
, ARRAY_SIZE(row_types
));
8362 IHTMLElementCollection_Release(col
);
8364 test_elem_all((IUnknown
*)table
, all_types
, ARRAY_SIZE(all_types
));
8366 node
= clone_node((IUnknown
*)table
, VARIANT_TRUE
);
8367 test_elem_tag((IUnknown
*)node
, L
"TABLE");
8368 test_elem_all((IUnknown
*)node
, all_types
, ARRAY_SIZE(all_types
));
8369 IHTMLDOMNode_Release(node
);
8371 node
= clone_node((IUnknown
*)table
, VARIANT_FALSE
);
8372 test_elem_tag((IUnknown
*)node
, L
"TABLE");
8373 test_elem_all((IUnknown
*)node
, NULL
, 0);
8374 IHTMLDOMNode_Release(node
);
8377 hres
= IHTMLTable_get_tBodies(table
, &col
);
8378 ok(hres
== S_OK
, "get_tBodies failed: %08lx\n", hres
);
8379 ok(col
!= NULL
, "get_tBodies returned NULL\n");
8381 test_elem_collection((IUnknown
*)col
, tbodies_types
, ARRAY_SIZE(tbodies_types
));
8382 IHTMLElementCollection_Release(col
);
8384 test_table_cell_spacing(table
, NULL
);
8388 hres
= IHTMLTable_put_cellSpacing(table
, v
);
8389 ok(hres
== S_OK
, "put_cellSpacing = %08lx\n", hres
);
8390 test_table_cell_spacing(table
, L
"10");
8393 V_BSTR(&v
) = SysAllocString(L
"11");
8394 hres
= IHTMLTable_put_cellSpacing(table
, v
);
8395 ok(hres
== S_OK
, "put_cellSpacing = %08lx\n", hres
);
8396 test_table_cell_spacing(table
, L
"11");
8399 test_table_cell_padding(table
, NULL
);
8403 hres
= IHTMLTable_put_cellPadding(table
, v
);
8404 ok(hres
== S_OK
, "put_cellPadding = %08lx\n", hres
);
8405 test_table_cell_padding(table
, L
"10");
8408 V_BSTR(&v
) = SysAllocString(L
"11");
8409 hres
= IHTMLTable_put_cellPadding(table
, v
);
8410 ok(hres
== S_OK
, "put_cellPadding = %08lx\n", hres
);
8411 test_table_cell_padding(table
, L
"11");
8416 hres
= IHTMLTable_put_cellPadding(table
, v
);
8417 ok(hres
== S_OK
, "put_cellPadding = %08lx\n", hres
);
8418 test_table_cell_padding(table
, L
"5");
8420 bstr
= SysAllocString(L
"left");
8421 hres
= IHTMLTable_put_align(table
, bstr
);
8422 ok(hres
== S_OK
, "set_align failed: %08lx\n", hres
);
8423 SysFreeString(bstr
);
8426 hres
= IHTMLTable_get_align(table
, &bstr
);
8427 ok(hres
== S_OK
, "get_align failed: %08lx\n", hres
);
8428 ok(bstr
!= NULL
, "get_align returned NULL\n");
8429 ok(!lstrcmpW(bstr
, L
"left"), "get_align returned %s\n", wine_dbgstr_w(bstr
));
8430 SysFreeString(bstr
);
8432 hres
= IHTMLTable_get_bgColor(table
, &vDefaultbg
);
8433 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8434 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
8435 ok(!V_BSTR(&vDefaultbg
), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg
)));
8437 V_VT(&vbg
) = VT_BSTR
;
8438 V_BSTR(&vbg
) = SysAllocString(L
"red");
8439 hres
= IHTMLTable_put_bgColor(table
, vbg
);
8440 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8443 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
8444 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8445 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
8446 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
8450 V_I4(&vbg
) = 0xff0000;
8451 hres
= IHTMLTable_put_bgColor(table
, vbg
);
8452 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8455 hres
= IHTMLTable_get_bgColor(table
, &vbg
);
8456 ok(hres
== S_OK
, "get_bgColor failed: %08lx\n", hres
);
8457 ok(V_VT(&vbg
) == VT_BSTR
, "V_VT(&vbg) != VT_BSTR\n");
8458 ok(!lstrcmpW(V_BSTR(&vbg
), L
"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg
)));
8461 /* Restore Original */
8462 hres
= IHTMLTable_put_bgColor(table
, vDefaultbg
);
8463 ok(hres
== S_OK
, "put_bgColor failed: %08lx\n", hres
);
8464 VariantClear(&vDefaultbg
);
8467 V_BSTR(&v
) = SysAllocString(L
"12px");
8468 hres
= IHTMLTable_put_width(table
, v
);
8469 ok(hres
== S_OK
, "put_width = %08lx\n", hres
);
8471 hres
= IHTMLTable_get_width(table
, &v
);
8472 ok(hres
== S_OK
, "get_width = %08lx\n", hres
);
8473 ok(!lstrcmpW(V_BSTR(&v
), L
"12"), "Expected 12, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8477 V_BSTR(&v
) = SysAllocString(L
"11");
8478 hres
= IHTMLTable_put_width(table
, v
);
8479 ok(hres
== S_OK
, "put_width = %08lx\n", hres
);
8481 hres
= IHTMLTable_get_width(table
, &v
);
8482 ok(hres
== S_OK
, "get_width = %08lx\n", hres
);
8483 ok(!lstrcmpW(V_BSTR(&v
), L
"11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8487 V_BSTR(&v
) = SysAllocString(L
"11.9");
8488 hres
= IHTMLTable_put_width(table
, v
);
8489 ok(hres
== S_OK
, "put_width = %08lx\n", hres
);
8491 hres
= IHTMLTable_get_width(table
, &v
);
8492 ok(hres
== S_OK
, "get_width = %08lx\n", hres
);
8493 ok(!lstrcmpW(V_BSTR(&v
), L
"11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8497 V_BSTR(&v
) = SysAllocString(L
"40.2%");
8498 hres
= IHTMLTable_put_width(table
, v
);
8499 ok(hres
== S_OK
, "put_width = %08lx\n", hres
);
8501 hres
= IHTMLTable_get_width(table
, &v
);
8502 ok(hres
== S_OK
, "get_width = %08lx\n", hres
);
8503 ok(!lstrcmpW(V_BSTR(&v
), L
"40.2%"), "Expected 40.2%%, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8508 hres
= IHTMLTable_put_width(table
, v
);
8509 ok(hres
== S_OK
, "put_width = %08lx\n", hres
);
8510 hres
= IHTMLTable_get_width(table
, &v
);
8511 ok(hres
== S_OK
, "get_width = %08lx\n", hres
);
8512 ok(!lstrcmpW(V_BSTR(&v
), L
"11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8517 hres
= IHTMLTable_put_width(table
, v
);
8518 ok(hres
== S_OK
, "put_width = %08lx\n", hres
);
8519 hres
= IHTMLTable_get_width(table
, &v
);
8520 ok(hres
== S_OK
, "get_width = %08lx\n", hres
);
8521 ok(!lstrcmpW(V_BSTR(&v
), L
"11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8524 bstr
= SysAllocString(L
"box");
8525 hres
= IHTMLTable_put_frame(table
, bstr
);
8526 ok(hres
== S_OK
, "put_frame = %08lx\n", hres
);
8527 SysFreeString(bstr
);
8528 hres
= IHTMLTable_get_frame(table
, &bstr
);
8529 ok(hres
== S_OK
, "get_frame = %08lx\n", hres
);
8530 ok(!lstrcmpW(bstr
, L
"box"), "Expected box, got %s\n", wine_dbgstr_w(bstr
));
8531 SysFreeString(bstr
);
8533 test_table_modify(table
);
8534 bstr
= SysAllocString(L
"summary");
8535 hres
= IHTMLTable3_put_summary(table3
, bstr
);
8536 ok(hres
== S_OK
, "put_summary = %08lx\n", hres
);
8537 SysFreeString(bstr
);
8539 hres
= IHTMLTable3_get_summary(table3
, &bstr
);
8540 ok(hres
== S_OK
, "get_summary = %08lx\n", hres
);
8541 ok(!lstrcmpW(bstr
, L
"summary"), "Expected summary, got %s\n", wine_dbgstr_w(bstr
));
8542 SysFreeString(bstr
);
8544 IHTMLTable3_Release(table3
);
8545 IHTMLTable_Release(table
);
8548 static void doc_write(IHTMLDocument2
*doc
, BOOL ln
, const WCHAR
*text
)
8557 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
8558 hres
= SafeArrayAccessData(sa
, (void**)&var
);
8559 ok(hres
== S_OK
, "Failed to access array data: %08lx\n", hres
);
8560 V_VT(var
) = VT_BSTR
;
8561 V_BSTR(var
) = SysAllocString(text
);
8562 SafeArrayUnaccessData(sa
);
8565 hres
= IHTMLDocument2_writeln(doc
, sa
);
8567 hres
= IHTMLDocument2_write(doc
, sa
);
8568 ok(hres
== S_OK
, "write failed: %08lx\n", hres
);
8570 SafeArrayDestroy(sa
);
8573 static void doc_complex_write(IHTMLDocument2
*doc
)
8575 SAFEARRAYBOUND dim
= {5, 0};
8580 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
8581 hres
= SafeArrayAccessData(sa
, (void**)&args
);
8582 ok(hres
== S_OK
, "Failed to access array data: %08lx\n", hres
);
8584 V_VT(args
) = VT_BSTR
;
8585 V_BSTR(args
) = SysAllocString(L
"<body i4val=\"");
8586 V_VT(args
+1) = VT_I4
;
8588 V_VT(args
+2) = VT_BSTR
;
8589 V_BSTR(args
+2) = SysAllocString(L
"\" r8val=\"");
8590 V_VT(args
+3) = VT_R8
;
8591 V_R8(args
+3) = 3.14;
8592 V_VT(args
+4) = VT_BSTR
;
8593 V_BSTR(args
+4) = SysAllocString(L
"\">");
8594 SafeArrayUnaccessData(sa
);
8596 hres
= IHTMLDocument2_write(doc
, sa
);
8597 ok(hres
== S_OK
, "write failed: %08lx\n", hres
);
8599 SafeArrayDestroy(sa
);
8602 static void test_frame_doc(IUnknown
*frame_elem
, BOOL iframe
)
8604 IHTMLDocument2
*window_doc
, *elem_doc
;
8605 IHTMLFrameElement3
*frame_elem3
;
8606 IHTMLWindow2
*content_window
;
8609 content_window
= get_frame_content_window(frame_elem
);
8610 test_ifaces((IUnknown
*)content_window
, window_iids
);
8611 window_doc
= get_window_doc(content_window
);
8612 IHTMLWindow2_Release(content_window
);
8614 elem_doc
= get_elem_doc(frame_elem
);
8615 ok(iface_cmp((IUnknown
*)window_doc
, (IUnknown
*)elem_doc
), "content_doc != elem_doc\n");
8618 hres
= IUnknown_QueryInterface(frame_elem
, &IID_IHTMLFrameElement3
, (void**)&frame_elem3
);
8619 if(SUCCEEDED(hres
)) {
8620 IDispatch
*disp
= NULL
;
8622 hres
= IHTMLFrameElement3_get_contentDocument(frame_elem3
, &disp
);
8623 ok(hres
== S_OK
, "get_contentDocument failed: %08lx\n", hres
);
8624 ok(disp
!= NULL
, "contentDocument == NULL\n");
8625 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)window_doc
), "contentDocument != contentWindow.document\n");
8627 IDispatch_Release(disp
);
8628 IHTMLFrameElement3_Release(frame_elem3
);
8630 win_skip("IHTMLFrameElement3 not supported\n");
8634 IHTMLDocument2_Release(elem_doc
);
8635 IHTMLDocument2_Release(window_doc
);
8638 #define test_iframe_height(a,b) _test_iframe_height(__LINE__,a,b)
8639 static void _test_iframe_height(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exval
)
8641 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
8645 hres
= IHTMLIFrameElement2_get_height(iframe
, &v
);
8646 ok_(__FILE__
,line
)(hres
== S_OK
, "get_height failed: %08lx\n", hres
);
8647 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(height) = %d\n", V_VT(&v
));
8649 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&v
), exval
), "height = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8651 ok_(__FILE__
,line
)(!V_BSTR(&v
), "height = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
8653 IHTMLIFrameElement2_Release(iframe
);
8656 #define set_iframe_height(a,b) _set_iframe_height(__LINE__,a,b)
8657 static void _set_iframe_height(unsigned line
, IHTMLElement
*elem
, const WCHAR
*val
)
8659 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
8664 V_BSTR(&v
) = SysAllocString(val
);
8665 hres
= IHTMLIFrameElement2_put_height(iframe
, v
);
8666 ok_(__FILE__
,line
)(hres
== S_OK
, "put_height failed: %08lx\n", hres
);
8668 IHTMLIFrameElement2_Release(iframe
);
8671 #define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b)
8672 static void _test_iframe_width(unsigned line
, IHTMLElement
*elem
, const WCHAR
*exval
)
8674 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
8678 hres
= IHTMLIFrameElement2_get_width(iframe
, &v
);
8679 ok_(__FILE__
,line
)(hres
== S_OK
, "get_width failed: %08lx\n", hres
);
8680 ok_(__FILE__
,line
)(V_VT(&v
) == VT_BSTR
, "V_VT(width) = %d\n", V_VT(&v
));
8682 ok_(__FILE__
,line
)(!lstrcmpW(V_BSTR(&v
), exval
), "width = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8684 ok_(__FILE__
,line
)(!V_BSTR(&v
), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v
)));
8686 IHTMLIFrameElement2_Release(iframe
);
8689 #define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b)
8690 static void _set_iframe_width(unsigned line
, IHTMLElement
*elem
, const WCHAR
*val
)
8692 IHTMLIFrameElement2
*iframe
= _get_iframe2_iface(line
, (IUnknown
*)elem
);
8697 V_BSTR(&v
) = SysAllocString(val
);
8698 hres
= IHTMLIFrameElement2_put_width(iframe
, v
);
8699 ok_(__FILE__
,line
)(hres
== S_OK
, "put_width failed: %08lx\n", hres
);
8701 IHTMLIFrameElement2_Release(iframe
);
8704 static void test_iframe_elem(IHTMLElement
*elem
)
8706 IHTMLDocument2
*content_doc
, *owner_doc
;
8707 IHTMLIFrameElement2
*iframe2
;
8708 IHTMLIFrameElement3
*iframe3
;
8709 IHTMLElementCollection
*col
;
8710 IHTMLWindow2
*content_window
;
8717 static const elem_type_t all_types
[] = {
8725 test_frame_doc((IUnknown
*)elem
, TRUE
);
8726 test_framebase((IUnknown
*)elem
);
8728 content_window
= get_frame_content_window((IUnknown
*)elem
);
8729 test_ifaces((IUnknown
*)content_window
, window_iids
);
8730 test_window_length(content_window
, 0);
8732 content_doc
= get_window_doc(content_window
);
8733 IHTMLWindow2_Release(content_window
);
8735 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLIFrameElement3
, (void**)&iframe3
);
8736 if(SUCCEEDED(hres
)) {
8737 hres
= IHTMLIFrameElement3_get_contentDocument(iframe3
, &disp
);
8738 ok(hres
== S_OK
, "get_contentDocument failed: %08lx\n", hres
);
8739 ok(iface_cmp((IUnknown
*)content_doc
, (IUnknown
*)disp
), "content_doc != disp\n");
8740 IDispatch_Release(disp
);
8742 IHTMLIFrameElement3_Release(iframe3
);
8744 win_skip("IHTMLIFrameElement3 not supported\n");
8747 iframe2
= get_iframe2_iface((IUnknown
*)elem
);
8749 test_iframe_height(elem
, NULL
);
8750 set_iframe_height(elem
, L
"100px");
8751 set_iframe_height(elem
, L
"50%");
8752 test_iframe_height(elem
, L
"50%");
8756 hres
= IHTMLIFrameElement2_put_height(iframe2
, v
);
8757 ok(hres
== S_OK
, "put_height failed: %08lx\n", hres
);
8758 test_iframe_height(elem
, L
"100");
8760 test_iframe_width(elem
, NULL
);
8761 set_iframe_width(elem
, L
"150px");
8762 set_iframe_width(elem
, L
"70%");
8763 test_iframe_width(elem
, L
"70%");
8764 test_framebase_src(elem
, L
"about:blank");
8768 hres
= IHTMLIFrameElement2_put_width(iframe2
, v
);
8769 ok(hres
== S_OK
, "put_height failed: %08lx\n", hres
);
8770 test_iframe_width(elem
, L
"110");
8772 str
= SysAllocString(L
"text/html");
8773 V_VT(&errv
) = VT_ERROR
;
8775 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
8777 ok(hres
== S_OK
, "open failed: %08lx\n", hres
);
8778 ok(disp
!= NULL
, "disp == NULL\n");
8779 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
8780 IDispatch_Release(disp
);
8782 doc_write(content_doc
, FALSE
, L
"<html><head><title>test</title></head>");
8783 doc_complex_write(content_doc
);
8784 doc_write(content_doc
, TRUE
, L
"<br />");
8785 doc_write(content_doc
, TRUE
, L
"</html>");
8787 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
8788 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
8789 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
8790 IHTMLElementCollection_Release(col
);
8792 body
= doc_get_body(content_doc
);
8793 test_elem_attr(body
, L
"i4val", L
"4");
8794 test_elem_attr(body
, L
"r8val", L
"3.14");
8795 IHTMLElement_Release(body
);
8796 IHTMLIFrameElement2_Release(iframe2
);
8798 hres
= IHTMLDocument2_close(content_doc
);
8799 ok(hres
== S_OK
, "close failed: %08lx\n", hres
);
8801 owner_doc
= get_owner_doc((IUnknown
*)content_doc
);
8802 ok(!owner_doc
, "owner_doc = %p\n", owner_doc
);
8804 IHTMLDocument2_Release(content_doc
);
8807 static void test_elem_spellcheck(IHTMLElement
*iface
)
8809 IHTMLElement7
*elem
;
8813 hres
= IUnknown_QueryInterface(iface
, &IID_IHTMLElement7
, (void**)&elem
);
8814 if(hres
== E_NOINTERFACE
) {
8815 win_skip("IHTMLElement7 not supported\n");
8818 ok(hres
== S_OK
, "Could not get IHTMLElement7 interface: %08lx\n", hres
);
8820 V_VT(&v
) = VT_ERROR
;
8821 hres
= IHTMLElement7_get_spellcheck(elem
, &v
);
8822 ok(hres
== S_OK
, "get_spellcheck failed: %08lx\n", hres
);
8823 ok(V_VT(&v
) == VT_BOOL
&& !V_BOOL(&v
), "spellcheck = %s\n", wine_dbgstr_variant(&v
));
8826 V_BOOL(&v
) = VARIANT_TRUE
;
8827 hres
= IHTMLElement7_put_spellcheck(elem
, v
);
8828 ok(hres
== S_OK
, "put_spellcheck failed: %08lx\n", hres
);
8830 V_VT(&v
) = VT_ERROR
;
8831 hres
= IHTMLElement7_get_spellcheck(elem
, &v
);
8832 ok(hres
== S_OK
, "get_spellcheck failed: %08lx\n", hres
);
8833 ok(V_VT(&v
) == VT_BOOL
&& V_BOOL(&v
) == VARIANT_TRUE
, "spellcheck = %s\n",
8834 wine_dbgstr_variant(&v
));
8837 V_BOOL(&v
) = VARIANT_FALSE
;
8838 hres
= IHTMLElement7_put_spellcheck(elem
, v
);
8839 ok(hres
== S_OK
, "put_spellcheck failed: %08lx\n", hres
);
8841 V_VT(&v
) = VT_ERROR
;
8842 hres
= IHTMLElement7_get_spellcheck(elem
, &v
);
8843 ok(hres
== S_OK
, "get_spellcheck failed: %08lx\n", hres
);
8844 ok(V_VT(&v
) == VT_BOOL
&& !V_BOOL(&v
), "spellcheck = %s\n", wine_dbgstr_variant(&v
));
8846 IHTMLElement7_Release(elem
);
8849 #define test_stylesheet_csstext(a,b,c) _test_stylesheet_csstext(__LINE__,a,b,c)
8850 static void _test_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const WCHAR
*exstr
, BOOL is_todo
)
8855 hres
= IHTMLStyleSheet_get_cssText(stylesheet
, &str
);
8856 ok_(__FILE__
,line
)(hres
== S_OK
, "get_cssText failed: %08lx\n", hres
);
8857 todo_wine_if(is_todo
) {
8859 ok_(__FILE__
,line
)(str
&& !wcsncmp(str
, exstr
, lstrlenW(exstr
)), "cssText = %s\n", wine_dbgstr_w(str
));
8861 ok_(__FILE__
,line
)(!str
, "cssText = %s\n", wine_dbgstr_w(str
));
8867 #define set_stylesheet_csstext(a,b,c) _set_stylesheet_csstext(__LINE__,a,b,c)
8868 static void _set_stylesheet_csstext(unsigned line
, IHTMLStyleSheet
*stylesheet
, const WCHAR
*csstext
, BOOL is_todo
)
8870 BSTR str
= SysAllocString(csstext
);
8873 hres
= IHTMLStyleSheet_put_cssText(stylesheet
, str
);
8874 todo_wine_if(is_todo
)
8875 ok_(__FILE__
,line
)(hres
== S_OK
, "put_cssText failed: %08lx\n", hres
);
8879 static void test_stylesheet(IDispatch
*disp
)
8881 IHTMLStyleSheetRulesCollection
*col
= NULL
;
8882 IHTMLStyleSheet
*stylesheet
;
8883 IHTMLStyleSheetRule
*rule
;
8887 test_disp2((IUnknown
*)disp
, &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, NULL
, L
"[object]");
8889 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
8890 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08lx\n", hres
);
8892 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
8893 ok(hres
== S_OK
, "get_rules failed: %08lx\n", hres
);
8894 ok(col
!= NULL
, "col == NULL\n");
8896 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetRulesCollection
, &IID_IHTMLStyleSheetRulesCollection
, NULL
, L
"[object]");
8897 IHTMLStyleSheetRulesCollection_Release(col
);
8899 href
= (void*)0xdeadbeef;
8900 hres
= IHTMLStyleSheet_get_href(stylesheet
, &href
);
8901 ok(hres
== S_OK
, "get_href failed: %08lx\n", hres
);
8902 ok(href
== NULL
, "got href != NULL\n");
8903 SysFreeString(href
);
8905 test_stylesheet_csstext(stylesheet
, L
".body {", FALSE
);
8906 set_stylesheet_csstext(stylesheet
, L
".div { margin-right: 1px; }\n.body { margin-right: 2px; }", TRUE
);
8907 test_stylesheet_csstext(stylesheet
, L
".div {", TRUE
);
8908 set_stylesheet_csstext(stylesheet
, L
"", FALSE
);
8909 test_stylesheet_csstext(stylesheet
, NULL
, FALSE
);
8910 set_stylesheet_csstext(stylesheet
, L
".div { margin-right: 1px; }", FALSE
);
8911 test_stylesheet_csstext(stylesheet
, L
".div {", FALSE
);
8913 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
8914 ok(hres
== S_OK
, "get_rules failed: %08lx\n", hres
);
8915 ok(col
!= NULL
, "col == NULL\n");
8917 hres
= IHTMLStyleSheetRulesCollection_item(col
, 0, &rule
);
8918 ok(hres
== S_OK
, "IHTMLStyleSheetRulesCollection_item failed: %08lx\n", hres
);
8919 ok(rule
!= NULL
, "rule = NULL\n");
8920 test_disp((IUnknown
*)rule
, &DIID_DispHTMLStyleSheetRule
, NULL
, L
"[object]");
8921 IHTMLStyleSheetRule_Release(rule
);
8923 hres
= IHTMLStyleSheetRulesCollection_item(col
, 1, &rule
);
8924 ok(hres
== E_INVALIDARG
, "IHTMLStyleSheetRulesCollection_item failed: %08lx\n", hres
);
8926 IHTMLStyleSheetRulesCollection_Release(col
);
8928 IHTMLStyleSheet_Release(stylesheet
);
8931 static void test_stylesheets(IHTMLDocument2
*doc
)
8933 IHTMLStyleSheetsCollection
*col
= NULL
;
8934 IEnumVARIANT
*enum_var
;
8941 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
8942 ok(hres
== S_OK
, "get_styleSheets failed: %08lx\n", hres
);
8943 ok(col
!= NULL
, "col == NULL\n");
8945 test_disp2((IUnknown
*)col
, &DIID_DispHTMLStyleSheetsCollection
, &IID_IHTMLStyleSheetsCollection
, NULL
, L
"[object]");
8947 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
8948 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
8949 ok(len
== 1, "len=%ld\n", len
);
8955 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8956 ok(hres
== S_OK
, "item failed: %08lx\n", hres
);
8957 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
8958 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
8959 test_stylesheet(V_DISPATCH(&res
));
8966 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
8967 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
8968 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
8971 hres
= IHTMLStyleSheetsCollection_get__newEnum(col
, &enum_unk
);
8972 ok(hres
== S_OK
, "_newEnum failed: %08lx\n", hres
);
8974 hres
= IUnknown_QueryInterface(enum_unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
8975 IUnknown_Release(enum_unk
);
8976 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
8979 V_VT(&res
) = VT_ERROR
;
8980 hres
= IEnumVARIANT_Next(enum_var
, 1, &res
, &fetched
);
8981 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
8982 ok(fetched
== 1, "fetched = %lu\n", fetched
);
8983 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
8984 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
8985 test_disp2((IUnknown
*)V_DISPATCH(&res
), &DIID_DispHTMLStyleSheet
, &IID_IHTMLStyleSheet
, NULL
, L
"[object]");
8989 V_VT(&res
) = VT_ERROR
;
8990 hres
= IEnumVARIANT_Next(enum_var
, 1, &res
, &fetched
);
8991 ok(hres
== S_FALSE
, "Next failed: %08lx\n", hres
);
8992 ok(fetched
== 0, "fetched = %lu\n", fetched
);
8993 IEnumVARIANT_Release(enum_var
);
8995 IHTMLStyleSheetsCollection_Release(col
);
8998 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
9000 IDispatchEx
*dispex
;
9002 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
9010 static const WCHAR w0
[] = {'0',0};
9011 static const WCHAR w100
[] = {'1','0','0',0};
9013 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
9014 ok(hres
== S_OK
, "Could not get IDispatchEx: %08lx\n", hres
);
9016 bstr
= SysAllocString(w0
);
9017 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
9018 ok(hres
== S_OK
, "GetDispID failed: %08lx\n", hres
);
9019 SysFreeString(bstr
);
9022 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
9023 ok(hres
== S_OK
, "InvokeEx failed: %08lx\n", hres
);
9024 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
9025 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
9026 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
9027 type
= get_node_type((IUnknown
*)node
);
9028 ok(type
== 3, "type=%ld\n", type
);
9029 IHTMLDOMNode_Release(node
);
9032 bstr
= SysAllocString(w100
);
9033 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
9034 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08lx, expected DISP_E_UNKNOWNNAME\n", hres
);
9035 SysFreeString(bstr
);
9037 IDispatchEx_Release(dispex
);
9040 static void test_enum_children(IUnknown
*unk
, unsigned len
)
9042 IEnumVARIANT
*enum_var
;
9047 hres
= IUnknown_QueryInterface(unk
, &IID_IEnumVARIANT
, (void**)&enum_var
);
9048 ok(hres
== S_OK
, "Could not get IEnumVARIANT iface: %08lx\n", hres
);
9050 for(i
=0; i
<len
; i
++) {
9052 V_VT(&v
) = VT_ERROR
;
9053 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, i
? &fetched
: NULL
);
9054 ok(hres
== S_OK
, "Next failed: %08lx\n", hres
);
9056 ok(fetched
== 1, "fetched = %ld\n", fetched
);
9057 ok(V_VT(&v
) == VT_DISPATCH
&& V_DISPATCH(&v
), "V_VT(v) = %d\n", V_VT(&v
));
9058 IDispatch_Release(V_DISPATCH(&v
));
9061 fetched
= 0xdeadbeef;
9063 hres
= IEnumVARIANT_Next(enum_var
, 1, &v
, &fetched
);
9064 ok(hres
== S_FALSE
, "Next returned %08lx, expected S_FALSE\n", hres
);
9065 ok(fetched
== 0, "fetched = %ld\n", fetched
);
9066 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
9068 hres
= IEnumVARIANT_Reset(enum_var
);
9069 ok(hres
== S_OK
, "Reset failed: %08lx\n", hres
);
9071 fetched
= 0xdeadbeef;
9073 hres
= IEnumVARIANT_Next(enum_var
, 0, &v
, &fetched
);
9074 ok(hres
== S_OK
, "Next returned %08lx, expected S_FALSE\n", hres
);
9075 ok(fetched
== 0, "fetched = %ld\n", fetched
);
9076 ok(V_VT(&v
) == VT_BOOL
, "V_VT(v) = %d\n", V_VT(&v
));
9078 hres
= IEnumVARIANT_Skip(enum_var
, len
> 2 ? len
-2 : 0);
9079 ok(hres
== S_OK
, "Skip failed: %08lx\n", hres
);
9081 hres
= IEnumVARIANT_Reset(enum_var
);
9082 ok(hres
== S_OK
, "Reset failed: %08lx\n", hres
);
9084 hres
= IEnumVARIANT_Skip(enum_var
, len
+1);
9085 ok(hres
== S_FALSE
, "Skip failed: %08lx\n", hres
);
9087 IEnumVARIANT_Release(enum_var
);
9090 static void test_selectors(IHTMLDocument2
*doc
, IHTMLElement
*div
)
9092 IHTMLDOMChildrenCollection
*collection
;
9093 IDocumentSelector
*doc_selector
;
9094 IElementSelector
*elem_selector
;
9098 test_elem_set_innerhtml((IUnknown
*)div
, L
"<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
9100 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IDocumentSelector
, (void**)&doc_selector
);
9101 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IDocumentSelector iface: %08lx\n", hres
);
9103 win_skip("IDocumentSelector tests skipped.\n");
9108 str
= SysAllocString(L
"nomatch");
9109 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
9110 ok(hres
== S_OK
, "querySelectorAll failed: %08lx\n", hres
);
9111 ok(collection
!= NULL
, "collection == NULL\n");
9112 test_children_collection_length(collection
, 0);
9113 IHTMLDOMChildrenCollection_Release(collection
);
9117 str
= SysAllocString(L
".cl1");
9118 hres
= IDocumentSelector_querySelectorAll(doc_selector
, str
, &collection
);
9119 ok(hres
== S_OK
, "querySelectorAll failed: %08lx\n", hres
);
9120 ok(collection
!= NULL
, "collection == NULL\n");
9121 test_children_collection_length(collection
, 2);
9122 IHTMLDOMChildrenCollection_Release(collection
);
9125 IDocumentSelector_Release(doc_selector
);
9127 hres
= IHTMLElement_QueryInterface(div
, &IID_IElementSelector
, (void**)&elem_selector
);
9128 ok(hres
== S_OK
, "Could not get IElementSelector iface: %08lx\n", hres
);
9131 str
= SysAllocString(L
"nomatch");
9132 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
9133 ok(hres
== S_OK
, "querySelectorAll failed: %08lx\n", hres
);
9134 ok(collection
!= NULL
, "collection == NULL\n");
9135 test_children_collection_length(collection
, 0);
9136 IHTMLDOMChildrenCollection_Release(collection
);
9140 str
= SysAllocString(L
".cl1");
9141 hres
= IElementSelector_querySelectorAll(elem_selector
, str
, &collection
);
9142 ok(hres
== S_OK
, "querySelectorAll failed: %08lx\n", hres
);
9143 ok(collection
!= NULL
, "collection == NULL\n");
9144 test_children_collection_length(collection
, 2);
9145 IHTMLDOMChildrenCollection_Release(collection
);
9148 IElementSelector_Release(elem_selector
);
9151 static void test_elemsbyclass(IHTMLElement
*div
)
9153 IHTMLElementCollection
*collection
;
9154 IHTMLElement6
*elem
;
9158 static const elem_type_t types
[] = {ET_DIV
, ET_FORM
};
9160 test_elem_set_innerhtml((IUnknown
*)div
, L
"<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
9162 hres
= IHTMLElement_QueryInterface(div
, &IID_IHTMLElement6
, (void**)&elem
);
9163 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
), "Could not get IHTMLElement6 iface: %08lx\n", hres
);
9165 win_skip("IHTMLElement6 tests skipped.\n");
9170 str
= SysAllocString(L
"nomatch");
9171 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
9172 ok(hres
== S_OK
, "getElementsByClassName failed: %08lx\n", hres
);
9173 ok(collection
!= NULL
, "collection == NULL\n");
9174 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
9175 IHTMLElementCollection_Release(collection
);
9179 str
= SysAllocString(L
"cl1");
9180 hres
= IHTMLElement6_getElementsByClassName(elem
, str
, &collection
);
9181 ok(hres
== S_OK
, "getElementsByClassName failed: %08lx\n", hres
);
9182 ok(collection
!= NULL
, "collection == NULL\n");
9183 test_elem_collection((IUnknown
*)collection
, types
, ARRAY_SIZE(types
));
9184 IHTMLElementCollection_Release(collection
);
9187 IHTMLElement6_Release(elem
);
9190 static void test_elems(IHTMLDocument2
*doc
)
9192 IHTMLElementCollection
*col
;
9193 IHTMLDOMChildrenCollection
*child_col
;
9194 IHTMLElement
*elem
, *elem2
, *elem3
;
9195 IHTMLDOMNode
*node
, *node2
;
9196 IHTMLWindow2
*window
;
9200 IHTMLElementCollection
*collection
;
9201 IHTMLDocument3
*doc3
;
9204 static const elem_type_t all_types
[] = {
9238 static const elem_type_t item_types
[] = {
9244 hres
= IHTMLDocument2_get_all(doc
, &col
);
9245 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
9246 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
9247 test_elem_col_item(col
, L
"x", item_types
, ARRAY_SIZE(item_types
));
9249 elem
= get_elem_col_item_idx(col
, 0);
9250 test_elem_source_index(elem
, 0);
9251 IHTMLElement_Release(elem
);
9253 elem
= get_elem_col_item_idx(col
, 3);
9254 test_elem_source_index(elem
, 3);
9255 IHTMLElement_Release(elem
);
9257 IHTMLElementCollection_Release(col
);
9259 hres
= IHTMLDocument2_get_images(doc
, &collection
);
9260 ok(hres
== S_OK
, "get_images failed: %08lx\n", hres
);
9263 static const elem_type_t images_types
[] = {ET_IMG
};
9264 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
9266 IHTMLElementCollection_Release(collection
);
9269 hres
= IHTMLDocument2_get_links(doc
, &collection
);
9270 ok(hres
== S_OK
, "get_links failed: %08lx\n", hres
);
9273 static const elem_type_t link_types
[] = {ET_A
,ET_AREA
};
9274 test_elem_collection((IUnknown
*)collection
, link_types
, 2);
9276 IHTMLElementCollection_Release(collection
);
9279 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
9280 ok(hres
== S_OK
, "get_anchors failed: %08lx\n", hres
);
9283 static const elem_type_t anchor_types
[] = {ET_A
};
9284 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
9286 IHTMLElementCollection_Release(collection
);
9289 hres
= IHTMLDocument2_get_scripts(doc
, &collection
);
9290 ok(hres
== S_OK
, "get_scripts failed: %08lx\n", hres
);
9292 static const elem_type_t script_types
[] = {ET_SCRIPT
};
9293 test_elem_collection((IUnknown
*)collection
, script_types
, 1);
9294 IHTMLElementCollection_Release(collection
);
9297 test_plugins_col(doc
);
9299 elem
= get_doc_elem(doc
);
9300 test_elem_istextedit(elem
, VARIANT_FALSE
);
9301 test_elem_all((IUnknown
*)elem
, all_types
+1, ARRAY_SIZE(all_types
)-1);
9302 IHTMLElement_Release(elem
);
9304 get_elem_by_id(doc
, L
"xxx", FALSE
);
9305 elem
= get_doc_elem_by_id(doc
, L
"xxx");
9306 ok(!elem
, "elem != NULL\n");
9308 elem
= get_doc_elem_by_id(doc
, L
"s");
9309 ok(elem
!= NULL
, "elem == NULL\n");
9311 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
9312 test_elem_attr(elem
, L
"xxx", NULL
);
9313 test_elem_attr(elem
, L
"id", L
"s");
9314 test_elem_class((IUnknown
*)elem
, NULL
);
9315 test_elem_set_class((IUnknown
*)elem
, L
"cl");
9316 test_elem_set_class((IUnknown
*)elem
, NULL
);
9317 test_elem_tabindex((IUnknown
*)elem
, 0);
9318 test_elem_set_tabindex((IUnknown
*)elem
, 1);
9319 test_elem_filters((IUnknown
*)elem
);
9320 test_elem_istextedit(elem
, VARIANT_FALSE
);
9322 node
= test_node_get_parent((IUnknown
*)elem
);
9323 ok(node
!= NULL
, "node == NULL\n");
9324 test_node_name((IUnknown
*)node
, L
"BODY");
9325 node2
= test_node_get_parent((IUnknown
*)node
);
9326 IHTMLDOMNode_Release(node
);
9327 ok(node2
!= NULL
, "node == NULL\n");
9328 test_node_name((IUnknown
*)node2
, L
"HTML");
9329 node
= test_node_get_parent((IUnknown
*)node2
);
9330 IHTMLDOMNode_Release(node2
);
9331 ok(node
!= NULL
, "node == NULL\n");
9334 test_node_name((IUnknown
*)node
, L
"#document");
9335 type
= get_node_type((IUnknown
*)node
);
9336 ok(type
== 9, "type=%ld, expected 9\n", type
);
9337 node2
= test_node_get_parent((IUnknown
*)node
);
9338 IHTMLDOMNode_Release(node
);
9339 ok(node2
== NULL
, "node != NULL\n");
9342 elem2
= test_elem_get_parent((IUnknown
*)elem
);
9343 ok(elem2
!= NULL
, "elem2 == NULL\n");
9344 test_node_name((IUnknown
*)elem2
, L
"BODY");
9346 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
9347 ok(elem3
!= NULL
, "elem3 == NULL\n");
9348 test_node_name((IUnknown
*)elem3
, L
"HTML");
9350 test_elem_contains(elem3
, elem2
, VARIANT_TRUE
);
9351 test_elem_contains(elem3
, elem
, VARIANT_TRUE
);
9352 test_elem_contains(elem2
, elem
, VARIANT_TRUE
);
9353 test_elem_contains(elem2
, elem3
, VARIANT_FALSE
);
9354 test_elem_contains(elem
, elem3
, VARIANT_FALSE
);
9355 test_elem_contains(elem
, elem2
, VARIANT_FALSE
);
9356 test_elem_contains(elem
, elem
, VARIANT_TRUE
);
9357 test_elem_contains(elem
, NULL
, VARIANT_FALSE
);
9358 IHTMLElement_Release(elem2
);
9360 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
9361 ok(elem2
== NULL
, "elem2 != NULL\n");
9362 test_elem_source_index(elem3
, 0);
9363 IHTMLElement_Release(elem3
);
9365 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2, NULL
);
9366 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0, NULL
);
9367 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0, NULL
);
9369 test_elem_innertext(elem
, L
"opt1opt2");
9371 IHTMLElement_Release(elem
);
9374 elem
= get_elem_by_id(doc
, L
"s", TRUE
);
9376 IHTMLSelectElement
*select
= get_select_iface((IUnknown
*)elem
);
9377 IHTMLDocument2
*doc_node
, *elem_doc
;
9379 test_select_elem(select
);
9381 test_elem_istextedit(elem
, VARIANT_FALSE
);
9382 test_elem_title((IUnknown
*)select
, NULL
);
9383 test_elem_set_title((IUnknown
*)select
, L
"Title");
9384 test_elem_title((IUnknown
*)select
, L
"Title");
9385 test_elem_offset((IUnknown
*)select
, L
"BODY");
9386 test_elem_bounding_client_rect((IUnknown
*)select
);
9388 node
= get_first_child((IUnknown
*)select
);
9389 ok(node
!= NULL
, "node == NULL\n");
9391 test_elem_type((IUnknown
*)node
, ET_OPTION
);
9392 IHTMLDOMNode_Release(node
);
9395 type
= get_node_type((IUnknown
*)select
);
9396 ok(type
== 1, "type=%ld\n", type
);
9398 IHTMLSelectElement_Release(select
);
9400 elem_doc
= get_elem_doc((IUnknown
*)elem
);
9402 doc_node
= get_doc_node(doc
);
9403 ok(iface_cmp((IUnknown
*)elem_doc
, (IUnknown
*)doc_node
), "disp != doc\n");
9404 IHTMLDocument2_Release(doc_node
);
9405 IHTMLDocument2_Release(elem_doc
);
9407 IHTMLElement_Release(elem
);
9410 elem
= doc_get_body(doc
);
9411 test_elem_offset((IUnknown
*)elem
, NULL
);
9412 IHTMLElement_Release(elem
);
9414 elem
= get_elem_by_id(doc
, L
"sc", TRUE
);
9416 IHTMLScriptElement
*script
;
9419 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
9420 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08lx\n", hres
);
9422 test_elem_language(elem
, NULL
);
9423 test_elem_istextedit(elem
, VARIANT_FALSE
);
9429 hres
= IHTMLScriptElement_put_type (script
, NULL
);
9430 ok(hres
== S_OK
, "put_type failed: %08lx\n", hres
);
9431 hres
= IHTMLScriptElement_get_type(script
, &type
);
9432 ok(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
9433 ok(type
== NULL
, "Unexpected type %s\n", wine_dbgstr_w(type
));
9435 type
= SysAllocString(L
"text/javascript");
9436 hres
= IHTMLScriptElement_put_type (script
, type
);
9437 ok(hres
== S_OK
, "put_type failed: %08lx\n", hres
);
9438 SysFreeString(type
);
9439 hres
= IHTMLScriptElement_get_type(script
, &type
);
9440 ok(hres
== S_OK
, "get_type failed: %08lx\n", hres
);
9441 ok(!lstrcmpW(type
, L
"text/javascript"), "Unexpected type %s\n", wine_dbgstr_w(type
));
9442 SysFreeString(type
);
9444 test_script_text(script
, L
"<!--\nfunction Testing() {}\n// -->\n");
9447 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
9448 ok(hres
== S_OK
, "put_defer failed: %08lx\n", hres
);
9450 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
9451 ok(hres
== S_OK
, "get_defer failed: %08lx\n", hres
);
9452 ok(vb
== VARIANT_TRUE
, "get_defer result is %08lx\n", hres
);
9454 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
9455 ok(hres
== S_OK
, "put_defer failed: %08lx\n", hres
);
9457 str
= (BSTR
)0xdeadbeef;
9458 hres
= IHTMLScriptElement_get_src(script
, &str
);
9459 ok(hres
== S_OK
, "get_src failed: %08lx\n", hres
);
9460 ok(!str
, "src = %s\n", wine_dbgstr_w(str
));
9462 str
= (BSTR
)0xdeadbeef;
9463 hres
= IHTMLScriptElement_get_htmlFor(script
, &str
);
9464 ok(hres
== S_OK
, "get_htmlFor failed: %08lx\n", hres
);
9465 ok(!str
, "htmlFor = %s\n", wine_dbgstr_w(str
));
9468 IHTMLScriptElement_Release(script
);
9470 set_elem_language(elem
, L
"vbscript");
9471 set_elem_language(elem
, L
"xxx");
9473 IHTMLElement_Release(elem
);
9476 elem
= get_elem_by_id(doc
, L
"in", TRUE
);
9478 IHTMLInputElement
*input
;
9480 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
9481 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08lx\n", hres
);
9483 test_elem_id((IUnknown
*)elem
, L
"in");
9484 test_elem_put_id((IUnknown
*)elem
, L
"newin");
9485 test_input_get_disabled(input
, VARIANT_FALSE
);
9486 test_input_set_disabled(input
, VARIANT_TRUE
);
9487 test_input_set_disabled(input
, VARIANT_FALSE
);
9488 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
9489 test_input_get_disabled(input
, VARIANT_TRUE
);
9490 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
9491 test_input_get_disabled(input
, VARIANT_FALSE
);
9492 test_elem_client_size((IUnknown
*)elem
);
9493 test_input_type(input
, L
"text");
9494 test_elem_istextedit(elem
, VARIANT_TRUE
);
9495 test_elem_spellcheck(elem
);
9497 test_node_get_value_str((IUnknown
*)elem
, NULL
);
9498 test_node_put_value_str((IUnknown
*)elem
, L
"test");
9499 test_node_get_value_str((IUnknown
*)elem
, NULL
);
9500 test_input_value((IUnknown
*)elem
, NULL
);
9501 test_input_defaultValue((IUnknown
*)elem
, NULL
);
9502 test_input_put_value((IUnknown
*)elem
, L
"test");
9503 test_input_defaultValue((IUnknown
*)elem
, NULL
);
9504 test_elem_class((IUnknown
*)elem
, L
"testclass");
9505 test_elem_tabindex((IUnknown
*)elem
, 2);
9506 test_elem_set_tabindex((IUnknown
*)elem
, 3);
9507 test_elem_title((IUnknown
*)elem
, L
"test title");
9509 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
9510 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
9511 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
9513 test_input_get_checked(input
, VARIANT_FALSE
);
9514 test_input_set_checked(input
, VARIANT_TRUE
);
9515 test_input_set_checked(input
, VARIANT_FALSE
);
9517 test_input_maxlength(input
, 0x7fffffff);
9518 test_input_set_maxlength(input
, 30);
9520 test_input_name(input
, NULL
);
9521 test_input_set_name(input
, L
"test");
9523 test_input_src(input
, NULL
);
9524 test_input_set_src(input
, L
"about:blank");
9526 test_input_set_size(input
, 15, S_OK
);
9527 test_input_get_size(input
, 15);
9528 test_input_set_size(input
, -100, CTL_E_INVALIDPROPERTYVALUE
);
9529 test_input_get_size(input
, 15);
9530 test_input_set_size(input
, 0, CTL_E_INVALIDPROPERTYVALUE
);
9531 test_input_get_size(input
, 15);
9533 test_input_readOnly(input
, VARIANT_TRUE
);
9534 test_input_readOnly(input
, VARIANT_FALSE
);
9536 test_elem_lang(elem
, NULL
);
9537 set_elem_lang(elem
, L
"en-us");
9539 IHTMLInputElement_Release(input
);
9540 IHTMLElement_Release(elem
);
9543 elem
= get_elem_by_id(doc
, L
"imgid", TRUE
);
9545 test_img_align((IUnknown
*)elem
, L
"left");
9546 test_img_name((IUnknown
*)elem
, L
"WineImg");
9547 test_img_src((IUnknown
*)elem
, L
"", NULL
);
9548 test_img_set_src((IUnknown
*)elem
, L
"about:blank");
9549 test_img_src((IUnknown
*)elem
, L
"about:blank", NULL
);
9550 test_img_alt((IUnknown
*)elem
, NULL
);
9551 test_img_set_alt((IUnknown
*)elem
, L
"alt test");
9552 test_img_name((IUnknown
*)elem
, L
"WineImg");
9553 test_img_complete(elem
, VARIANT_FALSE
);
9554 test_img_isMap((IUnknown
*)elem
, VARIANT_TRUE
);
9555 test_img_isMap((IUnknown
*)elem
, VARIANT_FALSE
);
9556 IHTMLElement_Release(elem
);
9559 elem
= get_elem_by_id(doc
, L
"attr", TRUE
);
9561 test_dynamic_properties(elem
);
9562 test_attr_collection(elem
);
9563 test_contenteditable((IUnknown
*)elem
);
9564 IHTMLElement_Release(elem
);
9567 elem
= get_elem_by_id(doc
, L
"styleid", TRUE
);
9569 test_style_media((IUnknown
*)elem
, NULL
);
9570 test_style_put_media((IUnknown
*)elem
, L
"screen");
9571 test_style_type((IUnknown
*)elem
, NULL
);
9572 test_style_put_type((IUnknown
*)elem
, L
"text/css");
9573 IHTMLElement_Release(elem
);
9576 elem
= get_doc_elem_by_id(doc
, L
"tbl");
9577 ok(elem
!= NULL
, "elem == NULL\n");
9579 test_table_elem(elem
);
9580 IHTMLElement_Release(elem
);
9583 elem
= get_doc_elem_by_id(doc
, L
"labelid");
9584 ok(elem
!= NULL
, "elem == NULL\n");
9586 test_label_elem(elem
);
9587 IHTMLElement_Release(elem
);
9590 elem
= get_doc_elem_by_id(doc
, L
"row2");
9591 ok(elem
!= NULL
, "elem == NULL\n");
9594 IHTMLElement_Release(elem
);
9597 elem
= get_doc_elem_by_id(doc
, L
"ifr");
9598 ok(elem
!= NULL
, "elem == NULL\n");
9600 test_iframe_elem(elem
);
9601 IHTMLElement_Release(elem
);
9604 elem
= get_doc_elem_by_id(doc
, L
"btnid");
9605 ok(elem
!= NULL
, "elem == NULL\n");
9607 test_button_elem(elem
);
9608 test_button_get_disabled(elem
, VARIANT_FALSE
);
9609 test_button_set_disabled(elem
, VARIANT_TRUE
);
9610 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
9611 test_button_get_disabled(elem
, VARIANT_FALSE
);
9612 IHTMLElement_Release(elem
);
9615 elem
= get_doc_elem_by_id(doc
, L
"objid");
9616 ok(elem
!= NULL
, "elem == NULL\n");
9618 IDispatchEx
*dispex
= get_dispex_iface((IUnknown
*)doc
);
9619 DISPPARAMS dp
= { 0 };
9624 test_object_vspace((IUnknown
*)elem
, 100);
9625 test_object_name(elem
, L
"objname");
9627 name
= SysAllocString(L
"objname");
9628 hres
= IDispatchEx_GetDispID(dispex
, name
, fdexNameCaseSensitive
, &dispid
);
9629 ok(hres
== S_OK
, "GetDispID(objname) returned: %08lx\n", hres
);
9630 SysFreeString(name
);
9632 hres
= IDispatchEx_Invoke(dispex
, dispid
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dp
, &var
, NULL
, NULL
);
9633 ok(hres
== S_OK
, "Invoke(objname) failed: %08lx\n", hres
);
9634 ok(V_VT(&var
) == VT_DISPATCH
, "VT = %d\n", V_VT(&var
));
9635 ok(V_DISPATCH(&var
) != NULL
, "objname = null\n");
9637 elem2
= get_elem_iface((IUnknown
*)V_DISPATCH(&var
));
9638 IDispatch_Release(V_DISPATCH(&var
));
9640 test_object_vspace((IUnknown
*)elem2
, 100);
9641 test_object_name(elem2
, L
"objname");
9643 ok(elem
!= elem2
, "elem == elem2\n");
9644 IHTMLElement_Release(elem2
);
9646 set_object_name(elem
, L
"test");
9647 set_object_name(elem
, NULL
);
9648 IDispatchEx_Release(dispex
);
9649 IHTMLElement_Release(elem
);
9652 elem
= get_elem_by_id(doc
, L
"a", TRUE
);
9654 test_anchor_href((IUnknown
*)elem
, L
"http://test/");
9655 test_anchor_port((IUnknown
*)elem
, L
"80");
9657 /* Change the href */
9658 test_anchor_put_href((IUnknown
*)elem
, L
"http://test1:8080/");
9659 test_anchor_href((IUnknown
*)elem
, L
"http://test1:8080/");
9660 test_anchor_hostname((IUnknown
*)elem
, L
"test1");
9661 test_anchor_port((IUnknown
*)elem
, L
"8080");
9664 test_anchor_put_href((IUnknown
*)elem
, L
"about:blank");
9665 test_anchor_href((IUnknown
*)elem
, L
"about:blank");
9666 test_anchor_hostname((IUnknown
*)elem
, NULL
);
9667 test_anchor_port((IUnknown
*)elem
, NULL
);
9669 /* Restore the href */
9670 test_anchor_put_href((IUnknown
*)elem
, L
"http://test/");
9671 test_anchor_href((IUnknown
*)elem
, L
"http://test/");
9672 test_anchor_hostname((IUnknown
*)elem
, L
"test");
9673 test_anchor_hash(elem
, NULL
);
9676 test_anchor_get_target((IUnknown
*)elem
, NULL
);
9678 test_anchor_rel((IUnknown
*)elem
, NULL
);
9679 test_anchor_put_rel((IUnknown
*)elem
, L
"Next");
9680 test_anchor_rel((IUnknown
*)elem
, L
"Next");
9682 /* Change the target */
9683 test_anchor_put_target((IUnknown
*)elem
, L
"wine");
9684 test_anchor_get_target((IUnknown
*)elem
, L
"wine");
9686 /* Restore the target */
9687 test_anchor_put_target((IUnknown
*)elem
, NULL
);
9688 test_anchor_get_target((IUnknown
*)elem
, NULL
);
9690 test_anchor_name((IUnknown
*)elem
, L
"x");
9691 test_anchor_put_name((IUnknown
*)elem
, L
"anchor name");
9692 test_anchor_put_name((IUnknown
*)elem
, NULL
);
9693 test_anchor_put_name((IUnknown
*)elem
, L
"x");
9695 test_anchor_put_href((IUnknown
*)elem
, L
"http://test/?how#hash");
9696 test_anchor_hash(elem
, L
"#hash");
9697 test_anchor_search((IUnknown
*)elem
, L
"?how", FALSE
);
9699 test_anchor_put_search((IUnknown
*)elem
, L
"?word=press");
9700 test_anchor_search((IUnknown
*)elem
, L
"?word=press", FALSE
);
9701 test_anchor_put_search((IUnknown
*)elem
, L
"?????word???press");
9702 test_anchor_search((IUnknown
*)elem
, L
"?????word???press", FALSE
);
9704 test_anchor_put_search((IUnknown
*)elem
, L
"?q=%E4%BD%A0%E5%A5%BD"); /* encoded cjk characters */
9705 test_anchor_search((IUnknown
*)elem
, L
"?q=%E4%BD%A0%E5%A5%BD", FALSE
);
9707 test_anchor_put_search((IUnknown
*)elem
, L
"?how?old=are");
9708 test_anchor_search((IUnknown
*)elem
, L
"?how?old=are", FALSE
);
9710 /* due to incorrect behavior of ie6, search string without leading "?" is interpreted
9711 as part of the pathname, and cannot be accessed by get_search. */
9712 test_anchor_put_search((IUnknown
*)elem
, L
"word=abc");
9713 test_anchor_search((IUnknown
*)elem
, L
"?word=abc", TRUE
);
9715 IHTMLElement_Release(elem
);
9718 elem
= get_elem_by_id(doc
, L
"area", TRUE
);
9720 test_area_href((IUnknown
*)elem
, L
"http://test/");
9722 /* Change the href */
9723 test_area_put_href((IUnknown
*)elem
, L
"http://test1/");
9724 test_area_href((IUnknown
*)elem
, L
"http://test1/");
9726 /* Restore the href */
9727 test_area_put_href((IUnknown
*)elem
, L
"http://test/");
9728 test_area_href((IUnknown
*)elem
, L
"http://test/");
9730 IHTMLElement_Release(elem
);
9733 elem
= get_doc_elem_by_id(doc
, L
"metaid");
9735 test_meta_name((IUnknown
*)elem
, L
"meta name");
9736 test_meta_content((IUnknown
*)elem
, L
"text/html; charset=utf-8");
9737 test_meta_httpequiv((IUnknown
*)elem
, L
"Content-Type");
9738 test_meta_charset((IUnknown
*)elem
, NULL
);
9739 set_meta_charset((IUnknown
*)elem
, L
"utf-8");
9740 IHTMLElement_Release(elem
);
9743 elem
= doc_get_body(doc
);
9745 node
= get_first_child((IUnknown
*)elem
);
9746 ok(node
!= NULL
, "node == NULL\n");
9748 test_ifaces((IUnknown
*)node
, text_iids
);
9749 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, L
"[object]");
9751 node2
= get_first_child((IUnknown
*)node
);
9752 ok(!node2
, "node2 != NULL\n");
9754 type
= get_node_type((IUnknown
*)node
);
9755 ok(type
== 3, "type=%ld\n", type
);
9757 test_node_get_value_str((IUnknown
*)node
, L
"text test");
9758 test_node_put_value_str((IUnknown
*)elem
, L
"test text");
9759 test_node_get_value_str((IUnknown
*)node
, L
"text test");
9761 hres
= IHTMLDOMNode_get_attributes(node
, &disp
);
9762 ok(hres
== S_OK
, "get_attributes failed: %08lx\n", hres
);
9763 ok(!disp
, "disp != NULL\n");
9765 IHTMLDOMNode_Release(node
);
9768 child_col
= get_child_nodes((IUnknown
*)elem
);
9769 ok(child_col
!= NULL
, "child_coll == NULL\n");
9774 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
, NULL
, L
"[object]");
9775 length
= test_children_collection_length(child_col
, -1);
9778 node
= get_child_item(child_col
, 0);
9779 ok(node
!= NULL
, "node == NULL\n");
9783 type
= get_node_type((IUnknown
*)node
);
9784 ok(type
== 3, "type=%ld\n", type
);
9785 node2
= node_get_next((IUnknown
*)node
);
9787 prev
= node_get_prev((IUnknown
*)node2
);
9788 ok(iface_cmp((IUnknown
*)node
, (IUnknown
*)prev
), "node != prev\n");
9789 IHTMLDOMNode_Release(prev
);
9791 IHTMLDOMNode_Release(node
);
9794 node
= get_child_item(child_col
, 1);
9795 ok(node
!= NULL
, "node == NULL\n");
9797 type
= get_node_type((IUnknown
*)node
);
9798 ok(type
== 8, "type=%ld\n", type
);
9800 test_elem_id((IUnknown
*)node
, NULL
);
9801 ok(iface_cmp((IUnknown
*)node2
, (IUnknown
*)node
), "node2 != node\n");
9802 IHTMLDOMNode_Release(node2
);
9803 IHTMLDOMNode_Release(node
);
9806 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
- 1, NULL
);
9807 ok(hres
== E_POINTER
, "item failed: %08lx, expected E_POINTER\n", hres
);
9809 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, NULL
);
9810 ok(hres
== E_POINTER
, "item failed: %08lx, expected E_POINTER\n", hres
);
9812 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
9813 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
9815 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
9816 ok(hres
== E_INVALIDARG
, "item failed: %08lx, expected E_INVALIDARG\n", hres
);
9818 test_child_col_disp(child_col
);
9820 hres
= IHTMLDOMChildrenCollection_get__newEnum(child_col
, &enum_unk
);
9821 ok(hres
== S_OK
, "get__newEnum failed: %08lx\n", hres
);
9823 test_enum_children(enum_unk
, length
);
9825 IUnknown_Release(enum_unk
);
9827 IHTMLDOMChildrenCollection_Release(child_col
);
9830 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
9831 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
9832 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
9834 IHTMLElement_Release(elem
);
9836 elem
= get_doc_elem_by_id(doc
, L
"frm");
9837 ok(elem
!= NULL
, "elem == NULL\n");
9839 test_form_length((IUnknown
*)elem
, 0);
9840 test_form_elements((IUnknown
*)elem
, NULL
, 0);
9841 IHTMLElement_Release(elem
);
9844 test_stylesheets(doc
);
9845 test_create_option_elem(doc
);
9846 test_create_img_elem(doc
);
9848 elem
= get_doc_elem_by_id(doc
, L
"tbl");
9849 ok(elem
!= NULL
, "elem = NULL\n");
9850 test_elem_set_innertext(elem
, L
"inner text");
9851 IHTMLElement_Release(elem
);
9853 test_doc_title(doc
, L
"test");
9854 test_doc_set_title(doc
, L
"test title");
9855 test_doc_title(doc
, L
"test title");
9858 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
9859 ok(hres
== S_OK
, "get_Script failed: %08lx\n", hres
);
9862 IDispatchEx
*dispex
;
9863 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
9864 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08lx\n", hres
);
9868 BSTR str
= SysAllocString(L
"Testing");
9869 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
9870 ok(hres
== S_OK
, "GetDispID failed: %08lx\n", hres
);
9871 ok(pid
!= -1, "pid == -1\n");
9873 IDispatchEx_Release(dispex
);
9876 IDispatch_Release(disp
);
9878 test_doc_getelembytag(doc
, "Img", ET_IMG
, 1);
9880 elem
= get_doc_elem_by_id(doc
, L
"y");
9881 test_elem_set_innerhtml((IUnknown
*)elem
, L
"inner html");
9882 test_elem_innerhtml((IUnknown
*)elem
, L
"inner html");
9883 test_elem_set_innerhtml((IUnknown
*)elem
, L
"");
9884 test_elem_innerhtml((IUnknown
*)elem
, NULL
);
9885 node
= node_get_next((IUnknown
*)elem
);
9886 ok(!node
, "node = %p\n", node
);
9888 elem2
= get_doc_elem_by_id(doc
, L
"x");
9889 test_elem_tag((IUnknown
*)elem2
, L
"A");
9890 node
= node_get_next((IUnknown
*)elem2
);
9891 IHTMLDOMNode_Release(node
);
9892 IHTMLElement_Release(elem2
);
9893 IHTMLElement_Release(elem
);
9895 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
9896 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08lx\n", hres
);
9898 hres
= IHTMLDocument3_recalc(doc3
, VARIANT_TRUE
);
9899 ok(hres
== S_OK
, "recalc failed: %08lx\n", hres
);
9901 IHTMLDocument3_Release(doc3
);
9903 elem
= get_elem_by_id(doc
, L
"s", TRUE
);
9905 static const elem_type_t select_types
[] = { ET_OPTION
, ET_OPTION
, ET_OPTION
};
9907 test_select_put_length((IUnknown
*)elem
, 3);
9908 test_elem_all((IUnknown
*)elem
, select_types
, ARRAY_SIZE(select_types
));
9909 test_select_put_length((IUnknown
*)elem
, 1);
9910 test_elem_all((IUnknown
*)elem
, select_types
, 1);
9911 IHTMLElement_Release(elem
);
9914 window
= get_doc_window(doc
);
9915 test_window_name(window
, NULL
);
9916 set_window_name(window
, L
"test name");
9917 test_window_length(window
, 1);
9918 IHTMLWindow2_Release(window
);
9921 static void test_attr(IHTMLDocument2
*doc
, IHTMLElement
*elem
)
9923 IHTMLDOMAttribute
*attr
, *attr2
, *attr3
;
9924 IHTMLElement4
*elem4
;
9928 get_elem_attr_node((IUnknown
*)elem
, L
"noattr", FALSE
);
9930 attr
= get_elem_attr_node((IUnknown
*)elem
, L
"id", TRUE
);
9932 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, L
"[object]");
9933 test_ifaces((IUnknown
*)attr
, attr_iids
);
9934 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
9935 test_attr_specified(attr
, VARIANT_TRUE
);
9936 test_attr_parent(attr
);
9937 test_attr_GetIDsOfNames(attr
);
9939 attr2
= get_elem_attr_node((IUnknown
*)elem
, L
"id", TRUE
);
9940 ok(iface_cmp((IUnknown
*)attr
, (IUnknown
*)attr2
), "attr != attr2\n");
9941 IHTMLDOMAttribute_Release(attr2
);
9943 get_attr_node_value(attr
, &v
, VT_BSTR
);
9944 ok(!lstrcmpW(V_BSTR(&v
), L
"divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9948 V_BSTR(&v
) = SysAllocString(L
"divid2");
9949 put_attr_node_value(attr
, v
);
9952 get_attr_node_value(attr
, &v
, VT_BSTR
);
9953 ok(!lstrcmpW(V_BSTR(&v
), L
"divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9956 put_attr_value(attr
, L
"divid3");
9958 get_attr_node_value(attr
, &v
, VT_BSTR
);
9959 ok(!lstrcmpW(V_BSTR(&v
), L
"divid3"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9962 IHTMLDOMAttribute_Release(attr
);
9964 attr
= get_elem_attr_node((IUnknown
*)elem
, L
"emptyattr", TRUE
);
9965 get_attr_node_value(attr
, &v
, VT_BSTR
);
9966 ok(!V_BSTR(&v
), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9970 V_BSTR(&v
) = SysAllocString(L
"newvalue");
9971 put_attr_node_value(attr
, v
);
9973 IHTMLDOMAttribute_Release(attr
);
9975 attr
= get_elem_attr_node((IUnknown
*)elem
, L
"emptyattr", TRUE
);
9976 get_attr_node_value(attr
, &v
, VT_BSTR
);
9977 ok(!lstrcmpW(V_BSTR(&v
), L
"newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9980 test_attr_specified(attr
, VARIANT_TRUE
);
9981 IHTMLDOMAttribute_Release(attr
);
9985 set_dispex_value((IUnknown
*)elem
, L
"dispprop", &v
);
9986 attr
= get_elem_attr_node((IUnknown
*)elem
, L
"dispprop", TRUE
);
9987 get_attr_node_value(attr
, &v
, VT_I4
);
9988 ok(V_I4(&v
) == 100, "V_I4(v) = %ld\n", V_I4(&v
));
9989 test_attr_specified(attr
, VARIANT_TRUE
);
9993 put_attr_node_value(attr
, v
);
9995 get_attr_node_value(attr
, &v
, VT_I4
);
9996 ok(V_I4(&v
) == 150, "V_I4(v) = %ld\n", V_I4(&v
));
9998 put_attr_value(attr
, L
"160");
9999 get_attr_node_value(attr
, &v
, VT_BSTR
);
10000 ok(!lstrcmpW(V_BSTR(&v
), L
"160"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v
)));
10003 IHTMLDOMAttribute_Release(attr
);
10005 attr
= get_elem_attr_node((IUnknown
*)elem
, L
"tabIndex", TRUE
);
10006 test_attr_specified(attr
, VARIANT_FALSE
);
10007 test_attr_expando(attr
, VARIANT_FALSE
);
10008 IHTMLDOMAttribute_Release(attr
);
10010 /* Test created, detached attribute. */
10011 attr
= create_attr((IUnknown
*)doc
, "Test");
10013 test_disp((IUnknown
*)attr
, &DIID_DispHTMLDOMAttribute
, NULL
, L
"[object]");
10014 test_ifaces((IUnknown
*)attr
, attr_iids
);
10015 test_no_iface((IUnknown
*)attr
, &IID_IHTMLDOMNode
);
10017 test_attr_node_name(attr
, L
"Test");
10018 test_attr_expando(attr
, VARIANT_FALSE
);
10020 get_attr_node_value(attr
, &v
, VT_EMPTY
);
10024 put_attr_node_value(attr
, v
);
10026 get_attr_node_value(attr
, &v
, VT_I4
);
10027 ok(V_I4(&v
) == 1, "nodeValue = %ld\n", V_I4(&v
));
10028 test_attr_value(attr
, L
"1");
10030 V_VT(&v
) = VT_EMPTY
;
10031 put_attr_node_value(attr
, v
);
10032 get_attr_node_value(attr
, &v
, VT_EMPTY
);
10034 V_VT(&v
) = VT_BSTR
;
10035 V_BSTR(&v
) = SysAllocString(L
"testing");
10036 put_attr_node_value(attr
, v
);
10037 SysFreeString(V_BSTR(&v
));
10038 test_attr_value(attr
, L
"testing");
10040 elem4
= get_elem4_iface((IUnknown
*)elem
);
10042 hres
= IHTMLElement4_setAttributeNode(elem4
, attr
, &attr2
);
10043 ok(hres
== S_OK
, "setAttributeNode failed: %08lx\n", hres
);
10044 ok(!attr2
, "attr2 != NULL\n");
10046 test_elem_attr(elem
, L
"Test", L
"testing");
10047 put_attr_value(attr
, L
"new value");
10048 test_elem_attr(elem
, L
"Test", L
"new value");
10050 attr2
= get_elem_attr_node((IUnknown
*)elem
, L
"Test", TRUE
);
10051 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
10052 IHTMLDOMAttribute_Release(attr2
);
10054 attr3
= create_attr((IUnknown
*)doc
, "Test");
10055 put_attr_value(attr3
, L
"replace test");
10057 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
10058 ok(hres
== S_OK
, "setAttributeNode failed: %08lx\n", hres
);
10059 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr
), "attr2 != attr\n");
10060 IHTMLDOMAttribute_Release(attr2
);
10062 test_elem_attr(elem
, L
"Test", L
"replace test");
10063 test_attr_value(attr
, L
"new value");
10064 test_attr_value(attr3
, L
"replace test");
10066 attr2
= get_elem_attr_node((IUnknown
*)elem
, L
"Test", TRUE
);
10067 ok(iface_cmp((IUnknown
*)attr2
, (IUnknown
*)attr3
), "attr2 != attr3\n");
10068 IHTMLDOMAttribute_Release(attr2
);
10070 put_attr_value(attr
, L
"new value2");
10071 test_elem_attr(elem
, L
"Test", L
"replace test");
10072 test_attr_value(attr
, L
"new value2");
10073 test_attr_value(attr3
, L
"replace test");
10075 put_attr_value(attr3
, L
"new replace value");
10076 test_elem_attr(elem
, L
"Test", L
"new replace value");
10077 test_attr_value(attr
, L
"new value2");
10078 test_attr_value(attr3
, L
"new replace value");
10080 /* Attached attributes cause errors. */
10081 hres
= IHTMLElement4_setAttributeNode(elem4
, attr3
, &attr2
);
10082 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08lx, expected E_INVALIDARG\n", hres
);
10083 IHTMLDOMAttribute_Release(attr3
);
10085 attr2
= get_elem_attr_node((IUnknown
*)elem
, L
"id", TRUE
);
10086 hres
= IHTMLElement4_setAttributeNode(elem4
, attr2
, &attr3
);
10087 ok(hres
== E_INVALIDARG
, "setAttributeNode failed: %08lx, expected E_INVALIDARG\n", hres
);
10088 IHTMLDOMAttribute_Release(attr2
);
10090 IHTMLElement4_Release(elem4
);
10091 IHTMLDOMAttribute_Release(attr
);
10094 static void test_blocked(IHTMLDocument2
*doc
, IHTMLElement
*outer_elem
)
10096 IHTMLElement
*elem
;
10098 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
10099 L
"<img id=\"imgid\" src=\"BLOCKED::http://www.winehq.org/img.png\" />");
10100 elem
= get_elem_by_id(doc
, L
"imgid", TRUE
);
10102 test_img_src((IUnknown
*)elem
, L
"BLOCKED::", L
"blocked::http://www.winehq.org/img.png");
10103 IHTMLElement_Release(elem
);
10106 test_elem_set_innerhtml((IUnknown
*)outer_elem
,
10107 L
"<img id=\"imgid\" src=\"BLOCKE::http://www.winehq.org/img.png\" />");
10108 elem
= get_elem_by_id(doc
, L
"imgid", TRUE
);
10110 test_img_src((IUnknown
*)elem
, L
"blocke::http://www.winehq.org/img.png", NULL
);
10111 test_img_set_src((IUnknown
*)elem
, L
"BLOCKED:http://www.winehq.org/img.png");
10112 test_img_src((IUnknown
*)elem
, L
"blocked:http://www.winehq.org/img.png", NULL
);
10113 test_img_set_src((IUnknown
*)elem
, L
"blocked::http://www.winehq.org/img.png");
10114 test_img_src((IUnknown
*)elem
, L
"BLOCKED::", L
"blocked::http://www.winehq.org/img.png");
10115 IHTMLElement_Release(elem
);
10119 #define doc_get_elems_by_name(a,b) _doc_get_elems_by_name(__LINE__,a,b)
10120 static IHTMLElementCollection
*_doc_get_elems_by_name(unsigned line
, IHTMLDocument2
*doc
, const WCHAR
*name
)
10122 IHTMLDocument3
*doc3
= _get_doc3_iface(line
, doc
);
10123 IHTMLElementCollection
*col
;
10124 BSTR str
= SysAllocString(name
);
10127 hres
= IHTMLDocument3_getElementsByName(doc3
, str
, &col
);
10128 ok_(__FILE__
,line
)(hres
== S_OK
, "getElementsByName failed: %08lx\n", hres
);
10129 ok_(__FILE__
,line
)(col
!= NULL
, "col = NULL\n");
10131 IHTMLDocument3_Release(doc3
);
10132 SysFreeString(str
);
10136 static void test_elem_names(IHTMLDocument2
*doc
)
10138 IHTMLElementCollection
*col
;
10142 static const elem_type_t test1_types
[] = {ET_INPUT
, ET_A
, ET_DIV
};
10144 set_body_html(doc
, L
"<input name=\"test\"><a name=\"test\"></a><a name=\"xxx\"></a><div id=\"test\"></div>");
10145 col
= doc_get_elems_by_name(doc
, L
"test");
10146 test_elem_collection((IUnknown
*)col
, test1_types
, ARRAY_SIZE(test1_types
));
10147 IHTMLElementCollection_Release(col
);
10149 col
= doc_get_elems_by_name(doc
, L
"yyy");
10150 test_elem_collection((IUnknown
*)col
, NULL
, 0);
10151 IHTMLElementCollection_Release(col
);
10153 /* case insensivity test */
10154 col
= doc_get_elems_by_name(doc
, L
"Xxx");
10155 hres
= IHTMLElementCollection_get_length(col
, &len
);
10156 ok(hres
== S_OK
, "get_length failed: %08lx\n", hres
);
10157 todo_wine
ok(len
== 1, "len = %ld\n", len
);
10158 IHTMLElementCollection_Release(col
);
10161 static void test_elems2(IHTMLDocument2
*doc
)
10163 IHTMLElement
*elem
, *elem2
, *div
;
10165 static const elem_type_t outer_types
[] = {
10170 div
= get_doc_elem_by_id(doc
, L
"divid");
10172 elem
= get_elem_by_id(doc
, L
"linkid", TRUE
);
10174 test_link_disabled(elem
, VARIANT_FALSE
);
10175 test_link_rel(elem
, L
"stylesheet");
10176 test_link_rev(elem
, NULL
);
10177 test_link_type(elem
, L
"text/css");
10178 test_link_href(elem
, L
"about:blank");
10179 test_link_media(elem
, L
"all");
10180 link_put_disabled(elem
, VARIANT_TRUE
);
10181 link_put_rel(elem
, L
"prev");
10182 link_put_rev(elem
, L
"next");
10183 link_put_type(elem
, L
"text/plain");
10184 link_put_href(elem
, L
"about:prev");
10185 IHTMLElement_Release(elem
);
10188 test_elem_set_innerhtml((IUnknown
*)div
, L
"<div id=\"innerid\"></div>");
10189 elem2
= get_doc_elem_by_id(doc
, L
"innerid");
10190 ok(elem2
!= NULL
, "elem2 == NULL\n");
10191 test_elem_set_outerhtml((IUnknown
*)elem2
, L
"<br><a href=\"about:blank\" id=\"aid\">a</a>");
10192 test_elem_all((IUnknown
*)div
, outer_types
, ARRAY_SIZE(outer_types
));
10193 IHTMLElement_Release(elem2
);
10195 elem2
= get_doc_elem_by_id(doc
, L
"aid");
10196 ok(elem2
!= NULL
, "elem2 == NULL\n");
10197 test_elem_set_outerhtml((IUnknown
*)elem2
, L
"");
10198 test_elem_all((IUnknown
*)div
, outer_types
, 1);
10199 IHTMLElement_Release(elem2
);
10201 test_elem_set_innerhtml((IUnknown
*)div
,
10202 L
"<input value=\"val\" id =\"inputid\" />");
10203 elem
= get_elem_by_id(doc
, L
"inputid", TRUE
);
10205 test_input_defaultValue((IUnknown
*)elem
, L
"val");
10206 test_input_put_value((IUnknown
*)elem
, L
"test");
10207 test_input_put_defaultValue((IUnknown
*)elem
, L
"new val");
10208 test_input_value((IUnknown
*)elem
, L
"test");
10209 IHTMLElement_Release(elem
);
10212 test_elem_set_innerhtml((IUnknown
*)div
, L
"");
10213 test_insert_adjacent_elems(doc
, div
);
10215 test_elem_set_innerhtml((IUnknown
*)div
,
10216 L
"<form id=\"form\" name=\"form_name\"><select id=\"sform\"><option id=\"oform\"></option></select><button id=\"btnid\"></button></form>");
10217 elem
= get_elem_by_id(doc
, L
"sform", TRUE
);
10218 elem2
= get_elem_by_id(doc
, L
"form", TRUE
);
10219 if(elem
&& elem2
) {
10220 IHTMLFormElement
*form
;
10222 test_select_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
10223 IHTMLElement_Release(elem
);
10225 elem
= get_elem_by_id(doc
, L
"oform", TRUE
);
10227 test_option_form((IUnknown
*)elem
, (IUnknown
*)elem2
);
10228 IHTMLElement_Release(elem
);
10231 elem
= get_elem_by_id(doc
, L
"btnid", TRUE
);
10233 form
= get_button_form(elem
);
10234 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)elem2
), "form != elem2\n");
10235 IHTMLFormElement_Release(form
);
10237 IHTMLElement_Release(elem
);
10238 IHTMLElement_Release(elem2
);
10241 test_selectors(doc
, div
);
10242 test_elemsbyclass(div
);
10244 test_elem_set_innerhtml((IUnknown
*)div
, L
"<div id=\"elemid\">test</div>");
10245 elem
= get_elem_by_id(doc
, L
"elemid", TRUE
);
10247 test_elem_outertext(elem
, L
"test");
10248 test_elem_set_outertext(elem
, L
"outer text");
10249 test_elem_outertext(elem
, NULL
);
10250 test_elem_all((IUnknown
*)div
, NULL
, 0);
10251 elem2
= test_elem_get_parent((IUnknown
*)elem
);
10252 ok(!elem2
, "parent != NULL\n");
10253 IHTMLElement_Release(elem
);
10256 test_elem_set_innerhtml((IUnknown
*)div
, L
"<map><area id=\"areaid\"></area></map>");
10257 elem
= get_elem_by_id(doc
, L
"areaid", TRUE
);
10259 test_elem_type((IUnknown
*)elem
, ET_AREA
);
10260 IHTMLElement_Release(elem
);
10263 test_td_elem(doc
, div
);
10264 test_attr(doc
, div
);
10265 test_blocked(doc
, div
);
10266 test_elem_names(doc
);
10268 IHTMLElement_Release(div
);
10271 static void test_textarea_element(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
10273 IHTMLElement
*form_elem
, *elem
;
10274 IHTMLFormElement
*form
;
10276 test_elem_set_innerhtml((IUnknown
*)parent
,
10277 L
"<form id=\"fid\"><textarea id=\"ta\"></textarea></form>");
10278 elem
= get_elem_by_id(doc
, L
"ta", TRUE
);
10279 test_elem_type((IUnknown
*)elem
, ET_TEXTAREA
);
10281 form_elem
= get_elem_by_id(doc
, L
"fid", TRUE
);
10282 ok(form_elem
!= NULL
, "form_elem == NULL\n");
10284 form
= get_textarea_form((IUnknown
*)elem
);
10285 ok(form
!= NULL
, "form = NULL\n");
10286 ok(iface_cmp((IUnknown
*)form
, (IUnknown
*)form_elem
), "form != form_elem\n");
10288 IHTMLFormElement_Release(form
);
10289 IHTMLElement_Release(form_elem
);
10290 IHTMLElement_Release(elem
);
10292 test_elem_set_innerhtml((IUnknown
*)parent
, L
"<textarea id=\"ta\"></textarea>");
10293 elem
= get_elem_by_id(doc
, L
"ta", TRUE
);
10295 test_textarea_value((IUnknown
*)elem
, NULL
);
10296 test_textarea_put_value((IUnknown
*)elem
, L
"test");
10297 test_textarea_defaultvalue((IUnknown
*)elem
, NULL
);
10298 test_textarea_put_defaultvalue((IUnknown
*)elem
, L
"defval text");
10299 test_textarea_put_value((IUnknown
*)elem
, L
"test");
10300 test_textarea_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
10301 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_TRUE
);
10302 test_textarea_put_readonly((IUnknown
*)elem
, VARIANT_FALSE
);
10303 test_textarea_type((IUnknown
*)elem
);
10305 form
= get_textarea_form((IUnknown
*)elem
);
10306 ok(!form
, "form = %p\n", form
);
10308 test_elem_istextedit(elem
, VARIANT_TRUE
);
10310 IHTMLElement_Release(elem
);
10312 test_elem_set_innerhtml((IUnknown
*)parent
, L
"<textarea id=\"ta\">default text</textarea>");
10313 elem
= get_elem_by_id(doc
, L
"ta", TRUE
);
10314 test_textarea_defaultvalue((IUnknown
*)elem
, L
"default text");
10315 IHTMLElement_Release(elem
);
10318 static void test_form_element(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
10320 IHTMLElement
*elem
, *input_elem
;
10322 static const elem_type_t elems_textarea_input
[] = { ET_TEXTAREA
, ET_INPUT
};
10324 test_elem_set_innerhtml((IUnknown
*)parent
,
10325 L
"<form id=\"form\">"
10326 "<textarea></textarea>"
10327 "<div><input type=\"text\" id=\"inputid\" /></div>"
10329 elem
= get_elem_by_id(doc
, L
"form", TRUE
);
10330 test_elem_type((IUnknown
*)elem
, ET_FORM
);
10332 test_form_length((IUnknown
*)elem
, 2);
10333 test_form_item(elem
);
10334 test_form_action((IUnknown
*)elem
, NULL
);
10335 test_form_put_action((IUnknown
*)elem
, L
"about:blank");
10336 test_form_method((IUnknown
*)elem
, L
"get");
10337 test_form_put_method((IUnknown
*)elem
, S_OK
, L
"post");
10338 test_form_put_method((IUnknown
*)elem
, E_INVALIDARG
, L
"put");
10339 test_form_method((IUnknown
*)elem
, L
"post");
10340 test_form_name((IUnknown
*)elem
, NULL
);
10341 test_form_put_name((IUnknown
*)elem
, L
"Name");
10342 test_form_encoding((IUnknown
*)elem
, L
"application/x-www-form-urlencoded");
10343 test_form_put_encoding((IUnknown
*)elem
, S_OK
, L
"text/plain");
10344 test_form_put_encoding((IUnknown
*)elem
, S_OK
, L
"multipart/form-data");
10345 test_form_put_encoding((IUnknown
*)elem
, E_INVALIDARG
, L
"image/png");
10346 test_form_encoding((IUnknown
*)elem
, L
"multipart/form-data");
10347 test_form_elements((IUnknown
*)elem
, elems_textarea_input
, ARRAY_SIZE(elems_textarea_input
));
10348 test_form_reset((IUnknown
*)elem
);
10349 test_form_target((IUnknown
*)elem
);
10351 input_elem
= get_elem_by_id(doc
, L
"inputid", TRUE
);
10352 test_input_get_form((IUnknown
*)input_elem
, L
"form");
10353 IHTMLElement_Release(input_elem
);
10355 IHTMLElement_Release(elem
);
10358 static void test_svg_element(IHTMLDocument2
*doc
, IHTMLElement
*parent
)
10360 IHTMLDOMNode
*svg_node
, *circle_node
, *tspan_node
;
10362 test_elem_set_innerhtml((IUnknown
*)parent
,
10363 L
"<svg width=\"100\" height=\"100\" id=\"svgid\">"
10364 "<circle cx=\"50\" cy=\"50\" r=\"40\" fill=\"black\" />"
10367 svg_node
= get_first_child((IUnknown
*)parent
);
10368 if(compat_mode
< COMPAT_IE9
) {
10370 ok(!svg_node
, "svg_node != NULL\n");
10372 IHTMLDOMNode_Release(svg_node
);
10375 ok(svg_node
!= NULL
, "svg_node = NULL\n");
10376 test_elem_type((IUnknown
*)svg_node
, ET_SVG
);
10378 circle_node
= get_first_child((IUnknown
*)svg_node
);
10379 ok(circle_node
!= NULL
, "circle_node = NULL\n");
10382 test_elem_type((IUnknown
*)circle_node
, ET_CIRCLE
);
10384 tspan_node
= node_get_next((IUnknown
*)circle_node
);
10385 test_elem_type((IUnknown
*)tspan_node
, ET_TSPAN
);
10387 IHTMLDOMNode_Release(tspan_node
);
10388 IHTMLDOMNode_Release(circle_node
);
10389 IHTMLDOMNode_Release(svg_node
);
10392 static void test_dom_elements(IHTMLDocument2
*doc
)
10396 set_body_html(doc
, L
"<div id=\"parentdiv\"></div>");
10397 div
= get_doc_elem_by_id(doc
, L
"parentdiv");
10399 test_textarea_element(doc
, div
);
10400 test_form_element(doc
, div
);
10401 test_svg_element(doc
, div
);
10403 IHTMLElement_Release(div
);
10406 static void test_create_elems(IHTMLDocument2
*doc
)
10408 IHTMLElement
*elem
, *body
, *elem2
;
10409 IHTMLDOMNode
*node
, *node2
, *node3
, *comment
;
10410 IHTMLDocument5
*doc5
;
10417 static const elem_type_t types1
[] = { ET_TESTG
};
10419 elem
= test_create_elem(doc
, L
"TEST");
10420 test_elem_tag((IUnknown
*)elem
, L
"TEST");
10421 type
= get_node_type((IUnknown
*)elem
);
10422 ok(type
== 1, "type=%ld\n", type
);
10423 test_ifaces((IUnknown
*)elem
, elem_iids
);
10424 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
, &CLSID_HTMLGenericElement
, L
"[object]");
10425 test_elem_source_index(elem
, -1);
10427 body
= doc_get_body(doc
);
10428 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
10430 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
10431 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
10432 elem2
= get_elem_iface((IUnknown
*)node
);
10433 IHTMLElement_Release(elem2
);
10435 hres
= IHTMLElement_get_all(body
, &disp
);
10436 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
10437 test_elem_collection((IUnknown
*)disp
, types1
, ARRAY_SIZE(types1
));
10438 IDispatch_Release(disp
);
10440 test_node_remove_child((IUnknown
*)body
, node
);
10442 hres
= IHTMLElement_get_all(body
, &disp
);
10443 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
10444 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
10445 IDispatch_Release(disp
);
10446 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
10448 IHTMLElement_Release(elem
);
10449 IHTMLDOMNode_Release(node
);
10451 node
= test_create_text(doc
, L
"abc");
10452 test_ifaces((IUnknown
*)node
, text_iids
);
10453 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
, NULL
, L
"[object]");
10454 test_text_length((IUnknown
*)node
, 3);
10455 test_text_data((IUnknown
*)node
, L
"abc");
10456 set_text_data((IUnknown
*)node
, L
"test");
10457 test_text_data((IUnknown
*)node
, L
"test");
10458 text_append_data((IUnknown
*)node
, L
" append");
10459 test_text_data((IUnknown
*)node
, L
"test append");
10460 text_append_data((IUnknown
*)node
, NULL
);
10461 test_text_data((IUnknown
*)node
, L
"test append");
10462 set_text_data((IUnknown
*)node
, L
"test");
10464 V_VT(&var
) = VT_NULL
;
10465 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
10466 IHTMLDOMNode_Release(node
);
10468 node
= test_create_text(doc
, L
"insert ");
10470 V_VT(&var
) = VT_DISPATCH
;
10471 V_DISPATCH(&var
) = (IDispatch
*)node2
;
10472 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
10473 IHTMLDOMNode_Release(node
);
10474 IHTMLDOMNode_Release(node2
);
10475 IHTMLDOMNode_Release(node3
);
10477 test_elem_innertext(body
, L
"insert test");
10478 test_elem_innerhtml((IUnknown
*)body
, L
"insert test");
10480 node
= test_create_text(doc
, L
" Test");
10481 V_VT(&var
) = VT_DISPATCH
;
10482 V_DISPATCH(&var
) = NULL
;
10483 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
10484 test_elem_innertext(body
, L
"insert test Test");
10485 IHTMLDOMNode_Release(node2
);
10486 IHTMLDOMNode_Release(node
);
10488 doc5
= get_htmldoc5_iface((IUnknown
*)doc
);
10490 str
= SysAllocString(L
"testing");
10491 hres
= IHTMLDocument5_createComment(doc5
, str
, &comment
);
10492 SysFreeString(str
);
10493 ok(hres
== S_OK
, "createComment failed: %08lx\n", hres
);
10496 type
= get_node_type((IUnknown
*)comment
);
10497 ok(type
== 8, "type=%ld, expected 8\n", type
);
10499 test_node_get_value_str((IUnknown
*)comment
, L
"testing");
10500 test_elem_title((IUnknown
*)comment
, NULL
);
10501 test_elem_set_title((IUnknown
*)comment
, L
"comment title");
10502 test_elem_title((IUnknown
*)comment
, L
"comment title");
10503 test_comment_text((IUnknown
*)comment
, L
"<!--testing-->");
10504 test_elem_outerhtml((IUnknown
*)comment
, L
"<!--testing-->");
10505 test_comment_attrs((IUnknown
*)comment
);
10507 node2
= clone_node((IUnknown
*)comment
, VARIANT_TRUE
);
10508 test_comment_text((IUnknown
*)node2
, L
"<!--testing-->");
10509 IHTMLDOMNode_Release(node2
);
10511 test_elem_getelembytag((IUnknown
*)comment
, ET_COMMENT
, 0, NULL
);
10513 IHTMLDOMNode_Release(comment
);
10516 IHTMLDocument5_Release(doc5
);
10519 IHTMLElement_Release(body
);
10522 static void test_replacechild_elems(IHTMLDocument2
*doc
)
10524 IHTMLElement
*body
;
10525 IHTMLDOMNode
*node
, *node2
, *node3
;
10526 IHTMLDOMNode
*nodeBody
, *nodeNew
;
10530 body
= doc_get_body(doc
);
10532 node
= test_create_text(doc
, L
"insert");
10534 V_VT(&var
) = VT_NULL
;
10535 V_DISPATCH(&var
) = NULL
;
10536 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
10537 IHTMLDOMNode_Release(node
);
10539 test_elem_innertext(body
, L
"insert");
10541 node3
= test_create_text(doc
, L
"replaced");
10543 nodeBody
= _get_node_iface(__LINE__
, (IUnknown
*)body
);
10545 hres
= IHTMLDOMNode_replaceChild(nodeBody
, node3
, node2
, &nodeNew
);
10546 ok(hres
== S_OK
, "Expected S_OK, got 0x%08lx\n", hres
);
10548 test_elem_innertext(body
, L
"replaced");
10550 IHTMLDOMNode_Release(node2
);
10551 IHTMLDOMNode_Release(node3
);
10552 IHTMLDOMNode_Release(nodeBody
);
10553 IHTMLDOMNode_Release(nodeNew
);
10555 IHTMLElement_Release(body
);
10558 static void test_noscript(IHTMLDocument2
*doc
)
10560 IHTMLElementCollection
*col
;
10561 IHTMLElement
*body
;
10564 static const elem_type_t all_types
[] = {
10573 static const elem_type_t body_all_types
[] = {
10578 hres
= IHTMLDocument2_get_all(doc
, &col
);
10579 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
10580 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
10581 IHTMLElementCollection_Release(col
);
10583 body
= doc_get_body(doc
);
10584 test_elem_set_innerhtml((IUnknown
*)body
, L
"<div>test</div><noscript><a href=\"about:blank\">A</a></noscript>");
10585 test_elem_all((IUnknown
*)body
, body_all_types
, ARRAY_SIZE(body_all_types
));
10586 IHTMLElement_Release(body
);
10589 static void test_doctype(IHTMLDocument2
*doc
)
10591 IHTMLDocument2
*doc_node
;
10592 IHTMLDOMNode
*doctype
;
10595 doc_node
= get_doc_node(doc
);
10596 doctype
= get_first_child((IUnknown
*)doc_node
);
10597 IHTMLDocument2_Release(doc_node
);
10599 type
= get_node_type((IUnknown
*)doctype
);
10600 ok(type
== 8, "type = %d\n", type
);
10602 test_comment_text((IUnknown
*)doctype
, L
"<!DOCTYPE html>");
10603 test_elem_type((IUnknown
*)doctype
, ET_COMMENT
);
10604 IHTMLDOMNode_Release(doctype
);
10607 static void test_null_write(IHTMLDocument2
*doc
)
10611 doc_write(doc
, FALSE
, NULL
);
10612 doc_write(doc
, TRUE
, NULL
);
10614 hres
= IHTMLDocument2_write(doc
, NULL
);
10616 "Expected IHTMLDocument2::write to return S_OK, got 0x%08lx\n", hres
);
10618 hres
= IHTMLDocument2_writeln(doc
, NULL
);
10620 "Expected IHTMLDocument2::writeln to return S_OK, got 0x%08lx\n", hres
);
10623 static void test_create_stylesheet(IHTMLDocument2
*doc
)
10625 IHTMLStyleSheet
*stylesheet
, *stylesheet2
;
10626 IHTMLStyleElement2
*style_elem2
;
10627 IHTMLStyleElement
*style_elem
;
10628 IHTMLElement
*doc_elem
, *elem
;
10631 static const elem_type_t all_types
[] = {
10639 static const elem_type_t all_types2
[] = {
10648 test_doc_all(doc
, all_types
, ARRAY_SIZE(all_types
));
10650 hres
= IHTMLDocument2_createStyleSheet(doc
, NULL
, -1, &stylesheet
);
10651 ok(hres
== S_OK
, "createStyleSheet failed: %08lx\n", hres
);
10653 test_doc_all(doc
, all_types2
, ARRAY_SIZE(all_types2
));
10655 doc_elem
= get_doc_elem(doc
);
10657 test_elem_getelembytag((IUnknown
*)doc_elem
, ET_STYLE
, 1, &elem
);
10658 IHTMLElement_Release(doc_elem
);
10660 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLStyleElement
, (void**)&style_elem
);
10661 IHTMLElement_Release(elem
);
10662 ok(hres
== S_OK
, "Could not get IHTMLStyleElement iface: %08lx\n", hres
);
10664 stylesheet2
= NULL
;
10665 hres
= IHTMLStyleElement_get_styleSheet(style_elem
, &stylesheet2
);
10666 ok(hres
== S_OK
, "get_styleSheet failed: %08lx\n", hres
);
10667 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
10668 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
10669 IHTMLStyleSheet_Release(stylesheet2
);
10671 hres
= IHTMLStyleElement_QueryInterface(style_elem
, &IID_IHTMLStyleElement2
, (void**)&style_elem2
);
10672 ok(hres
== S_OK
, "Could not get IHTMLStyleElement2: %08lx\n", hres
);
10674 hres
= IHTMLStyleElement2_get_sheet(style_elem2
, &stylesheet2
);
10675 ok(hres
== S_OK
, "get_styleSheet failed: %08lx\n", hres
);
10676 ok(stylesheet2
!= NULL
, "stylesheet2 == NULL\n");
10677 ok(iface_cmp((IUnknown
*)stylesheet
, (IUnknown
*)stylesheet2
), "stylesheet != stylesheet2\n");
10678 IHTMLStyleSheet_Release(stylesheet2
);
10680 IHTMLStyleElement2_Release(style_elem2
);
10681 IHTMLStyleSheet_Release(stylesheet
);
10683 IHTMLStyleElement_Release(style_elem
);
10686 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
10688 IOleCommandTarget
*cmdtrg
;
10691 hres
= IUnknown_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
10692 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08lx\n", hres
);
10694 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
10695 ok(hres
== S_OK
, "Exec failed: %08lx\n", hres
);
10697 IOleCommandTarget_Release(cmdtrg
);
10700 static void test_indent(IHTMLDocument2
*doc
)
10702 IHTMLElementCollection
*col
;
10703 IHTMLTxtRange
*range
;
10706 static const elem_type_t all_types
[] = {
10715 static const elem_type_t indent_types
[] = {
10726 hres
= IHTMLDocument2_get_all(doc
, &col
);
10727 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
10728 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
10729 IHTMLElementCollection_Release(col
);
10731 range
= test_create_body_range(doc
);
10732 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
10733 IHTMLTxtRange_Release(range
);
10735 hres
= IHTMLDocument2_get_all(doc
, &col
);
10736 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
10737 test_elem_collection((IUnknown
*)col
, indent_types
, ARRAY_SIZE(indent_types
));
10738 IHTMLElementCollection_Release(col
);
10741 static void test_cond_comment(IHTMLDocument2
*doc
)
10743 IHTMLElementCollection
*col
;
10746 static const elem_type_t all_types
[] = {
10754 hres
= IHTMLDocument2_get_all(doc
, &col
);
10755 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
10756 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
10757 IHTMLElementCollection_Release(col
);
10760 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
10762 ok(IsEqualGUID(riid
, &IID_IServiceProvider
), "riid = %s\n", wine_dbgstr_guid(riid
));
10763 return E_NOINTERFACE
;
10766 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
10771 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
10776 static const IUnknownVtbl UnknownVtbl
= {
10777 Unknown_QueryInterface
,
10781 static IUnknown obj_ident_test
= { &UnknownVtbl
};
10783 static void test_frame(IDispatch
*disp
, const WCHAR
*exp_id
)
10785 IHTMLWindow2
*frame2
, *parent
, *top
;
10786 IHTMLDocument2
*parent_doc
, *top_doc
;
10787 IHTMLWindow4
*frame
;
10788 IHTMLFrameBase
*frame_elem
;
10789 IObjectIdentity
*obj_ident
;
10790 ITravelLogClient
*tlc
;
10793 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow4
, (void**)&frame
);
10794 ok(hres
== S_OK
, "Could not get IHTMLWindow4 interface: 0x%08lx\n", hres
);
10798 hres
= IHTMLWindow4_get_frameElement(frame
, &frame_elem
);
10799 ok(hres
== S_OK
, "IHTMLWindow4_get_frameElement failed: 0x%08lx\n", hres
);
10800 IHTMLWindow4_Release(frame
);
10804 test_elem_type((IUnknown
*)frame_elem
, ET_FRAME
);
10805 test_frame_doc((IUnknown
*)frame_elem
, FALSE
);
10806 test_elem_id((IUnknown
*)frame_elem
, exp_id
);
10807 IHTMLFrameBase_Release(frame_elem
);
10809 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLWindow2
, (void**)&frame2
);
10810 ok(hres
== S_OK
, "Could not get IHTMLWindow2 interface: 0x%08lx\n", hres
);
10814 hres
= IHTMLWindow2_get_parent(frame2
, &parent
);
10815 ok(hres
== S_OK
, "IHTMLWindow2_get_parent failed: 0x%08lx\n", hres
);
10817 IHTMLWindow2_Release(frame2
);
10821 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_IObjectIdentity
, (void**)&obj_ident
);
10822 ok(hres
== S_OK
, "Could not get IObjectIdentity interface: %08lx\n", hres
);
10823 hres
= IHTMLWindow2_QueryInterface(frame2
, &IID_ITravelLogClient
, (void**)&tlc
);
10824 if(hres
== E_NOINTERFACE
) {
10825 win_skip("IID_ITravelLogClient not available\n");
10828 ok(hres
== S_OK
, "Could not get ITravelLogClient interface: %08lx\n", hres
);
10830 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)tlc
);
10831 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08lx\n", hres
);
10832 ITravelLogClient_Release(tlc
);
10835 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)obj_ident
);
10836 ok(hres
== S_OK
, "IsEqualObject returned: 0x%08lx\n", hres
);
10837 hres
= IObjectIdentity_IsEqualObject(obj_ident
, (IUnknown
*)parent
);
10838 ok(hres
== S_FALSE
, "IsEqualObject returned: 0x%08lx\n", hres
);
10839 hres
= IObjectIdentity_IsEqualObject(obj_ident
, &obj_ident_test
);
10840 ok(hres
== E_NOINTERFACE
, "IsEqualObject returned: 0x%08lx\n", hres
);
10842 IObjectIdentity_Release(obj_ident
);
10844 hres
= IHTMLWindow2_get_document(parent
, &parent_doc
);
10845 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08lx\n", hres
);
10846 IHTMLWindow2_Release(parent
);
10848 IHTMLWindow2_Release(frame2
);
10852 test_doc_title(parent_doc
, L
"frameset test");
10853 IHTMLDocument2_Release(parent_doc
);
10856 hres
= IHTMLWindow2_get_top(frame2
, &top
);
10857 ok(hres
== S_OK
, "IHTMLWindow2_get_top failed: 0x%08lx\n", hres
);
10858 IHTMLWindow2_Release(frame2
);
10862 hres
= IHTMLWindow2_get_document(top
, &top_doc
);
10863 ok(hres
== S_OK
, "IHTMLWindow2_get_document failed: 0x%08lx\n", hres
);
10864 IHTMLWindow2_Release(top
);
10868 test_doc_title(top_doc
, L
"frameset test");
10869 IHTMLDocument2_Release(top_doc
);
10872 static void test_frames_collection(IHTMLFramesCollection2
*frames
, const WCHAR
*frid
)
10874 VARIANT index_var
, result_var
;
10878 /* test result length */
10879 hres
= IHTMLFramesCollection2_get_length(frames
, &length
);
10880 ok(hres
== S_OK
, "IHTMLFramesCollection2_get_length failed: 0x%08lx\n", hres
);
10881 ok(length
== 3, "IHTMLFramesCollection2_get_length should have been 3, was: %ld\n", length
);
10883 /* test first frame */
10884 V_VT(&index_var
) = VT_I4
;
10885 V_I4(&index_var
) = 0;
10886 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
10887 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08lx\n", hres
);
10888 if(SUCCEEDED(hres
)) {
10889 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
10890 test_frame((IDispatch
*)V_DISPATCH(&result_var
), L
"fr1");
10892 VariantClear(&result_var
);
10894 /* test second frame */
10895 V_I4(&index_var
) = 1;
10896 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
10897 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08lx\n", hres
);
10898 if(SUCCEEDED(hres
)) {
10899 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
10900 test_frame((IDispatch
*)V_DISPATCH(&result_var
), L
"fr2");
10902 VariantClear(&result_var
);
10904 /* fail on next frame */
10905 V_I4(&index_var
) = 3;
10906 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
10907 ok(hres
== DISP_E_MEMBERNOTFOUND
, "IHTMLFramesCollection2_item should have"
10908 "failed with DISP_E_MEMBERNOTFOUND, instead: 0x%08lx\n", hres
);
10909 VariantClear(&result_var
);
10911 /* string argument (element id lookup) */
10912 V_VT(&index_var
) = VT_BSTR
;
10913 V_BSTR(&index_var
) = SysAllocString(frid
);
10914 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
10915 ok(hres
== S_OK
, "IHTMLFramesCollection2_item failed: 0x%08lx\n", hres
);
10916 if(SUCCEEDED(hres
)) {
10917 ok(V_VT(&result_var
) == VT_DISPATCH
, "result type should have been VT_DISPATCH, was: 0x%x\n", V_VT(&result_var
));
10918 test_frame(V_DISPATCH(&result_var
), frid
);
10920 VariantClear(&result_var
);
10921 VariantClear(&index_var
);
10923 /* invalid argument */
10924 V_VT(&index_var
) = VT_BOOL
;
10925 V_BOOL(&index_var
) = VARIANT_TRUE
;
10926 hres
= IHTMLFramesCollection2_item(frames
, &index_var
, &result_var
);
10927 ok(hres
== E_INVALIDARG
, "IHTMLFramesCollection2_item should have"
10928 "failed with E_INVALIDARG, instead: 0x%08lx\n", hres
);
10929 VariantClear(&result_var
);
10932 static void test_frameset(IHTMLDocument2
*doc
)
10934 IHTMLWindow2
*window
;
10935 IHTMLFramesCollection2
*frames
;
10936 IHTMLDocument6
*doc6
;
10937 IHTMLElement
*elem
;
10940 window
= get_doc_window(doc
);
10942 /* test using IHTMLFramesCollection object */
10944 hres
= IHTMLWindow2_get_frames(window
, &frames
);
10945 ok(hres
== S_OK
, "IHTMLWindow2_get_frames failed: 0x%08lx\n", hres
);
10949 test_frames_collection(frames
, L
"fr1");
10950 IHTMLFramesCollection2_Release(frames
);
10952 hres
= IHTMLDocument2_get_frames(doc
, &frames
);
10953 ok(hres
== S_OK
, "IHTMLDocument2_get_frames failed: 0x%08lx\n", hres
);
10957 test_frames_collection(frames
, L
"fr1");
10958 IHTMLFramesCollection2_Release(frames
);
10960 /* test using IHTMLWindow2 inheritance */
10961 test_frames_collection((IHTMLFramesCollection2
*)window
, L
"fr2");
10963 /* getElementById with node name attributes */
10964 elem
= get_doc_elem_by_id(doc
, L
"nm1");
10965 test_elem_id((IUnknown
*)elem
, L
"fr1");
10967 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument6
, (void**)&doc6
);
10968 if(SUCCEEDED(hres
)) {
10969 IHTMLElement2
*elem2
;
10972 str
= SysAllocString(L
"nm1");
10973 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
10974 ok(hres
== S_OK
, "getElementById failed: %08lx\n", hres
);
10975 ok(!elem2
, "elem = %p\n", elem2
);
10976 SysFreeString(str
);
10978 str
= SysAllocString(L
"fr1");
10979 hres
= IHTMLDocument6_getElementById(doc6
, str
, &elem2
);
10980 ok(hres
== S_OK
, "getElementById failed: %08lx\n", hres
);
10981 ok(elem2
!= NULL
, "elem2 is NULL\n");
10982 test_elem_id((IUnknown
*)elem2
, L
"fr1");
10983 IHTMLElement2_Release(elem2
);
10984 SysFreeString(str
);
10986 IHTMLDocument6_Release(doc6
);
10988 win_skip("IHTMLDocument6 not supported\n");
10991 test_framebase((IUnknown
*)elem
);
10992 test_framebase_name(elem
, L
"nm1");
10993 test_framebase_put_name(elem
, L
"frame name");
10994 test_framebase_put_name(elem
, NULL
);
10995 test_framebase_put_name(elem
, L
"nm1");
10996 test_framebase_src(elem
, L
"about:blank");
10997 IHTMLElement_Release(elem
);
10999 /* get_name with no name attr */
11000 elem
= get_doc_elem_by_id(doc
, L
"fr3");
11001 test_framebase_name(elem
, NULL
);
11002 test_framebase_put_name(elem
, L
"frame name");
11003 test_framebase_put_name(elem
, NULL
);
11004 IHTMLElement_Release(elem
);
11006 IHTMLWindow2_Release(window
);
11009 static IHTMLDocument2
*create_docfrag(IHTMLDocument2
*doc
)
11011 IHTMLDocument2
*frag
;
11012 IHTMLDocument3
*doc3
;
11015 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
11016 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08lx\n", hres
);
11018 hres
= IHTMLDocument3_createDocumentFragment(doc3
, &frag
);
11019 IHTMLDocument3_Release(doc3
);
11020 ok(hres
== S_OK
, "createDocumentFragment failed: %08lx\n", hres
);
11021 ok(frag
!= NULL
, "frag == NULL\n");
11026 static void test_docfrag(IHTMLDocument2
*doc
)
11028 IHTMLDocument2
*frag
, *owner_doc
, *doc_node
;
11029 IHTMLElement
*div
, *main_body
, *frag_body
, *br
,*html
;
11030 IHTMLElementCollection
*col
;
11031 IHTMLLocation
*location
;
11034 static const elem_type_t all_types
[] = {
11043 static const elem_type_t empty_types
[] = {};
11045 static const elem_type_t frag_types
[] = {
11052 frag
= create_docfrag(doc
);
11054 test_disp((IUnknown
*)frag
, &DIID_DispHTMLDocument
, &CLSID_HTMLDocument
, L
"[object]");
11056 frag_body
= (void*)0xdeadbeef;
11057 hres
= IHTMLDocument2_get_body(frag
, &frag_body
);
11058 ok(hres
== S_OK
, "get_body failed: %08lx\n", hres
);
11059 ok(!frag_body
, "body != NULL\n");
11061 location
= (void*)0xdeadbeef;
11062 hres
= IHTMLDocument2_get_location(frag
, &location
);
11063 ok(hres
== E_UNEXPECTED
, "get_location failed: %08lx\n", hres
);
11064 ok(location
== (void*)0xdeadbeef, "location changed\n");
11067 hres
= IHTMLDocument2_get_all(frag
, &col
);
11068 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
11069 ok(col
!= NULL
, "got null elements collection\n");
11071 test_elem_collection((IUnknown
*) col
, empty_types
, ARRAY_SIZE(empty_types
));
11072 IHTMLElementCollection_Release(col
);
11075 br
= test_create_elem(doc
, L
"BR");
11076 test_elem_source_index(br
, -1);
11077 test_node_append_child_discard((IUnknown
*)frag
, (IUnknown
*)br
);
11078 test_elem_source_index(br
, 0);
11079 IHTMLElement_Release(br
);
11081 test_doc_getelembytag(frag
, "a", ET_A
, 0);
11082 test_doc_getelembytag(frag
, "Br", ET_BR
, 1);
11084 div
= get_elem_by_id(doc
, L
"divid", TRUE
);
11085 test_node_append_child_discard((IUnknown
*)div
, (IUnknown
*)frag
);
11086 IHTMLElement_Release(div
);
11088 hres
= IHTMLDocument2_get_all(doc
, &col
);
11089 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
11090 test_elem_collection((IUnknown
*)col
, all_types
, ARRAY_SIZE(all_types
));
11091 IHTMLElementCollection_Release(col
);
11093 html
= test_create_elem(doc
, L
"HTML");
11094 test_elem_source_index(html
, -1);
11095 test_node_append_child_discard((IUnknown
*)frag
, (IUnknown
*)html
);
11096 test_elem_source_index(html
, 0);
11098 div
= test_create_elem(doc
, L
"DIV");
11099 test_elem_source_index(div
, -1);
11100 test_node_append_child_discard((IUnknown
*)html
, (IUnknown
*)div
);
11101 test_elem_source_index(div
, 1);
11102 IHTMLElement_Release(div
);
11104 div
= test_create_elem(doc
, L
"DIV");
11105 test_elem_source_index(div
, -1);
11106 test_node_append_child_discard((IUnknown
*)html
, (IUnknown
*)div
);
11107 test_elem_source_index(div
, 2);
11109 frag_body
= test_create_elem(doc
, L
"BODY");
11110 test_elem_source_index(frag_body
, -1);
11111 test_node_append_child_discard((IUnknown
*)div
, (IUnknown
*)frag_body
);
11112 test_elem_source_index(frag_body
, 3);
11113 IHTMLElement_Release(frag_body
);
11114 IHTMLElement_Release(div
);
11115 IHTMLElement_Release(html
);
11117 hres
= IHTMLDocument2_get_body(doc
, &main_body
);
11118 ok(hres
== S_OK
, "get_body failed: %08lx\n", hres
);
11119 ok(main_body
!= NULL
, "body == NULL\n");
11121 hres
= IHTMLDocument2_get_body(frag
, &frag_body
);
11122 ok(hres
== S_OK
, "get_body failed: %08lx\n", hres
);
11123 ok(frag_body
!= NULL
, "body == NULL\n");
11125 ok(!iface_cmp((IUnknown
*) frag_body
, (IUnknown
*) main_body
), "frag_body == main_body\n");
11126 IHTMLElement_Release(frag_body
);
11128 IHTMLElement_Release(main_body
);
11131 hres
= IHTMLDocument2_get_all(frag
, &col
);
11132 ok(hres
== S_OK
, "get_all failed: %08lx\n", hres
);
11133 ok(col
!= NULL
, "got null elements collection\n");
11135 test_elem_collection((IUnknown
*) col
, frag_types
, ARRAY_SIZE(frag_types
));
11136 IHTMLElementCollection_Release(col
);
11139 div
= test_create_elem(frag
, L
"div");
11140 owner_doc
= get_owner_doc((IUnknown
*)div
);
11141 doc_node
= get_doc_node(doc
);
11142 ok(iface_cmp((IUnknown
*)owner_doc
, (IUnknown
*)doc_node
), "owner_doc != doc_node\n");
11143 IHTMLDocument2_Release(doc_node
);
11144 IHTMLDocument2_Release(owner_doc
);
11145 IHTMLElement_Release(div
);
11147 IHTMLDocument2_Release(frag
);
11150 static void test_about_blank_storage(IHTMLDocument2
*doc
)
11152 IHTMLStorage
*storage
;
11153 IHTMLWindow6
*window6
;
11154 IHTMLWindow2
*window
;
11157 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
11158 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
11159 ok(window
!= NULL
, "window == NULL\n");
11161 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow6
, (void**)&window6
);
11162 IHTMLWindow2_Release(window
);
11164 win_skip("IHTMLWindow6 not supported\n");
11168 storage
= (IHTMLStorage
*)(INT_PTR
)0xdeadbeef;
11169 hres
= IHTMLWindow6_get_sessionStorage(window6
, &storage
);
11170 ok(hres
== S_FALSE
, "get_sessionStorage failed: %08lx\n", hres
);
11171 ok(storage
== NULL
, "session_storage != NULL\n");
11173 storage
= (IHTMLStorage
*)(INT_PTR
)0xdeadbeef;
11174 hres
= IHTMLWindow6_get_localStorage(window6
, &storage
);
11175 ok(hres
== S_FALSE
, "get_localStorage failed: %08lx\n", hres
);
11176 ok(storage
== NULL
, "local_storage != NULL\n");
11178 IHTMLWindow6_Release(window6
);
11181 static void check_quirks_mode(IHTMLDocument2
*doc
)
11183 test_compatmode(doc
, L
"BackCompat");
11186 static void check_strict_mode(IHTMLDocument2
*doc
)
11188 test_compatmode(doc
, L
"CSS1Compat");
11191 static void test_quirks_mode_offsetHeight(IHTMLDocument2
*doc
)
11193 IHTMLElement
*elem
;
11197 hres
= IHTMLDocument2_get_body(doc
, &elem
);
11198 ok(hres
== S_OK
, "get_body fauled: %08lx\n", hres
);
11200 /* body.offsetHeight value depends on window size in quirks mode */
11201 hres
= IHTMLElement_get_offsetHeight(elem
, &oh
);
11202 ok(hres
== S_OK
, "get_offsetHeight failed: %08lx\n", hres
);
11203 todo_wine
ok(oh
== 500, "offsetHeight = %ld\n", oh
);
11204 IHTMLElement_Release(elem
);
11207 static IHTMLDocument2
*notif_doc
;
11208 static BOOL doc_complete
;
11210 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
11211 REFIID riid
, void**ppv
)
11213 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
11218 ok(0, "unexpected call\n");
11219 return E_NOINTERFACE
;
11222 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
11227 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
11232 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
11234 if(dispID
== DISPID_READYSTATE
){
11238 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
11239 ok(hres
== S_OK
, "get_readyState failed: %08lx\n", hres
);
11241 if(!lstrcmpW(state
, L
"complete"))
11242 doc_complete
= TRUE
;
11244 SysFreeString(state
);
11250 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
11252 ok(0, "unexpected call\n");
11256 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
11257 PropertyNotifySink_QueryInterface
,
11258 PropertyNotifySink_AddRef
,
11259 PropertyNotifySink_Release
,
11260 PropertyNotifySink_OnChanged
,
11261 PropertyNotifySink_OnRequestEdit
11264 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
11266 static HRESULT
cs_qi(REFIID
,void **);
11267 static IOleDocumentView
*view
;
11268 static HWND container_hwnd
;
11270 static HRESULT WINAPI
InPlaceFrame_QueryInterface(IOleInPlaceFrame
*iface
, REFIID riid
, void **ppv
)
11272 static const GUID undocumented_frame_iid
= {0xfbece6c9,0x48d7,0x4a37,{0x8f,0xe3,0x6a,0xd4,0x27,0x2f,0xdd,0xac}};
11274 if(!IsEqualGUID(&undocumented_frame_iid
, riid
))
11275 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
11278 return E_NOINTERFACE
;
11281 static ULONG WINAPI
InPlaceFrame_AddRef(IOleInPlaceFrame
*iface
)
11286 static ULONG WINAPI
InPlaceFrame_Release(IOleInPlaceFrame
*iface
)
11291 static HRESULT WINAPI
InPlaceFrame_GetWindow(IOleInPlaceFrame
*iface
, HWND
*phwnd
)
11296 static HRESULT WINAPI
InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame
*iface
, BOOL fEnterMode
)
11301 static HRESULT WINAPI
InPlaceFrame_GetBorder(IOleInPlaceFrame
*iface
, LPRECT lprectBorder
)
11306 static HRESULT WINAPI
InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame
*iface
,
11307 LPCBORDERWIDTHS pborderwidths
)
11312 static HRESULT WINAPI
InPlaceFrame_SetBorderSpace(IOleInPlaceFrame
*iface
,
11313 LPCBORDERWIDTHS pborderwidths
)
11318 static HRESULT WINAPI
InPlaceFrame_SetActiveObject(IOleInPlaceFrame
*iface
,
11319 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
11324 static HRESULT WINAPI
InPlaceFrame_InsertMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
11325 LPOLEMENUGROUPWIDTHS lpMenuWidths
)
11330 static HRESULT WINAPI
InPlaceFrame_SetMenu(IOleInPlaceFrame
*iface
, HMENU hmenuShared
,
11331 HOLEMENU holemenu
, HWND hwndActiveObject
)
11333 ok(0, "unexpected call\n");
11337 static HRESULT WINAPI
InPlaceFrame_RemoveMenus(IOleInPlaceFrame
*iface
, HMENU hmenuShared
)
11339 ok(0, "unexpected call\n");
11343 static HRESULT WINAPI
InPlaceFrame_SetStatusText(IOleInPlaceFrame
*iface
, LPCOLESTR pszStatusText
)
11348 static HRESULT WINAPI
InPlaceFrame_EnableModeless(IOleInPlaceFrame
*iface
, BOOL fEnable
)
11353 static HRESULT WINAPI
InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame
*iface
, LPMSG lpmsg
, WORD wID
)
11355 ok(0, "unexpected call\n");
11359 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl
= {
11360 InPlaceFrame_QueryInterface
,
11361 InPlaceFrame_AddRef
,
11362 InPlaceFrame_Release
,
11363 InPlaceFrame_GetWindow
,
11364 InPlaceFrame_ContextSensitiveHelp
,
11365 InPlaceFrame_GetBorder
,
11366 InPlaceFrame_RequestBorderSpace
,
11367 InPlaceFrame_SetBorderSpace
,
11368 InPlaceFrame_SetActiveObject
,
11369 InPlaceFrame_InsertMenus
,
11370 InPlaceFrame_SetMenu
,
11371 InPlaceFrame_RemoveMenus
,
11372 InPlaceFrame_SetStatusText
,
11373 InPlaceFrame_EnableModeless
,
11374 InPlaceFrame_TranslateAccelerator
11377 static IOleInPlaceFrame InPlaceFrame
= { &InPlaceFrameVtbl
};
11379 static HRESULT WINAPI
InPlaceSite_QueryInterface(IOleInPlaceSite
*iface
, REFIID riid
, void **ppv
)
11381 return cs_qi(riid
, ppv
);
11384 static ULONG WINAPI
InPlaceSite_AddRef(IOleInPlaceSite
*iface
)
11389 static ULONG WINAPI
InPlaceSite_Release(IOleInPlaceSite
*iface
)
11394 static HRESULT WINAPI
InPlaceSite_GetWindow(IOleInPlaceSite
*iface
, HWND
*phwnd
)
11396 *phwnd
= container_hwnd
;
11400 static HRESULT WINAPI
InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite
*iface
, BOOL fEnterMode
)
11402 ok(0, "unexpected call\n");
11406 static HRESULT WINAPI
InPlaceSite_CanInPlaceActivate(IOleInPlaceSite
*iface
)
11411 static HRESULT WINAPI
InPlaceSite_OnInPlaceActivate(IOleInPlaceSite
*iface
)
11416 static HRESULT WINAPI
InPlaceSite_OnUIActivate(IOleInPlaceSite
*iface
)
11421 static HRESULT WINAPI
InPlaceSite_GetWindowContext(IOleInPlaceSite
*iface
,
11422 IOleInPlaceFrame
**ppFrame
, IOleInPlaceUIWindow
**ppDoc
, LPRECT lprcPosRect
,
11423 LPRECT lprcClipRect
, LPOLEINPLACEFRAMEINFO lpFrameInfo
)
11425 static const RECT rect
= {0,0,500,500};
11427 *ppFrame
= &InPlaceFrame
;
11429 *lprcPosRect
= rect
;
11430 *lprcClipRect
= rect
;
11432 lpFrameInfo
->fMDIApp
= FALSE
;
11433 lpFrameInfo
->hwndFrame
= container_hwnd
;
11434 lpFrameInfo
->haccel
= NULL
;
11435 lpFrameInfo
->cAccelEntries
= 0;
11440 static HRESULT WINAPI
InPlaceSite_Scroll(IOleInPlaceSite
*iface
, SIZE scrollExtant
)
11445 static HRESULT WINAPI
InPlaceSite_OnUIDeactivate(IOleInPlaceSite
*iface
, BOOL fUndoable
)
11450 static HRESULT WINAPI
InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite
*iface
)
11455 static HRESULT WINAPI
InPlaceSite_DiscardUndoState(IOleInPlaceSite
*iface
)
11460 static HRESULT WINAPI
InPlaceSite_DeactivateAndUndo(IOleInPlaceSite
*iface
)
11465 static HRESULT WINAPI
InPlaceSite_OnPosRectChange(IOleInPlaceSite
*iface
, LPCRECT lprcPosRect
)
11470 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl
= {
11471 InPlaceSite_QueryInterface
,
11472 InPlaceSite_AddRef
,
11473 InPlaceSite_Release
,
11474 InPlaceSite_GetWindow
,
11475 InPlaceSite_ContextSensitiveHelp
,
11476 InPlaceSite_CanInPlaceActivate
,
11477 InPlaceSite_OnInPlaceActivate
,
11478 InPlaceSite_OnUIActivate
,
11479 InPlaceSite_GetWindowContext
,
11480 InPlaceSite_Scroll
,
11481 InPlaceSite_OnUIDeactivate
,
11482 InPlaceSite_OnInPlaceDeactivate
,
11483 InPlaceSite_DiscardUndoState
,
11484 InPlaceSite_DeactivateAndUndo
,
11485 InPlaceSite_OnPosRectChange
,
11488 static IOleInPlaceSite InPlaceSite
= { &InPlaceSiteVtbl
};
11490 static HRESULT WINAPI
ClientSite_QueryInterface(IOleClientSite
*iface
, REFIID riid
, void **ppv
)
11492 return cs_qi(riid
, ppv
);
11495 static ULONG WINAPI
ClientSite_AddRef(IOleClientSite
*iface
)
11500 static ULONG WINAPI
ClientSite_Release(IOleClientSite
*iface
)
11505 static HRESULT WINAPI
ClientSite_SaveObject(IOleClientSite
*iface
)
11507 ok(0, "unexpected call\n");
11511 static HRESULT WINAPI
ClientSite_GetMoniker(IOleClientSite
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
,
11514 ok(0, "unexpected call\n");
11518 static HRESULT WINAPI
ClientSite_GetContainer(IOleClientSite
*iface
, IOleContainer
**ppContainer
)
11523 static HRESULT WINAPI
ClientSite_ShowObject(IOleClientSite
*iface
)
11525 ok(0, "unexpected call\n");
11529 static HRESULT WINAPI
ClientSite_OnShowWindow(IOleClientSite
*iface
, BOOL fShow
)
11531 ok(0, "unexpected call\n");
11535 static HRESULT WINAPI
ClientSite_RequestNewObjectLayout(IOleClientSite
*iface
)
11537 ok(0, "unexpected call\n");
11541 static const IOleClientSiteVtbl ClientSiteVtbl
= {
11542 ClientSite_QueryInterface
,
11544 ClientSite_Release
,
11545 ClientSite_SaveObject
,
11546 ClientSite_GetMoniker
,
11547 ClientSite_GetContainer
,
11548 ClientSite_ShowObject
,
11549 ClientSite_OnShowWindow
,
11550 ClientSite_RequestNewObjectLayout
11553 static IOleClientSite ClientSite
= { &ClientSiteVtbl
};
11555 static HRESULT WINAPI
DocumentSite_QueryInterface(IOleDocumentSite
*iface
, REFIID riid
, void **ppv
)
11557 return cs_qi(riid
, ppv
);
11560 static ULONG WINAPI
DocumentSite_AddRef(IOleDocumentSite
*iface
)
11565 static ULONG WINAPI
DocumentSite_Release(IOleDocumentSite
*iface
)
11570 static HRESULT WINAPI
DocumentSite_ActivateMe(IOleDocumentSite
*iface
, IOleDocumentView
*pViewToActivate
)
11572 RECT rect
= {0,0,500,500};
11573 IOleDocument
*document
;
11576 hres
= IOleDocumentView_QueryInterface(pViewToActivate
, &IID_IOleDocument
, (void**)&document
);
11577 ok(hres
== S_OK
, "could not get IOleDocument: %08lx\n", hres
);
11579 hres
= IOleDocument_CreateView(document
, &InPlaceSite
, NULL
, 0, &view
);
11580 IOleDocument_Release(document
);
11581 ok(hres
== S_OK
, "CreateView failed: %08lx\n", hres
);
11583 hres
= IOleDocumentView_SetInPlaceSite(view
, &InPlaceSite
);
11584 ok(hres
== S_OK
, "SetInPlaceSite failed: %08lx\n", hres
);
11586 hres
= IOleDocumentView_UIActivate(view
, TRUE
);
11587 ok(hres
== S_OK
, "UIActivate failed: %08lx\n", hres
);
11589 hres
= IOleDocumentView_SetRect(view
, &rect
);
11590 ok(hres
== S_OK
, "SetRect failed: %08lx\n", hres
);
11592 hres
= IOleDocumentView_Show(view
, TRUE
);
11593 ok(hres
== S_OK
, "Show failed: %08lx\n", hres
);
11598 static const IOleDocumentSiteVtbl DocumentSiteVtbl
= {
11599 DocumentSite_QueryInterface
,
11600 DocumentSite_AddRef
,
11601 DocumentSite_Release
,
11602 DocumentSite_ActivateMe
11605 static IOleDocumentSite DocumentSite
= { &DocumentSiteVtbl
};
11607 static HRESULT
cs_qi(REFIID riid
, void **ppv
)
11611 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IOleClientSite
, riid
))
11612 *ppv
= &ClientSite
;
11613 else if(IsEqualGUID(&IID_IOleDocumentSite
, riid
))
11614 *ppv
= &DocumentSite
;
11615 else if(IsEqualGUID(&IID_IOleWindow
, riid
) || IsEqualGUID(&IID_IOleInPlaceSite
, riid
))
11616 *ppv
= &InPlaceSite
;
11618 return *ppv
? S_OK
: E_NOINTERFACE
;
11621 static void set_client_site(IHTMLDocument2
*doc
, BOOL set
)
11623 IOleObject
*oleobj
;
11627 IOleDocumentView_Show(view
, FALSE
);
11628 IOleDocumentView_CloseView(view
, 0);
11629 IOleDocumentView_SetInPlaceSite(view
, NULL
);
11630 IOleDocumentView_Release(view
);
11634 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IOleObject
, (void**)&oleobj
);
11635 ok(hres
== S_OK
, "Could not et IOleObject: %08lx\n", hres
);
11637 hres
= IOleObject_SetClientSite(oleobj
, set
? &ClientSite
: NULL
);
11638 ok(hres
== S_OK
, "SetClientSite failed: %08lx\n", hres
);
11641 IHlinkTarget
*hlink
;
11643 hres
= IOleObject_QueryInterface(oleobj
, &IID_IHlinkTarget
, (void**)&hlink
);
11644 ok(hres
== S_OK
, "Could not get IHlinkTarget iface: %08lx\n", hres
);
11646 hres
= IHlinkTarget_Navigate(hlink
, 0, NULL
);
11647 ok(hres
== S_OK
, "Navgate failed: %08lx\n", hres
);
11649 IHlinkTarget_Release(hlink
);
11652 IOleObject_Release(oleobj
);
11655 static IHTMLDocument2
*create_doc_with_string(const char *str
)
11657 IPersistStreamInit
*init
;
11659 IHTMLDocument2
*doc
;
11664 notif_doc
= doc
= create_document();
11668 doc_complete
= FALSE
;
11670 mem
= GlobalAlloc(0, len
);
11671 memcpy(mem
, str
, len
);
11672 hr
= CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
11673 ok(hr
== S_OK
, "Failed to create a stream, hr %#lx.\n", hr
);
11675 hr
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
11676 ok(hr
== S_OK
, "Failed to get IPersistStreamInit, hr %#lx.\n", hr
);
11678 IPersistStreamInit_Load(init
, stream
);
11679 IPersistStreamInit_Release(init
);
11680 IStream_Release(stream
);
11685 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
11687 IConnectionPointContainer
*container
;
11688 IConnectionPoint
*cp
;
11692 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
11693 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08lx\n", hres
);
11695 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
11696 IConnectionPointContainer_Release(container
);
11697 ok(hres
== S_OK
, "FindConnectionPoint failed: %08lx\n", hres
);
11699 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
11700 IConnectionPoint_Release(cp
);
11701 ok(hres
== S_OK
, "Advise failed: %08lx\n", hres
);
11704 typedef void (*domtest_t
)(IHTMLDocument2
*);
11706 static void run_domtest(const char *str
, domtest_t test
)
11708 IHTMLDocument2
*doc
;
11712 doc
= create_doc_with_string(str
);
11716 set_client_site(doc
, TRUE
);
11717 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
11719 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
11720 TranslateMessage(&msg
);
11721 DispatchMessageW(&msg
);
11726 set_client_site(doc
, FALSE
);
11727 ref
= IHTMLDocument2_Release(doc
);
11728 ok(!ref
|| broken(ref
== 1), /* Vista */
11729 "ref = %ld\n", ref
);
11732 static float expected_document_mode
;
11734 static void test_document_mode(IHTMLDocument2
*doc2
)
11736 IEventTarget
*event_target
;
11737 IHTMLDocument2
*doc_node
;
11738 IHTMLDocument6
*doc
;
11739 IHTMLElement
*body
;
11743 hres
= IHTMLDocument2_QueryInterface(doc2
, &IID_IHTMLDocument6
, (void**)&doc
);
11744 if(hres
== E_NOINTERFACE
) {
11745 win_skip("IHTMLDocument6 not supported\n");
11748 ok(hres
== S_OK
, "Could not get IHTMLDocument6 interface: %08lx\n", hres
);
11750 V_VT(&v
) = VT_EMPTY
;
11751 hres
= IHTMLDocument6_get_documentMode(doc
, &v
);
11752 ok(hres
== S_OK
, "get_documentMode failed: %08lx\n", hres
);
11753 ok(V_VT(&v
) == VT_R4
, "V_VT(documentMode) = %u\n", V_VT(&v
));
11754 ok(V_R4(&v
) == expected_document_mode
, "documentMode = %f\n", V_R4(&v
));
11755 IHTMLDocument6_Release(doc
);
11757 doc_node
= get_doc_node(doc2
);
11759 hres
= IHTMLDocument2_QueryInterface(doc_node
, &IID_IEventTarget
, (void**)&event_target
);
11760 if(expected_document_mode
>= 9) {
11761 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08lx\n", hres
);
11762 IEventTarget_Release(event_target
);
11764 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08lx\n", hres
);
11767 IHTMLDocument2_Release(doc_node
);
11770 body
= doc_get_body(doc2
);
11772 hres
= IHTMLElement_QueryInterface(body
, &IID_IEventTarget
, (void**)&event_target
);
11773 if(expected_document_mode
>= 9) {
11774 ok(hres
== S_OK
, "Could not get IEventTarget interface: %08lx\n", hres
);
11775 IEventTarget_Release(event_target
);
11777 ok(hres
== E_NOINTERFACE
, "QI(IEventTarget) returned %08lx\n", hres
);
11780 IHTMLElement_Release(body
);
11783 static void test_quirks_mode(void)
11785 static const struct {
11787 unsigned expected_mode
;
11791 { " 5 , 8 , 7", 8 },
11792 { " 8 , 7 , 5", 8 },
11793 { " 5 , 5 , 7", 7 },
11794 { " 5 , 9 , 7", 9 },
11797 { " 5, edge,8", 11 },
11798 { " 5, foo,8", 5 },
11799 { " 5, 8,foo", 8 },
11805 run_domtest("<html></html>", check_quirks_mode
);
11806 run_domtest("<!DOCTYPE html>\n<html></html>", check_strict_mode
);
11807 run_domtest("<!-- comment --><!DOCTYPE html>\n<html></html>", check_quirks_mode
);
11808 run_domtest("<html><body></body></html>", test_quirks_mode_offsetHeight
);
11810 expected_document_mode
= 5;
11811 run_domtest("<html><body></body></html>", test_document_mode
);
11813 expected_document_mode
= 7;
11814 run_domtest("<!DOCTYPE html>\n<html></html>", test_document_mode
);
11819 for(i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
11821 expected_document_mode
= tests
[i
].expected_mode
;
11822 sprintf(buf
, "<!DOCTYPE html>\n<html><head>"
11823 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=%s\" />"
11824 "</head><body></body></html>", tests
[i
].str
);
11825 run_domtest(buf
, test_document_mode
);
11828 expected_document_mode
= 8;
11829 run_domtest("<!DOCTYPE html>\n"
11832 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" />"
11833 " <meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" />"
11837 "</html>", test_document_mode
);
11840 static void test_document_mode_lock(void)
11842 IHTMLOptionElementFactory
*option
, *option2
;
11843 IHTMLDocument2
*doc
, *doc_node
, *doc_node2
;
11844 IHTMLImageElementFactory
*image
, *image2
;
11845 IOmNavigator
*navigator
, *navigator2
;
11846 IHTMLLocation
*location
, *location2
;
11847 IHTMLPerformance
*perf
, *perf2
;
11848 IOmHistory
*history
, *history2
;
11849 IHTMLScreen
*screen
, *screen2
;
11850 IEventTarget
*event_target
;
11851 IPersistStreamInit
*init
;
11852 IHTMLWindow7
*window7
;
11853 IHTMLWindow5
*window5
;
11854 IHTMLWindow2
*window
;
11855 IDispatchEx
*dispex
;
11865 notif_doc
= doc
= create_document();
11868 doc_complete
= FALSE
;
11870 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IEventTarget
, (void**)&event_target
);
11871 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IEventTarget) returned %08lx.\n", hres
);
11872 ok(event_target
== NULL
, "event_target != NULL\n");
11874 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
11875 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
11877 hres
= IHTMLWindow2_get_document(window
, &doc_node
);
11878 ok(hres
== S_OK
, "get_document failed: %08lx\n", hres
);
11880 hres
= IHTMLWindow2_get_location(window
, &location
);
11881 ok(hres
== S_OK
, "get_location failed: %08lx\n", hres
);
11883 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
11884 ok(hres
== S_OK
, "get_navigator failed: %08lx\n", hres
);
11886 hres
= IHTMLWindow2_get_history(window
, &history
);
11887 ok(hres
== S_OK
, "get_history failed: %08lx\n", hres
);
11889 hres
= IHTMLWindow2_get_screen(window
, &screen
);
11890 ok(hres
== S_OK
, "get_screen failed: %08lx\n", hres
);
11892 hres
= IHTMLWindow2_get_Image(window
, &image
);
11893 ok(hres
== S_OK
, "get_image failed: %08lx\n", hres
);
11895 hres
= IHTMLWindow2_get_Option(window
, &option
);
11896 ok(hres
== S_OK
, "get_option failed: %08lx\n", hres
);
11898 V_VT(&var
) = VT_NULL
;
11899 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow5
, (void**)&window5
);
11900 ok(hres
== S_OK
, "Could not get IHTMLWindow5: %08lx\n", hres
);
11901 hres
= IHTMLWindow5_get_XMLHttpRequest(window5
, &var
);
11902 ok(hres
== S_OK
, "get_XMLHttpRequest failed: %08lx\n", hres
);
11903 ok(V_VT(&var
) == VT_EMPTY
, "V_VT(XMLHttpRequest) = %d\n", V_VT(&var
));
11904 IHTMLWindow5_Release(window5
);
11906 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow7
, (void**)&window7
);
11907 ok(hres
== S_OK
, "Could not get IHTMLWindow7: %08lx\n", hres
);
11908 hres
= IHTMLWindow7_get_performance(window7
, &var
);
11909 ok(hres
== S_OK
, "get_performance failed: %08lx\n", hres
);
11910 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(performance) = %d\n", V_VT(&var
));
11911 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLPerformance
, (void**)&perf
);
11912 ok(hres
== S_OK
, "Could not get IHTMLPerformance: %08lx\n", hres
);
11913 IHTMLWindow7_Release(window7
);
11914 IHTMLWindow2_Release(window
);
11915 VariantClear(&var
);
11917 bstr
= SysAllocString(L
"wineTestProp");
11918 hres
= IHTMLLocation_QueryInterface(location
, &IID_IDispatchEx
, (void**)&dispex
);
11919 ok(hres
== S_OK
, "Could not get IDispatchEx: %08lx\n", hres
);
11920 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameEnsure
, &dispid
);
11921 ok(hres
== S_OK
, "GetDispID(wineTestProp) returned: %08lx\n", hres
);
11922 IDispatchEx_Release(dispex
);
11923 SysFreeString(bstr
);
11925 len
= strlen(doc_blank_ie9
);
11926 mem
= GlobalAlloc(0, len
);
11927 memcpy(mem
, doc_blank_ie9
, len
);
11928 hres
= CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
11929 ok(hres
== S_OK
, "Failed to create stream: %08lx.\n", hres
);
11931 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
11932 ok(hres
== S_OK
, "QueryInterface(IID_IPersistStreamInit) failed: %08lx.\n", hres
);
11934 IPersistStreamInit_Load(init
, stream
);
11935 IPersistStreamInit_Release(init
);
11936 IStream_Release(stream
);
11938 set_client_site(doc
, TRUE
);
11939 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
11941 while(!doc_complete
&& GetMessageW(&msg
, NULL
, 0, 0)) {
11942 TranslateMessage(&msg
);
11943 DispatchMessageW(&msg
);
11946 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IEventTarget
, (void**)&event_target
);
11947 ok(hres
== S_OK
, "QueryInterface(IID_IEventTarget) returned %08lx.\n", hres
);
11948 ok(event_target
!= NULL
, "event_target == NULL\n");
11949 IEventTarget_Release(event_target
);
11951 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
11952 ok(hres
== S_OK
, "get_parentWindow failed: %08lx\n", hres
);
11954 hres
= IHTMLWindow2_get_document(window
, &doc_node2
);
11955 ok(hres
== S_OK
, "get_document failed: %08lx\n", hres
);
11956 ok(doc_node
!= doc_node2
, "doc_node == doc_node2\n");
11957 IHTMLDocument2_Release(doc_node2
);
11958 IHTMLDocument2_Release(doc_node
);
11960 hres
= IHTMLWindow2_get_location(window
, &location2
);
11961 ok(hres
== S_OK
, "get_location failed: %08lx\n", hres
);
11962 ok(location
== location2
, "location != location2\n");
11964 bstr
= SysAllocString(L
"wineTestProp");
11965 hres
= IHTMLLocation_GetIDsOfNames(location2
, &IID_NULL
, &bstr
, 1, 0, &dispid
);
11966 ok(hres
== DISP_E_UNKNOWNNAME
, "GetIDsOfNames(wineTestProp) returned: %08lx\n", hres
);
11967 IHTMLLocation_Release(location2
);
11968 IHTMLLocation_Release(location
);
11969 SysFreeString(bstr
);
11971 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
11972 ok(hres
== S_OK
, "get_navigator failed: %08lx\n", hres
);
11973 ok(navigator
!= navigator2
, "navigator == navigator2\n");
11974 IOmNavigator_Release(navigator2
);
11975 IOmNavigator_Release(navigator
);
11977 hres
= IHTMLWindow2_get_history(window
, &history2
);
11978 ok(hres
== S_OK
, "get_history failed: %08lx\n", hres
);
11979 ok(history
!= history2
, "history == history2\n");
11980 IOmHistory_Release(history2
);
11981 IOmHistory_Release(history
);
11983 hres
= IHTMLWindow2_get_screen(window
, &screen2
);
11984 ok(hres
== S_OK
, "get_screen failed: %08lx\n", hres
);
11985 ok(screen
!= screen2
, "screen == screen2\n");
11986 IHTMLScreen_Release(screen2
);
11987 IHTMLScreen_Release(screen
);
11989 hres
= IHTMLWindow2_get_Image(window
, &image2
);
11990 ok(hres
== S_OK
, "get_image failed: %08lx\n", hres
);
11991 ok(image
!= image2
, "image == image2\n");
11992 IHTMLImageElementFactory_Release(image2
);
11993 IHTMLImageElementFactory_Release(image
);
11995 hres
= IHTMLWindow2_get_Option(window
, &option2
);
11996 ok(hres
== S_OK
, "get_option failed: %08lx\n", hres
);
11997 ok(option
!= option2
, "option == option2\n");
11998 IHTMLOptionElementFactory_Release(option2
);
11999 IHTMLOptionElementFactory_Release(option
);
12001 hres
= IHTMLWindow2_QueryInterface(window
, &IID_IHTMLWindow7
, (void**)&window7
);
12002 ok(hres
== S_OK
, "Could not get IHTMLWindow7: %08lx\n", hres
);
12003 hres
= IHTMLWindow7_get_performance(window7
, &var
);
12004 ok(hres
== S_OK
, "get_performance failed: %08lx\n", hres
);
12005 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(performance) = %d\n", V_VT(&var
));
12006 hres
= IDispatch_QueryInterface(V_DISPATCH(&var
), &IID_IHTMLPerformance
, (void**)&perf2
);
12007 ok(hres
== S_OK
, "Could not get IHTMLPerformance: %08lx\n", hres
);
12008 ok(perf
!= perf2
, "perf == perf2\n");
12009 IHTMLPerformance_Release(perf2
);
12010 IHTMLPerformance_Release(perf
);
12011 IHTMLWindow7_Release(window7
);
12012 IHTMLWindow2_Release(window
);
12013 VariantClear(&var
);
12015 set_client_site(doc
, FALSE
);
12016 IHTMLDocument2_Release(doc
);
12019 static DWORD WINAPI
create_document_proc(void *param
)
12021 IHTMLDocument2
*doc
= NULL
;
12024 CoInitialize(NULL
);
12026 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
12027 &IID_IHTMLDocument2
, (void**)&doc
);
12029 ok(hres
== S_OK
, "Creation of an HTMLDocument in a separate thread failed: %08lx\n", hres
);
12031 if (doc
) IHTMLDocument2_Release(doc
);
12035 static void test_threads(void)
12037 HANDLE thread
= CreateThread(NULL
, 0, create_document_proc
, 0, 0, NULL
);
12038 DWORD ret
= WaitForSingleObject(thread
, 2000);
12039 ok(!ret
, "Document creation thread failed to complete\n");
12042 static void test_custom_user_agent(IHTMLDocument2
*doc
)
12044 static const WCHAR ua
[] = L
"1234567890xxxABC";
12045 static char ua_ascii
[] = "1234567890xxxABC";
12046 IOmNavigator
*navigator
;
12047 IHTMLWindow2
*window
;
12051 /* Set it only first time, to test it doesn't get reset on compat mode change */
12052 if(compat_mode
== COMPAT_NONE
) {
12053 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, ua_ascii
, sizeof(ua_ascii
), 0);
12054 ok(hres
== S_OK
, "UrlMkSetSessionOption failed: %08lx\n", hres
);
12057 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
12058 ok(hres
== S_OK
, "parentWidnow failed: %08lx\n", hres
);
12060 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
12061 ok(hres
== S_OK
, "get_navigator failed: %08lx\n", hres
);
12062 ok(navigator
!= NULL
, "navigator == NULL\n");
12063 IHTMLWindow2_Release(window
);
12065 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
12066 ok(hres
== S_OK
, "get_appVersion failed: %08lx\n", hres
);
12067 ok(!lstrcmpW(bstr
, ua
+8), "appVersion returned %s, expected %s\n", wine_dbgstr_w(bstr
), wine_dbgstr_w(ua
+8));
12068 SysFreeString(bstr
);
12070 hres
= IOmNavigator_get_userAgent(navigator
, &bstr
);
12071 ok(hres
== S_OK
, "get_userAgent failed: %08lx\n", hres
);
12072 ok(!lstrcmpW(bstr
, ua
), "userAgent returned %s, expected %s\n", wine_dbgstr_w(bstr
), wine_dbgstr_w(ua
));
12073 SysFreeString(bstr
);
12075 IOmNavigator_Release(navigator
);
12078 static void check_ie(void)
12080 IHTMLDocument2
*doc
;
12081 IHTMLDocument7
*doc7
;
12084 doc
= create_document();
12088 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument7
, (void**)&doc7
);
12089 if(SUCCEEDED(hres
)) {
12091 IHTMLDocument7_Release(doc7
);
12094 trace("is_ie9plus %x\n", is_ie9plus
);
12096 IHTMLDocument2_Release(doc
);
12101 HMODULE hkernel32
= GetModuleHandleA("kernel32.dll");
12102 pLCIDToLocaleName
= (void*)GetProcAddress(hkernel32
, "LCIDToLocaleName");
12103 pGetUserDefaultUILanguage
= (void*)GetProcAddress(hkernel32
, "GetUserDefaultUILanguage");
12105 CoInitialize(NULL
);
12106 container_hwnd
= CreateWindowA("static", NULL
, WS_POPUP
|WS_VISIBLE
,
12107 CW_USEDEFAULT
, CW_USEDEFAULT
, 500, 500, NULL
, NULL
, NULL
, NULL
);
12111 run_domtest(doc_str1
, test_doc_elem
);
12112 run_domtest(doc_str1
, test_get_set_attr
);
12113 run_domtest(doc_blank
, test_range
);
12114 if (winetest_interactive
|| ! is_ie_hardened()) {
12115 run_domtest(elem_test_str
, test_elems
);
12116 run_domtest(elem_test2_str
, test_elems2
);
12117 run_domtest(doc_blank
, test_dom_elements
);
12118 run_domtest(doc_blank
, test_about_blank_storage
);
12120 compat_mode
= COMPAT_IE9
;
12121 run_domtest(doc_blank_ie9
, test_dom_elements
);
12122 run_domtest(doc_blank_ie9
, test_about_blank_storage
);
12123 compat_mode
= COMPAT_NONE
;
12125 run_domtest(noscript_str
, test_noscript
);
12127 skip("IE running in Enhanced Security Configuration\n");
12129 run_domtest(doc_blank
, test_create_elems
);
12130 run_domtest(doc_blank
, test_defaults
);
12131 run_domtest(doc_blank
, test_null_write
);
12132 run_domtest(emptydiv_str
, test_create_stylesheet
);
12133 run_domtest(indent_test_str
, test_indent
);
12134 run_domtest(cond_comment_str
, test_cond_comment
);
12135 run_domtest(frameset_str
, test_frameset
);
12136 run_domtest(emptydiv_str
, test_docfrag
);
12137 run_domtest(doc_blank
, test_replacechild_elems
);
12138 run_domtest(doctype_str
, test_doctype
);
12140 test_quirks_mode();
12141 test_document_mode_lock();
12144 /* Run this last since it messes with the process-wide user agent */
12145 if (winetest_interactive
|| ! is_ie_hardened()) {
12146 run_domtest(doc_blank
, test_custom_user_agent
);
12148 compat_mode
= COMPAT_IE9
;
12149 run_domtest(doc_blank_ie9
, test_custom_user_agent
);
12150 compat_mode
= COMPAT_NONE
;
12154 DestroyWindow(container_hwnd
);