2 * Copyright 2007-2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
35 static const char doc_blank
[] = "<html></html>";
36 static const char doc_str1
[] = "<html><body>test</body></html>";
37 static const char range_test_str
[] =
38 "<html><body>test \na<font size=\"2\">bc\t123<br /> it's\r\n \t</font>text<br /></body></html>";
39 static const char range_test2_str
[] =
40 "<html><body>abc<hr />123<br /><hr />def</body></html>";
41 static const char elem_test_str
[] =
42 "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
43 "<body onload=\"Testing()\">text test<!-- a comment -->"
44 "<a href=\"http://test\" name=\"x\">link</a>"
45 "<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
46 "<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
47 "<textarea id=\"X\">text text</textarea>"
48 "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
49 "<script id=\"sc\" type=\"text/javascript\"><!--\nfunction Testing() {}\n// -->\n</script>"
52 "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
54 static const char indent_test_str
[] =
55 "<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
56 static const char cond_comment_str
[] =
57 "<html><head><title>test</title></head><body>"
58 "<!--[if gte IE 4]> <br> <![endif]-->"
61 static const WCHAR noneW
[] = {'N','o','n','e',0};
63 static WCHAR characterW
[] = {'c','h','a','r','a','c','t','e','r',0};
64 static WCHAR texteditW
[] = {'t','e','x','t','e','d','i','t',0};
65 static WCHAR wordW
[] = {'w','o','r','d',0};
67 static const WCHAR text_javascriptW
[] = {'t','e','x','t','/','j','a','v','a','s','c','r','i','p','t',0};
69 static const WCHAR idW
[] = {'i','d',0};
98 static const IID
* const none_iids
[] = {
103 static const IID
* const elem_iids
[] = {
110 &IID_IConnectionPointContainer
,
114 static const IID
* const body_iids
[] = {
120 &IID_IHTMLTextContainer
,
121 &IID_IHTMLBodyElement
,
123 &IID_IConnectionPointContainer
,
127 static const IID
* const anchor_iids
[] = {
133 &IID_IHTMLAnchorElement
,
135 &IID_IConnectionPointContainer
,
139 static const IID
* const input_iids
[] = {
145 &IID_IHTMLInputElement
,
146 &IID_IHTMLInputTextElement
,
148 &IID_IConnectionPointContainer
,
152 static const IID
* const select_iids
[] = {
158 &IID_IHTMLSelectElement
,
160 &IID_IConnectionPointContainer
,
164 static const IID
* const textarea_iids
[] = {
170 &IID_IHTMLTextAreaElement
,
172 &IID_IConnectionPointContainer
,
176 static const IID
* const option_iids
[] = {
182 &IID_IHTMLOptionElement
,
184 &IID_IConnectionPointContainer
,
188 static const IID
* const table_iids
[] = {
196 &IID_IConnectionPointContainer
,
200 static const IID
* const script_iids
[] = {
206 &IID_IHTMLScriptElement
,
208 &IID_IConnectionPointContainer
,
212 static const IID
* const text_iids
[] = {
215 &IID_IHTMLDOMTextNode
,
219 static const IID
* const location_iids
[] = {
225 static const IID
* const window_iids
[] = {
233 static const IID
* const comment_iids
[] = {
239 &IID_IHTMLCommentElement
,
241 &IID_IConnectionPointContainer
,
245 static const IID
* const img_iids
[] = {
252 &IID_IHTMLImgElement
,
253 &IID_IConnectionPointContainer
,
257 static const IID
* const tr_iids
[] = {
265 &IID_IConnectionPointContainer
,
269 static const IID
* const td_iids
[] = {
276 &IID_IConnectionPointContainer
,
280 static const IID
* const iframe_iids
[] = {
286 &IID_IHTMLFrameBase2
,
288 &IID_IConnectionPointContainer
,
292 static const IID
* const generic_iids
[] = {
298 &IID_IHTMLGenericElement
,
300 &IID_IConnectionPointContainer
,
304 static const IID
* const style_iids
[] = {
313 static const IID
* const cstyle_iids
[] = {
317 &IID_IHTMLCurrentStyle
,
327 static const elem_type_info_t elem_type_infos
[] = {
328 {"", none_iids
, NULL
},
329 {"HTML", elem_iids
, NULL
},
330 {"HEAD", elem_iids
, NULL
},
331 {"TITLE", elem_iids
, NULL
},
332 {"BODY", body_iids
, &DIID_DispHTMLBody
},
333 {"A", anchor_iids
, NULL
},
334 {"INPUT", input_iids
, &DIID_DispHTMLInputElement
},
335 {"SELECT", select_iids
, &DIID_DispHTMLSelectElement
},
336 {"TEXTAREA", textarea_iids
, NULL
},
337 {"OPTION", option_iids
, &DIID_DispHTMLOptionElement
},
338 {"STYLE", elem_iids
, NULL
},
339 {"BLOCKQUOTE",elem_iids
, NULL
},
340 {"P", elem_iids
, NULL
},
341 {"BR", elem_iids
, NULL
},
342 {"TABLE", table_iids
, &DIID_DispHTMLTable
},
343 {"TBODY", elem_iids
, NULL
},
344 {"SCRIPT", script_iids
, NULL
},
345 {"TEST", elem_iids
, &DIID_DispHTMLUnknownElement
},
346 {"TEST", generic_iids
, &DIID_DispHTMLGenericElement
},
347 {"!", comment_iids
, &DIID_DispHTMLCommentElement
},
348 {"IMG", img_iids
, &DIID_DispHTMLImg
},
349 {"TR", tr_iids
, &DIID_DispHTMLTableRow
},
350 {"TD", td_iids
, NULL
},
351 {"IFRAME", iframe_iids
, &DIID_DispHTMLIFrame
}
354 static const char *dbgstr_w(LPCWSTR str
)
356 static char buf
[512];
359 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
363 static const char *dbgstr_guid(REFIID riid
)
367 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
368 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
369 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
370 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
375 static int strcmp_wa(LPCWSTR strw
, const char *stra
)
378 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, sizeof(buf
)/sizeof(WCHAR
));
379 return lstrcmpW(strw
, buf
);
382 static BSTR
a2bstr(const char *str
)
387 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
388 ret
= SysAllocStringLen(NULL
, len
);
389 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
394 static BOOL
iface_cmp(IUnknown
*iface1
, IUnknown
*iface2
)
396 IUnknown
*unk1
, *unk2
;
401 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk1
);
402 IUnknown_Release(unk1
);
403 IUnknown_QueryInterface(iface1
, &IID_IUnknown
, (void**)&unk2
);
404 IUnknown_Release(unk2
);
409 static IHTMLDocument2
*create_document(void)
412 IHTMLDocument5
*doc5
;
415 hres
= CoCreateInstance(&CLSID_HTMLDocument
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
416 &IID_IHTMLDocument2
, (void**)&doc
);
417 ok(hres
== S_OK
, "CoCreateInstance failed: %08x\n", hres
);
419 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
421 win_skip("Could not get IHTMLDocument5, probably too old IE\n");
422 IHTMLDocument2_Release(doc
);
426 IHTMLDocument5_Release(doc5
);
430 #define test_ifaces(i,ids) _test_ifaces(__LINE__,i,ids)
431 static void _test_ifaces(unsigned line
, IUnknown
*iface
, REFIID
*iids
)
433 const IID
* const *piid
;
437 for(piid
= iids
; *piid
; piid
++) {
438 hres
= IDispatch_QueryInterface(iface
, *piid
, (void**)&unk
);
439 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get %s interface: %08x\n", dbgstr_guid(*piid
), hres
);
441 IUnknown_Release(unk
);
445 #define test_disp(u,id) _test_disp(__LINE__,u,id)
446 static void _test_disp(unsigned line
, IUnknown
*unk
, const IID
*diid
)
453 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
454 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
459 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
460 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
461 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
463 hres
= IDispatchEx_GetTypeInfo(dispex
, 0, 0, &typeinfo
);
464 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfo failed: %08x\n", hres
);
466 if(SUCCEEDED(hres
)) {
469 hres
= ITypeInfo_GetTypeAttr(typeinfo
, &type_attr
);
470 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeAttr failed: %08x\n", hres
);
471 ok_(__FILE__
,line
) (IsEqualGUID(&type_attr
->guid
, diid
), "unexpected guid %s\n", dbgstr_guid(&type_attr
->guid
));
473 ITypeInfo_ReleaseTypeAttr(typeinfo
, type_attr
);
474 ITypeInfo_Release(typeinfo
);
477 IDispatchEx_Release(dispex
);
480 #define get_elem_iface(u) _get_elem_iface(__LINE__,u)
481 static IHTMLElement
*_get_elem_iface(unsigned line
, IUnknown
*unk
)
486 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement
, (void**)&elem
);
487 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement: %08x\n", hres
);
491 #define get_elem2_iface(u) _get_elem2_iface(__LINE__,u)
492 static IHTMLElement2
*_get_elem2_iface(unsigned line
, IUnknown
*unk
)
497 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement2
, (void**)&elem
);
498 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement2: %08x\n", hres
);
502 #define get_elem3_iface(u) _get_elem3_iface(__LINE__,u)
503 static IHTMLElement3
*_get_elem3_iface(unsigned line
, IUnknown
*unk
)
508 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElement3
, (void**)&elem
);
509 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLElement3: %08x\n", hres
);
513 #define get_node_iface(u) _get_node_iface(__LINE__,u)
514 static IHTMLDOMNode
*_get_node_iface(unsigned line
, IUnknown
*unk
)
519 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLDOMNode
, (void**)&node
);
520 ok_(__FILE__
,line
) (hres
== S_OK
, "Coule not get IHTMLDOMNode: %08x\n", hres
);
524 #define get_img_iface(u) _get_img_iface(__LINE__,u)
525 static IHTMLImgElement
*_get_img_iface(unsigned line
, IUnknown
*unk
)
527 IHTMLImgElement
*img
;
530 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLImgElement
, (void**)&img
);
531 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLImgElement: %08x\n", hres
);
535 #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
536 static void _test_node_name(unsigned line
, IUnknown
*unk
, const char *exname
)
538 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
542 hres
= IHTMLDOMNode_get_nodeName(node
, &name
);
543 IHTMLDOMNode_Release(node
);
544 ok_(__FILE__
, line
) (hres
== S_OK
, "get_nodeName failed: %08x\n", hres
);
545 ok_(__FILE__
, line
) (!strcmp_wa(name
, exname
), "got name: %s, expected %s\n", dbgstr_w(name
), exname
);
550 #define test_elem_tag(u,n) _test_elem_tag(__LINE__,u,n)
551 static void _test_elem_tag(unsigned line
, IUnknown
*unk
, const char *extag
)
553 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
557 hres
= IHTMLElement_get_tagName(elem
, &tag
);
558 IHTMLElement_Release(elem
);
559 ok_(__FILE__
, line
) (hres
== S_OK
, "get_tagName failed: %08x\n", hres
);
560 ok_(__FILE__
, line
) (!strcmp_wa(tag
, extag
), "got tag: %s, expected %s\n", dbgstr_w(tag
), extag
);
565 #define test_elem_type(ifc,t) _test_elem_type(__LINE__,ifc,t)
566 static void _test_elem_type(unsigned line
, IUnknown
*unk
, elem_type_t type
)
568 _test_elem_tag(line
, unk
, elem_type_infos
[type
].tag
);
569 _test_ifaces(line
, unk
, elem_type_infos
[type
].iids
);
571 if(elem_type_infos
[type
].dispiid
)
572 _test_disp(line
, unk
, elem_type_infos
[type
].dispiid
);
575 #define get_node_type(n) _get_node_type(__LINE__,n)
576 static long _get_node_type(unsigned line
, IUnknown
*unk
)
578 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
582 hres
= IHTMLDOMNode_get_nodeType(node
, &type
);
583 ok(hres
== S_OK
, "get_nodeType failed: %08x\n", hres
);
585 IHTMLDOMNode_Release(node
);
590 #define get_child_nodes(u) _get_child_nodes(__LINE__,u)
591 static IHTMLDOMChildrenCollection
*_get_child_nodes(unsigned line
, IUnknown
*unk
)
593 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
594 IHTMLDOMChildrenCollection
*col
= NULL
;
598 hres
= IHTMLDOMNode_get_childNodes(node
, &disp
);
599 IHTMLDOMNode_Release(node
);
600 ok_(__FILE__
,line
) (hres
== S_OK
, "get_childNodes failed: %08x\n", hres
);
604 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLDOMChildrenCollection
, (void**)&col
);
605 IDispatch_Release(disp
);
606 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDOMChildrenCollection: %08x\n", hres
);
611 #define get_child_item(c,i) _get_child_item(__LINE__,c,i)
612 static IHTMLDOMNode
*_get_child_item(unsigned line
, IHTMLDOMChildrenCollection
*col
, long idx
)
614 IHTMLDOMNode
*node
= NULL
;
618 hres
= IHTMLDOMChildrenCollection_item(col
, idx
, &disp
);
619 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
621 node
= _get_node_iface(line
, (IUnknown
*)disp
);
622 IDispatch_Release(disp
);
627 #define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
628 static void _test_elem_attr(unsigned line
, IHTMLElement
*elem
, LPCWSTR name
, LPCWSTR exval
)
636 tmp
= SysAllocString(name
);
637 hres
= IHTMLElement_getAttribute(elem
, tmp
, 0, &value
);
639 ok_(__FILE__
,line
) (hres
== S_OK
, "getAttribute failed: %08x\n", hres
);
642 ok_(__FILE__
,line
) (V_VT(&value
) == VT_BSTR
, "vt=%d\n", V_VT(&value
));
643 ok_(__FILE__
,line
) (!lstrcmpW(exval
, V_BSTR(&value
)), "unexpected value %s\n", dbgstr_w(V_BSTR(&value
)));
645 ok_(__FILE__
,line
) (V_VT(&value
) == VT_NULL
, "vt=%d\n", V_VT(&value
));
648 VariantClear(&value
);
651 #define test_elem_offset(u) _test_elem_offset(__LINE__,u)
652 static void _test_elem_offset(unsigned line
, IUnknown
*unk
)
654 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
658 hres
= IHTMLElement_get_offsetTop(elem
, &l
);
659 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetTop failed: %08x\n", hres
);
661 hres
= IHTMLElement_get_offsetHeight(elem
, &l
);
662 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetHeight failed: %08x\n", hres
);
664 hres
= IHTMLElement_get_offsetWidth(elem
, &l
);
665 ok_(__FILE__
,line
) (hres
== S_OK
, "get_offsetWidth failed: %08x\n", hres
);
667 IHTMLElement_Release(elem
);
670 static void test_doc_elem(IHTMLDocument2
*doc
)
673 IHTMLDocument3
*doc3
;
676 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
677 ok(hres
== S_OK
, "QueryInterface(IID_IHTMLDocument3) failed: %08x\n", hres
);
679 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
680 IHTMLDocument3_Release(doc3
);
681 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
683 test_node_name((IUnknown
*)elem
, "HTML");
684 test_elem_tag((IUnknown
*)elem
, "HTML");
686 IHTMLElement_Release(elem
);
689 #define get_doc_elem(d) _get_doc_elem(__LINE__,d)
690 static IHTMLElement
*_get_doc_elem(unsigned line
, IHTMLDocument2
*doc
)
693 IHTMLDocument3
*doc3
;
696 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
697 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3 interface: %08x\n", hres
);
698 hres
= IHTMLDocument3_get_documentElement(doc3
, &elem
);
699 ok_(__FILE__
,line
) (hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
700 IHTMLDocument3_Release(doc3
);
705 #define test_option_text(o,t) _test_option_text(__LINE__,o,t)
706 static void _test_option_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
711 hres
= IHTMLOptionElement_get_text(option
, &bstr
);
712 ok_(__FILE__
,line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
713 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, text
), "text=%s\n", dbgstr_w(bstr
));
717 #define test_option_put_text(o,t) _test_option_put_text(__LINE__,o,t)
718 static void _test_option_put_text(unsigned line
, IHTMLOptionElement
*option
, const char *text
)
724 hres
= IHTMLOptionElement_put_text(option
, bstr
);
726 ok(hres
== S_OK
, "put_text failed: %08x\n", hres
);
728 _test_option_text(line
, option
, text
);
731 #define test_option_value(o,t) _test_option_value(__LINE__,o,t)
732 static void _test_option_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
737 hres
= IHTMLOptionElement_get_value(option
, &bstr
);
738 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
739 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, value
), "value=%s\n", dbgstr_w(bstr
));
743 #define test_option_put_value(o,t) _test_option_put_value(__LINE__,o,t)
744 static void _test_option_put_value(unsigned line
, IHTMLOptionElement
*option
, const char *value
)
749 bstr
= a2bstr(value
);
750 hres
= IHTMLOptionElement_put_value(option
, bstr
);
752 ok(hres
== S_OK
, "put_value failed: %08x\n", hres
);
754 _test_option_value(line
, option
, value
);
757 #define create_option_elem(d,t,v) _create_option_elem(__LINE__,d,t,v)
758 static IHTMLOptionElement
*_create_option_elem(unsigned line
, IHTMLDocument2
*doc
,
759 const char *txt
, const char *val
)
761 IHTMLOptionElementFactory
*factory
;
762 IHTMLOptionElement
*option
;
763 IHTMLWindow2
*window
;
764 VARIANT text
, value
, empty
;
767 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
768 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
770 hres
= IHTMLWindow2_get_Option(window
, &factory
);
771 IHTMLWindow2_Release(window
);
772 ok_(__FILE__
,line
) (hres
== S_OK
, "get_Option failed: %08x\n", hres
);
774 V_VT(&text
) = VT_BSTR
;
775 V_BSTR(&text
) = a2bstr(txt
);
776 V_VT(&value
) = VT_BSTR
;
777 V_BSTR(&value
) = a2bstr(val
);
778 V_VT(&empty
) = VT_EMPTY
;
780 hres
= IHTMLOptionElementFactory_create(factory
, text
, value
, empty
, empty
, &option
);
781 ok_(__FILE__
,line
) (hres
== S_OK
, "create failed: %08x\n", hres
);
783 IHTMLOptionElementFactory_Release(factory
);
785 VariantClear(&value
);
787 _test_option_text(line
, option
, txt
);
788 _test_option_value(line
, option
, val
);
793 #define test_select_length(s,l) _test_select_length(__LINE__,s,l)
794 static void _test_select_length(unsigned line
, IHTMLSelectElement
*select
, long length
)
796 long len
= 0xdeadbeef;
799 hres
= IHTMLSelectElement_get_length(select
, &len
);
800 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
801 ok_(__FILE__
,line
) (len
== length
, "len=%ld, expected %ld\n", len
, length
);
804 #define test_select_selidx(s,i) _test_select_selidx(__LINE__,s,i)
805 static void _test_select_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
807 long idx
= 0xdeadbeef;
810 hres
= IHTMLSelectElement_get_selectedIndex(select
, &idx
);
811 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
812 ok_(__FILE__
,line
) (idx
== index
, "idx=%ld, expected %ld\n", idx
, index
);
815 #define test_select_put_selidx(s,i) _test_select_put_selidx(__LINE__,s,i)
816 static void _test_select_put_selidx(unsigned line
, IHTMLSelectElement
*select
, long index
)
820 hres
= IHTMLSelectElement_put_selectedIndex(select
, index
);
821 ok_(__FILE__
,line
) (hres
== S_OK
, "get_selectedIndex failed: %08x\n", hres
);
822 _test_select_selidx(line
, select
, index
);
825 #define test_select_value(s,v) _test_select_value(__LINE__,s,v)
826 static void _test_select_value(unsigned line
, IHTMLSelectElement
*select
, const char *exval
)
831 hres
= IHTMLSelectElement_get_value(select
, &val
);
832 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
834 ok_(__FILE__
,line
) (!strcmp_wa(val
, exval
), "unexpected value %s\n", dbgstr_w(val
));
836 ok_(__FILE__
,line
) (val
== NULL
, "val=%s, expected NULL\n", dbgstr_w(val
));
839 #define test_select_set_value(s,v) _test_select_set_value(__LINE__,s,v)
840 static void _test_select_set_value(unsigned line
, IHTMLSelectElement
*select
, const char *val
)
846 hres
= IHTMLSelectElement_put_value(select
, bstr
);
848 ok_(__FILE__
,line
) (hres
== S_OK
, "put_value failed: %08x\n", hres
);
851 #define test_select_type(s,t) _test_select_type(__LINE__,s,t)
852 static void _test_select_type(unsigned line
, IHTMLSelectElement
*select
, const char *extype
)
857 hres
= IHTMLSelectElement_get_type(select
, &type
);
858 ok_(__FILE__
,line
) (hres
== S_OK
, "get_type failed: %08x\n", hres
);
859 ok_(__FILE__
,line
) (!strcmp_wa(type
, extype
), "type=%s, expected %s\n", dbgstr_w(type
), extype
);
862 #define test_range_text(r,t) _test_range_text(__LINE__,r,t)
863 static void _test_range_text(unsigned line
, IHTMLTxtRange
*range
, const char *extext
)
868 hres
= IHTMLTxtRange_get_text(range
, &text
);
869 ok_(__FILE__
, line
) (hres
== S_OK
, "get_text failed: %08x\n", hres
);
872 ok_(__FILE__
, line
) (text
!= NULL
, "text == NULL\n");
873 ok_(__FILE__
, line
) (!strcmp_wa(text
, extext
), "text=\"%s\", expected \"%s\"\n", dbgstr_w(text
), extext
);
875 ok_(__FILE__
, line
) (text
== NULL
, "text=\"%s\", expected NULL\n", dbgstr_w(text
));
882 #define test_range_collapse(r,b) _test_range_collapse(__LINE__,r,b)
883 static void _test_range_collapse(unsigned line
, IHTMLTxtRange
*range
, BOOL b
)
887 hres
= IHTMLTxtRange_collapse(range
, b
);
888 ok_(__FILE__
, line
) (hres
== S_OK
, "collapse failed: %08x\n", hres
);
889 _test_range_text(line
, range
, NULL
);
892 #define test_range_expand(r,u,b,t) _test_range_expand(__LINE__,r,u,b,t)
893 static void _test_range_expand(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
,
894 VARIANT_BOOL exb
, const char *extext
)
896 VARIANT_BOOL b
= 0xe0e0;
899 hres
= IHTMLTxtRange_expand(range
, unit
, &b
);
900 ok_(__FILE__
,line
) (hres
== S_OK
, "expand failed: %08x\n", hres
);
901 ok_(__FILE__
,line
) (b
== exb
, "b=%x, expected %x\n", b
, exb
);
902 _test_range_text(line
, range
, extext
);
905 #define test_range_move(r,u,c,e) _test_range_move(__LINE__,r,u,c,e)
906 static void _test_range_move(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
911 hres
= IHTMLTxtRange_move(range
, unit
, cnt
, &c
);
912 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
913 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
914 _test_range_text(line
, range
, NULL
);
917 #define test_range_movestart(r,u,c,e) _test_range_movestart(__LINE__,r,u,c,e)
918 static void _test_range_movestart(unsigned line
, IHTMLTxtRange
*range
,
919 LPWSTR unit
, long cnt
, long excnt
)
924 hres
= IHTMLTxtRange_moveStart(range
, unit
, cnt
, &c
);
925 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
926 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
929 #define test_range_moveend(r,u,c,e) _test_range_moveend(__LINE__,r,u,c,e)
930 static void _test_range_moveend(unsigned line
, IHTMLTxtRange
*range
, LPWSTR unit
, long cnt
, long excnt
)
935 hres
= IHTMLTxtRange_moveEnd(range
, unit
, cnt
, &c
);
936 ok_(__FILE__
,line
) (hres
== S_OK
, "move failed: %08x\n", hres
);
937 ok_(__FILE__
,line
) (c
== excnt
, "count=%ld, expected %ld\n", c
, excnt
);
940 #define test_range_put_text(r,t) _test_range_put_text(__LINE__,r,t)
941 static void _test_range_put_text(unsigned line
, IHTMLTxtRange
*range
, const char *text
)
944 BSTR bstr
= a2bstr(text
);
946 hres
= IHTMLTxtRange_put_text(range
, bstr
);
947 ok_(__FILE__
,line
) (hres
== S_OK
, "put_text failed: %08x\n", hres
);
949 _test_range_text(line
, range
, NULL
);
952 #define test_range_inrange(r1,r2,b) _test_range_inrange(__LINE__,r1,r2,b)
953 static void _test_range_inrange(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
959 hres
= IHTMLTxtRange_inRange(range1
, range2
, &b
);
960 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
961 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
964 #define test_range_isequal(r1,r2,b) _test_range_isequal(__LINE__,r1,r2,b)
965 static void _test_range_isequal(unsigned line
, IHTMLTxtRange
*range1
, IHTMLTxtRange
*range2
, VARIANT_BOOL exb
)
971 hres
= IHTMLTxtRange_isEqual(range1
, range2
, &b
);
972 ok_(__FILE__
,line
) (hres
== S_OK
, "(1->2) isEqual failed: %08x\n", hres
);
973 ok_(__FILE__
,line
) (b
== exb
, "(1->2) b=%x, expected %x\n", b
, exb
);
976 hres
= IHTMLTxtRange_isEqual(range2
, range1
, &b
);
977 ok_(__FILE__
,line
) (hres
== S_OK
, "(2->1) isEqual failed: %08x\n", hres
);
978 ok_(__FILE__
,line
) (b
== exb
, "(2->1) b=%x, expected %x\n", b
, exb
);
981 test_range_inrange(range1
, range2
, VARIANT_TRUE
);
982 test_range_inrange(range2
, range1
, VARIANT_TRUE
);
986 #define test_range_parent(r,t) _test_range_parent(__LINE__,r,t)
987 static void _test_range_parent(unsigned line
, IHTMLTxtRange
*range
, elem_type_t type
)
992 hres
= IHTMLTxtRange_parentElement(range
, &elem
);
993 ok_(__FILE__
,line
) (hres
== S_OK
, "parentElement failed: %08x\n", hres
);
995 _test_elem_type(line
, (IUnknown
*)elem
, type
);
997 IHTMLElement_Release(elem
);
1000 #define test_elem_collection(c,t,l) _test_elem_collection(__LINE__,c,t,l)
1001 static void _test_elem_collection(unsigned line
, IUnknown
*unk
,
1002 const elem_type_t
*elem_types
, long exlen
)
1004 IHTMLElementCollection
*col
;
1007 VARIANT name
, index
;
1011 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLElementCollection
, (void**)&col
);
1012 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
1014 test_disp((IUnknown
*)col
, &DIID_DispHTMLElementCollection
);
1016 hres
= IHTMLElementCollection_get_length(col
, &len
);
1017 ok_(__FILE__
,line
) (hres
== S_OK
, "get_length failed: %08x\n", hres
);
1018 ok_(__FILE__
,line
) (len
== exlen
, "len=%ld, expected %ld\n", len
, exlen
);
1023 V_VT(&index
) = VT_EMPTY
;
1024 V_VT(&name
) = VT_I4
;
1026 for(i
=0; i
<len
; i
++) {
1028 disp
= (void*)0xdeadbeef;
1029 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1030 ok_(__FILE__
,line
) (hres
== S_OK
, "item(%d) failed: %08x\n", i
, hres
);
1031 ok_(__FILE__
,line
) (disp
!= NULL
, "item returned NULL\n");
1032 if(FAILED(hres
) || !disp
)
1035 _test_elem_type(line
, (IUnknown
*)disp
, elem_types
[i
]);
1036 IDispatch_Release(disp
);
1040 disp
= (void*)0xdeadbeef;
1041 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1042 ok_(__FILE__
,line
) (hres
== S_OK
, "item failed: %08x\n", hres
);
1043 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1046 disp
= (void*)0xdeadbeef;
1047 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1048 ok_(__FILE__
,line
) (hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1049 ok_(__FILE__
,line
) (disp
== NULL
, "disp != NULL\n");
1051 IHTMLElementCollection_Release(col
);
1054 #define test_elem_getelembytag(u,t,l) _test_elem_getelembytag(__LINE__,u,t,l)
1055 static void _test_elem_getelembytag(unsigned line
, IUnknown
*unk
, elem_type_t type
, long exlen
)
1057 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1058 IHTMLElementCollection
*col
= NULL
;
1059 elem_type_t
*types
= NULL
;
1064 tmp
= a2bstr(elem_type_infos
[type
].tag
);
1065 hres
= IHTMLElement2_getElementsByTagName(elem
, tmp
, &col
);
1067 IHTMLElement2_Release(elem
);
1068 ok_(__FILE__
,line
) (hres
== S_OK
, "getElementByTagName failed: %08x\n", hres
);
1069 ok_(__FILE__
,line
) (col
!= NULL
, "col == NULL\n");
1072 types
= HeapAlloc(GetProcessHeap(), 0, exlen
*sizeof(elem_type_t
));
1073 for(i
=0; i
<exlen
; i
++)
1077 _test_elem_collection(line
, (IUnknown
*)col
, types
, exlen
);
1079 HeapFree(GetProcessHeap(), 0, types
);
1082 #define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
1083 static void _test_elem_innertext(unsigned line
, IHTMLElement
*elem
, const char *extext
)
1088 hres
= IHTMLElement_get_innerText(elem
, &text
);
1089 ok_(__FILE__
,line
) (hres
== S_OK
, "get_innerText failed: %08x\n", hres
);
1090 ok_(__FILE__
,line
) (!strcmp_wa(text
, extext
), "get_innerText returned %s expected %s\n",
1091 dbgstr_w(text
), extext
);
1092 SysFreeString(text
);
1095 #define test_elem_set_innertext(e,t) _test_elem_set_innertext(__LINE__,e,t)
1096 static void _test_elem_set_innertext(unsigned line
, IHTMLElement
*elem
, const char *text
)
1098 IHTMLDOMChildrenCollection
*col
;
1103 hres
= IHTMLElement_put_innerText(elem
, str
);
1104 ok_(__FILE__
,line
) (hres
== S_OK
, "put_innerText failed: %08x\n", hres
);
1107 _test_elem_innertext(line
, elem
, text
);
1110 col
= _get_child_nodes(line
, (IUnknown
*)elem
);
1111 ok(col
!= NULL
, "col == NULL\n");
1113 long length
= 0, type
;
1116 hres
= IHTMLDOMChildrenCollection_get_length(col
, &length
);
1117 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
1118 ok(length
== 1, "length = %ld\n", length
);
1120 node
= _get_child_item(line
, col
, 0);
1121 ok(node
!= NULL
, "node == NULL\n");
1123 type
= _get_node_type(line
, (IUnknown
*)node
);
1124 ok(type
== 3, "type=%ld\n", type
);
1125 IHTMLDOMNode_Release(node
);
1128 IHTMLDOMChildrenCollection_Release(col
);
1133 #define get_first_child(n) _get_first_child(__LINE__,n)
1134 static IHTMLDOMNode
*_get_first_child(unsigned line
, IUnknown
*unk
)
1136 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1137 IHTMLDOMNode
*child
= NULL
;
1140 hres
= IHTMLDOMNode_get_firstChild(node
, &child
);
1141 IHTMLDOMNode_Release(node
);
1142 ok_(__FILE__
,line
) (hres
== S_OK
, "get_firstChild failed: %08x\n", hres
);
1147 #define test_node_has_child(u,b) _test_node_has_child(__LINE__,u,b)
1148 static void _test_node_has_child(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1150 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1151 VARIANT_BOOL b
= 0xdead;
1154 hres
= IHTMLDOMNode_hasChildNodes(node
, &b
);
1155 ok_(__FILE__
,line
) (hres
== S_OK
, "hasChildNodes failed: %08x\n", hres
);
1156 ok_(__FILE__
,line
) (b
== exb
, "hasChildNodes=%x, expected %x\n", b
, exb
);
1158 IHTMLDOMNode_Release(node
);
1161 #define test_node_get_parent(u) _test_node_get_parent(__LINE__,u)
1162 static IHTMLDOMNode
*_test_node_get_parent(unsigned line
, IUnknown
*unk
)
1164 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1165 IHTMLDOMNode
*parent
;
1168 hres
= IHTMLDOMNode_get_parentNode(node
, &parent
);
1169 IHTMLDOMNode_Release(node
);
1170 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentNode failed: %08x\n", hres
);
1175 #define test_elem_get_parent(u) _test_elem_get_parent(__LINE__,u)
1176 static IHTMLElement
*_test_elem_get_parent(unsigned line
, IUnknown
*unk
)
1178 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1179 IHTMLElement
*parent
;
1182 hres
= IHTMLElement_get_parentElement(elem
, &parent
);
1183 IHTMLElement_Release(elem
);
1184 ok_(__FILE__
,line
) (hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
1189 #define test_elem3_get_disabled(i,b) _test_elem3_get_disabled(__LINE__,i,b)
1190 static void _test_elem3_get_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL exb
)
1192 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1193 VARIANT_BOOL disabled
= 100;
1197 hres
= IHTMLElement3_get_disabled(elem3
, &disabled
);
1198 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1199 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1200 IHTMLElement3_Release(elem3
);
1203 #define test_elem3_set_disabled(i,b) _test_elem3_set_disabled(__LINE__,i,b)
1204 static void _test_elem3_set_disabled(unsigned line
, IUnknown
*unk
, VARIANT_BOOL b
)
1206 IHTMLElement3
*elem3
= _get_elem3_iface(line
, unk
);
1210 hres
= IHTMLElement3_put_disabled(elem3
, b
);
1211 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1213 IHTMLElement3_Release(elem3
);
1214 _test_elem3_get_disabled(line
, unk
, b
);
1217 #define test_select_get_disabled(i,b) _test_select_get_disabled(__LINE__,i,b)
1218 static void _test_select_get_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL exb
)
1220 VARIANT_BOOL disabled
= 100;
1223 hres
= IHTMLSelectElement_get_disabled(select
, &disabled
);
1224 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1225 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1227 _test_elem3_get_disabled(line
, (IUnknown
*)select
, exb
);
1230 #define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
1231 static void _test_select_set_disabled(unsigned line
, IHTMLSelectElement
*select
, VARIANT_BOOL b
)
1235 hres
= IHTMLSelectElement_put_disabled(select
, b
);
1236 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1238 _test_select_get_disabled(line
, select
, b
);
1241 #define elem_get_scroll_height(u) _elem_get_scroll_height(__LINE__,u)
1242 static long _elem_get_scroll_height(unsigned line
, IUnknown
*unk
)
1244 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1245 IHTMLTextContainer
*txtcont
;
1246 long l
= -1, l2
= -1;
1249 hres
= IHTMLElement2_get_scrollHeight(elem
, &l
);
1250 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollHeight failed: %08x\n", hres
);
1251 IHTMLElement2_Release(elem
);
1253 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1254 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1256 hres
= IHTMLTextContainer_get_scrollHeight(txtcont
, &l2
);
1257 IHTMLTextContainer_Release(txtcont
);
1258 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollHeight failed: %ld\n", l2
);
1259 ok_(__FILE__
,line
) (l
== l2
, "unexpected height %ld, expected %ld\n", l2
, l
);
1264 #define elem_get_scroll_width(u) _elem_get_scroll_width(__LINE__,u)
1265 static long _elem_get_scroll_width(unsigned line
, IUnknown
*unk
)
1267 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1268 IHTMLTextContainer
*txtcont
;
1269 long l
= -1, l2
= -1;
1272 hres
= IHTMLElement2_get_scrollWidth(elem
, &l
);
1273 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollWidth failed: %08x\n", hres
);
1274 IHTMLElement2_Release(elem
);
1276 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1277 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1279 hres
= IHTMLTextContainer_get_scrollWidth(txtcont
, &l2
);
1280 IHTMLTextContainer_Release(txtcont
);
1281 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollWidth failed: %ld\n", l2
);
1282 ok_(__FILE__
,line
) (l
== l2
, "unexpected width %ld, expected %ld\n", l2
, l
);
1287 #define elem_get_scroll_top(u) _elem_get_scroll_top(__LINE__,u)
1288 static long _elem_get_scroll_top(unsigned line
, IUnknown
*unk
)
1290 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1291 IHTMLTextContainer
*txtcont
;
1292 long l
= -1, l2
= -1;
1295 hres
= IHTMLElement2_get_scrollTop(elem
, &l
);
1296 ok_(__FILE__
,line
) (hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1297 IHTMLElement2_Release(elem
);
1299 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1300 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1302 hres
= IHTMLTextContainer_get_scrollTop(txtcont
, &l2
);
1303 IHTMLTextContainer_Release(txtcont
);
1304 ok_(__FILE__
,line
) (hres
== S_OK
, "IHTMLTextContainer::get_scrollTop failed: %ld\n", l2
);
1305 ok_(__FILE__
,line
) (l
== l2
, "unexpected top %ld, expected %ld\n", l2
, l
);
1310 #define elem_get_scroll_left(u) _elem_get_scroll_left(__LINE__,u)
1311 static void _elem_get_scroll_left(unsigned line
, IUnknown
*unk
)
1313 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1314 IHTMLTextContainer
*txtcont
;
1315 long l
= -1, l2
= -1;
1318 hres
= IHTMLElement2_get_scrollLeft(elem
, NULL
);
1319 ok(hres
== E_INVALIDARG
, "expect E_INVALIDARG got 0x%08x\n", hres
);
1321 hres
= IHTMLElement2_get_scrollLeft(elem
, &l
);
1322 ok(hres
== S_OK
, "get_scrollTop failed: %08x\n", hres
);
1323 IHTMLElement2_Release(elem
);
1325 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLTextContainer
, (void**)&txtcont
);
1326 ok(hres
== S_OK
, "Could not get IHTMLTextContainer: %08x\n", hres
);
1328 hres
= IHTMLTextContainer_get_scrollLeft(txtcont
, &l2
);
1329 IHTMLTextContainer_Release(txtcont
);
1330 ok(hres
== S_OK
, "IHTMLTextContainer::get_scrollLeft failed: %ld\n", l2
);
1331 ok(l
== l2
, "unexpected left %ld, expected %ld\n", l2
, l
);
1334 #define test_img_src(i,s) _test_img_src(__LINE__,i,s)
1335 static void _test_img_src(unsigned line
, IUnknown
*unk
, const char *exsrc
)
1337 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1341 hres
= IHTMLImgElement_get_src(img
, &src
);
1342 IHTMLImgElement_Release(img
);
1343 ok_(__FILE__
,line
) (hres
== S_OK
, "get_src failed: %08x\n", hres
);
1344 ok_(__FILE__
,line
) (!strcmp_wa(src
, exsrc
), "get_src returned %s expected %s\n", dbgstr_w(src
), exsrc
);
1348 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
1349 static void _test_img_set_src(unsigned line
, IUnknown
*unk
, const char *src
)
1351 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1356 hres
= IHTMLImgElement_put_src(img
, tmp
);
1357 IHTMLImgElement_Release(img
);
1359 ok_(__FILE__
,line
) (hres
== S_OK
, "put_src failed: %08x\n", hres
);
1361 _test_img_src(line
, unk
, src
);
1364 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
1365 static void _test_img_alt(unsigned line
, IUnknown
*unk
, const char *exalt
)
1367 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1371 hres
= IHTMLImgElement_get_alt(img
, &alt
);
1372 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1374 ok_(__FILE__
,line
) (!strcmp_wa(alt
, exalt
), "inexopected alt %s\n", dbgstr_w(alt
));
1376 ok_(__FILE__
,line
) (!alt
, "alt != NULL\n");
1380 #define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
1381 static void _test_img_set_alt(unsigned line
, IUnknown
*unk
, const char *alt
)
1383 IHTMLImgElement
*img
= _get_img_iface(line
, unk
);
1388 hres
= IHTMLImgElement_put_alt(img
, tmp
);
1389 ok_(__FILE__
,line
) (hres
== S_OK
, "get_alt failed: %08x\n", hres
);
1392 _test_img_alt(line
, unk
, alt
);
1395 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
1396 static void _test_input_get_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1398 VARIANT_BOOL disabled
= 100;
1401 hres
= IHTMLInputElement_get_disabled(input
, &disabled
);
1402 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1403 ok_(__FILE__
,line
) (disabled
== exb
, "disabled=%x, expected %x\n", disabled
, exb
);
1405 _test_elem3_get_disabled(line
, (IUnknown
*)input
, exb
);
1408 #define test_input_set_disabled(i,b) _test_input_set_disabled(__LINE__,i,b)
1409 static void _test_input_set_disabled(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1413 hres
= IHTMLInputElement_put_disabled(input
, b
);
1414 ok_(__FILE__
,line
) (hres
== S_OK
, "get_disabled failed: %08x\n", hres
);
1416 _test_input_get_disabled(line
, input
, b
);
1419 #define test_input_get_defaultchecked(i,b) _test_input_get_defaultchecked(__LINE__,i,b)
1420 static void _test_input_get_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1422 VARIANT_BOOL checked
= 100;
1425 hres
= IHTMLInputElement_get_defaultChecked(input
, &checked
);
1426 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
1427 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
1430 #define test_input_set_defaultchecked(i,b) _test_input_set_defaultchecked(__LINE__,i,b)
1431 static void _test_input_set_defaultchecked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1435 hres
= IHTMLInputElement_put_defaultChecked(input
, b
);
1436 ok_(__FILE__
,line
) (hres
== S_OK
, "get_defaultChecked failed: %08x\n", hres
);
1438 _test_input_get_defaultchecked(line
, input
, b
);
1441 #define test_input_get_checked(i,b) _test_input_get_checked(__LINE__,i,b)
1442 static void _test_input_get_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL exb
)
1444 VARIANT_BOOL checked
= 100;
1447 hres
= IHTMLInputElement_get_checked(input
, &checked
);
1448 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
1449 ok_(__FILE__
,line
) (checked
== exb
, "checked=%x, expected %x\n", checked
, exb
);
1452 #define test_input_set_checked(i,b) _test_input_set_checked(__LINE__,i,b)
1453 static void _test_input_set_checked(unsigned line
, IHTMLInputElement
*input
, VARIANT_BOOL b
)
1457 hres
= IHTMLInputElement_put_checked(input
, b
);
1458 ok_(__FILE__
,line
) (hres
== S_OK
, "get_checked failed: %08x\n", hres
);
1460 _test_input_get_checked(line
, input
, b
);
1463 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
1464 static void _test_input_value(unsigned line
, IUnknown
*unk
, const char *exval
)
1466 IHTMLInputElement
*input
;
1470 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
1471 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1475 hres
= IHTMLInputElement_get_value(input
, &bstr
);
1476 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1478 ok_(__FILE__
,line
) (!strcmp_wa(bstr
, exval
), "value=%s\n", dbgstr_w(bstr
));
1480 ok_(__FILE__
,line
) (!exval
, "exval != NULL\n");
1481 SysFreeString(bstr
);
1482 IHTMLInputElement_Release(input
);
1485 #define test_input_put_value(o,v) _test_input_put_value(__LINE__,o,v)
1486 static void _test_input_put_value(unsigned line
, IUnknown
*unk
, const char *val
)
1488 IHTMLInputElement
*input
;
1492 hres
= IUnknown_QueryInterface(unk
, &IID_IHTMLInputElement
, (void**)&input
);
1493 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
1498 hres
= IHTMLInputElement_get_value(input
, &bstr
);
1499 ok_(__FILE__
,line
) (hres
== S_OK
, "get_value failed: %08x\n", hres
);
1500 SysFreeString(bstr
);
1501 IHTMLInputElement_Release(input
);
1504 #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
1505 static void _test_elem_class(unsigned line
, IUnknown
*unk
, const char *exclass
)
1507 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1508 BSTR
class = (void*)0xdeadbeef;
1511 hres
= IHTMLElement_get_className(elem
, &class);
1512 IHTMLElement_Release(elem
);
1513 ok_(__FILE__
,line
) (hres
== S_OK
, "get_className failed: %08x\n", hres
);
1515 ok_(__FILE__
,line
) (!strcmp_wa(class, exclass
), "unexpected className %s\n", dbgstr_w(class));
1517 ok_(__FILE__
,line
) (!class, "class != NULL\n");
1518 SysFreeString(class);
1521 #define test_elem_tabindex(u,i) _test_elem_tabindex(__LINE__,u,i)
1522 static void _test_elem_tabindex(unsigned line
, IUnknown
*unk
, short exindex
)
1524 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
1528 hres
= IHTMLElement2_get_tabIndex(elem2
, &index
);
1529 IHTMLElement2_Release(elem2
);
1530 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
1531 ok_(__FILE__
,line
) (index
== exindex
, "unexpected index %d\n", index
);
1534 #define test_elem_set_tabindex(u,i) _test_elem_set_tabindex(__LINE__,u,i)
1535 static void _test_elem_set_tabindex(unsigned line
, IUnknown
*unk
, short index
)
1537 IHTMLElement2
*elem2
= _get_elem2_iface(line
, unk
);
1540 hres
= IHTMLElement2_put_tabIndex(elem2
, index
);
1541 IHTMLElement2_Release(elem2
);
1542 ok_(__FILE__
,line
) (hres
== S_OK
, "get_tabIndex failed: %08x\n", hres
);
1544 _test_elem_tabindex(line
, unk
, index
);
1547 #define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c)
1548 static void _test_elem_set_class(unsigned line
, IUnknown
*unk
, const char *class)
1550 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1554 tmp
= class ? a2bstr(class) : NULL
;
1555 hres
= IHTMLElement_put_className(elem
, tmp
);
1556 IHTMLElement_Release(elem
);
1557 ok_(__FILE__
,line
) (hres
== S_OK
, "put_className failed: %08x\n", hres
);
1560 _test_elem_class(line
, unk
, class);
1563 #define test_elem_id(e,i) _test_elem_id(__LINE__,e,i)
1564 static void _test_elem_id(unsigned line
, IUnknown
*unk
, const char *exid
)
1566 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1567 BSTR id
= (void*)0xdeadbeef;
1570 hres
= IHTMLElement_get_id(elem
, &id
);
1571 IHTMLElement_Release(elem
);
1572 ok_(__FILE__
,line
) (hres
== S_OK
, "get_id failed: %08x\n", hres
);
1575 ok_(__FILE__
,line
) (!strcmp_wa(id
, exid
), "unexpected id %s\n", dbgstr_w(id
));
1577 ok_(__FILE__
,line
) (!id
, "id=%s\n", dbgstr_w(id
));
1582 #define test_elem_put_id(u,i) _test_elem_put_id(__LINE__,u,i)
1583 static void _test_elem_put_id(unsigned line
, IUnknown
*unk
, const char *new_id
)
1585 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1586 BSTR tmp
= a2bstr(new_id
);
1589 hres
= IHTMLElement_put_id(elem
, tmp
);
1590 IHTMLElement_Release(elem
);
1592 ok_(__FILE__
,line
) (hres
== S_OK
, "put_id failed: %08x\n", hres
);
1594 _test_elem_id(line
, unk
, new_id
);
1597 #define test_elem_title(u,t) _test_elem_title(__LINE__,u,t)
1598 static void _test_elem_title(unsigned line
, IUnknown
*unk
, const char *extitle
)
1600 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1604 hres
= IHTMLElement_get_title(elem
, &title
);
1605 IHTMLElement_Release(elem
);
1606 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1608 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", dbgstr_w(title
));
1610 ok_(__FILE__
,line
) (!title
, "title=%s, expected NULL\n", dbgstr_w(title
));
1612 SysFreeString(title
);
1615 #define test_elem_set_title(u,t) _test_elem_set_title(__LINE__,u,t)
1616 static void _test_elem_set_title(unsigned line
, IUnknown
*unk
, const char *title
)
1618 IHTMLElement
*elem
= _get_elem_iface(line
, unk
);
1622 tmp
= a2bstr(title
);
1623 hres
= IHTMLElement_put_title(elem
, tmp
);
1624 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1626 IHTMLElement_Release(elem
);
1630 #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e)
1631 static void _test_node_get_value_str(unsigned line
, IUnknown
*unk
, const char *exval
)
1633 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1637 hres
= IHTMLDOMNode_get_nodeValue(node
, &var
);
1638 IHTMLDOMNode_Release(node
);
1639 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
1642 ok_(__FILE__
,line
) (V_VT(&var
) == VT_BSTR
, "vt=%d\n", V_VT(&var
));
1643 ok_(__FILE__
,line
) (!strcmp_wa(V_BSTR(&var
), exval
), "unexpected value %s\n", dbgstr_w(V_BSTR(&var
)));
1645 ok_(__FILE__
,line
) (V_VT(&var
) == VT_NULL
, "vt=%d, expected VT_NULL\n", V_VT(&var
));
1651 #define test_node_put_value_str(u,v) _test_node_put_value_str(__LINE__,u,v)
1652 static void _test_node_put_value_str(unsigned line
, IUnknown
*unk
, const char *val
)
1654 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1658 V_VT(&var
) = VT_BSTR
;
1659 V_BSTR(&var
) = a2bstr(val
);
1661 hres
= IHTMLDOMNode_put_nodeValue(node
, var
);
1662 ok_(__FILE__
,line
) (hres
== S_OK
, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres
);
1663 IHTMLDOMNode_Release(node
);
1667 #define test_elem_client_size(u) _test_elem_client_size(__LINE__,u)
1668 static void _test_elem_client_size(unsigned line
, IUnknown
*unk
)
1670 IHTMLElement2
*elem
= _get_elem2_iface(line
, unk
);
1674 hres
= IHTMLElement2_get_clientWidth(elem
, &l
);
1675 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientWidth failed: %08x\n", hres
);
1676 hres
= IHTMLElement2_get_clientHeight(elem
, &l
);
1677 ok_(__FILE__
,line
) (hres
== S_OK
, "get_clientHeight failed: %08x\n", hres
);
1679 IHTMLElement2_Release(elem
);
1682 #define test_create_elem(d,t) _test_create_elem(__LINE__,d,t)
1683 static IHTMLElement
*_test_create_elem(unsigned line
, IHTMLDocument2
*doc
, const char *tag
)
1685 IHTMLElement
*elem
= NULL
;
1690 hres
= IHTMLDocument2_createElement(doc
, tmp
, &elem
);
1691 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
1692 ok_(__FILE__
,line
) (elem
!= NULL
, "elem == NULL\n");
1697 #define test_create_text(d,t) _test_create_text(__LINE__,d,t)
1698 static IHTMLDOMNode
*_test_create_text(unsigned line
, IHTMLDocument2
*doc
, const char *text
)
1700 IHTMLDocument3
*doc3
;
1701 IHTMLDOMNode
*node
= NULL
;
1705 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1706 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IHTMLDocument3: %08x\n", hres
);
1709 hres
= IHTMLDocument3_createTextNode(doc3
, tmp
, &node
);
1710 IHTMLDocument3_Release(doc3
);
1711 ok_(__FILE__
,line
) (hres
== S_OK
, "createElement failed: %08x\n", hres
);
1712 ok_(__FILE__
,line
) (node
!= NULL
, "node == NULL\n");
1717 #define test_node_append_child(n,c) _test_node_append_child(__LINE__,n,c)
1718 static IHTMLDOMNode
*_test_node_append_child(unsigned line
, IUnknown
*node_unk
, IUnknown
*child_unk
)
1720 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
1721 IHTMLDOMNode
*child
= _get_node_iface(line
, child_unk
);
1722 IHTMLDOMNode
*new_child
= NULL
;
1725 hres
= IHTMLDOMNode_appendChild(node
, child
, &new_child
);
1726 ok_(__FILE__
,line
) (hres
== S_OK
, "appendChild failed: %08x\n", hres
);
1727 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
1728 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1730 IHTMLDOMNode_Release(node
);
1731 IHTMLDOMNode_Release(child
);
1736 #define test_node_insertbefore(n,c,v) _test_node_insertbefore(__LINE__,n,c,v)
1737 static IHTMLDOMNode
*_test_node_insertbefore(unsigned line
, IUnknown
*node_unk
, IHTMLDOMNode
*child
, VARIANT
*var
)
1739 IHTMLDOMNode
*node
= _get_node_iface(line
, node_unk
);
1740 IHTMLDOMNode
*new_child
= NULL
;
1743 hres
= IHTMLDOMNode_insertBefore(node
, child
, *var
, &new_child
);
1744 ok_(__FILE__
,line
) (hres
== S_OK
, "insertBefore failed: %08x\n", hres
);
1745 ok_(__FILE__
,line
) (new_child
!= NULL
, "new_child == NULL\n");
1746 /* TODO ok_(__FILE__,line) (new_child != child, "new_child == child\n"); */
1748 IHTMLDOMNode_Release(node
);
1753 #define test_node_remove_child(n,c) _test_node_remove_child(__LINE__,n,c)
1754 static void _test_node_remove_child(unsigned line
, IUnknown
*unk
, IHTMLDOMNode
*child
)
1756 IHTMLDOMNode
*node
= _get_node_iface(line
, unk
);
1757 IHTMLDOMNode
*new_node
= NULL
;
1760 hres
= IHTMLDOMNode_removeChild(node
, child
, &new_node
);
1761 ok_(__FILE__
,line
) (hres
== S_OK
, "removeChild failed: %08x\n", hres
);
1762 ok_(__FILE__
,line
) (new_node
!= NULL
, "new_node == NULL\n");
1763 /* TODO ok_(__FILE__,line) (new_node != child, "new_node == child\n"); */
1765 IHTMLDOMNode_Release(node
);
1766 IHTMLDOMNode_Release(new_node
);
1769 #define test_doc_title(d,t) _test_doc_title(__LINE__,d,t)
1770 static void _test_doc_title(unsigned line
, IHTMLDocument2
*doc
, const char *extitle
)
1775 hres
= IHTMLDocument2_get_title(doc
, &title
);
1776 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1777 ok_(__FILE__
,line
) (!strcmp_wa(title
, extitle
), "unexpected title %s\n", dbgstr_w(title
));
1778 SysFreeString(title
);
1781 #define test_doc_set_title(d,t) _test_doc_set_title(__LINE__,d,t)
1782 static void _test_doc_set_title(unsigned line
, IHTMLDocument2
*doc
, const char *title
)
1787 tmp
= a2bstr(title
);
1788 hres
= IHTMLDocument2_put_title(doc
, tmp
);
1789 ok_(__FILE__
,line
) (hres
== S_OK
, "get_title failed: %08x\n", hres
);
1793 static void test_elem_col_item(IHTMLElementCollection
*col
, LPCWSTR n
,
1794 const elem_type_t
*elem_types
, long len
)
1797 VARIANT name
, index
;
1801 V_VT(&index
) = VT_EMPTY
;
1802 V_VT(&name
) = VT_BSTR
;
1803 V_BSTR(&name
) = SysAllocString(n
);
1805 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1806 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1808 test_elem_collection((IUnknown
*)disp
, elem_types
, len
);
1809 IDispatch_Release(disp
);
1810 ok(hres
== S_OK
, "Could not get IHTMLElementCollection interface: %08x\n", hres
);
1814 V_VT(&index
) = VT_I4
;
1816 for(i
=0; i
<len
; i
++) {
1818 disp
= (void*)0xdeadbeef;
1819 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1820 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1821 ok(disp
!= NULL
, "disp == NULL\n");
1822 if(FAILED(hres
) || !disp
)
1825 test_elem_type((IUnknown
*)disp
, elem_types
[i
]);
1827 IDispatch_Release(disp
);
1831 disp
= (void*)0xdeadbeef;
1832 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1833 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1834 ok(disp
== NULL
, "disp != NULL\n");
1837 disp
= (void*)0xdeadbeef;
1838 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1839 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
1840 ok(disp
== NULL
, "disp != NULL\n");
1843 SysFreeString(V_BSTR(&name
));
1846 static IHTMLElement
*get_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
, BOOL expect_success
)
1848 IHTMLElementCollection
*col
;
1850 IDispatch
*disp
= (void*)0xdeadbeef;
1851 VARIANT name
, index
;
1854 hres
= IHTMLDocument2_get_all(doc
, &col
);
1855 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
1856 ok(col
!= NULL
, "col == NULL\n");
1857 if(FAILED(hres
) || !col
)
1860 V_VT(&index
) = VT_EMPTY
;
1861 V_VT(&name
) = VT_BSTR
;
1862 V_BSTR(&name
) = SysAllocString(id
);
1864 hres
= IHTMLElementCollection_item(col
, name
, index
, &disp
);
1865 IHTMLElementCollection_Release(col
);
1866 SysFreeString(V_BSTR(&name
));
1867 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
1868 if(!expect_success
) {
1869 ok(disp
== NULL
, "disp != NULL\n");
1873 ok(disp
!= NULL
, "disp == NULL\n");
1877 elem
= get_elem_iface((IUnknown
*)disp
);
1878 IDispatch_Release(disp
);
1883 static IHTMLElement
*get_doc_elem_by_id(IHTMLDocument2
*doc
, LPCWSTR id
)
1885 IHTMLDocument3
*doc3
;
1890 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument3
, (void**)&doc3
);
1891 ok(hres
== S_OK
, "Could not get IHTMLDocument3 iface: %08x\n", hres
);
1893 tmp
= SysAllocString(id
);
1894 hres
= IHTMLDocument3_getElementById(doc3
, tmp
, &elem
);
1896 ok(hres
== S_OK
, "getElementById(%s) failed: %08x\n", dbgstr_w(id
), hres
);
1898 IHTMLDocument3_Release(doc3
);
1903 static void test_select_elem(IHTMLSelectElement
*select
)
1905 test_select_type(select
, "select-one");
1906 test_select_length(select
, 2);
1907 test_select_selidx(select
, 0);
1908 test_select_put_selidx(select
, 1);
1910 test_select_set_value(select
, "val1");
1911 test_select_value(select
, "val1");
1913 test_select_get_disabled(select
, VARIANT_FALSE
);
1914 test_select_set_disabled(select
, VARIANT_TRUE
);
1915 test_select_set_disabled(select
, VARIANT_FALSE
);
1918 static void test_create_option_elem(IHTMLDocument2
*doc
)
1920 IHTMLOptionElement
*option
;
1922 option
= create_option_elem(doc
, "test text", "test value");
1924 test_option_put_text(option
, "new text");
1925 test_option_put_value(option
, "new value");
1927 IHTMLOptionElement_Release(option
);
1930 static IHTMLTxtRange
*test_create_body_range(IHTMLDocument2
*doc
)
1932 IHTMLBodyElement
*body
;
1933 IHTMLTxtRange
*range
;
1937 hres
= IHTMLDocument2_get_body(doc
, &elem
);
1938 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
1940 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
1941 IHTMLElement_Release(elem
);
1943 hres
= IHTMLBodyElement_createTextRange(body
, &range
);
1944 IHTMLBodyElement_Release(body
);
1945 ok(hres
== S_OK
, "createTextRange failed: %08x\n", hres
);
1950 static void test_txtrange(IHTMLDocument2
*doc
)
1952 IHTMLTxtRange
*body_range
, *range
, *range2
;
1953 IHTMLSelectionObject
*selection
;
1954 IDispatch
*disp_range
;
1957 body_range
= test_create_body_range(doc
);
1959 test_range_text(body_range
, "test abc 123\r\nit's text");
1961 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
1962 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1964 hres
= IHTMLTxtRange_duplicate(body_range
, &range2
);
1965 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
1966 test_range_isequal(range
, range2
, VARIANT_TRUE
);
1968 test_range_text(range
, "test abc 123\r\nit's text");
1969 test_range_text(body_range
, "test abc 123\r\nit's text");
1971 test_range_collapse(range
, TRUE
);
1972 test_range_isequal(range
, range2
, VARIANT_FALSE
);
1973 test_range_inrange(range
, range2
, VARIANT_FALSE
);
1974 test_range_inrange(range2
, range
, VARIANT_TRUE
);
1975 IHTMLTxtRange_Release(range2
);
1977 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1978 test_range_expand(range
, wordW
, VARIANT_FALSE
, "test ");
1979 test_range_move(range
, characterW
, 2, 2);
1980 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
1982 test_range_collapse(range
, FALSE
);
1983 test_range_expand(range
, wordW
, VARIANT_TRUE
, "abc ");
1985 test_range_collapse(range
, FALSE
);
1986 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1987 test_range_expand(range
, wordW
, VARIANT_FALSE
, "123");
1988 test_range_move(range
, characterW
, 2, 2);
1989 test_range_expand(range
, wordW
, VARIANT_TRUE
, "123");
1990 test_range_moveend(range
, characterW
, -5, -5);
1991 test_range_text(range
, NULL
);
1992 test_range_moveend(range
, characterW
, 3, 3);
1993 test_range_text(range
, "c 1");
1994 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "test abc 123\r\nit's text");
1995 test_range_collapse(range
, TRUE
);
1996 test_range_move(range
, characterW
, 4, 4);
1997 test_range_moveend(range
, characterW
, 1, 1);
1998 test_range_text(range
, " ");
1999 test_range_move(range
, wordW
, 1, 1);
2000 test_range_moveend(range
, characterW
, 2, 2);
2001 test_range_text(range
, "ab");
2003 IHTMLTxtRange_Release(range
);
2005 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2006 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2008 test_range_text(range
, "test abc 123\r\nit's text");
2009 test_range_move(range
, characterW
, 3, 3);
2010 test_range_moveend(range
, characterW
, 1, 1);
2011 test_range_text(range
, "t");
2012 test_range_moveend(range
, characterW
, 3, 3);
2013 test_range_text(range
, "t ab");
2014 test_range_moveend(range
, characterW
, -2, -2);
2015 test_range_text(range
, "t ");
2016 test_range_move(range
, characterW
, 6, 6);
2017 test_range_moveend(range
, characterW
, 3, 3);
2018 test_range_text(range
, "123");
2019 test_range_moveend(range
, characterW
, 2, 2);
2020 test_range_text(range
, "123\r\ni");
2022 IHTMLTxtRange_Release(range
);
2024 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2025 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2027 test_range_move(range
, wordW
, 1, 1);
2028 test_range_moveend(range
, characterW
, 2, 2);
2029 test_range_text(range
, "ab");
2031 test_range_move(range
, characterW
, -2, -2);
2032 test_range_moveend(range
, characterW
, 2, 2);
2033 test_range_text(range
, "t ");
2035 test_range_move(range
, wordW
, 3, 3);
2036 test_range_move(range
, wordW
, -2, -2);
2037 test_range_moveend(range
, characterW
, 2, 2);
2038 test_range_text(range
, "ab");
2040 test_range_move(range
, characterW
, -6, -5);
2041 test_range_moveend(range
, characterW
, -1, 0);
2042 test_range_moveend(range
, characterW
, -6, 0);
2043 test_range_move(range
, characterW
, 2, 2);
2044 test_range_moveend(range
, characterW
, 2, 2);
2045 test_range_text(range
, "st");
2046 test_range_moveend(range
, characterW
, -6, -4);
2047 test_range_moveend(range
, characterW
, 2, 2);
2049 IHTMLTxtRange_Release(range
);
2051 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2052 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2054 test_range_move(range
, wordW
, 2, 2);
2055 test_range_moveend(range
, characterW
, 2, 2);
2056 test_range_text(range
, "12");
2058 test_range_move(range
, characterW
, 15, 14);
2059 test_range_move(range
, characterW
, -2, -2);
2060 test_range_moveend(range
, characterW
, 3, 2);
2061 test_range_text(range
, "t");
2062 test_range_moveend(range
, characterW
, -1, -1);
2063 test_range_text(range
, "t");
2064 test_range_expand(range
, wordW
, VARIANT_TRUE
, "text");
2065 test_range_move(range
, characterW
, -2, -2);
2066 test_range_moveend(range
, characterW
, 2, 2);
2067 test_range_text(range
, "s ");
2068 test_range_move(range
, characterW
, 100, 7);
2069 test_range_move(range
, wordW
, 1, 0);
2070 test_range_move(range
, characterW
, -2, -2);
2071 test_range_moveend(range
, characterW
, 3, 2);
2072 test_range_text(range
, "t");
2074 IHTMLTxtRange_Release(range
);
2076 hres
= IHTMLTxtRange_duplicate(body_range
, &range
);
2077 ok(hres
== S_OK
, "duplicate failed: %08x\n", hres
);
2079 test_range_collapse(range
, TRUE
);
2080 test_range_expand(range
, wordW
, VARIANT_TRUE
, "test ");
2081 test_range_put_text(range
, "word");
2082 test_range_text(body_range
, "wordabc 123\r\nit's text");
2083 test_range_text(range
, NULL
);
2084 test_range_moveend(range
, characterW
, 3, 3);
2085 test_range_text(range
, "abc");
2086 test_range_movestart(range
, characterW
, -2, -2);
2087 test_range_text(range
, "rdabc");
2088 test_range_movestart(range
, characterW
, 3, 3);
2089 test_range_text(range
, "bc");
2090 test_range_movestart(range
, characterW
, 4, 4);
2091 test_range_text(range
, NULL
);
2092 test_range_movestart(range
, characterW
, -3, -3);
2093 test_range_text(range
, "c 1");
2094 test_range_movestart(range
, characterW
, -7, -6);
2095 test_range_text(range
, "wordabc 1");
2096 test_range_movestart(range
, characterW
, 100, 22);
2097 test_range_text(range
, NULL
);
2099 IHTMLTxtRange_Release(range
);
2100 IHTMLTxtRange_Release(body_range
);
2102 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
2103 ok(hres
== S_OK
, "IHTMLDocument2_get_selection failed: %08x\n", hres
);
2105 hres
= IHTMLSelectionObject_createRange(selection
, &disp_range
);
2106 ok(hres
== S_OK
, "IHTMLSelectionObject_createRange failed: %08x\n", hres
);
2107 IHTMLSelectionObject_Release(selection
);
2109 hres
= IDispatch_QueryInterface(disp_range
, &IID_IHTMLTxtRange
, (void **)&range
);
2110 ok(hres
== S_OK
, "Could not get IID_IHTMLTxtRange interface: 0x%08x\n", hres
);
2111 IDispatch_Release(disp_range
);
2113 test_range_text(range
, NULL
);
2114 test_range_moveend(range
, characterW
, 3, 3);
2115 test_range_text(range
, "wor");
2116 test_range_parent(range
, ET_BODY
);
2117 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2118 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "wordabc 123\r\nit's text");
2119 test_range_move(range
, characterW
, 3, 3);
2120 test_range_expand(range
, wordW
, VARIANT_TRUE
, "wordabc ");
2121 test_range_moveend(range
, characterW
, -4, -4);
2122 test_range_put_text(range
, "abc def ");
2123 test_range_expand(range
, texteditW
, VARIANT_TRUE
, "abc def abc 123\r\nit's text");
2124 test_range_move(range
, wordW
, 1, 1);
2125 test_range_movestart(range
, characterW
, -1, -1);
2126 test_range_text(range
, " ");
2127 test_range_move(range
, wordW
, 1, 1);
2128 test_range_moveend(range
, characterW
, 3, 3);
2129 test_range_text(range
, "def");
2130 test_range_put_text(range
, "xyz");
2131 test_range_moveend(range
, characterW
, 1, 1);
2132 test_range_move(range
, wordW
, 1, 1);
2133 test_range_moveend(range
, characterW
, 2, 2);
2134 test_range_text(range
, "ab");
2136 IHTMLTxtRange_Release(range
);
2139 static void test_txtrange2(IHTMLDocument2
*doc
)
2141 IHTMLTxtRange
*range
;
2143 range
= test_create_body_range(doc
);
2145 test_range_text(range
, "abc\r\n\r\n123\r\n\r\n\r\ndef");
2146 test_range_move(range
, characterW
, 5, 5);
2147 test_range_moveend(range
, characterW
, 1, 1);
2148 test_range_text(range
, "2");
2149 test_range_move(range
, characterW
, -3, -3);
2150 test_range_moveend(range
, characterW
, 3, 3);
2151 test_range_text(range
, "c\r\n\r\n1");
2152 test_range_collapse(range
, VARIANT_FALSE
);
2153 test_range_moveend(range
, characterW
, 4, 4);
2154 test_range_text(range
, "23");
2155 test_range_moveend(range
, characterW
, 1, 1);
2156 test_range_text(range
, "23\r\n\r\n\r\nd");
2157 test_range_moveend(range
, characterW
, -1, -1);
2158 test_range_text(range
, "23");
2159 test_range_moveend(range
, characterW
, -1, -1);
2160 test_range_text(range
, "23");
2161 test_range_moveend(range
, characterW
, -2, -2);
2162 test_range_text(range
, "2");
2164 IHTMLTxtRange_Release(range
);
2167 static void test_compatmode(IHTMLDocument2
*doc
)
2169 IHTMLDocument5
*doc5
;
2173 hres
= IHTMLDocument2_QueryInterface(doc
, &IID_IHTMLDocument5
, (void**)&doc5
);
2174 ok(hres
== S_OK
, "Could not get IHTMLDocument5 interface: %08x\n", hres
);
2178 hres
= IHTMLDocument5_get_compatMode(doc5
, &mode
);
2179 IHTMLDocument5_Release(doc5
);
2180 ok(hres
== S_OK
, "get_compatMode failed: %08x\n", hres
);
2181 ok(!strcmp_wa(mode
, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode
));
2182 SysFreeString(mode
);
2185 static void test_location(IHTMLDocument2
*doc
)
2187 IHTMLLocation
*location
, *location2
;
2188 IHTMLWindow2
*window
;
2192 hres
= IHTMLDocument2_get_location(doc
, &location
);
2193 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
2195 hres
= IHTMLDocument2_get_location(doc
, &location2
);
2196 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
2198 ok(location
== location2
, "location != location2\n");
2199 IHTMLLocation_Release(location2
);
2201 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2202 ok(hres
== S_OK
, "get_parentWindow failed: %08x\n", hres
);
2204 hres
= IHTMLWindow2_get_location(window
, &location2
);
2205 ok(hres
== S_OK
, "get_location failed: %08x\n", hres
);
2206 ok(location
== location2
, "location != location2\n");
2207 IHTMLLocation_Release(location2
);
2209 test_ifaces((IUnknown
*)location
, location_iids
);
2210 test_disp((IUnknown
*)location
, &IID_IHTMLLocation
);
2212 ref
= IHTMLLocation_Release(location
);
2213 ok(!ref
, "location chould be destroyed here\n");
2216 static void test_navigator(IHTMLDocument2
*doc
)
2218 IHTMLWindow2
*window
;
2219 IOmNavigator
*navigator
, *navigator2
;
2224 static const WCHAR v40
[] = {'4','.','0'};
2226 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2227 ok(hres
== S_OK
, "parentWidnow failed: %08x\n", hres
);
2229 hres
= IHTMLWindow2_get_navigator(window
, &navigator
);
2230 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
2231 ok(navigator
!= NULL
, "navigator == NULL\n");
2232 test_disp((IUnknown
*)navigator
, &IID_IOmNavigator
);
2234 hres
= IHTMLWindow2_get_navigator(window
, &navigator2
);
2235 ok(hres
== S_OK
, "get_navigator failed: %08x\n", hres
);
2236 ok(navigator
!= navigator2
, "navigator2 != navihgator\n");
2238 IHTMLWindow2_Release(window
);
2239 IOmNavigator_Release(navigator2
);
2241 hres
= IOmNavigator_get_appCodeName(navigator
, &bstr
);
2242 ok(hres
== S_OK
, "get_appCodeName failed: %08x\n", hres
);
2243 ok(!strcmp_wa(bstr
, "Mozilla"), "Unexpected appCodeName %s\n", dbgstr_w(bstr
));
2244 SysFreeString(bstr
);
2247 hres
= IOmNavigator_get_platform(navigator
, &bstr
);
2248 ok(hres
== S_OK
, "get_platform failed: %08x\n", hres
);
2250 ok(!strcmp_wa(bstr
, "Win64"), "unexpected platform %s\n", dbgstr_w(bstr
));
2252 ok(!strcmp_wa(bstr
, "Win32"), "unexpected platform %s\n", dbgstr_w(bstr
));
2254 SysFreeString(bstr
);
2257 hres
= IOmNavigator_get_appVersion(navigator
, &bstr
);
2258 ok(hres
== S_OK
, "get_appVersion failed: %08x\n", hres
);
2259 ok(!memcmp(bstr
, v40
, sizeof(v40
)), "appVersion is %s\n", dbgstr_w(bstr
));
2260 SysFreeString(bstr
);
2262 ref
= IOmNavigator_Release(navigator
);
2263 ok(!ref
, "navigator should be destroyed here\n");
2266 static void test_current_style(IHTMLCurrentStyle
*current_style
)
2271 test_disp((IUnknown
*)current_style
, &DIID_DispHTMLCurrentStyle
);
2272 test_ifaces((IUnknown
*)current_style
, cstyle_iids
);
2274 hres
= IHTMLCurrentStyle_get_display(current_style
, &str
);
2275 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
2276 ok(!strcmp_wa(str
, "block"), "get_display returned %s\n", dbgstr_w(str
));
2280 static void test_style2(IHTMLStyle2
*style2
)
2285 str
= (void*)0xdeadbeef;
2286 hres
= IHTMLStyle2_get_position(style2
, &str
);
2287 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2288 ok(!str
, "str != NULL\n");
2290 str
= a2bstr("absolute");
2291 hres
= IHTMLStyle2_put_position(style2
, str
);
2292 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2296 hres
= IHTMLStyle2_get_position(style2
, &str
);
2297 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2298 ok(!strcmp_wa(str
, "absolute"), "get_position returned %s\n", dbgstr_w(str
));
2302 static void test_default_style(IHTMLStyle
*style
)
2304 IHTMLStyle2
*style2
;
2310 BSTR sOverflowDefault
;
2313 test_disp((IUnknown
*)style
, &DIID_DispHTMLStyle
);
2314 test_ifaces((IUnknown
*)style
, style_iids
);
2316 hres
= IHTMLStyle_get_position(style
, &str
);
2317 ok(hres
== S_OK
, "get_position failed: %08x\n", hres
);
2318 ok(!str
, "str=%s\n", dbgstr_w(str
));
2320 str
= (void*)0xdeadbeef;
2321 hres
= IHTMLStyle_get_fontFamily(style
, &str
);
2322 ok(hres
== S_OK
, "get_fontFamily failed: %08x\n", hres
);
2323 ok(!str
, "fontFamily = %s\n", dbgstr_w(str
));
2325 str
= (void*)0xdeadbeef;
2326 hres
= IHTMLStyle_get_fontWeight(style
, &str
);
2327 ok(hres
== S_OK
, "get_fontWeight failed: %08x\n", hres
);
2328 ok(!str
, "fontWeight = %s\n", dbgstr_w(str
));
2331 hres
= IHTMLStyle_get_fontVariant(style
, NULL
);
2332 ok(hres
== E_INVALIDARG
, "get_fontVariant failed: %08x\n", hres
);
2334 hres
= IHTMLStyle_get_fontVariant(style
, &sDefault
);
2335 ok(hres
== S_OK
, "get_fontVariant failed: %08x\n", hres
);
2337 str
= a2bstr("test");
2338 hres
= IHTMLStyle_put_fontVariant(style
, str
);
2339 ok(hres
== E_INVALIDARG
, "fontVariant failed: %08x\n", hres
);
2342 str
= a2bstr("small-caps");
2343 hres
= IHTMLStyle_put_fontVariant(style
, str
);
2344 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
2347 str
= a2bstr("normal");
2348 hres
= IHTMLStyle_put_fontVariant(style
, str
);
2349 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
2352 hres
= IHTMLStyle_put_fontVariant(style
, sDefault
);
2353 ok(hres
== S_OK
, "fontVariant failed: %08x\n", hres
);
2354 SysFreeString(sDefault
);
2356 str
= (void*)0xdeadbeef;
2357 hres
= IHTMLStyle_get_display(style
, &str
);
2358 ok(hres
== S_OK
, "get_display failed: %08x\n", hres
);
2359 ok(!str
, "display = %s\n", dbgstr_w(str
));
2361 str
= (void*)0xdeadbeef;
2362 hres
= IHTMLStyle_get_visibility(style
, &str
);
2363 ok(hres
== S_OK
, "get_visibility failed: %08x\n", hres
);
2364 ok(!str
, "visibility = %s\n", dbgstr_w(str
));
2367 hres
= IHTMLStyle_get_fontSize(style
, &v
);
2368 ok(hres
== S_OK
, "get_fontSize failed: %08x\n", hres
);
2369 ok(V_VT(&v
) == VT_BSTR
, "V_VT(fontSize) = %d\n", V_VT(&v
));
2370 ok(!V_BSTR(&v
), "V_BSTR(fontSize) = %s\n", dbgstr_w(V_BSTR(&v
)));
2373 hres
= IHTMLStyle_get_color(style
, &v
);
2374 ok(hres
== S_OK
, "get_color failed: %08x\n", hres
);
2375 ok(V_VT(&v
) == VT_BSTR
, "V_VT(color) = %d\n", V_VT(&v
));
2376 ok(!V_BSTR(&v
), "V_BSTR(color) = %s\n", dbgstr_w(V_BSTR(&v
)));
2379 hres
= IHTMLStyle_get_textDecorationUnderline(style
, &b
);
2380 ok(hres
== S_OK
, "get_textDecorationUnderline failed: %08x\n", hres
);
2381 ok(b
== VARIANT_FALSE
, "textDecorationUnderline = %x\n", b
);
2384 hres
= IHTMLStyle_get_textDecorationLineThrough(style
, &b
);
2385 ok(hres
== S_OK
, "get_textDecorationLineThrough failed: %08x\n", hres
);
2386 ok(b
== VARIANT_FALSE
, "textDecorationLineThrough = %x\n", b
);
2388 hres
= IHTMLStyle_get_posWidth(style
, NULL
);
2389 ok(hres
== E_POINTER
, "get_posWidth failed: %08x\n", hres
);
2391 hres
= IHTMLStyle_get_posWidth(style
, &f
);
2392 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
2393 ok(f
== 0.0f
, "f = %f\n", f
);
2395 V_VT(&v
) = VT_EMPTY
;
2396 hres
= IHTMLStyle_get_width(style
, &v
);
2397 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
2398 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2399 ok(!V_BSTR(&v
), "V_BSTR(v)=%p\n", V_BSTR(&v
));
2401 hres
= IHTMLStyle_put_posWidth(style
, 2.2);
2402 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
2404 hres
= IHTMLStyle_get_posWidth(style
, &f
);
2405 ok(hres
== S_OK
, "get_posWidth failed: %08x\n", hres
);
2406 ok(f
== 2.0f
, "f = %f\n", f
);
2409 V_BSTR(&v
) = a2bstr("auto");
2410 hres
= IHTMLStyle_put_width(style
, v
);
2411 ok(hres
== S_OK
, "put_width failed: %08x\n", hres
);
2414 V_VT(&v
) = VT_EMPTY
;
2415 hres
= IHTMLStyle_get_width(style
, &v
);
2416 ok(hres
== S_OK
, "get_width failed: %08x\n", hres
);
2417 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2418 ok(!strcmp_wa(V_BSTR(&v
), "auto"), "V_BSTR(v)=%s\n", dbgstr_w(V_BSTR(&v
)));
2422 str
= (void*)0xdeadbeef;
2423 hres
= IHTMLStyle_get_margin(style
, &str
);
2424 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2425 ok(!str
, "margin = %s\n", dbgstr_w(str
));
2428 hres
= IHTMLStyle_put_margin(style
, str
);
2429 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2432 hres
= IHTMLStyle_get_margin(style
, &str
);
2433 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2434 ok(strcmp_wa(str
, "1"), "margin = %s\n", dbgstr_w(str
));
2436 hres
= IHTMLStyle_put_margin(style
, NULL
);
2437 ok(hres
== S_OK
, "get_margin failed: %08x\n", hres
);
2440 hres
= IHTMLStyle_get_border(style
, &str
);
2441 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
2442 ok(!str
|| !*str
, "str is not empty\n");
2445 str
= a2bstr("1px");
2446 hres
= IHTMLStyle_put_border(style
, str
);
2447 ok(hres
== S_OK
, "get_border failed: %08x\n", hres
);
2450 V_VT(&v
) = VT_EMPTY
;
2451 hres
= IHTMLStyle_get_left(style
, &v
);
2452 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2453 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2454 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2458 hres
= IHTMLStyle_get_posLeft(style
, NULL
);
2459 ok(hres
== E_POINTER
, "get_left failed: %08x\n", hres
);
2462 hres
= IHTMLStyle_get_posLeft(style
, &f
);
2463 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2464 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
2466 hres
= IHTMLStyle_put_posLeft(style
, 4.9f
);
2467 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2469 hres
= IHTMLStyle_get_posLeft(style
, &f
);
2470 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2471 ok(f
== 4.0, "expected 4.0 got %f\n", f
);
2473 /* Ensure left is updated correctly. */
2474 V_VT(&v
) = VT_EMPTY
;
2475 hres
= IHTMLStyle_get_left(style
, &v
);
2476 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2477 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2478 ok(!strcmp_wa(V_BSTR(&v
), "4px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2483 V_BSTR(&v
) = a2bstr("3px");
2484 hres
= IHTMLStyle_put_left(style
, v
);
2485 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
2488 hres
= IHTMLStyle_get_posLeft(style
, &f
);
2489 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2490 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
2492 V_VT(&v
) = VT_EMPTY
;
2493 hres
= IHTMLStyle_get_left(style
, &v
);
2494 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2495 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2496 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2500 hres
= IHTMLStyle_put_left(style
, v
);
2501 ok(hres
== S_OK
, "put_left failed: %08x\n", hres
);
2503 V_VT(&v
) = VT_EMPTY
;
2504 hres
= IHTMLStyle_get_left(style
, &v
);
2505 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2506 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2507 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2510 V_VT(&v
) = VT_EMPTY
;
2511 hres
= IHTMLStyle_get_top(style
, &v
);
2512 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
2513 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2514 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2518 hres
= IHTMLStyle_get_posTop(style
, NULL
);
2519 ok(hres
== E_POINTER
, "get_left failed: %08x\n", hres
);
2522 hres
= IHTMLStyle_get_posTop(style
, &f
);
2523 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2524 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
2526 hres
= IHTMLStyle_put_posTop(style
, 4.9f
);
2527 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2529 hres
= IHTMLStyle_get_posTop(style
, &f
);
2530 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2531 ok(f
== 4.0, "expected 4.0 got %f\n", f
);
2534 V_BSTR(&v
) = a2bstr("3px");
2535 hres
= IHTMLStyle_put_top(style
, v
);
2536 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
2539 V_VT(&v
) = VT_EMPTY
;
2540 hres
= IHTMLStyle_get_top(style
, &v
);
2541 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
2542 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2543 ok(!strcmp_wa(V_BSTR(&v
), "3px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2546 hres
= IHTMLStyle_get_posTop(style
, &f
);
2547 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2548 ok(f
== 3.0, "expected 3.0 got %f\n", f
);
2551 hres
= IHTMLStyle_put_top(style
, v
);
2552 ok(hres
== S_OK
, "put_top failed: %08x\n", hres
);
2554 V_VT(&v
) = VT_EMPTY
;
2555 hres
= IHTMLStyle_get_top(style
, &v
);
2556 ok(hres
== S_OK
, "get_top failed: %08x\n", hres
);
2557 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2558 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2561 /* Test posHeight */
2562 hres
= IHTMLStyle_get_posHeight(style
, NULL
);
2563 ok(hres
== E_POINTER
, "get_left failed: %08x\n", hres
);
2565 V_VT(&v
) = VT_EMPTY
;
2566 hres
= IHTMLStyle_get_height(style
, &v
);
2567 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
2568 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2569 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2573 hres
= IHTMLStyle_get_posHeight(style
, &f
);
2574 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2575 ok(f
== 0.0, "expected 0.0 got %f\n", f
);
2577 hres
= IHTMLStyle_put_posHeight(style
, 4.9f
);
2578 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2580 hres
= IHTMLStyle_get_posHeight(style
, &f
);
2581 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2582 ok(f
== 4.0, "expected 4.0 got %f\n", f
);
2585 V_BSTR(&v
) = a2bstr("64px");
2586 hres
= IHTMLStyle_put_height(style
, v
);
2587 ok(hres
== S_OK
, "put_height failed: %08x\n", hres
);
2590 V_VT(&v
) = VT_EMPTY
;
2591 hres
= IHTMLStyle_get_height(style
, &v
);
2592 ok(hres
== S_OK
, "get_height failed: %08x\n", hres
);
2593 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2594 ok(!strcmp_wa(V_BSTR(&v
), "64px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2597 hres
= IHTMLStyle_get_posHeight(style
, &f
);
2598 ok(hres
== S_OK
, "get_left failed: %08x\n", hres
);
2599 ok(f
== 64.0, "expected 64.0 got %f\n", f
);
2601 str
= (void*)0xdeadbeef;
2602 hres
= IHTMLStyle_get_cursor(style
, &str
);
2603 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
2604 ok(!str
, "get_cursor != NULL\n");
2607 str
= a2bstr("default");
2608 hres
= IHTMLStyle_put_cursor(style
, str
);
2609 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
2613 hres
= IHTMLStyle_get_cursor(style
, &str
);
2614 ok(hres
== S_OK
, "get_cursor failed: %08x\n", hres
);
2615 ok(!strcmp_wa(str
, "default"), "get_cursor returned %s\n", dbgstr_w(str
));
2618 V_VT(&v
) = VT_EMPTY
;
2619 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
2620 ok(hres
== S_OK
, "get_vertivalAlign failed: %08x\n", hres
);
2621 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2622 ok(!V_BSTR(&v
), "V_BSTR(v) != NULL\n");
2626 V_BSTR(&v
) = a2bstr("middle");
2627 hres
= IHTMLStyle_put_verticalAlign(style
, v
);
2628 ok(hres
== S_OK
, "put_vertivalAlign failed: %08x\n", hres
);
2631 V_VT(&v
) = VT_EMPTY
;
2632 hres
= IHTMLStyle_get_verticalAlign(style
, &v
);
2633 ok(hres
== S_OK
, "get_verticalAlign failed: %08x\n", hres
);
2634 ok(V_VT(&v
) == VT_BSTR
, "V_VT(v)=%d\n", V_VT(&v
));
2635 ok(!strcmp_wa(V_BSTR(&v
), "middle"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v
)));
2638 str
= (void*)0xdeadbeef;
2639 hres
= IHTMLStyle_get_textAlign(style
, &str
);
2640 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
2641 ok(!str
, "textAlign != NULL\n");
2643 str
= a2bstr("center");
2644 hres
= IHTMLStyle_put_textAlign(style
, str
);
2645 ok(hres
== S_OK
, "put_textAlign failed: %08x\n", hres
);
2649 hres
= IHTMLStyle_get_textAlign(style
, &str
);
2650 ok(hres
== S_OK
, "get_textAlign failed: %08x\n", hres
);
2651 ok(!strcmp_wa(str
, "center"), "textAlign = %s\n", dbgstr_w(V_BSTR(&v
)));
2654 str
= (void*)0xdeadbeef;
2655 hres
= IHTMLStyle_get_filter(style
, &str
);
2656 ok(hres
== S_OK
, "get_filter failed: %08x\n", hres
);
2657 ok(!str
, "filter != NULL\n");
2659 str
= a2bstr("alpha(opacity=100)");
2660 hres
= IHTMLStyle_put_filter(style
, str
);
2661 ok(hres
== S_OK
, "put_filter failed: %08x\n", hres
);
2664 V_VT(&v
) = VT_EMPTY
;
2665 hres
= IHTMLStyle_get_zIndex(style
, &v
);
2666 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
2667 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
2668 ok(!V_I4(&v
), "V_I4(v) != 0\n");
2672 V_BSTR(&v
) = a2bstr("1");
2673 hres
= IHTMLStyle_put_zIndex(style
, v
);
2674 ok(hres
== S_OK
, "put_zIndex failed: %08x\n", hres
);
2677 V_VT(&v
) = VT_EMPTY
;
2678 hres
= IHTMLStyle_get_zIndex(style
, &v
);
2679 ok(hres
== S_OK
, "get_zIndex failed: %08x\n", hres
);
2680 ok(V_VT(&v
) == VT_I4
, "V_VT(v)=%d\n", V_VT(&v
));
2681 ok(V_I4(&v
) == 1, "V_I4(v) = %d\n", V_I4(&v
));
2685 hres
= IHTMLStyle_get_fontStyle(style
, &sDefault
);
2686 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
2688 str
= a2bstr("test");
2689 hres
= IHTMLStyle_put_fontStyle(style
, str
);
2690 ok(hres
== E_INVALIDARG
, "put_fontStyle failed: %08x\n", hres
);
2693 str
= a2bstr("italic");
2694 hres
= IHTMLStyle_put_fontStyle(style
, str
);
2695 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
2698 str
= a2bstr("oblique");
2699 hres
= IHTMLStyle_put_fontStyle(style
, str
);
2700 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
2703 str
= a2bstr("normal");
2704 hres
= IHTMLStyle_put_fontStyle(style
, str
);
2705 ok(hres
== S_OK
, "put_fontStyle failed: %08x\n", hres
);
2708 hres
= IHTMLStyle_put_fontStyle(style
, sDefault
);
2709 ok(hres
== S_OK
, "get_fontStyle failed: %08x\n", hres
);
2712 hres
= IHTMLStyle_get_overflow(style
, NULL
);
2713 ok(hres
== E_INVALIDARG
, "get_overflow failed: %08x\n", hres
);
2715 hres
= IHTMLStyle_get_overflow(style
, &sOverflowDefault
);
2716 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
2718 str
= a2bstr("test");
2719 hres
= IHTMLStyle_put_overflow(style
, str
);
2720 ok(hres
== E_INVALIDARG
, "put_overflow failed: %08x\n", hres
);
2723 str
= a2bstr("visible");
2724 hres
= IHTMLStyle_put_overflow(style
, str
);
2725 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
2728 str
= a2bstr("scroll");
2729 hres
= IHTMLStyle_put_overflow(style
, str
);
2730 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
2733 str
= a2bstr("hidden");
2734 hres
= IHTMLStyle_put_overflow(style
, str
);
2735 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
2738 str
= a2bstr("auto");
2739 hres
= IHTMLStyle_put_overflow(style
, str
);
2740 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
2743 hres
= IHTMLStyle_get_overflow(style
, &str
);
2744 ok(hres
== S_OK
, "get_overflow failed: %08x\n", hres
);
2745 ok(!strcmp_wa(str
, "auto"), "str=%s\n", dbgstr_w(str
));
2748 /* restore overflow default */
2749 hres
= IHTMLStyle_put_overflow(style
, sOverflowDefault
);
2750 ok(hres
== S_OK
, "put_overflow failed: %08x\n", hres
);
2751 SysFreeString(sOverflowDefault
);
2753 hres
= IHTMLStyle_QueryInterface(style
, &IID_IHTMLStyle2
, (void**)&style2
);
2754 ok(hres
== S_OK
, "Could not get IHTMLStyle2 iface: %08x\n", hres
);
2755 if(SUCCEEDED(hres
)) {
2756 test_style2(style2
);
2757 IHTMLStyle2_Release(style2
);
2761 static void test_default_selection(IHTMLDocument2
*doc
)
2763 IHTMLSelectionObject
*selection
;
2764 IHTMLTxtRange
*range
;
2769 hres
= IHTMLDocument2_get_selection(doc
, &selection
);
2770 ok(hres
== S_OK
, "get_selection failed: %08x\n", hres
);
2772 hres
= IHTMLSelectionObject_get_type(selection
, &str
);
2773 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
2774 ok(!lstrcmpW(str
, noneW
), "type = %s\n", dbgstr_w(str
));
2777 hres
= IHTMLSelectionObject_createRange(selection
, &disp
);
2778 IHTMLSelectionObject_Release(selection
);
2779 ok(hres
== S_OK
, "createRange failed: %08x\n", hres
);
2781 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLTxtRange
, (void**)&range
);
2782 IDispatch_Release(disp
);
2783 ok(hres
== S_OK
, "Could not get IHTMLTxtRange interface: %08x\n", hres
);
2785 test_range_text(range
, NULL
);
2786 IHTMLTxtRange_Release(range
);
2789 static void test_default_body(IHTMLBodyElement
*body
)
2795 WCHAR sBodyText
[] = {'#','F','F','0','0','0','0',0};
2796 WCHAR sTextInvalid
[] = {'I','n','v','a','l','i','d',0};
2797 WCHAR sResInvalid
[] = {'#','0','0','a','0','d','0',0};
2799 bstr
= (void*)0xdeadbeef;
2800 hres
= IHTMLBodyElement_get_background(body
, &bstr
);
2801 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2802 ok(bstr
== NULL
, "bstr != NULL\n");
2804 l
= elem_get_scroll_height((IUnknown
*)body
);
2805 ok(l
!= -1, "scrollHeight == -1\n");
2806 l
= elem_get_scroll_width((IUnknown
*)body
);
2807 ok(l
!= -1, "scrollWidth == -1\n");
2808 l
= elem_get_scroll_top((IUnknown
*)body
);
2809 ok(!l
, "scrollTop = %ld\n", l
);
2810 elem_get_scroll_left((IUnknown
*)body
);
2812 /* get_text tests */
2813 hres
= IHTMLBodyElement_get_text(body
, &v
);
2814 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2815 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
2816 ok(bstr
== NULL
, "bstr != NULL\n");
2819 /* get_text - Invalid Text */
2821 V_BSTR(&v
) = SysAllocString(sTextInvalid
);
2822 hres
= IHTMLBodyElement_put_text(body
, v
);
2823 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2826 hres
= IHTMLBodyElement_get_text(body
, &v
);
2827 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2828 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
2829 ok(!lstrcmpW(sResInvalid
, V_BSTR(&v
)), "bstr != sResInvalid\n");
2832 /* get_text - Valid Text */
2834 V_BSTR(&v
) = SysAllocString(sBodyText
);
2835 hres
= IHTMLBodyElement_put_text(body
, v
);
2836 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2839 hres
= IHTMLBodyElement_get_text(body
, &v
);
2840 ok(hres
== S_OK
, "expect S_OK got 0x%08d\n", hres
);
2841 ok(V_VT(&v
) == VT_BSTR
, "Expected VT_BSTR got %d\n", V_VT(&v
));
2842 ok(lstrcmpW(bstr
, V_BSTR(&v
)), "bstr != V_BSTR(&v)\n");
2846 static void test_body_funs(IHTMLBodyElement
*body
)
2848 static WCHAR sRed
[] = {'r','e','d',0};
2849 static WCHAR sRedbg
[] = {'#','f','f','0','0','0','0',0};
2854 hres
= IHTMLBodyElement_get_bgColor(body
, &vDefaultbg
);
2855 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2856 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "bstr != NULL\n");
2858 V_VT(&vbg
) = VT_BSTR
;
2859 V_BSTR(&vbg
) = SysAllocString(sRed
);
2860 hres
= IHTMLBodyElement_put_bgColor(body
, vbg
);
2861 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2864 hres
= IHTMLBodyElement_get_bgColor(body
, &vbg
);
2865 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2866 ok(V_VT(&vDefaultbg
) == VT_BSTR
, "V_VT(&vDefaultbg) != VT_BSTR\n");
2867 ok(!lstrcmpW(V_BSTR(&vbg
), sRedbg
), "Unexpected type %s\n", dbgstr_w(V_BSTR(&vbg
)));
2870 /* Restore Originial */
2871 hres
= IHTMLBodyElement_put_bgColor(body
, vDefaultbg
);
2872 ok(hres
== S_OK
, "get_background failed: %08x\n", hres
);
2873 VariantClear(&vDefaultbg
);
2876 static void test_window(IHTMLDocument2
*doc
)
2878 IHTMLWindow2
*window
, *window2
, *self
;
2879 IHTMLDocument2
*doc2
= NULL
;
2883 hres
= IHTMLDocument2_get_parentWindow(doc
, &window
);
2884 ok(hres
== S_OK
, "get_parentElement failed: %08x\n", hres
);
2885 test_ifaces((IUnknown
*)window
, window_iids
);
2886 test_disp((IUnknown
*)window
, &DIID_DispHTMLWindow2
);
2888 hres
= IHTMLWindow2_get_document(window
, &doc2
);
2889 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
2890 ok(doc2
!= NULL
, "doc2 == NULL\n");
2892 IHTMLDocument_Release(doc2
);
2894 hres
= IHTMLWindow2_get_window(window
, &window2
);
2895 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
2896 ok(window2
!= NULL
, "window2 == NULL\n");
2898 hres
= IHTMLWindow2_get_self(window
, &self
);
2899 ok(hres
== S_OK
, "get_window failed: %08x\n", hres
);
2900 ok(window2
!= NULL
, "self == NULL\n");
2902 ok(self
== window2
, "self != window2\n");
2904 IHTMLWindow2_Release(window2
);
2905 IHTMLWindow2_Release(self
);
2908 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
2909 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
2910 ok(disp
== (void*)window
, "disp != window\n");
2911 IDispatch_Release(disp
);
2913 IHTMLWindow2_Release(window
);
2916 static void test_defaults(IHTMLDocument2
*doc
)
2918 IHTMLStyleSheetsCollection
*stylesheetcol
;
2919 IHTMLCurrentStyle
*cstyle
;
2920 IHTMLBodyElement
*body
;
2921 IHTMLElement2
*elem2
;
2926 IHTMLElementCollection
*collection
;
2928 hres
= IHTMLDocument2_get_body(doc
, &elem
);
2929 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
2931 hres
= IHTMLDocument2_get_images(doc
, NULL
);
2932 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
2934 hres
= IHTMLDocument2_get_images(doc
, &collection
);
2935 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
2938 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
2939 IHTMLElementCollection_Release(collection
);
2942 hres
= IHTMLDocument2_get_applets(doc
, NULL
);
2943 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
2945 hres
= IHTMLDocument2_get_applets(doc
, &collection
);
2946 ok(hres
== S_OK
, "get_applets failed: %08x\n", hres
);
2949 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
2950 IHTMLElementCollection_Release(collection
);
2953 hres
= IHTMLDocument2_get_links(doc
, NULL
);
2954 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
2956 hres
= IHTMLDocument2_get_links(doc
, &collection
);
2957 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
2960 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
2961 IHTMLElementCollection_Release(collection
);
2964 hres
= IHTMLDocument2_get_forms(doc
, NULL
);
2965 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
2967 hres
= IHTMLDocument2_get_forms(doc
, &collection
);
2968 ok(hres
== S_OK
, "get_forms failed: %08x\n", hres
);
2971 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
2972 IHTMLElementCollection_Release(collection
);
2975 hres
= IHTMLDocument2_get_anchors(doc
, NULL
);
2976 ok(hres
== E_INVALIDARG
, "hres %08x\n", hres
);
2978 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
2979 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
2982 test_elem_collection((IUnknown
*)collection
, NULL
, 0);
2983 IHTMLElementCollection_Release(collection
);
2986 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLBodyElement
, (void**)&body
);
2987 ok(hres
== S_OK
, "Could not get IHTMBodyElement: %08x\n", hres
);
2988 test_default_body(body
);
2989 test_body_funs(body
);
2990 IHTMLBodyElement_Release(body
);
2992 hres
= IHTMLElement_get_style(elem
, &style
);
2993 ok(hres
== S_OK
, "get_style failed: %08x\n", hres
);
2995 test_default_style(style
);
2997 test_compatmode(doc
);
2999 test_navigator(doc
);
3001 IHTMLStyle_Release(style
);
3003 elem2
= get_elem2_iface((IUnknown
*)elem
);
3004 hres
= IHTMLElement2_get_currentStyle(elem2
, &cstyle
);
3005 ok(hres
== S_OK
, "get_currentStyle failed: %08x\n", hres
);
3006 if(SUCCEEDED(hres
)) {
3007 test_current_style(cstyle
);
3008 IHTMLCurrentStyle_Release(cstyle
);
3010 IHTMLElement2_Release(elem2
);
3012 IHTMLElement_Release(elem
);
3014 hres
= IHTMLDocument2_get_styleSheets(doc
, &stylesheetcol
);
3015 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
3018 hres
= IHTMLStyleSheetsCollection_get_length(stylesheetcol
, &l
);
3019 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3020 ok(l
== 0, "length = %ld\n", l
);
3022 IHTMLStyleSheetsCollection_Release(stylesheetcol
);
3024 test_default_selection(doc
);
3025 test_doc_title(doc
, "");
3028 static void test_tr_elem(IHTMLElement
*elem
)
3030 IHTMLElementCollection
*col
;
3034 static const elem_type_t cell_types
[] = {ET_TD
,ET_TD
};
3036 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTableRow
, (void**)&row
);
3037 ok(hres
== S_OK
, "Could not get IHTMLTableRow iface: %08x\n", hres
);
3042 hres
= IHTMLTableRow_get_cells(row
, &col
);
3043 ok(hres
== S_OK
, "get_cells failed: %08x\n", hres
);
3044 ok(col
!= NULL
, "get_cells returned NULL\n");
3046 test_elem_collection((IUnknown
*)col
, cell_types
, sizeof(cell_types
)/sizeof(*cell_types
));
3047 IHTMLElementCollection_Release(col
);
3049 IHTMLTable_Release(row
);
3052 static void test_table_elem(IHTMLElement
*elem
)
3054 IHTMLElementCollection
*col
;
3058 static const elem_type_t row_types
[] = {ET_TR
,ET_TR
};
3060 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLTable
, (void**)&table
);
3061 ok(hres
== S_OK
, "Could not get IHTMLTable iface: %08x\n", hres
);
3066 hres
= IHTMLTable_get_rows(table
, &col
);
3067 ok(hres
== S_OK
, "get_rows failed: %08x\n", hres
);
3068 ok(col
!= NULL
, "get_ros returned NULL\n");
3070 test_elem_collection((IUnknown
*)col
, row_types
, sizeof(row_types
)/sizeof(*row_types
));
3071 IHTMLElementCollection_Release(col
);
3073 IHTMLTable_Release(table
);
3076 static void doc_write(IHTMLDocument2
*doc
, const char *text
)
3086 sa
= SafeArrayCreate(VT_VARIANT
, 1, &dim
);
3087 SafeArrayAccessData(sa
, (void**)&var
);
3088 V_VT(var
) = VT_BSTR
;
3089 V_BSTR(var
) = str
= a2bstr(text
);
3090 SafeArrayUnaccessData(sa
);
3092 hres
= IHTMLDocument2_write(doc
, sa
);
3093 ok(hres
== S_OK
, "write failed: %08x\n", hres
);
3096 SafeArrayDestroy(sa
);
3099 static void test_iframe_elem(IHTMLElement
*elem
)
3101 IHTMLElementCollection
*col
;
3102 IHTMLDocument2
*content_doc
;
3103 IHTMLWindow2
*content_window
;
3104 IHTMLFrameBase2
*base2
;
3110 static const elem_type_t all_types
[] = {
3118 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLFrameBase2
, (void**)&base2
);
3119 ok(hres
== S_OK
, "Could not get IHTMFrameBase2 iface: %08x\n", hres
);
3122 content_window
= NULL
;
3123 hres
= IHTMLFrameBase2_get_contentWindow(base2
, &content_window
);
3124 IHTMLFrameBase2_Release(base2
);
3125 ok(hres
== S_OK
, "get_contentWindow failed: %08x\n", hres
);
3126 ok(content_window
!= NULL
, "contentWindow = NULL\n");
3129 hres
= IHTMLWindow2_get_document(content_window
, &content_doc
);
3130 IHTMLWindow2_Release(content_window
);
3131 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
3132 ok(content_doc
!= NULL
, "content_doc = NULL\n");
3134 str
= a2bstr("text/html");
3135 V_VT(&errv
) = VT_ERROR
;
3137 hres
= IHTMLDocument2_open(content_doc
, str
, errv
, errv
, errv
, &disp
);
3139 ok(hres
== S_OK
, "open failed: %08x\n", hres
);
3140 ok(disp
!= NULL
, "disp == NULL\n");
3141 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)content_window
), "disp != content_window\n");
3142 IDispatch_Release(disp
);
3144 doc_write(content_doc
, "<html><head><title>test</title></head><body><br /></body></html>");
3146 hres
= IHTMLDocument2_get_all(content_doc
, &col
);
3147 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3148 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3149 IHTMLElementCollection_Release(col
);
3151 hres
= IHTMLDocument2_close(content_doc
);
3152 ok(hres
== S_OK
, "close failed: %08x\n", hres
);
3154 IHTMLDocument2_Release(content_doc
);
3157 static void test_stylesheet(IDispatch
*disp
)
3159 IHTMLStyleSheetRulesCollection
*col
= NULL
;
3160 IHTMLStyleSheet
*stylesheet
;
3163 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLStyleSheet
, (void**)&stylesheet
);
3164 ok(hres
== S_OK
, "Could not get IHTMLStyleSheet: %08x\n", hres
);
3166 hres
= IHTMLStyleSheet_get_rules(stylesheet
, &col
);
3167 ok(hres
== S_OK
, "get_rules failed: %08x\n", hres
);
3168 ok(col
!= NULL
, "col == NULL\n");
3170 IHTMLStyleSheetRulesCollection_Release(col
);
3171 IHTMLStyleSheet_Release(stylesheet
);
3174 static void test_stylesheets(IHTMLDocument2
*doc
)
3176 IHTMLStyleSheetsCollection
*col
= NULL
;
3181 hres
= IHTMLDocument2_get_styleSheets(doc
, &col
);
3182 ok(hres
== S_OK
, "get_styleSheets failed: %08x\n", hres
);
3183 ok(col
!= NULL
, "col == NULL\n");
3185 hres
= IHTMLStyleSheetsCollection_get_length(col
, &len
);
3186 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3187 ok(len
== 1, "len=%ld\n", len
);
3193 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
3194 ok(hres
== S_OK
, "item failed: %08x\n", hres
);
3195 ok(V_VT(&res
) == VT_DISPATCH
, "V_VT(res) = %d\n", V_VT(&res
));
3196 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
3197 test_stylesheet(V_DISPATCH(&res
));
3204 hres
= IHTMLStyleSheetsCollection_item(col
, &idx
, &res
);
3205 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3206 ok(V_VT(&res
) == VT_EMPTY
, "V_VT(res) = %d\n", V_VT(&res
));
3207 ok(V_DISPATCH(&res
) != NULL
, "V_DISPATCH(&res) == NULL\n");
3210 IHTMLStyleSheetsCollection_Release(col
);
3213 static void test_child_col_disp(IHTMLDOMChildrenCollection
*col
)
3215 IDispatchEx
*dispex
;
3217 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
3225 static const WCHAR w0
[] = {'0',0};
3226 static const WCHAR w100
[] = {'1','0','0',0};
3228 hres
= IHTMLDOMChildrenCollection_QueryInterface(col
, &IID_IDispatchEx
, (void**)&dispex
);
3229 ok(hres
== S_OK
, "Could not get IDispatchEx: %08x\n", hres
);
3231 bstr
= SysAllocString(w0
);
3232 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3233 ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3234 SysFreeString(bstr
);
3237 hres
= IDispatchEx_InvokeEx(dispex
, id
, LOCALE_NEUTRAL
, INVOKE_PROPERTYGET
, &dp
, &var
, &ei
, NULL
);
3238 ok(hres
== S_OK
, "InvokeEx failed: %08x\n", hres
);
3239 ok(V_VT(&var
) == VT_DISPATCH
, "V_VT(var)=%d\n", V_VT(&var
));
3240 ok(V_DISPATCH(&var
) != NULL
, "V_DISPATCH(var) == NULL\n");
3241 node
= get_node_iface((IUnknown
*)V_DISPATCH(&var
));
3242 type
= get_node_type((IUnknown
*)node
);
3243 ok(type
== 3, "type=%ld\n", type
);
3244 IHTMLDOMNode_Release(node
);
3247 bstr
= SysAllocString(w100
);
3248 hres
= IDispatchEx_GetDispID(dispex
, bstr
, fdexNameCaseSensitive
, &id
);
3249 ok(hres
== DISP_E_UNKNOWNNAME
, "GetDispID failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres
);
3250 SysFreeString(bstr
);
3252 IDispatchEx_Release(dispex
);
3257 static void test_elems(IHTMLDocument2
*doc
)
3259 IHTMLElementCollection
*col
;
3260 IHTMLDOMChildrenCollection
*child_col
;
3261 IHTMLElement
*elem
, *elem2
, *elem3
;
3262 IHTMLDOMNode
*node
, *node2
;
3266 IHTMLElementCollection
*collection
;
3268 static const WCHAR imgidW
[] = {'i','m','g','i','d',0};
3269 static const WCHAR inW
[] = {'i','n',0};
3270 static const WCHAR xW
[] = {'x',0};
3271 static const WCHAR sW
[] = {'s',0};
3272 static const WCHAR scW
[] = {'s','c',0};
3273 static const WCHAR xxxW
[] = {'x','x','x',0};
3274 static const WCHAR tblW
[] = {'t','b','l',0};
3275 static const WCHAR row2W
[] = {'r','o','w','2',0};
3276 static const WCHAR ifrW
[] = {'i','f','r',0};
3278 static const elem_type_t all_types
[] = {
3303 static const elem_type_t item_types
[] = {
3309 hres
= IHTMLDocument2_get_all(doc
, &col
);
3310 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3311 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3312 test_elem_col_item(col
, xW
, item_types
, sizeof(item_types
)/sizeof(item_types
[0]));
3313 IHTMLElementCollection_Release(col
);
3315 hres
= IHTMLDocument2_get_images(doc
, &collection
);
3316 ok(hres
== S_OK
, "get_images failed: %08x\n", hres
);
3319 static const elem_type_t images_types
[] = {ET_IMG
};
3320 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
3322 IHTMLElementCollection_Release(collection
);
3325 hres
= IHTMLDocument2_get_links(doc
, &collection
);
3326 ok(hres
== S_OK
, "get_links failed: %08x\n", hres
);
3329 static const elem_type_t images_types
[] = {ET_A
};
3330 test_elem_collection((IUnknown
*)collection
, images_types
, 1);
3332 IHTMLElementCollection_Release(collection
);
3335 hres
= IHTMLDocument2_get_anchors(doc
, &collection
);
3336 ok(hres
== S_OK
, "get_anchors failed: %08x\n", hres
);
3339 static const elem_type_t anchor_types
[] = {ET_A
};
3340 test_elem_collection((IUnknown
*)collection
, anchor_types
, 1);
3342 IHTMLElementCollection_Release(collection
);
3345 elem
= get_doc_elem(doc
);
3346 ok(hres
== S_OK
, "get_documentElement failed: %08x\n", hres
);
3347 hres
= IHTMLElement_get_all(elem
, &disp
);
3348 IHTMLElement_Release(elem
);
3349 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3351 hres
= IDispatch_QueryInterface(disp
, &IID_IHTMLElementCollection
, (void**)&col
);
3352 IDispatch_Release(disp
);
3353 ok(hres
== S_OK
, "Could not get IHTMLElementCollection: %08x\n", hres
);
3354 test_elem_collection((IUnknown
*)col
, all_types
+1, sizeof(all_types
)/sizeof(all_types
[0])-1);
3355 IHTMLElementCollection_Release(col
);
3357 get_elem_by_id(doc
, xxxW
, FALSE
);
3358 elem
= get_doc_elem_by_id(doc
, xxxW
);
3359 ok(!elem
, "elem != NULL\n");
3361 elem
= get_doc_elem_by_id(doc
, sW
);
3362 ok(elem
!= NULL
, "elem == NULL\n");
3364 test_elem_type((IUnknown
*)elem
, ET_SELECT
);
3365 test_elem_attr(elem
, xxxW
, NULL
);
3366 test_elem_attr(elem
, idW
, sW
);
3367 test_elem_class((IUnknown
*)elem
, NULL
);
3368 test_elem_set_class((IUnknown
*)elem
, "cl");
3369 test_elem_set_class((IUnknown
*)elem
, NULL
);
3370 test_elem_tabindex((IUnknown
*)elem
, 0);
3371 test_elem_set_tabindex((IUnknown
*)elem
, 1);
3373 node
= test_node_get_parent((IUnknown
*)elem
);
3374 ok(node
!= NULL
, "node == NULL\n");
3375 test_node_name((IUnknown
*)node
, "BODY");
3376 node2
= test_node_get_parent((IUnknown
*)node
);
3377 IHTMLDOMNode_Release(node
);
3378 ok(node2
!= NULL
, "node == NULL\n");
3379 test_node_name((IUnknown
*)node2
, "HTML");
3380 node
= test_node_get_parent((IUnknown
*)node2
);
3381 IHTMLDOMNode_Release(node2
);
3382 ok(node
!= NULL
, "node == NULL\n");
3385 test_node_name((IUnknown
*)node
, "#document");
3386 type
= get_node_type((IUnknown
*)node
);
3387 ok(type
== 9, "type=%ld, expected 9\n", type
);
3388 node2
= test_node_get_parent((IUnknown
*)node
);
3389 IHTMLDOMNode_Release(node
);
3390 ok(node2
== NULL
, "node != NULL\n");
3393 elem2
= test_elem_get_parent((IUnknown
*)elem
);
3394 ok(elem2
!= NULL
, "elem2 == NULL\n");
3395 test_node_name((IUnknown
*)elem2
, "BODY");
3396 elem3
= test_elem_get_parent((IUnknown
*)elem2
);
3397 IHTMLElement_Release(elem2
);
3398 ok(elem3
!= NULL
, "elem3 == NULL\n");
3399 test_node_name((IUnknown
*)elem3
, "HTML");
3400 elem2
= test_elem_get_parent((IUnknown
*)elem3
);
3401 IHTMLElement_Release(elem3
);
3402 ok(elem2
== NULL
, "elem2 != NULL\n");
3404 test_elem_getelembytag((IUnknown
*)elem
, ET_OPTION
, 2);
3405 test_elem_getelembytag((IUnknown
*)elem
, ET_SELECT
, 0);
3406 test_elem_getelembytag((IUnknown
*)elem
, ET_HTML
, 0);
3408 test_elem_innertext(elem
, "opt1opt2");
3410 IHTMLElement_Release(elem
);
3413 elem
= get_elem_by_id(doc
, sW
, TRUE
);
3415 IHTMLSelectElement
*select
;
3417 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLSelectElement
, (void**)&select
);
3418 ok(hres
== S_OK
, "Could not get IHTMLSelectElement interface: %08x\n", hres
);
3420 test_select_elem(select
);
3422 test_elem_title((IUnknown
*)select
, NULL
);
3423 test_elem_set_title((IUnknown
*)select
, "Title");
3424 test_elem_title((IUnknown
*)select
, "Title");
3425 test_elem_offset((IUnknown
*)select
);
3427 node
= get_first_child((IUnknown
*)select
);
3428 ok(node
!= NULL
, "node == NULL\n");
3430 test_elem_type((IUnknown
*)node
, ET_OPTION
);
3431 IHTMLDOMNode_Release(node
);
3434 type
= get_node_type((IUnknown
*)select
);
3435 ok(type
== 1, "type=%ld\n", type
);
3437 IHTMLSelectElement_Release(select
);
3439 hres
= IHTMLElement_get_document(elem
, &disp
);
3440 ok(hres
== S_OK
, "get_document failed: %08x\n", hres
);
3441 ok(iface_cmp((IUnknown
*)disp
, (IUnknown
*)doc
), "disp != doc\n");
3443 IHTMLElement_Release(elem
);
3446 elem
= get_elem_by_id(doc
, scW
, TRUE
);
3448 IHTMLScriptElement
*script
;
3451 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLScriptElement
, (void**)&script
);
3452 ok(hres
== S_OK
, "Could not get IHTMLScriptElement interface: %08x\n", hres
);
3458 hres
= IHTMLScriptElement_get_type(script
, &type
);
3459 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3460 ok(!lstrcmpW(type
, text_javascriptW
), "Unexpected type %s\n", dbgstr_w(type
));
3461 SysFreeString(type
);
3464 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_TRUE
);
3465 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3467 hres
= IHTMLScriptElement_get_defer(script
, &vb
);
3468 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3469 ok(vb
== VARIANT_TRUE
, "get_type failed: %08x\n", hres
);
3471 hres
= IHTMLScriptElement_put_defer(script
, VARIANT_FALSE
);
3472 ok(hres
== S_OK
, "get_type failed: %08x\n", hres
);
3475 IHTMLScriptElement_Release(script
);
3478 elem
= get_elem_by_id(doc
, inW
, TRUE
);
3480 IHTMLInputElement
*input
;
3482 hres
= IHTMLElement_QueryInterface(elem
, &IID_IHTMLInputElement
, (void**)&input
);
3483 ok(hres
== S_OK
, "Could not get IHTMLInputElement: %08x\n", hres
);
3485 test_elem_id((IUnknown
*)elem
, "in");
3486 test_elem_put_id((IUnknown
*)elem
, "newin");
3487 test_input_get_disabled(input
, VARIANT_FALSE
);
3488 test_input_set_disabled(input
, VARIANT_TRUE
);
3489 test_input_set_disabled(input
, VARIANT_FALSE
);
3490 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_TRUE
);
3491 test_input_get_disabled(input
, VARIANT_TRUE
);
3492 test_elem3_set_disabled((IUnknown
*)input
, VARIANT_FALSE
);
3493 test_input_get_disabled(input
, VARIANT_FALSE
);
3494 test_elem_client_size((IUnknown
*)elem
);
3496 test_node_get_value_str((IUnknown
*)elem
, NULL
);
3497 test_node_put_value_str((IUnknown
*)elem
, "test");
3498 test_node_get_value_str((IUnknown
*)elem
, NULL
);
3499 test_input_value((IUnknown
*)elem
, NULL
);
3500 test_input_put_value((IUnknown
*)elem
, "test");
3501 test_input_value((IUnknown
*)elem
, NULL
);
3502 test_elem_class((IUnknown
*)elem
, "testclass");
3503 test_elem_tabindex((IUnknown
*)elem
, 2);
3504 test_elem_set_tabindex((IUnknown
*)elem
, 3);
3505 test_elem_title((IUnknown
*)elem
, "test title");
3507 test_input_get_defaultchecked(input
, VARIANT_FALSE
);
3508 test_input_set_defaultchecked(input
, VARIANT_TRUE
);
3509 test_input_set_defaultchecked(input
, VARIANT_FALSE
);
3511 test_input_get_checked(input
, VARIANT_FALSE
);
3512 test_input_set_checked(input
, VARIANT_TRUE
);
3513 test_input_set_checked(input
, VARIANT_FALSE
);
3515 IHTMLInputElement_Release(input
);
3516 IHTMLElement_Release(elem
);
3519 elem
= get_elem_by_id(doc
, imgidW
, TRUE
);
3521 test_img_src((IUnknown
*)elem
, "");
3522 test_img_set_src((IUnknown
*)elem
, "about:blank");
3523 test_img_alt((IUnknown
*)elem
, NULL
);
3524 test_img_set_alt((IUnknown
*)elem
, "alt test");
3525 IHTMLElement_Release(elem
);
3528 elem
= get_doc_elem_by_id(doc
, tblW
);
3529 ok(elem
!= NULL
, "elem == NULL\n");
3531 test_table_elem(elem
);
3532 IHTMLElement_Release(elem
);
3535 elem
= get_doc_elem_by_id(doc
, row2W
);
3536 ok(elem
!= NULL
, "elem == NULL\n");
3539 IHTMLElement_Release(elem
);
3542 elem
= get_doc_elem_by_id(doc
, ifrW
);
3543 ok(elem
!= NULL
, "elem == NULL\n");
3545 test_iframe_elem(elem
);
3546 IHTMLElement_Release(elem
);
3549 hres
= IHTMLDocument2_get_body(doc
, &elem
);
3550 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3552 node
= get_first_child((IUnknown
*)elem
);
3553 ok(node
!= NULL
, "node == NULL\n");
3555 test_ifaces((IUnknown
*)node
, text_iids
);
3556 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
3558 node2
= get_first_child((IUnknown
*)node
);
3559 ok(!node2
, "node2 != NULL\n");
3561 type
= get_node_type((IUnknown
*)node
);
3562 ok(type
== 3, "type=%ld\n", type
);
3564 test_node_get_value_str((IUnknown
*)node
, "text test");
3565 test_node_put_value_str((IUnknown
*)elem
, "test text");
3566 test_node_get_value_str((IUnknown
*)node
, "text test");
3568 IHTMLDOMNode_Release(node
);
3571 child_col
= get_child_nodes((IUnknown
*)elem
);
3572 ok(child_col
!= NULL
, "child_coll == NULL\n");
3576 test_disp((IUnknown
*)child_col
, &DIID_DispDOMChildrenCollection
);
3578 hres
= IHTMLDOMChildrenCollection_get_length(child_col
, &length
);
3579 ok(hres
== S_OK
, "get_length failed: %08x\n", hres
);
3580 ok(length
, "length=0\n");
3582 node
= get_child_item(child_col
, 0);
3583 ok(node
!= NULL
, "node == NULL\n");
3585 type
= get_node_type((IUnknown
*)node
);
3586 ok(type
== 3, "type=%ld\n", type
);
3587 IHTMLDOMNode_Release(node
);
3590 node
= get_child_item(child_col
, 1);
3591 ok(node
!= NULL
, "node == NULL\n");
3593 type
= get_node_type((IUnknown
*)node
);
3594 ok(type
== 8, "type=%ld\n", type
);
3596 test_elem_id((IUnknown
*)node
, NULL
);
3597 IHTMLDOMNode_Release(node
);
3600 disp
= (void*)0xdeadbeef;
3601 hres
= IHTMLDOMChildrenCollection_item(child_col
, 6000, &disp
);
3602 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3603 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
3605 disp
= (void*)0xdeadbeef;
3606 hres
= IHTMLDOMChildrenCollection_item(child_col
, length
, &disp
);
3607 ok(hres
== E_INVALIDARG
, "item failed: %08x, expected E_INVALIDARG\n", hres
);
3608 ok(disp
== (void*)0xdeadbeef, "disp=%p\n", disp
);
3610 test_child_col_disp(child_col
);
3612 IHTMLDOMChildrenCollection_Release(child_col
);
3615 test_elem3_get_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
3616 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_TRUE
);
3617 test_elem3_set_disabled((IUnknown
*)elem
, VARIANT_FALSE
);
3619 IHTMLElement_Release(elem
);
3621 test_stylesheets(doc
);
3622 test_create_option_elem(doc
);
3624 elem
= get_doc_elem_by_id(doc
, tblW
);
3625 ok(elem
!= NULL
, "elem = NULL\n");
3626 test_elem_set_innertext(elem
, "inner text");
3627 IHTMLElement_Release(elem
);
3629 test_doc_title(doc
, "test");
3630 test_doc_set_title(doc
, "test title");
3631 test_doc_title(doc
, "test title");
3634 hres
= IHTMLDocument2_get_Script(doc
, &disp
);
3635 ok(hres
== S_OK
, "get_Script failed: %08x\n", hres
);
3638 IDispatchEx
*dispex
;
3639 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
3640 ok(hres
== S_OK
, "IDispatch_QueryInterface failed: %08x\n", hres
);
3644 BSTR str
= a2bstr("Testing");
3645 hres
= IDispatchEx_GetDispID(dispex
, str
, 1, &pid
);
3646 todo_wine
ok(hres
== S_OK
, "GetDispID failed: %08x\n", hres
);
3647 todo_wine
ok(pid
!= -1, "pid == -1\n");
3649 IDispatchEx_Release(dispex
);
3652 IDispatch_Release(disp
);
3655 static void test_create_elems(IHTMLDocument2
*doc
)
3657 IHTMLElement
*elem
, *body
, *elem2
;
3658 IHTMLDOMNode
*node
, *node2
, *node3
;
3664 static const elem_type_t types1
[] = { ET_TESTG
};
3666 elem
= test_create_elem(doc
, "TEST");
3667 test_elem_tag((IUnknown
*)elem
, "TEST");
3668 type
= get_node_type((IUnknown
*)elem
);
3669 ok(type
== 1, "type=%ld\n", type
);
3670 test_ifaces((IUnknown
*)elem
, elem_iids
);
3671 test_disp((IUnknown
*)elem
, &DIID_DispHTMLGenericElement
);
3673 hres
= IHTMLDocument2_get_body(doc
, &body
);
3674 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3675 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
3677 node
= test_node_append_child((IUnknown
*)body
, (IUnknown
*)elem
);
3678 test_node_has_child((IUnknown
*)body
, VARIANT_TRUE
);
3679 elem2
= get_elem_iface((IUnknown
*)node
);
3680 IHTMLElement_Release(elem2
);
3682 hres
= IHTMLElement_get_all(body
, &disp
);
3683 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3684 test_elem_collection((IUnknown
*)disp
, types1
, sizeof(types1
)/sizeof(types1
[0]));
3685 IDispatch_Release(disp
);
3687 test_node_remove_child((IUnknown
*)body
, node
);
3689 hres
= IHTMLElement_get_all(body
, &disp
);
3690 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3691 test_elem_collection((IUnknown
*)disp
, NULL
, 0);
3692 IDispatch_Release(disp
);
3693 test_node_has_child((IUnknown
*)body
, VARIANT_FALSE
);
3695 IHTMLElement_Release(elem
);
3696 IHTMLDOMNode_Release(node
);
3698 node
= test_create_text(doc
, "test");
3699 test_ifaces((IUnknown
*)node
, text_iids
);
3700 test_disp((IUnknown
*)node
, &DIID_DispHTMLDOMTextNode
);
3702 V_VT(&var
) = VT_NULL
;
3703 node2
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
3704 IHTMLDOMNode_Release(node
);
3706 node
= test_create_text(doc
, "insert ");
3708 V_VT(&var
) = VT_DISPATCH
;
3709 V_DISPATCH(&var
) = (IDispatch
*)node2
;
3710 node3
= test_node_insertbefore((IUnknown
*)body
, node
, &var
);
3711 IHTMLDOMNode_Release(node
);
3712 IHTMLDOMNode_Release(node2
);
3713 IHTMLDOMNode_Release(node3
);
3715 test_elem_innertext(body
, "insert test");
3717 IHTMLElement_Release(body
);
3720 static void test_exec(IUnknown
*unk
, const GUID
*grpid
, DWORD cmdid
, VARIANT
*in
, VARIANT
*out
)
3722 IOleCommandTarget
*cmdtrg
;
3725 hres
= IHTMLTxtRange_QueryInterface(unk
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
3726 ok(hres
== S_OK
, "Could not get IOleCommandTarget interface: %08x\n", hres
);
3728 hres
= IOleCommandTarget_Exec(cmdtrg
, grpid
, cmdid
, 0, in
, out
);
3729 ok(hres
== S_OK
, "Exec failed: %08x\n", hres
);
3731 IOleCommandTarget_Release(cmdtrg
);
3734 static void test_indent(IHTMLDocument2
*doc
)
3736 IHTMLElementCollection
*col
;
3737 IHTMLTxtRange
*range
;
3740 static const elem_type_t all_types
[] = {
3749 static const elem_type_t indent_types
[] = {
3760 hres
= IHTMLDocument2_get_all(doc
, &col
);
3761 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3762 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3763 IHTMLElementCollection_Release(col
);
3765 range
= test_create_body_range(doc
);
3766 test_exec((IUnknown
*)range
, &CGID_MSHTML
, IDM_INDENT
, NULL
, NULL
);
3767 IHTMLTxtRange_Release(range
);
3769 hres
= IHTMLDocument2_get_all(doc
, &col
);
3770 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3771 test_elem_collection((IUnknown
*)col
, indent_types
, sizeof(indent_types
)/sizeof(indent_types
[0]));
3772 IHTMLElementCollection_Release(col
);
3775 static void test_cond_comment(IHTMLDocument2
*doc
)
3777 IHTMLElementCollection
*col
;
3780 static const elem_type_t all_types
[] = {
3788 hres
= IHTMLDocument2_get_all(doc
, &col
);
3789 ok(hres
== S_OK
, "get_all failed: %08x\n", hres
);
3790 test_elem_collection((IUnknown
*)col
, all_types
, sizeof(all_types
)/sizeof(all_types
[0]));
3791 IHTMLElementCollection_Release(col
);
3794 static IHTMLDocument2
*notif_doc
;
3795 static BOOL doc_complete
;
3797 static HRESULT WINAPI
PropertyNotifySink_QueryInterface(IPropertyNotifySink
*iface
,
3798 REFIID riid
, void**ppv
)
3800 if(IsEqualGUID(&IID_IPropertyNotifySink
, riid
)) {
3805 ok(0, "unexpected call\n");
3806 return E_NOINTERFACE
;
3809 static ULONG WINAPI
PropertyNotifySink_AddRef(IPropertyNotifySink
*iface
)
3814 static ULONG WINAPI
PropertyNotifySink_Release(IPropertyNotifySink
*iface
)
3819 static HRESULT WINAPI
PropertyNotifySink_OnChanged(IPropertyNotifySink
*iface
, DISPID dispID
)
3821 if(dispID
== DISPID_READYSTATE
){
3825 static const WCHAR completeW
[] = {'c','o','m','p','l','e','t','e',0};
3827 hres
= IHTMLDocument2_get_readyState(notif_doc
, &state
);
3828 ok(hres
== S_OK
, "get_readyState failed: %08x\n", hres
);
3830 if(!lstrcmpW(state
, completeW
))
3831 doc_complete
= TRUE
;
3833 SysFreeString(state
);
3839 static HRESULT WINAPI
PropertyNotifySink_OnRequestEdit(IPropertyNotifySink
*iface
, DISPID dispID
)
3841 ok(0, "unexpected call\n");
3845 static IPropertyNotifySinkVtbl PropertyNotifySinkVtbl
= {
3846 PropertyNotifySink_QueryInterface
,
3847 PropertyNotifySink_AddRef
,
3848 PropertyNotifySink_Release
,
3849 PropertyNotifySink_OnChanged
,
3850 PropertyNotifySink_OnRequestEdit
3853 static IPropertyNotifySink PropertyNotifySink
= { &PropertyNotifySinkVtbl
};
3855 static IHTMLDocument2
*create_doc_with_string(const char *str
)
3857 IPersistStreamInit
*init
;
3859 IHTMLDocument2
*doc
;
3863 notif_doc
= doc
= create_document();
3867 doc_complete
= FALSE
;
3869 mem
= GlobalAlloc(0, len
);
3870 memcpy(mem
, str
, len
);
3871 CreateStreamOnHGlobal(mem
, TRUE
, &stream
);
3873 IHTMLDocument2_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&init
);
3875 IPersistStreamInit_Load(init
, stream
);
3876 IPersistStreamInit_Release(init
);
3877 IStream_Release(stream
);
3882 static void do_advise(IUnknown
*unk
, REFIID riid
, IUnknown
*unk_advise
)
3884 IConnectionPointContainer
*container
;
3885 IConnectionPoint
*cp
;
3889 hres
= IUnknown_QueryInterface(unk
, &IID_IConnectionPointContainer
, (void**)&container
);
3890 ok(hres
== S_OK
, "QueryInterface(IID_IConnectionPointContainer) failed: %08x\n", hres
);
3892 hres
= IConnectionPointContainer_FindConnectionPoint(container
, riid
, &cp
);
3893 IConnectionPointContainer_Release(container
);
3894 ok(hres
== S_OK
, "FindConnectionPoint failed: %08x\n", hres
);
3896 hres
= IConnectionPoint_Advise(cp
, unk_advise
, &cookie
);
3897 IConnectionPoint_Release(cp
);
3898 ok(hres
== S_OK
, "Advise failed: %08x\n", hres
);
3901 typedef void (*domtest_t
)(IHTMLDocument2
*);
3903 static void run_domtest(const char *str
, domtest_t test
)
3905 IHTMLDocument2
*doc
;
3906 IHTMLElement
*body
= NULL
;
3911 doc
= create_doc_with_string(str
);
3915 do_advise((IUnknown
*)doc
, &IID_IPropertyNotifySink
, (IUnknown
*)&PropertyNotifySink
);
3917 while(!doc_complete
&& GetMessage(&msg
, NULL
, 0, 0)) {
3918 TranslateMessage(&msg
);
3919 DispatchMessage(&msg
);
3922 hres
= IHTMLDocument2_get_body(doc
, &body
);
3923 ok(hres
== S_OK
, "get_body failed: %08x\n", hres
);
3926 IHTMLElement_Release(body
);
3929 skip("Could not get document body. Assuming no Gecko installed.\n");
3932 ref
= IHTMLDocument2_Release(doc
);
3934 ref
== 1, /* Vista */
3938 static void gecko_installer_workaround(BOOL disable
)
3943 static BOOL has_url
= FALSE
;
3944 static char url
[2048];
3946 if(!disable
&& !has_url
)
3949 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
3950 if(res
!= ERROR_SUCCESS
)
3954 DWORD type
, size
= sizeof(url
);
3956 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
3957 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
3960 RegDeleteValue(hkey
, "GeckoUrl");
3962 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
3970 gecko_installer_workaround(TRUE
);
3973 run_domtest(doc_str1
, test_doc_elem
);
3974 run_domtest(range_test_str
, test_txtrange
);
3975 run_domtest(range_test2_str
, test_txtrange2
);
3976 run_domtest(elem_test_str
, test_elems
);
3977 run_domtest(doc_blank
, test_create_elems
);
3978 run_domtest(doc_blank
, test_defaults
);
3979 run_domtest(indent_test_str
, test_indent
);
3980 run_domtest(cond_comment_str
, test_cond_comment
);
3983 gecko_installer_workaround(FALSE
);